Fix bug: AC_EGREP_CPP with leading '-' in pattern

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.
This commit is contained in:
Paul Eggert 2022-06-05 14:19:21 -07:00
parent ef27f692a0
commit 0c76267536
2 changed files with 21 additions and 5 deletions

View 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*

View 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
])