diff --git a/library/changes b/library/changes index 5b6a6c3..807ae34 100644 --- a/library/changes +++ b/library/changes @@ -16,6 +16,10 @@ - Added code to the startup routine which allows you to monitor where command was started from and which parameters it was invoked with. +- If fread()/fwrite() fail to read/write any data because either the number + of records or the size of each record is zero, both now call clearerr() to + avoid giving the caller the wrong impression that an EOF or error occured. + c.lib 1.191 (9.4.2005) diff --git a/library/stdio_fgetpos.c b/library/stdio_fgetpos.c index 58e373b..bb60e10 100644 --- a/library/stdio_fgetpos.c +++ b/library/stdio_fgetpos.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fgetpos.c,v 1.6 2005-04-24 09:53:12 obarthel Exp $ + * $Id: stdio_fgetpos.c,v 1.7 2005-04-24 19:38:59 obarthel Exp $ * * :ts=4 * @@ -81,7 +81,7 @@ fgetpos(FILE *stream, fpos_t *pos) goto out; } - (*pos) = position; + (*pos) = (fpos_t)position; result = OK; diff --git a/library/stdio_fread.c b/library/stdio_fread.c index 5314e95..352e922 100644 --- a/library/stdio_fread.c +++ b/library/stdio_fread.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fread.c,v 1.5 2005-02-27 18:09:10 obarthel Exp $ + * $Id: stdio_fread.c,v 1.6 2005-04-24 19:38:59 obarthel Exp $ * * :ts=4 * @@ -137,6 +137,9 @@ fread(void *ptr,size_t element_size,size_t count,FILE *stream) SHOWVALUE(count); SHOWMSG("either element size or count is zero"); + + /* Don't let this appear like an EOF or error. */ + clearerr((FILE *)file); } D(("total number of elements read = %ld",result)); diff --git a/library/stdio_fwrite.c b/library/stdio_fwrite.c index 24a707f..a943b18 100644 --- a/library/stdio_fwrite.c +++ b/library/stdio_fwrite.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fwrite.c,v 1.8 2005-04-04 10:09:57 obarthel Exp $ + * $Id: stdio_fwrite.c,v 1.9 2005-04-24 19:38:59 obarthel Exp $ * * :ts=4 * @@ -161,6 +161,11 @@ fwrite(const void *ptr,size_t element_size,size_t count,FILE *stream) result = total_bytes_written / element_size; } + else + { + /* Don't let this appear like an EOF or error. */ + clearerr((FILE *)file); + } out: