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.
This commit is contained in:
Jeff Johnston 2004-12-13 19:42:16 +00:00
parent c6ad91f3f8
commit 82673116e1
2 changed files with 20 additions and 10 deletions

View File

@ -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> 2004-12-09 Alex Mogilnikov <alx@intellectronika.ru>
* libc/time/tzset_r (_tzset_r): Properly skip over * libc/time/tzset_r (_tzset_r): Properly skip over

View File

@ -149,7 +149,7 @@ _DEFUN(fread, (buf, size, count, fp),
FREEUB (fp); FREEUB (fp);
/* Finally read directly into user's buffer if needed. */ /* Finally read directly into user's buffer if needed. */
if (resid > 0) while (resid > 0)
{ {
int rc = 0; int rc = 0;
/* save fp buffering state */ /* save fp buffering state */
@ -162,20 +162,24 @@ _DEFUN(fread, (buf, size, count, fp),
fp->_p = p; fp->_p = p;
rc = __srefill (fp); rc = __srefill (fp);
/* restore fp buffering back to original state */ /* restore fp buffering back to original state */
resid -= fp->_r;
fp->_r = 0;
fp->_bf._base = old_base; fp->_bf._base = old_base;
fp->_bf._size = old_size; fp->_bf._size = old_size;
fp->_p = old_p; fp->_p = old_p;
#ifdef __SCLE resid -= fp->_r;
if (fp->_flags & __SCLE) p += fp->_r;
fp->_r = 0;
if (rc)
{ {
_funlockfile (fp); #ifdef __SCLE
return crlf (fp, buf, total-resid, 1) / size; if (fp->_flags & __SCLE)
} {
_funlockfile (fp);
return crlf (fp, buf, total-resid, 1) / size;
}
#endif #endif
_funlockfile (fp); _funlockfile (fp);
return (total - resid) / size; return (total - resid) / size;
}
} }
} }
else else