]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Use expr where possible.
authorStepan Kasal <kasal@ucw.cz>
Tue, 17 May 2005 09:29:05 +0000 (09:29 +0000)
committerStepan Kasal <kasal@ucw.cz>
Tue, 17 May 2005 09:29:05 +0000 (09:29 +0000)
ChangeLog
lib/autoconf/general.m4
lib/autoconf/status.m4
lib/autotest/general.m4
tests/local.at

index c6b256644624d2008860e55e3cfba0ae650c274f..3d0f0b9c086b8b9c18b6973ce592224474b2911f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2005-05-17  Stepan Kasal  <kasal@ucw.cz>
+
+       * lib/autoconf/general.m4 (_AC_INIT_HELP): Merge two consecutive
+         ``cat <<_ACEOF'' commands to one.
+       (_AC_CANONICAL_SPLIT): Use expr, not ``echo|sed.''
+       * lib/autoconf/status.m4: On various places, use expr instead of
+         ``echo|sed.''
+       (_AC_CONFIG_SPLIT, _AC_CONFIG_SPLIT_SOURCE_DEST):
+       (_AC_CONFIG_SPLIT_FILE_IN): New macros, to factor out common code.
+       * lib/autotest/general.m4 (AT_INIT): Use expr to get the numbers from
+         a range.
+       * tests/local.at (AT_CHECK_SHELL_SYNTAX): Use awk to search for
+         the wrong patterns between ``case'' and ``esac.''  The previous
+         code had false positives.
+
 2005-05-14  Alexandre Duret-Lutz  <adl@gnu.org>
 
        * lib/autoconf/functions.m4 (_AC_LIBOBJ_ALLOCA): Prepend ${LIBOBJDIR},
index e1ca2ee817cc27734e6614e52ca10876362e6515..1a020b8a2f33a66929d09cacc41ea9f0863c688f 100644 (file)
@@ -1004,9 +1004,6 @@ Configuration:
   -n, --no-create         do not create output files
       --srcdir=DIR        find the sources in DIR [configure dir or \`..']
 
-_ACEOF
-
-  cat <<_ACEOF
 Installation directories:
   --prefix=PREFIX         install architecture-independent files in PREFIX
                          [$ac_default_prefix]
@@ -1685,12 +1682,9 @@ m4_define([AC_REQUIRE_AUX_FILE],
 m4_define([_AC_CANONICAL_SPLIT],
 [AC_SUBST([$1],       [$ac_cv_$1])dnl
 dnl FIXME: AC_SUBST([$1_alias],  [$ac_cv_$1_alias])dnl
-AC_SUBST([$1_cpu],
-        [`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\1/'`])dnl
-AC_SUBST([$1_vendor],
-        [`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\2/'`])dnl
-AC_SUBST([$1_os],
-        [`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\3/'`])dnl
+AC_SUBST([$1_cpu],     [`expr "X$ac_cv_$1" : ['X\([^-]*\)']`])dnl
+AC_SUBST([$1_vendor],  [`expr "X$ac_cv_$1" : ['X[^-]*-\([^-]*\)']`])dnl
+AC_SUBST([$1_os],      [`expr "X$ac_cv_$1" : ['X[^-]*-[^-]*-\(.*\)']`])dnl
 ])# _AC_CANONICAL_SPLIT
 
 
index 9cd8535cb9553245f676454e1afceaa005ed4fdd..105dd9e749f71b88eada4a927ff5a9518dfad245 100644 (file)
@@ -153,7 +153,7 @@ case $srcdir in
     if test -z "$ac_top_builddir"; then
        ac_top_srcdir=.
     else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+       ac_top_srcdir=`expr $ac_top_builddir : ['\(.*[^/]\)']`
     fi
     ac_abs_top_srcdir=$ac_pwd ;;
   [[\\/]]* | ?:[[\\/]]* )  # Absolute name.
@@ -243,6 +243,44 @@ m4_popdef([AC_Dest])])dnl
 ])
 
 
+# _AC_CONFIG_SPLIT(LIST, DEST, SOURCE)
+# ------------------------------------
+#
+# Shell variable LIST must contain at least two file names, separated by
+# colon.  The first component goes to DEST, the rest to SOURCE.
+# We compute SOURCE first, so LIST and DEST can be the same variable.
+#
+m4_define([_AC_CONFIG_SPLIT],
+[      $3=`expr "X$$1" : ['X[^:]*:\(.*\)']`
+       $2=`expr "X$$1" : ['X\([^:]*\)']`[]dnl
+])
+
+# _AC_CONFIG_SPLIT_SOURCE_DEST
+# ----------------------------
+#
+# Used in CONFIG_COMMANDS and CONFIG_LINKS sections.
+#
+m4_define([_AC_CONFIG_SPLIT_SOURCE_DEST],
+[case $ac_file in
+  *:*) _AC_CONFIG_SPLIT(ac_file, ac_dest, ac_source) ;;
+  *)   ac_dest=$ac_file ac_source=$ac_file ;;
+esac[]dnl
+])
+
+# _AC_CONFIG_SPLIT_FILE_IN
+# ------------------------
+#
+# Used in CONFIG_HEADERS and CONFIG_FILES sections.
+#
+m4_define([_AC_CONFIG_SPLIT_FILE_IN],
+[case $ac_file in
+  *:*) _AC_CONFIG_SPLIT(ac_file, ac_file, ac_file_in) ;;
+  -)   ac_file_in=- ;;
+  *)   ac_file_in=$ac_file.in ;;
+esac[]dnl
+])
+
+
 
 ## ------------------------ ##
 ## Configuration commands.  ##
