]> Savannah Git Hosting - gnulib.git/commitdiff
fflush: NetBSD, OpenBSD can’t fflush input
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 16 Sep 2024 22:32:17 +0000 (15:32 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 16 Sep 2024 22:32:26 +0000 (15:32 -0700)
* m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Guess no on NetBSD and
OpenBSD; they document fflush to fail unless the stream is open
for writing.

ChangeLog
doc/posix-functions/fflush.texi
m4/fflush.m4

index b2f3e3ffb6f7ee5d8701c50fd076edf62f8cd1c1..d65e8cb88d5a6d4742e6f7b31d59c9200bda7934 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-09-16  Paul Eggert  <eggert@cs.ucla.edu>
+
+       fflush: NetBSD, OpenBSD can’t fflush input
+       * m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Guess no on NetBSD and
+       OpenBSD; they document fflush to fail unless the stream is open
+       for writing.
+
 2024-09-16  Bruno Haible  <bruno@clisp.org>
 
        unictype/category-of: Fix integer overflow in generated table.
index 0f6b7001722658979b85368f0fcec8d9172f1eb1..39f8ae973960b06a80be5319c0b8bcc6efdd9cc7 100644 (file)
@@ -20,6 +20,9 @@ end of the previous buffer, on some platforms: mingw, MSVC 14.
 @code{fflush} on an input stream right after @code{ungetc} does not discard
 the @code{ungetc} buffer, on some platforms:
 macOS 14, FreeBSD 6.0, NetBSD 10.0, OpenBSD 7.5, Cygwin 1.5.25-10.
+@item
+@code{fflush} fails with @code{EBADF} if the stream is not open for writing:
+NetBSD 10.0, OpenBSD 7.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 43fc3bf34660dcf2cd09b4656cfa9bbb07294a49..1b30fb91d4f249959b28c68db247c75d38968333 100644 (file)
@@ -1,5 +1,5 @@
 # fflush.m4
-# serial 19
+# serial 20
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -79,8 +79,9 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
        [gl_cv_func_fflush_stdin=yes],
        [gl_cv_func_fflush_stdin=no],
        [case "$host_os" in
-                             # Guess no on native Windows.
-          mingw* | windows*) gl_cv_func_fflush_stdin="guessing no" ;;
+                             # Guess no on NetBSD, OpenBSD, native Windows.
+          netbsd* | openbsd* | mingw* | windows*)
+                             gl_cv_func_fflush_stdin="guessing no" ;;
           *)                 gl_cv_func_fflush_stdin=cross ;;
         esac
        ])
@@ -92,8 +93,8 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
     *)    gl_func_fflush_stdin='(-1)' ;;
   esac
   AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin],
-    [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008,
-     0 if fflush is known to not work, -1 if unknown.])
+    [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008
+     or later, 0 if fflush is known to not work, -1 if unknown.])
 ])
 
 # Prerequisites of lib/fflush.c.