]> git.saurik.com Git - apple/libc.git/blame - stdio/FreeBSD/fflush.c.patch
Libc-763.13.tar.gz
[apple/libc.git] / stdio / FreeBSD / fflush.c.patch
CommitLineData
1f2f436a
A
1--- fflush.c.bsdnew 2009-11-11 13:33:04.000000000 -0800
2+++ fflush.c 2009-11-11 13:33:04.000000000 -0800
3@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/f
224c7076
A
4 #include "namespace.h"
5 #include <errno.h>
6 #include <stdio.h>
7+#include <string.h>
8 #include "un-namespace.h"
9 #include "libc_private.h"
10 #include "local.h"
1f2f436a 11@@ -122,6 +123,14 @@ __sflush(FILE *fp)
224c7076
A
12 for (; n > 0; n -= t, p += t) {
13 t = _swrite(fp, (char *)p, n);
14 if (t <= 0) {
15+ /* 5340694: reset _p and _w on EAGAIN */
16+ if (t < 0 && errno == EAGAIN) {
17+ if (p > fp->_p) /* some was written */
18+ memmove(fp->_p, p, n);
19+ fp->_p += n;
20+ if (!(fp->_flags & (__SLBF|__SNBF)))
21+ fp->_w -= n;
22+ }
23 fp->_flags |= __SERR;
24 return (EOF);
25 }