>From a690f1be8debcbe5d5265915233d533a7f9dcbaf Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 3 Jan 2022 16:17:18 +0100 Subject: [PATCH 4/5] fopen-gnu: Allow use as dependency from test modules. * m4/fopen.m4 (gl_FUNC_FOPEN_GNU): Set REPLACE_FOPEN_FOR_FOPEN_GNU instead of REPLACE_FOPEN. * m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize the fopen-gnu module indicator. (gl_STDIO_H_DEFAULTS): Initialize REPLACE_FOPEN_FOR_FOPEN_GNU. * modules/stdio (Makefile.am): Substitute GNULIB_FOPEN_GNU, REPLACE_FOPEN_FOR_FOPEN_GNU. * modules/fopen-gnu (Depends-on): Add more dependencies. (configure.ac): Test REPLACE_FOPEN_FOR_FOPEN_GNU instead of REPLACE_FOPEN. * lib/stdio.in.h (fopen): Test REPLACE_FOPEN, REPLACE_FOPEN_FOR_FOPEN_GNU, and the respective module indicators instead of just REPLACE_FOPEN. --- ChangeLog | 17 +++++++++++++++++ lib/stdio.in.h | 3 ++- m4/fopen.m4 | 7 ++++--- m4/stdio_h.m4 | 4 +++- modules/fopen-gnu | 9 +++++++-- modules/stdio | 2 ++ 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 655529e83..9824e5793 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2022-01-03 Bruno Haible + + fopen-gnu: Allow use as dependency from test modules. + * m4/fopen.m4 (gl_FUNC_FOPEN_GNU): Set REPLACE_FOPEN_FOR_FOPEN_GNU + instead of REPLACE_FOPEN. + * m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize the fopen-gnu + module indicator. + (gl_STDIO_H_DEFAULTS): Initialize REPLACE_FOPEN_FOR_FOPEN_GNU. + * modules/stdio (Makefile.am): Substitute GNULIB_FOPEN_GNU, + REPLACE_FOPEN_FOR_FOPEN_GNU. + * modules/fopen-gnu (Depends-on): Add more dependencies. + (configure.ac): Test REPLACE_FOPEN_FOR_FOPEN_GNU instead of + REPLACE_FOPEN. + * lib/stdio.in.h (fopen): Test REPLACE_FOPEN, + REPLACE_FOPEN_FOR_FOPEN_GNU, and the respective module indicators + instead of just REPLACE_FOPEN. + 2022-01-03 Bruno Haible realloc-gnu: Allow use as dependency from test modules. diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 8fcec011d..7b36dac2f 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -399,7 +399,8 @@ _GL_CXXALIASWARN (fileno); #endif #if @GNULIB_FOPEN@ -# if @REPLACE_FOPEN@ +# if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \ + || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fopen # define fopen rpl_fopen diff --git a/m4/fopen.m4 b/m4/fopen.m4 index a17719743..50767f828 100644 --- a/m4/fopen.m4 +++ b/m4/fopen.m4 @@ -1,4 +1,4 @@ -# fopen.m4 serial 12 +# fopen.m4 serial 13 dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -136,11 +136,12 @@ int main () ]) rm -f conftest.x ]) + REPLACE_FOPEN_FOR_FOPEN_GNU="$REPLACE_FOPEN" case "$gl_cv_func_fopen_mode_x" in - *no) REPLACE_FOPEN=1 ;; + *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;; esac case "$gl_cv_func_fopen_mode_e" in - *no) REPLACE_FOPEN=1 ;; + *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;; esac ]) diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 index 3180d43f4..cc80e7736 100644 --- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -1,4 +1,4 @@ -# stdio_h.m4 serial 56 +# stdio_h.m4 serial 57 dnl Copyright (C) 2007-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -119,6 +119,7 @@ AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE]) @@ -202,6 +203,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN]) REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) + REPLACE_FOPEN_FOR_FOPEN_GNU=0; AC_SUBST([REPLACE_FOPEN_FOR_FOPEN_GNU]) REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) diff --git a/modules/fopen-gnu b/modules/fopen-gnu index 9252c749b..86635a140 100644 --- a/modules/fopen-gnu +++ b/modules/fopen-gnu @@ -6,11 +6,16 @@ lib/fopen.c Depends-on: fopen -open [test $REPLACE_FOPEN = 1] +open [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] +fcntl-h [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] +stdbool [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] +unistd [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] +close [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] +fstat [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] configure.ac: gl_FUNC_FOPEN_GNU -if test $REPLACE_FOPEN = 1; then +if test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1; then AC_LIBOBJ([fopen]) gl_PREREQ_FOPEN fi diff --git a/modules/stdio b/modules/stdio index dab8d4e8b..0f250558d 100644 --- a/modules/stdio +++ b/modules/stdio @@ -66,6 +66,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \ + -e 's/@''GNULIB_FOPEN_GNU''@/$(GNULIB_FOPEN_GNU)/g' \ -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \ -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \ -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \ @@ -141,6 +142,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ + -e 's|@''REPLACE_FOPEN_FOR_FOPEN_GNU''@|$(REPLACE_FOPEN_FOR_FOPEN_GNU)|g' \ -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ -- 2.25.1