I have pushed the attached two patches, which replace internal uses of
AC_EGREP_CPP with simpler and/or robust checks.  See the discussion at
the bottom of
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/html_node/Running-the-Preprocessor.html
for why AC_EGREP_CPP is fragile and should generally be avoided.

zw



From dcf9bb7e3b12f3bd74edff60e80b53e668159579 Mon Sep 17 00:00:00 2001
From: Zack Weinberg <za...@panix.com>
Date: Sun, 2 Apr 2023 10:27:08 -0400
Subject: [PATCH 1/2] AC_XENIX_DIR: Rewrite using AC_CANONICAL_HOST.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

AC_XENIX_DIR is an obsolete macro, defined as AC_HEADER_DIRENT plus
code to make absolutely sure configure scripts that depended on a
shell variable internal to the original (2.13 era) definition of
AC_XENIX_DIR are not broken by autoupdate.  (That variable had the
temptingly public-sounding name “XENIX.”)  This compatibility code
uses AC_EGREP_CPP, which is itself discouraged for use in new
configure scripts.

(N.B. codesearch.debian.net does not find any uses whatsoever of
this macro, nor any code in an .ac or .m4 file that depends on the
XENIX variable.)

Change the compatibility code to use AC_CANONICAL_HOST instead,
and clarify which pieces of the code inserted by autoupdate are
probably still necessary.

* lib/autoconf/specific.m4 (AC_XENIX_DIR): Set XENIX variable
  based on value of host_os. Clarify what manual cleanup is
  recommended after autoupdate replaces this obsolete macro.
---
 lib/autoconf/specific.m4 | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4
index 1b3ee661..a2dc5d48 100644
--- a/lib/autoconf/specific.m4
+++ b/lib/autoconf/specific.m4
@@ -754,9 +754,9 @@ dnl it should only be defined when necessary.
 ## Checks for UNIX variants.  ##
 ## -------------------------- ##
 
-
-# These are kludges which should be replaced by a single POSIX check.
-# They aren't cached, to discourage their use.
+# These macros are all obsolete, from the early days of Autoconf,
+# before the invention of AC_CANONICAL_SYSTEM.  Autoupdate will
+# replace each with inline code for a more modern feature check.
 
 # AC_AIX
 # ------
@@ -776,19 +776,15 @@ AU_DEFUN([AC_ISC_POSIX], [AC_SEARCH_LIBS([strerror], [cposix])])
 # AC_XENIX_DIR
 # ------------
 AU_DEFUN([AC_XENIX_DIR],
-[AC_MSG_CHECKING([for Xenix])
-AC_EGREP_CPP([yes],
-[#if defined M_XENIX && ! defined M_UNIX
-  yes
-@%:@endif],
-	     [AC_MSG_RESULT([yes]); XENIX=yes],
-	     [AC_MSG_RESULT([no]); XENIX=])
-
-AC_HEADER_DIRENT[]dnl
+[AC_HEADER_DIRENT
+# Autoupdate added the next two lines to ensure that your configure
+# script's behavior did not change.  They are safe to remove unless
+# you have code that depends on the XENIX shell variable.
+AC_CANONICAL_HOST
+AS_CASE([$host_os], [xenix*], [XENIX=yes], [XENIX=no])
+# End of code added by autoupdate
 ],
-[You shouldn't need to depend upon XENIX.  Remove the
-'AC_MSG_CHECKING', 'AC_EGREP_CPP', and this warning if this part
-of the test is useless.])
+[Check for code depending on the XENIX shell variable.])
 
 
 # AC_DYNIX_SEQ
-- 
2.39.2

From 51d98495d1aac00970d791f064e83ca762bf81c7 Mon Sep 17 00:00:00 2001
From: Zack Weinberg <za...@panix.com>
Date: Sun, 2 Apr 2023 10:43:51 -0400
Subject: [PATCH 2/2] AC_TYPE_UID_T: Rewrite using AC_CHECK_TYPE.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

AC_TYPE_UID_T uses AC_EGREP_HEADER to search sys/types.h for
occurrences of the string ‘uid_t’ and, if found, assumes both
uid_t and gid_t are available.  This would be better done using
a pair of AC_CHECK_TYPE operations.

I also converted two uses of old-style AC_CHECK_TYPE, immediately
below, to new-style.  (There are probably other old-style uses in
this file, I only did the ones I happened to see.)

* lib/autoconf/types.m4 (AC_TYPE_UID_T): Check for uid_t and gid_t,
  separately, using AC_CHECK_TYPE, instead of grepping sys/types.h.
  (AC_TYPE_SIZE_T, AC_TYPE_SSIZE_T): Use new-style AC_CHECK_TYPE.
---
 lib/autoconf/types.m4 | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index ebac0cf6..ef245613 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -589,25 +589,29 @@ AC_DEFUN([AC_TYPE_MBSTATE_T],
 
 # AC_TYPE_UID_T
 # -------------
-# FIXME: Rewrite using AC_CHECK_TYPE.
 AN_IDENTIFIER([gid_t], [AC_TYPE_UID_T])
 AN_IDENTIFIER([uid_t], [AC_TYPE_UID_T])
 AC_DEFUN([AC_TYPE_UID_T],
-[AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
-[AC_EGREP_HEADER(uid_t, sys/types.h,
-  ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
-if test $ac_cv_type_uid_t = no; then
-  AC_DEFINE(uid_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
-  AC_DEFINE(gid_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
-fi
-])
-
+[AC_CHECK_TYPE([uid_t], [],
+  [AC_DEFINE([uid_t], [int],
+    [Define as 'int' if <sys/types.h> doesn't define.])])
+AC_CHECK_TYPE([gid_t], [],
+  [AC_DEFINE([gid_t], [int],
+    [Define as 'int' if <sys/types.h> doesn't define.])])])
 
+# This should be obsoleted, size_t is in C90.
 AN_IDENTIFIER([size_t], [AC_TYPE_SIZE_T])
-AC_DEFUN([AC_TYPE_SIZE_T], [AC_CHECK_TYPE(size_t, unsigned int)])
+AC_DEFUN([AC_TYPE_SIZE_T],
+[AC_CHECK_TYPE([size_t], [],
+  [AC_DEFINE([size_t], [unsigned int],
+    [Define as 'unsigned int' if <stddef.h> doesn't define.])])])
 
 AN_IDENTIFIER([ssize_t], [AC_TYPE_SSIZE_T])
-AC_DEFUN([AC_TYPE_SSIZE_T], [AC_CHECK_TYPE(ssize_t, int)])
+AC_DEFUN([AC_TYPE_SSIZE_T],
+[AC_CHECK_TYPE([ssize_t], [],
+  [AC_DEFINE([ssize_t], [int],
+    [Define as 'int' if <sys/types.h> doesn't define.])])])
+
 
 AN_IDENTIFIER([pid_t], [AC_TYPE_PID_T])
 AC_DEFUN([AC_TYPE_PID_T],
-- 
2.39.2

Reply via email to