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,
fs->offset = offset;
}
if (feof (fs->file))
{
if (nbytes)
*nbytes = 0;
return 0;
}
n = fread (optr, sizeof(char), osize, fs->file);
if (n == 0)
{
......@@ -122,6 +129,13 @@ _file_readline (stream_t stream, char *optr, size_t osize,
fs->offset = offset;
}
if (feof (fs->file))
{
if (nbytes)
*nbytes = 0;
return 0;
}
if (fgets (optr, osize, fs->file) != NULL)
{
char *tmp = optr;
......