]> git.saurik.com Git - apple/libc.git/blame - stdio/FreeBSD/fflush.c.patch
Libc-583.tar.gz
[apple/libc.git] / stdio / FreeBSD / fflush.c.patch
CommitLineData
224c7076
A
1--- fflush.c.orig 2007-07-20 11:15:28.000000000 -0700
2+++ fflush.c 2007-07-20 15:47:15.000000000 -0700
3@@ -43,6 +43,7 @@
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"
11@@ -126,6 +127,14 @@
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 }