-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Bruno Haible on 1/15/2009 4:24 PM: > The fflush-after-ungetc test fails on glibc, *BSD, mingw platforms. > This makes it work for glibc systems - at the cost of introducing a > slim override of fflush(). > > Eric, comments or objections?
In general, a big thanks for tackling this. Have you filed a glibc bug report on this? > +++ lib/fseeko.c 2009-01-16 00:18:29.000000000 +0100 > @@ -86,7 +86,14 @@ > #error "Please port gnulib fseeko.c to your platform! Look at the code in > fpurge.c, then report this to bug-gnulib." > #endif > { > - off_t pos = lseek (fileno (fp), offset, whence); > + /* We get here when an fflush() call immediately preceded this one. We > + know there are no buffers. > + POSIX requires us to modify the file descriptor's position. > + But we cannot position beyond end of file here. */ > + off_t pos = > + lseek (fileno (fp), > + whence == SEEK_END && offset > 0 ? 0 : offset, > + whence); I found this hunk a bit confusing in isolation; it should still be possible to seek beyond the end of a stream, with no impact until another action (such as fputc) modifies the stream, at which point NUL bytes are implicitly written in the gap between the former end of file and the new position. Does this happen latter (if so, the comment could give a reference to that), or am I missing something by not reading the final resulting file? - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAklwEoIACgkQ84KuGfSFAYBQRQCeJkTLBkT7DVzW+QCtz/6P+DGB CHwAn2p9dW241Gf94IFxN/JgrPeKV5Ef =MShD -----END PGP SIGNATURE-----