[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Don't assume grep handles -e in lib/freeze.mk
From: |
Paul Eggert |
Subject: |
Re: Don't assume grep handles -e in lib/freeze.mk |
Date: |
Sun, 02 May 2004 23:54:15 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Albert Chin <address@hidden> writes:
> - grep $(forbidden_patterns) $(forbidden_patterns_files)) \
> + egrep $(forbidden_patterns) $(forbidden_patterns_files)) \
Thanks, but we don't want to assume the existence of 'egrep', as POSIX
1003.1-2001 no longer requires support for 'egrep'. I installed the
following patch instead; it should work around the Solaris problem,
assuming you have either GNU grep or /usr/xpg4/bin/grep installed
somewhere.
2004-05-02 Paul Eggert <address@hidden>
* doc/autoconf.texi (Particular Programs): AC_PROG_GREP
now prefers 'grep' implementations that accept -e.
(Limitations of Usual Tools): Describe problems of traditional
egrep and fgrep with long input lines, and of traditional grep
with -e.
* lib/autoconf/programs.m4 (AC_PROG_GREP): Check for -e, too.
(_AC_PROG_GREP): Assume 3rd arg is properly quoted for the shell.
All callers changed. Append /usr/xpg4/bin to the PATH, for
Solaris.
(_AC_FEATURE_CHECK_LENGTH): Discard stderr, so we don't bother
the user with complaints about multiple -e options.
* tests/local.at (AC_STATE_SAVE): Use $GREP, not grep.
Define it with AC_PROG_GREP.
* configure.ac (AC_PROG_GREP): Add.
* lib/freeze.mk (GREP): New macro.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.810
diff -p -u -r1.810 autoconf.texi
--- doc/autoconf.texi 21 Apr 2004 08:23:18 -0000 1.810
+++ doc/autoconf.texi 3 May 2004 05:52:18 -0000
@@ -3239,9 +3239,11 @@ best implementation.
@acindex{PROG_GREP}
@ovindex GREP
On AIX the default @code{grep} silently truncates long lines on the
-input before matching. This macro looks for @sc{gnu} Grep or
+input before matching. On Solaris 9 @code{/usr/bin/grep} does not
+understand the @option{-e} option. This macro looks for @sc{gnu} Grep or
else the best available @code{grep} or @code{ggrep} in the user's
address@hidden, which accepts the longest input lines possible. Set the
address@hidden, which accepts the longest input lines possible and which
+accepts @option{-e}. Set the
output variable @code{GREP} to whatever is chosen.
@end defmac
@@ -11132,7 +11134,8 @@ of Unix.
@prindex @command{egrep}
@acronym{POSIX} 1003.1-2001 no longer requires @command{egrep},
but many older hosts do not yet support the @acronym{POSIX}
-replacement @code{grep -E}. To work around this problem, invoke
+replacement @code{grep -E}. Also, some traditional implementations do
+not work on long input lines. To work around these problems, invoke
@code{AC_PROG_EGREP} and then use @code{$EGREP}.
The empty alternative is not portable, use @samp{?} instead. For
@@ -11253,7 +11256,8 @@ set to @command{expr} or to @command{fal
@prindex @command{fgrep}
@acronym{POSIX} 1003.1-2001 no longer requires @command{fgrep},
but many older hosts do not yet support the @acronym{POSIX}
-replacement @code{grep -F}. To work around this problem, invoke
+replacement @code{grep -F}. Also, some traditional implementations do
+not work on long input lines. To work around these problems, invoke
@code{AC_PROG_FGREP} and then use @code{$FGREP}.
@@ -11287,10 +11291,12 @@ redirect the standard output and standar
doesn't exist) of @code{grep} to @file{/dev/null}. Check the exit
status of @code{grep} to determine whether it found a match.
-Don't use multiple regexps with @option{-e}, as some @code{grep} will only
-honor the last pattern (e.g., @sc{irix} 6.5 and Solaris 2.5.1). Anyway,
-Stardent Vistra SVR4 @code{grep} lacks @address@hidden Instead, use
-extended regular expressions and alternation.
+Some traditional @command{grep} implementations do not work on long
+input lines. Also, many implementations do not support multiple regexps
+with @option{-e}: they either reject @samp{-e} entirely (e.g., Solaris
+9) or honor only the the last pattern (e.g., @acronym{IRIX} 6.5). To
+work around these problems, invoke @code{AC_PROG_GREP} and then use
address@hidden
Don't rely on @option{-w}, as Irix 6.5.16m's @command{grep} does not
support it.
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.27
retrieving revision 1.29
diff -p -u -r1.27 -r1.29
--- lib/autoconf/programs.m4 23 Apr 2004 10:24:32 -0000 1.27
+++ lib/autoconf/programs.m4 3 May 2004 06:48:24 -0000 1.29
@@ -366,7 +366,7 @@ AC_CACHE_CHECK([for egrep], ac_cv_path_E
[if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
- _AC_PROG_GREP(EGREP, egrep, [EGREP$])
+ _AC_PROG_GREP(EGREP, egrep, ['EGREP$'])
fi])
EGREP="$ac_cv_path_EGREP"
AC_SUBST([EGREP])
@@ -381,7 +381,7 @@ AC_CACHE_CHECK([for fgrep], ac_cv_path_F
[if echo 'ab*c' | ($GREP -F 'ab*c') >/dev/null 2>&1
then ac_cv_path_FGREP="$GREP -F"
else
- _AC_PROG_GREP(FGREP, fgrep, FGREP)
+ _AC_PROG_GREP(FGREP, fgrep, [FGREP])
fi])
FGREP="$ac_cv_path_FGREP"
AC_SUBST([FGREP])
@@ -393,16 +393,19 @@ AC_CACHE_CHECK([for fgrep], ac_cv_path_F
# Check for a fully functional grep program that handles
# the longest lines possible. Prefer GNU grep if found.
AC_DEFUN([AC_PROG_GREP],
-[AC_CACHE_CHECK([for grep that handles long lines], ac_cv_path_GREP,
- [_$0(GREP, [grep ggrep], [GREP$])])
+[AC_CACHE_CHECK([for grep that handles long lines and -e], ac_cv_path_GREP,
+ [_$0(GREP, [grep ggrep], [-e 'GREP$' -e '-(cannot match)-'])])
GREP="$ac_cv_path_GREP"
AC_SUBST([GREP])
])
-# _AC_PROG_GREP(VARIABLE, PROGNAME-LIST, MATCH-EXPRESSION)
+# _AC_PROG_GREP(VARIABLE, PROGNAME-LIST, PROG-ARGUMENTS)
m4_define([_AC_PROG_GREP],
[_AC_PATH_PROG_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])],
+ dnl Add /usr/xpg4/bin/*grep as it is typically found on Solaris
+ dnl along with a /usr/bin/*grep that lacks -e.
+ [$PATH:/usr/xpg4/bin])
])
@@ -468,7 +471,7 @@ m4_define([_AC_FEATURE_CHECK_LENGTH],
mv "$tmp/conftest.tmp" "$tmp/conftest.in"
cp "$tmp/conftest.in" "$tmp/conftest.nl"
echo '$4' >> "$tmp/conftest.nl"
- $3 < "$tmp/conftest.nl" >"$tmp/conftest.out" || break
+ $3 < "$tmp/conftest.nl" >"$tmp/conftest.out" 2>/dev/null || break
diff "$tmp/conftest.out" "$tmp/conftest.nl" >/dev/null 2>&1 || break
ac_count=`expr $ac_count + 1`
if test $ac_count -gt ${$1_max-0}; then
@@ -720,7 +723,7 @@ AC_DEFUN([AC_PROG_SED],
[_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
["$ac_path_SED" -e 's/a$//'])],
dnl Add /usr/xpg4/bin/sed as it is typically found on Solaris
- dnl along with a /bin/sed that truncates output.
+ dnl along with a /usr/bin/sed that truncates output.
[$PATH:/usr/xpg4/bin])])
SED="$ac_cv_path_SED"
AC_SUBST([SED])
Index: tests/local.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/local.at,v
retrieving revision 1.5
diff -p -u -r1.5 local.at
--- tests/local.at 30 Jan 2004 14:21:36 -0000 1.5
+++ tests/local.at 3 May 2004 05:52:18 -0000
@@ -192,7 +192,7 @@ m4_define([AT_CONFIGURE_AC],
# to keep the error message but we can't: that would break AT_CHECK.
m4_defun([AC_STATE_SAVE],
[(set) 2>&1 |
- grep -E -v -e 'm4_join([|],
+ $GREP -E -v -e 'm4_join([|],
[^a[cs]_],
[^((exec_)?prefix|DEFS|CONFIG_STATUS)=],
[^(CC|CFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77)=],
@@ -209,7 +209,7 @@ m4_defun([AC_STATE_SAVE],
[^(_|@|.[*#?].|LINENO|OLDPWD|PIPESTATUS|RANDOM|SECONDS)=])' 2>/dev/null |
# There maybe variables spread on several lines, eg IFS, remove the dead
# lines.
- grep '^m4_defn([m4_re_word])=' >state-env.$][1
+ $GREP '^m4_defn([m4_re_word])=' >state-env.$][1
test $? = 0 || rm -f state-env.$][1
ls -1 | sed '/^at-/d;/^state-/d;/^config\./d' | sort >state-ls.$][1
])# AC_STATE_SAVE
@@ -219,6 +219,7 @@ AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_AUX_DIR($top_srcdir/config)
AC_CONFIG_HEADER(config.h:config.hin)
+AC_PROG_GREP
AC_STATE_SAVE(before)]
$1
[AC_OUTPUT
Index: configure.ac
===================================================================
RCS file: /cvsroot/autoconf/autoconf/configure.ac,v
retrieving revision 1.68
diff -p -u -r1.68 configure.ac
--- configure.ac 25 Dec 2003 15:49:59 -0000 1.68
+++ configure.ac 3 May 2004 06:17:55 -0000
@@ -1,9 +1,9 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003
-# Free Software Foundation, Inc.
-#
+# Copyright (C) 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003,
+# 2004 Free Software Foundation, Inc.
+
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
@@ -161,6 +161,12 @@ EOF
AC_SUBST([EMACS], [$TEST_EMACS])
AM_PATH_LISPDIR
+
+
+## ------ ##
+## Grep. ##
+## ------ ##
+AC_PROG_GREP
## ------------ ##
Index: lib/freeze.mk
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/freeze.mk,v
retrieving revision 1.9
diff -p -u -r1.9 freeze.mk
--- lib/freeze.mk 27 Oct 2002 18:16:06 -0000 1.9
+++ lib/freeze.mk 3 May 2004 06:17:55 -0000
@@ -1,6 +1,6 @@
## Freeze M4 files.
-## Copyright (C) 2002 Free Software Foundation, Inc.
+## Copyright (C) 2002, 2004 Free Software Foundation, Inc.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -113,13 +113,20 @@ ETAGS_FOR_AUTOCONF = \
--regex='/AN_\(FUNCTION\|HEADER\|IDENTIFIER\|LIBRARY\|MAKEVAR\|PROGRAM\)(\[\([^]]*\)\]/\2/'
+## ---------- ##
+## Run GREP. ##
+## ---------- ##
+
+GREP = @GREP@
+
+
## -------------------------------- ##
## Looking for forbidden patterns. ##
## -------------------------------- ##
check-forbidden-patterns:
if (cd $(srcdir) && \
- grep $(forbidden_patterns) $(forbidden_patterns_files)) \
+ $(GREP) $(forbidden_patterns) $(forbidden_patterns_files)) \
>forbidden.log; then \
echo "ERROR: forbidden patterns were found:" >&2; \
sed "s,^,$*.m4: ," <forbidden.log >&2; \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Don't assume grep handles -e in lib/freeze.mk,
Paul Eggert <=