From: Bruno Haible <bruno@clisp.org>
Date: Tue, 24 Dec 2024 10:19:49 +0000 (+0100)
Subject: stdio: Support several gnulib-tool invocations better.
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=153c19d2a86f6443c67e3cffc5f5146055a752f2;p=gnulib.git

stdio: Support several gnulib-tool invocations better.

* lib/stdio.in.h: Test _GL_SKIP_GNULIB_STDIO_H.
(_GL_ALREADY_INCLUDING_STDIO_H): Rename to a macro that depends on
GUARD_PREFIX.
* lib/fopen.c: Set _GL_SKIP_GNULIB_STDIO_H instead of
_GL_ALREADY_INCLUDING_STDIO_H.
* lib/freopen.c: Likewise.
---

diff --git a/ChangeLog b/ChangeLog
index b174dbc3c3..2deb5a5ef6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-12-24  Bruno Haible  <bruno@clisp.org>
+
+	stdio: Support several gnulib-tool invocations better.
+	* lib/stdio.in.h: Test _GL_SKIP_GNULIB_STDIO_H.
+	(_GL_ALREADY_INCLUDING_STDIO_H): Rename to a macro that depends on
+	GUARD_PREFIX.
+	* lib/fopen.c: Set _GL_SKIP_GNULIB_STDIO_H instead of
+	_GL_ALREADY_INCLUDING_STDIO_H.
+	* lib/freopen.c: Likewise.
+
 2024-12-24  Bruno Haible  <bruno@clisp.org>
 
 	spawn: Support several gnulib-tool invocations better.
diff --git a/lib/fopen.c b/lib/fopen.c
index d3b57a987a..b9e6e37374 100644
--- a/lib/fopen.c
+++ b/lib/fopen.c
@@ -19,12 +19,12 @@
 /* If the user's config.h happens to include <stdio.h>, let it include only
    the system's <stdio.h> here, so that orig_fopen doesn't recurse to
    rpl_fopen.  */
-#define _GL_ALREADY_INCLUDING_STDIO_H
+#define _GL_SKIP_GNULIB_STDIO_H
 #include <config.h>
 
 /* Get the original definition of fopen.  It might be defined as a macro.  */
 #include <stdio.h>
-#undef _GL_ALREADY_INCLUDING_STDIO_H
+#undef _GL_SKIP_GNULIB_STDIO_H
 
 static FILE *
 orig_fopen (const char *filename, const char *mode)
diff --git a/lib/freopen.c b/lib/freopen.c
index e003c0ba7f..ab4a40dfe0 100644
--- a/lib/freopen.c
+++ b/lib/freopen.c
@@ -19,12 +19,12 @@
 /* If the user's config.h happens to include <stdio.h>, let it include only
    the system's <stdio.h> here, so that orig_freopen doesn't recurse to
    rpl_freopen.  */
-#define _GL_ALREADY_INCLUDING_STDIO_H
+#define _GL_SKIP_GNULIB_STDIO_H
 #include <config.h>
 
 /* Get the original definition of freopen.  It might be defined as a macro.  */
 #include <stdio.h>
-#undef _GL_ALREADY_INCLUDING_STDIO_H
+#undef _GL_SKIP_GNULIB_STDIO_H
 
 #include <errno.h>
 
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 28dfefc390..748232b5fd 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -20,7 +20,7 @@
 #endif
 @PRAGMA_COLUMNS@
 
-#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
+#if defined __need_FILE || defined __need___FILE || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H || defined _GL_SKIP_GNULIB_STDIO_H
 /* Special invocation convention:
    - Inside glibc header files.
    - On OSF/1 5.1 we have a sequence of nested includes
@@ -48,12 +48,12 @@
 # endif
 #endif
 
-#define _GL_ALREADY_INCLUDING_STDIO_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H
 
 /* The include_next requires a split double-inclusion guard.  */
 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
 
-#undef _GL_ALREADY_INCLUDING_STDIO_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H
 
 #ifdef _GL_DEFINED__POSIX_C_SOURCE
 # undef _GL_DEFINED__POSIX_C_SOURCE