# HG changeset patch # User Eric Blake # Date 1304708477 21600 # Node ID 334032e8de7409bb9380b88fe16f66664b2d402e # Parent fe82559e011fb7d92bdad1a0b0927a4ed9659df6 fclose: guarantee behavior on seekable stdin * modules/fclose (Depends-on): Add fflush. * doc/posix-functions/fclose.texi (fclose): Document this. * tests/test-fclose.c (main): Make test for this unconditional. Signed-off-by: Eric Blake diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-05-06 Eric Blake + + fclose: guarantee behavior on seekable stdin + * modules/fclose (Depends-on): Add fflush. + * doc/posix-functions/fclose.texi (fclose): Document this. + * tests/test-fclose.c (main): Make test for this unconditional. + 2011-05-06 Bruno Haible fflush, fpurge: Relicense under LGPLv2+. diff --git a/doc/posix-functions/fclose.texi b/doc/posix-functions/fclose.texi --- a/doc/posix-functions/fclose.texi +++ b/doc/posix-functions/fclose.texi @@ -4,18 +4,14 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/fclose.html} -Gnulib module: fclose, fflush +Gnulib module: fclose -Portability problems fixed by Gnulib module @code{fclose} together with module @code{fflush}: +Portability problems fixed by Gnulib: @itemize @item On some platforms, this function fails to set the file position of a seekable input stream to the byte after the last one actually read: glibc 2.13, FreeBSD. -@end itemize - -Portability problems fixed by Gnulib module @code{fclose}: -@itemize @item On Windows platforms (excluding Cygwin), @code{socket} and @code{accept} followed by @code{fdopen} do not return streams that can be closed by diff --git a/modules/fclose b/modules/fclose --- a/modules/fclose +++ b/modules/fclose @@ -8,6 +8,7 @@ Depends-on: stdio close [test $REPLACE_FCLOSE = 1] +fflush [test $REPLACE_FCLOSE = 1] freading [test $REPLACE_FCLOSE = 1] lseek [test $REPLACE_FCLOSE = 1] @@ -25,4 +26,3 @@ Maintainer: Bruno Haible - diff --git a/tests/test-fclose.c b/tests/test-fclose.c --- a/tests/test-fclose.c +++ b/tests/test-fclose.c @@ -62,9 +62,7 @@ ASSERT (errno == EBADF); ASSERT (lseek (fd, 0, SEEK_CUR) == 2); -#if GNULIB_FFLUSH - /* Likewise for an input stream, but only when we know fflush works - on input streams. */ + /* Likewise for an input stream. */ fd2 = dup (fd); ASSERT (0 <= fd2); f = fdopen (fd2, "r"); @@ -75,7 +73,6 @@ ASSERT (lseek (fd2, 0, SEEK_CUR) == -1); ASSERT (errno == EBADF); ASSERT (lseek (fd, 0, SEEK_CUR) == 3); -#endif /* Test that fclose() sets errno if someone else closes the stream fd behind the back of stdio. */