Eric Blake <ebb9 <at> byu.net> writes: > > Eric Blake <ebb9 <at> byu.net> writes: > > > > #elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, > > Cygwin */ > > > fp->_p = fp->_bf._base; > > > fp->_r = 0; > > > fp->_w = ((fp->_flags & (__SLBF | __SNBF) == 0) /* fully buffered? */ > > Order of operations. I'm glad to know I'm not the only one that makes this > mistake. Checking this in as obvious; unfortunately, it still doesn't solve > the fpurge crash of cygwin.
Actually, I found the real problem, with a bit more looking at the code. With this patch, test-fpurge passes on cygwin (but there may still be a memory leak if the caller does ungetc before fpurge). Committing this instead. 2007-04-16 Eric Blake <[EMAIL PROTECTED]> Fix fpurge for cygwin. * lib/fpurge.c (fpurge): Fix order of operation flub, and return a value. * modules/fpurge-tests (Depends-on): Clean up trash. diff --git a/lib/fpurge.c b/lib/fpurge.c index dc56c8f..c4572fa 100644 --- a/lib/fpurge.c +++ b/lib/fpurge.c @@ -33,9 +33,10 @@ fpurge (FILE *fp) #elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwi n */ fp->_p = fp->_bf._base; fp->_r = 0; - fp->_w = ((fp->_flags & (__SLBF | __SNBF) == 0) /* fully buffered? */ + fp->_w = ((fp->_flags & (__SLBF | __SNBF)) == 0 /* fully buffered? */ ? fp->_bf._size : 0); + return 0; #elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw */ fp->_ptr = fp->_base; if (fp->_ptr != NULL) diff --git a/modules/fpurge-tests b/modules/fpurge-tests index c80a5eb..fc4da8a 100644 --- a/modules/fpurge-tests +++ b/modules/fpurge-tests @@ -8,4 +8,4 @@ configure.ac: Makefile.am: TESTS += test-fpurge check_PROGRAMS += test-fpurge - +MOSTLYCLEANFILES += t-fpurge.tmp