This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
[PATCH] Allow reading after EOF returned on Cygwin
- From: Christopher Faylor <me at cgf dot cx>
- To: newlib at sourceware dot org
- Date: Wed, 17 Nov 2004 12:04:44 -0500
- Subject: [PATCH] Allow reading after EOF returned on Cygwin
Someone recently fixed a problem with tty VTIME handling on Cygwin
so now it is possible for Cygwin to return EOF on a tty stream when
there still could potentially be data available.
This means that always returning EOF after the first EOF hit is
not a good idea (and isn't like linux).
So, I've conditionalized the code in __srefill to avoid this behavior
under Cygwin.
FYI,
cgf
2004-11-17 Christopher Faylor <cgf@timesys.com>
* libc/stdio/refill.c (__srefill): Try again after EOF on Cygwin.
Clear EOF flag if successful.
Index: libc/stdio/refill.c
===================================================================
RCS file: /cvs/uberbaum/newlib/libc/stdio/refill.c,v
retrieving revision 1.4
diff -u -p -r1.4 refill.c
--- libc/stdio/refill.c 23 Apr 2004 20:01:55 -0000 1.4
+++ libc/stdio/refill.c 17 Nov 2004 17:00:16 -0000
@@ -45,9 +45,11 @@ _DEFUN(__srefill, (fp),
fp->_r = 0; /* largely a convenience for callers */
+#ifndef __CYGWIN__
/* SysV does not make this test; take it out for compatibility */
if (fp->_flags & __SEOF)
return EOF;
+#endif
/* if not already reading, have to be reading and writing */
if ((fp->_flags & __SRD) == 0)
@@ -98,7 +100,13 @@ _DEFUN(__srefill, (fp),
fp->_p = fp->_bf._base;
fp->_r = (*fp->_read) (fp->_cookie, (char *) fp->_p, fp->_bf._size);
fp->_flags &= ~__SMOD; /* buffer contents are again pristine */
+#ifndef __CYGWIN__
if (fp->_r <= 0)
+#else
+ if (fp->_r > 0)
+ fp->_flags &= ~__SEOF;
+ else
+#endif
{
if (fp->_r == 0)
fp->_flags |= __SEOF;