diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-06-04 23:21:47 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-06-04 23:21:47 +0000 |
commit | a26dd5c4aded95b0f7e21811a7efeb468d51d687 (patch) | |
tree | eaf4bf0debb15b3358dbf4543f60c8cf570bc20d | |
parent | b85aa07ee10b880880661a9eedadb7d08fc5a24e (diff) | |
download | mailutils-a26dd5c4aded95b0f7e21811a7efeb468d51d687.tar.gz mailutils-a26dd5c4aded95b0f7e21811a7efeb468d51d687.tar.bz2 |
(_file_read, _file_readline): Check for eof.
-rw-r--r-- | mailbox/file_stream.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mailbox/file_stream.c b/mailbox/file_stream.c index 01175fe15..1698ff8be 100644 --- a/mailbox/file_stream.c +++ b/mailbox/file_stream.c @@ -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; |