From: Ralf Wildenhues Date: Tue, 8 Jun 2010 04:55:10 +0000 (+0200) Subject: Make AS_SET_CATFILE polymorphic, and add testsuite coverage. X-Git-Tag: v2.66~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cddfaa966c5536033df26106e3fdac3336bed7b2;p=thirdparty%2Fautoconf.git Make AS_SET_CATFILE polymorphic, and add testsuite coverage. * lib/m4sugar/m4sh.m4 (AS_SET_CATFILE): Use AS_VAR_SET to set the variable. * tests/m4sh.at (AS@&t@_SET_CATFILE): New test. * doc/autoconf.texi (Common Shell Constructs): Document that AS_SET_CATFILE is polymorphic in its VAR argument now. * NEWS: Update. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index 36632aec..dcb54a1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2010-06-08 Ralf Wildenhues + Make AS_SET_CATFILE polymorphic, and add testsuite coverage. + * lib/m4sugar/m4sh.m4 (AS_SET_CATFILE): Use AS_VAR_SET to set + the variable. + * tests/m4sh.at (AS@&t@_SET_CATFILE): New test. + * doc/autoconf.texi (Common Shell Constructs): Document that + AS_SET_CATFILE is polymorphic in its VAR argument now. + * NEWS: Update. + Testsuite coverage for AC_COPYRIGHT and AT_COPYRIGHT. * tests/autotest.at (AT@&t@_COPYRIGHT): New test. * tests/base.at (AC@&t@_COPYRIGHT): Likewise. diff --git a/NEWS b/NEWS index 04cf8dd9..dfe8cd77 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,8 @@ GNU Autoconf NEWS - User visible changes. ** AC_CHECK_DECL and AC_CHECK_DECLS accept optional function argument types for overloaded C++ functions. +** AS_SET_CATFILE accepts nonliterals in its variable name argument now. + * Major changes in Autoconf 2.65 (2009-11-21) [stable] Released by Eric Blake, based on git versions 2.64.*. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 0de54858..e99103da 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -13234,8 +13234,8 @@ if test "x$HAVE_sys_some_file_h" = xyes; then echo "Have it!"; fi @defmac AS_SET_CATFILE (@var{var}, @var{dir}, @var{file}) @asindex{SET_CATFILE} -Set the shell variable @var{var} to @var{dir}/@var{file}, but -optimizing the common cases (@var{dir} or @var{file} is @samp{.}, +Set the polymorphic shell variable @var{var} to @var{dir}/@var{file}, +but optimizing the common cases (@var{dir} or @var{file} is @samp{.}, @var{file} is absolute, etc.). @end defmac diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index f0565694..024498d4 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -1313,12 +1313,12 @@ IFS=$as_save_IFS # Optimize the common case where $2 or $3 is '.'. m4_define([AS_SET_CATFILE], [case $2 in @%:@(( -.) $1=$3;; +.) AS_VAR_SET([$1], [$3]);; *) case $3 in @%:@((( - .) $1=$2;; - [[\\/]]* | ?:[[\\/]]* ) $1=$3;; - *) $1=$2/$3;; + .) AS_VAR_SET([$1], [$2]);; + [[\\/]]* | ?:[[\\/]]* ) AS_VAR_SET([$1], [$3]);; + *) AS_VAR_SET([$1], [$2/$3]);; esac;; esac[]])# AS_SET_CATFILE diff --git a/tests/m4sh.at b/tests/m4sh.at index 7f2cc392..05cea853 100644 --- a/tests/m4sh.at +++ b/tests/m4sh.at @@ -241,6 +241,48 @@ AT_CHECK([$CONFIG_SHELL ./script]) AT_CLEANUP +## ---------------- ## +## AS_SET_CATFILE. ## +## ---------------- ## + +AT_SETUP([AS@&t@_SET_CATFILE]) +AT_KEYWORDS([m4sh]) + +AT_DATA_M4SH([script.as], +[[AS_INIT + +# CATFILE_TEST(DIR, FILE, EXPECTED) +m4_define([CATFILE_TEST], +[# AS_SET_CATFILE works and can be used in a compound list. +if AS_SET_CATFILE([var], [$1], [$2]) \ + && test "$var" = $3; then :; else + echo "catfile($1, $2) = $var != $3" >&2 +fi +# AS_SET_CATFILE can use non-literals in its arguments. +varname=var2 +dirpart=$1 +filepart=$2 +if AS_SET_CATFILE([$varname], [$dirpart], [$filepart]) \ + && test "$var2" = $3; then :; else + echo "catfile($dirpart, $filepart) = $var2 != $3" >&2 +fi +]) + +CATFILE_TEST([dir], [file], [dir/file]) +CATFILE_TEST([.], [file], [file]) +CATFILE_TEST([dir], [.], [dir]) +CATFILE_TEST([dir], [/abs/file], [/abs/file]) +CATFILE_TEST([dir], [C:/abs/file], [C:/abs/file]) +CATFILE_TEST(["dir name"], ['file name'], ['dir name/file name']) + +AS_EXIT(0) +]]) + +AT_CHECK_M4SH +AT_CHECK([$CONFIG_SHELL ./script]) + +AT_CLEANUP + ## --------- ## ## AS_ECHO. ##