[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Testsuite coverage for and polymorphic AS_SET_CATFILE.
From: |
Ralf Wildenhues |
Subject: |
Testsuite coverage for and polymorphic AS_SET_CATFILE. |
Date: |
Sun, 6 Jun 2010 13:51:42 +0200 |
User-agent: |
Mutt/1.5.20 (2009-10-28) |
AS_SET_CATFILE is unused in all of autotools AFAICS, we removed usage
within Autoconf a while ago. Still, it is public interface, and it
might as well be a bit more usable while we're testing it anyway.
OK now or after 2.66?
Thanks,
Ralf
Testsuite coverage for and polymorphic AS_SET_CATFILE.
* lib/m4sugar/m4sh.m4 (AS_SET_CATFILE): Use AS_VAR_SET to set
the variable.
* tests/m4sh.at (AS@&address@hidden): New test.
* doc/autoconf.texi (Common Shell Constructs): Document that
AS_SET_CATFILE is polymorphic in its VAR argument now.
* NEWS: Update.
diff --git a/NEWS b/NEWS
index 04cf8dd..dfe8cd7 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 42bbfcb..5464911 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -13234,8 +13234,8 @@ Common Shell Constructs
@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 f056569..024498d 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 7f2cc39..05cea85 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@&address@hidden)
+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. ##
- Testsuite coverage for and polymorphic AS_SET_CATFILE.,
Ralf Wildenhues <=