diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2004-12-13 19:42:16 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2004-12-13 19:42:16 +0000 |
commit | 82673116e1d1da7c070f4f9b6a130364ae3c6bc5 (patch) | |
tree | 8a5a1aa94b4425c6f302929a880439de8581d7ee /newlib | |
parent | c6ad91f3f8594a00290ad6f4c50553719fb858e4 (diff) | |
download | newlib-82673116e1d1da7c070f4f9b6a130364ae3c6bc5.zip newlib-82673116e1d1da7c070f4f9b6a130364ae3c6bc5.tar.gz newlib-82673116e1d1da7c070f4f9b6a130364ae3c6bc5.tar.bz2 |
2004-12-13 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/fread.c (fread): For unbuffered I/O, attempt
a low-level read if we don't get the full amount of bytes so
EOF or error flags will be set.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/ChangeLog | 6 | ||||
-rw-r--r-- | newlib/libc/stdio/fread.c | 22 |
2 files changed, 19 insertions, 9 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 349cc1e..1728367 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,9 @@ +2004-12-13 Jeff Johnston <jjohnstn@redhat.com> + + * libc/stdio/fread.c (fread): For unbuffered I/O, attempt + a low-level read if we don't get the full amount of bytes so + EOF or error flags will be set. + 2004-12-09 Alex Mogilnikov <alx@intellectronika.ru> * libc/time/tzset_r (_tzset_r): Properly skip over diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c index e0faa35..a90c50b 100644 --- a/newlib/libc/stdio/fread.c +++ b/newlib/libc/stdio/fread.c @@ -149,7 +149,7 @@ _DEFUN(fread, (buf, size, count, fp), FREEUB (fp); /* Finally read directly into user's buffer if needed. */ - if (resid > 0) + while (resid > 0) { int rc = 0; /* save fp buffering state */ @@ -162,20 +162,24 @@ _DEFUN(fread, (buf, size, count, fp), fp->_p = p; rc = __srefill (fp); /* restore fp buffering back to original state */ - resid -= fp->_r; - fp->_r = 0; fp->_bf._base = old_base; fp->_bf._size = old_size; fp->_p = old_p; -#ifdef __SCLE - if (fp->_flags & __SCLE) + resid -= fp->_r; + p += fp->_r; + fp->_r = 0; + if (rc) { +#ifdef __SCLE + if (fp->_flags & __SCLE) + { + _funlockfile (fp); + return crlf (fp, buf, total-resid, 1) / size; + } +#endif _funlockfile (fp); - return crlf (fp, buf, total-resid, 1) / size; + return (total - resid) / size; } -#endif - _funlockfile (fp); - return (total - resid) / size; } } else |