From 3606b90f3c4a19708ef05140837f2aa307f2516f Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 6 May 2011 13:01:17 -0600 Subject: [PATCH] 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 --- ChangeLog | 7 +++++++ doc/posix-functions/fclose.texi | 8 ++------ modules/fclose | 2 +- tests/test-fclose.c | 5 +---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49b2766401..b7251e6198 100644 --- 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 index a7b576088e..40a205289e 100644 --- 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 index ac383aa24b..e6493c908a 100644 --- a/modules/fclose +++ b/modules/fclose @@ -8,6 +8,7 @@ m4/fclose.m4 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 @@ LGPLv2+ Maintainer: Bruno Haible - diff --git a/tests/test-fclose.c b/tests/test-fclose.c index d9b940619b..a11eca96e3 100644 --- a/tests/test-fclose.c +++ b/tests/test-fclose.c @@ -62,9 +62,7 @@ main (int argc, char **argv) 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 @@ main (int argc, char **argv) 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. */ -- 2.30.2