* 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 <eblake@redhat.com>
+2011-05-06 Eric Blake <eblake@redhat.com>
+
+ 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 <bruno@clisp.org>
fflush, fpurge: Relicense under LGPLv2+.
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
Depends-on:
stdio
close [test $REPLACE_FCLOSE = 1]
+fflush [test $REPLACE_FCLOSE = 1]
freading [test $REPLACE_FCLOSE = 1]
lseek [test $REPLACE_FCLOSE = 1]
Maintainer:
Bruno Haible
-
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");
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. */