Commit a26dd5c4 a26dd5c4aded95b0f7e21811a7efeb468d51d687 by Sergey Poznyakoff

(_file_read, _file_readline): Check for eof.

1 parent b85aa07e
...@@ -85,6 +85,13 @@ _file_read (stream_t stream, char *optr, size_t osize, ...@@ -85,6 +85,13 @@ _file_read (stream_t stream, char *optr, size_t osize,
85 fs->offset = offset; 85 fs->offset = offset;
86 } 86 }
87 87
88 if (feof (fs->file))
89 {
90 if (nbytes)
91 *nbytes = 0;
92 return 0;
93 }
94
88 n = fread (optr, sizeof(char), osize, fs->file); 95 n = fread (optr, sizeof(char), osize, fs->file);
89 if (n == 0) 96 if (n == 0)
90 { 97 {
...@@ -122,6 +129,13 @@ _file_readline (stream_t stream, char *optr, size_t osize, ...@@ -122,6 +129,13 @@ _file_readline (stream_t stream, char *optr, size_t osize,
122 fs->offset = offset; 129 fs->offset = offset;
123 } 130 }
124 131
132 if (feof (fs->file))
133 {
134 if (nbytes)
135 *nbytes = 0;
136 return 0;
137 }
138
125 if (fgets (optr, osize, fs->file) != NULL) 139 if (fgets (optr, osize, fs->file) != NULL)
126 { 140 {
127 char *tmp = optr; 141 char *tmp = optr;
......