On 08/17/14 13:20, Andrey Chernov wrote:
On 16.08.2014 5:29, Pedro F. Giffuni wrote:
Author: pfg
Date: Sat Aug 16 01:29:49 2014
New Revision: 270035
URL: http://svnweb.freebsd.org/changeset/base/270035
Log:
MFC r268924:
Update fflush(3) to return success on a read-only stream.
This is done for compliance with SUSv3. The changes cause
no secondary effects in the gnulib tests (we pass them).
...
@@ -122,6 +123,12 @@ __sflush(FILE *fp)
for (; n > 0; n -= t, p += t) {
t = _swrite(fp, (char *)p, n);
if (t <= 0) {
+ /* Reset _p and _w. */
+ if (p > fp->_p) /* Some was written. */
+ memmove(fp->_p, p, n);
+ fp->_p += n;
+ if ((fp->_flags & (__SLBF | __SNBF)) == 0)
+ fp->_w -= n;
fp->_flags |= __SERR;
return (EOF);
}
The description is incomplete. This code also does internal stdio
structure adjustment for partial write.
Oh yes, I forgot about that part.
The story is that Apple only does this for EAGAIN but Bruce suggested it
should be done for other errors as well.
TBH, I wasn't going to merge this change but it seemed consistent to have
all the changes that originated from Apple's libc together.
Pedro.
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"