From: Stepan Kasal Date: Tue, 17 May 2005 09:29:05 +0000 (+0000) Subject: Use expr where possible. X-Git-Tag: AUTOCONF-2.59c~386 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a2545966ef65eee4c8bf39eb7a6d2c10d1725ea;p=thirdparty%2Fautoconf.git Use expr where possible. --- diff --git a/ChangeLog b/ChangeLog index c6b256644..3d0f0b9c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-05-17 Stepan Kasal + + * 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 * lib/autoconf/functions.m4 (_AC_LIBOBJ_ALLOCA): Prepend ${LIBOBJDIR}, diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index e1ca2ee81..1a020b8a2 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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 diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4 index 9cd8535cb..105dd9e74 100644 --- a/lib/autoconf/status.m4 +++ b/lib/autoconf/status.m4 @@ -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=: ;; -*) diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index fe1f2e884..6606735b0 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -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' ,' \ diff --git a/tests/local.at b/tests/local.at index ceb48630d..64de38992 100644 --- a/tests/local.at +++ b/tests/local.at @@ -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],