2010-06-08 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+ 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.
** 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.*.
@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
# 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
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. ##