@@ -363,8 +401,7 @@ m4_define([_AC_OUTPUT_COMMANDS],
 # CONFIG_COMMANDS section.
 #
 for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
-  ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
-  ac_source=`echo "$ac_file" | sed 's,[[^:]]*:,,'`
+  _AC_CONFIG_SPLIT_SOURCE_DEST
   ac_dir=`AS_DIRNAME(["$ac_dest"])`
   AS_MKDIR_P(["$ac_dir"])
   _AC_SRCDIRS(["$ac_dir"])
@@ -483,7 +520,7 @@ m4_define([_AC_OUTPUT_HEADERS],
 [cat >>$CONFIG_STATUS <<\_ACEOF
 
 #
-# CONFIG_HEADER section.
+# CONFIG_HEADERS section.
 #
 
 # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
@@ -505,13 +542,9 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
   case $ac_file in
   - | *:- | *:-:* ) # input from stdin
-       cat >"$tmp/stdin"
-       ac_file_in=`echo "$ac_file" | sed 's,[[^:]]*:,,'`
-       ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[[^:]]*:,,'`
-       ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  * )   ac_file_in=$ac_file.in ;;
+       cat >"$tmp/stdin" ;;
   esac
+  _AC_CONFIG_SPLIT_FILE_IN
 
   test x"$ac_file" != x- && AC_MSG_NOTICE([creating $ac_file])
 
@@ -727,7 +760,7 @@ m4_define([AC_LIST_LINKS_COMMANDS])
 # interest in creating config links with literal values, no special
 # mechanism is implemented to handle them.
 #
-# _AC_LINK_CNT is used to be robust to multiple calls.
+# _AC_LINK_FILES_CNT is used to be robust to multiple calls.
 AU_DEFUN([AC_LINK_FILES],
 [m4_if($#, 2, ,
        [m4_fatal([$0: incorrect number of arguments])])dnl
@@ -766,8 +799,7 @@ dnl Here we use : instead of .. because if AC_LINK_FILES was used
 dnl with empty parameters (as in gettext.m4), then we obtain here
 dnl `:', which we want to skip.  So let's keep a single exception: `:'.
 for ac_file in : $CONFIG_LINKS; do test "x$ac_file" = x: && continue
-  ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
-  ac_source=`echo "$ac_file" | sed 's,[[^:]]*:,,'`
+  _AC_CONFIG_SPLIT_SOURCE_DEST
 
   AC_MSG_NOTICE([linking $srcdir/$ac_source to $ac_dest])
 
@@ -932,13 +964,9 @@ for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
   case $ac_file in
   - | *:- | *:-:* ) # input from stdin
-       cat >"$tmp/stdin"
-       ac_file_in=`echo "$ac_file" | sed 's,[[^:]]*:,,'`
-       ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[[^:]]*:,,'`
-       ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  * )   ac_file_in=$ac_file.in ;;
+       cat >"$tmp/stdin" ;;
   esac
+  _AC_CONFIG_SPLIT_FILE_IN
 
   # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
   ac_dir=`AS_DIRNAME(["$ac_file"])`
@@ -1405,8 +1433,8 @@ while test $[#] != 0
 do
   case $[1] in
   --*=*)
-    ac_option=`expr "x$[1]" : 'x\([[^=]]*\)='`
-    ac_optarg=`expr "x$[1]" : 'x[[^=]]*=\(.*\)'`
+    ac_option=`expr "X$[1]" : 'X\([[^=]]*\)='`
+    ac_optarg=`expr "X$[1]" : 'X[[^=]]*=\(.*\)'`
     ac_shift=:
     ;;
   -*)
index fe1f2e884203cf19889ef2c352a92965abe7afc7..6606735b013fcda8f5668e56c5688eed7c276610 100644 (file)
@@ -320,8 +320,8 @@ do
     [[0-9][0-9][0-9]-[0-9][0-9][0-9]] | \
     [[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]] | \
     [[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]] )
-       at_range_start=`echo $at_option |sed 's,-.*,,'`
-       at_range_end=`echo $at_option |sed 's,.*-,,'`
+       at_range_start=`expr $at_option : '\([^-]*\)'`
+       at_range_end=`expr $at_option : '[^-]*-\(.*\)'`
        # FIXME: Maybe test to make sure start <= end?
        at_range=`echo " $at_groups_all " | \
          sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,' \
index ceb48630dc43663998d35510bf805c79144ba80e..64de38992a6be5f6fa263f33e812e9464ae03ce5 100644 (file)
@@ -53,7 +53,7 @@ AT_CHECK([$at_diff "$1" "$2"])
 m4_define([AT_CHECK_SHELL_SYNTAX],
 [AS_IF([test x"$ac_cv_sh_n_works" != xno],
   [AT_CHECK([/bin/sh -n $1], 0)], [$2])
-AT_CHECK([grep '\@<:@\^.*).*;;' $1], 1)])
+AT_CHECK([awk '/^[ \t]*case/,/^[ \t]*esac/{if(/\@<:@\^.*\)/) exit(1)}' $1])])
 
 m4_define([AT_CHECK_PERL_SYNTAX],
 [AT_CHECK([autom4te_perllibdir=$abs_top_srcdir/lib $PERL -c $abs_top_builddir/bin/$1],