]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix bug: AC_EGREP_CPP with leading '-' in pattern
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 5 Jun 2022 21:19:21 +0000 (14:19 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 9 Jun 2022 00:57:37 +0000 (17:57 -0700)
Also, port AC_EGREP_CPP to AT&T UnixPC.
Latter problem reported by Alain Knaff [sr #110657].
* lib/autoconf/general.m4 (AC_EGREP_CPP): Use new _AC_PROG_GREP.
Work even if the pattern starts with "-".
* lib/autoconf/programs.m4 (_AC_PROG_GREP):
New optional arg ACTION-IF-NOT-FOUND.
(_AC_PROG_EGREP_TRADITIONAL): New macro.

lib/autoconf/general.m4
lib/autoconf/programs.m4

index 3a0e47b98732f75e0d235fc0573dc1f2716ab5c2..5540ae057f31a91eecb16f934978b08e69f20b6c 100644 (file)
@@ -2770,13 +2770,13 @@ AU_DEFUN([AC_TRY_CPP],
 # come early, it is not included in AC_BEFORE checks.
 AC_DEFUN([AC_EGREP_CPP],
 [AC_LANG_PREPROC_REQUIRE()dnl
-AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([_AC_PROG_EGREP_TRADITIONAL])dnl
 AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
 AS_IF([dnl eval is necessary to expand ac_cpp.
 dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
 (eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
 dnl Quote $1 to prevent m4 from eating character classes
-  $EGREP "[$1]" >/dev/null 2>&1],
+  $EGREP_TRADITIONAL "m4_bregexp([$1],[^[$-]],[.?])[$1]" >/dev/null 2>&1],
   [$3],
   [$4])
 rm -rf conftest*
index 67435a9fd499dda90421216720964bfb7f1323e2..f29d61628ca3ddc35847df9dc76150e2ec0a2190 100644 (file)
@@ -373,6 +373,21 @@ AC_CACHE_CHECK([for egrep], ac_cv_path_EGREP,
  AC_SUBST([EGREP])
 ])# AC_PROG_EGREP
 
+# _AC_PROG_EGREP_TRADITIONAL
+# --------------------------
+# Check for a grep -E program or equivalent.
+# Less stringent than AC_PROG_EGREP, as it succeeds even if there
+# is no working 'grep' or if the -e option does not work (e.g., AT&T UnixPC).
+AC_DEFUN([_AC_PROG_EGREP_TRADITIONAL],
+[AC_CACHE_CHECK([for egrep -e], [ac_cv_path_EGREP_TRADITIONAL],
+   [_AC_PROG_GREP([EGREP_TRADITIONAL], [grep ggrep],
+      [-E 'EGR(EP|AC)_TRADITIONAL$'], [:])
+    AS_IF([test "$ac_cv_path_EGREP_TRADITIONAL"],
+      [ac_cv_path_EGREP_TRADITIONAL="$ac_cv_path_EGREP_TRADITIONAL -E"],
+      [_AC_PROG_GREP([EGREP_TRADITIONAL], [egrep],
+        ['EGR(EP|AC)_TRADITIONAL$'])])])
+ EGREP_TRADITIONAL=$ac_cv_path_EGREP_TRADITIONAL
+])
 
 # AC_PROG_FGREP
 # -------------
@@ -402,15 +417,16 @@ AC_DEFUN([AC_PROG_GREP],
 ])
 
 
-# _AC_PROG_GREP(VARIABLE, PROGNAME-LIST, PROG-ARGUMENTS)
-# ------------------------------------------------------
+# _AC_PROG_GREP(VARIABLE, PROGNAME-LIST, [PROG-ARGUMENTS],
+#              [ACTION-IF-NOT-FOUND])
+# --------------------------------------------------------
 # Solaris 9 /usr/xpg4/bin/*grep is suitable, but /usr/bin/*grep lacks -e.
 # AIX silently truncates long lines before matching.
 # NeXT understands only one -e and truncates long lines.
 m4_define([_AC_PROG_GREP],
 [_AC_PATH_PROGS_FEATURE_CHECK([$1], [$2],
        [_AC_FEATURE_CHECK_LENGTH([ac_path_$1], [ac_cv_path_$1],
-               ["$ac_path_$1" $3], [$1])], [],
+               ["$ac_path_$1" $3], [$1])], [$4],
        [$PATH$PATH_SEPARATOR/usr/xpg4/bin])dnl
 ])