]> Savannah Git Hosting - gnulib.git/commitdiff
fclose: Make last change more maintainable.
authorBruno Haible <bruno@clisp.org>
Wed, 26 Apr 2023 04:06:03 +0000 (06:06 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 26 Apr 2023 04:06:03 +0000 (06:06 +0200)
* m4/fclose.m4 (gl_FUNC_FCLOSE): Define through AC_DEFUN_ONCE. Don't
modify REPLACE_FOPEN.
* modules/fclose (Depends-on): Add comment.
(configure.ac): Don't modify REPLACE_FOPEN. Don't duplicate actions of
module 'fopen'.
* m4/fopen.m4 (gl_FUNC_FOPEN_ITSELF): Renamed from gl_FUNC_FOPEN.
(gl_FUNC_FOPEN): New macro.
* modules/fopen (Files): Add m4/fclose.m4, m4/fflush.m4.
* m4/close.m4 (gl_FUNC_CLOSE): Define through AC_DEFUN_ONCE.

ChangeLog
m4/close.m4
m4/fclose.m4
m4/fopen.m4
modules/fclose
modules/fopen

index 67378ac0aee77c1879a42242c50c0a470c6c5090..04c5243b2a090d7efcc2ca1fe7a1ed86715ba917 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-04-26  Bruno Haible  <bruno@clisp.org>
+
+       fclose: Make last change more maintainable.
+       * m4/fclose.m4 (gl_FUNC_FCLOSE): Define through AC_DEFUN_ONCE. Don't
+       modify REPLACE_FOPEN.
+       * modules/fclose (Depends-on): Add comment.
+       (configure.ac): Don't modify REPLACE_FOPEN. Don't duplicate actions of
+       module 'fopen'.
+       * m4/fopen.m4 (gl_FUNC_FOPEN_ITSELF): Renamed from gl_FUNC_FOPEN.
+       (gl_FUNC_FOPEN): New macro.
+       * modules/fopen (Files): Add m4/fclose.m4, m4/fflush.m4.
+       * m4/close.m4 (gl_FUNC_CLOSE): Define through AC_DEFUN_ONCE.
+
 2023-04-26  Po Lu  <luangruo@yahoo.com>  (tiny change)
             Bruno Haible  <bruno@clisp.org>
 
index 9f95c670e5ca06287c3599948746acc619173938..0feabd6917856be38dff3789e5adda94da865917 100644 (file)
@@ -1,10 +1,10 @@
-# close.m4 serial 9
+# close.m4 serial 10
 dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-AC_DEFUN([gl_FUNC_CLOSE],
+AC_DEFUN_ONCE([gl_FUNC_CLOSE],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   m4_ifdef([gl_MSVC_INVAL], [
index 74b7df0a77a783e024adfa0ec367e7a819bad148..e9291f0bdabcf536b9feb0c0693b6b0b295307ce 100644 (file)
@@ -1,10 +1,10 @@
-# fclose.m4 serial 10
+# fclose.m4 serial 11
 dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-AC_DEFUN([gl_FUNC_FCLOSE],
+AC_DEFUN_ONCE([gl_FUNC_FCLOSE],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
@@ -31,10 +31,6 @@ AC_DEFUN([gl_FUNC_FCLOSE],
       *) REPLACE_FCLOSE=1 ;;
     esac
   fi
-
-  if test $REPLACE_FCLOSE = 1; then
-    REPLACE_FOPEN=1
-  fi
 ])
 
 dnl Determine whether fclose works on input streams.
index 6806394f8c01e38521fbca8fedf58ea0c838b9cc..7daa4caec5b25e391c01ba8f5a29efee11b9f31d 100644 (file)
@@ -1,10 +1,10 @@
-# fopen.m4 serial 14
+# fopen.m4 serial 15
 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-AC_DEFUN([gl_FUNC_FOPEN],
+AC_DEFUN([gl_FUNC_FOPEN_ITSELF],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
@@ -58,6 +58,15 @@ changequote([,])dnl
   esac
 ])
 
+AC_DEFUN([gl_FUNC_FOPEN],
+[
+  AC_REQUIRE([gl_FUNC_FOPEN_ITSELF])
+  AC_REQUIRE([gl_FUNC_FCLOSE])
+  if test $REPLACE_FCLOSE = 1; then
+    REPLACE_FOPEN=1
+  fi
+])
+
 AC_DEFUN([gl_FUNC_FOPEN_GNU],
 [
   AC_REQUIRE([gl_FUNC_FOPEN])
index 9a949e48b8087a0ae4af46c733fc9eeeacafdc6d..0ef34bdfd9cc73872b960bfd9d2d472e74025ea8 100644 (file)
@@ -9,18 +9,16 @@ Depends-on:
 stdio
 close           [test $REPLACE_FCLOSE = 1]
 fflush          [test $REPLACE_FCLOSE = 1]
-fopen           [test $REPLACE_FCLOSE = 1]
 freading        [test $REPLACE_FCLOSE = 1]
 lseek           [test $REPLACE_FCLOSE = 1]
 msvc-inval      [test $REPLACE_FCLOSE = 1]
+# The code of fclose does not need to call fopen. But when gcc's '-fanalyzer'
+# option is in use and stdio.h does '#define fclose rpl_fclose', stdio.h also
+# needs to do '#define fopen rpl_fopen', otherwise a warning may result.
+fopen           [test $REPLACE_FCLOSE = 1]
 
 configure.ac:
 gl_FUNC_FCLOSE
-if test $REPLACE_FCLOSE = 1; then
-  REPLACE_FOPEN=1
-  AC_LIBOBJ([fopen])
-  gl_PREREQ_FOPEN
-fi
 gl_CONDITIONAL([GL_COND_OBJ_FCLOSE], [test $REPLACE_FCLOSE = 1])
 gl_STDIO_MODULE_INDICATOR([fclose])
 
index da216c9cec01cb13293d0e1fa356bffe81418877..3d538393f10822e184d9d7b9e1f1e945d3962e09 100644 (file)
@@ -4,6 +4,8 @@ fopen() function: open a stream to a file.
 Files:
 lib/fopen.c
 m4/fopen.m4
+m4/fclose.m4
+m4/fflush.m4
 
 Depends-on:
 stdio