2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: readFile.c,v 1.1 1998/04/10 10:54:43 simonm Exp $
6 * hGetContents Runtime Support
15 readBlock(StgAddr buf, StgAddr fp, StgInt size)
19 if (feof((FILE *) fp)) {
20 ghc_errtype = ERR_EOF;
25 while ((count = fread(buf, 1, size, (FILE *) fp)) == 0) {
26 if (feof((FILE *) fp)) {
27 ghc_errtype = ERR_EOF;
30 } else if (errno != EINTR) {
35 clearerr((FILE *) fp);
42 readLine(StgAddr buf, StgAddr fp, StgInt size)
44 if (feof((FILE *) fp)) {
45 ghc_errtype = ERR_EOF;
50 while (fgets(buf, size, (FILE *) fp) == NULL) {
51 if (feof((FILE *) fp)) {
52 ghc_errtype = ERR_EOF;
55 } else if (errno != EINTR) {
60 clearerr((FILE *) fp);
71 if (feof((FILE *) fp)) {
72 ghc_errtype = ERR_EOF;
77 while ((c = getc((FILE *) fp)) == EOF) {
78 if (feof((FILE *) fp)) {
79 ghc_errtype = ERR_EOF;
82 } else if (errno != EINTR) {
87 clearerr((FILE *) fp);
90 if (isatty(fileno((FILE *) fp)) && c == EOT)