]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autoconf/general.m4 (AC_SUBST): Raise a fatal error if VARIABLE is
authorNoah Misch <noah@cs.caltech.edu>
Tue, 12 Jun 2007 11:36:56 +0000 (11:36 +0000)
committerNoah Misch <noah@cs.caltech.edu>
Tue, 12 Jun 2007 11:36:56 +0000 (11:36 +0000)
not a valid shell variable name.
* tests/mktests.sh (ac_exclude_list): Add AC_ARG_VAR.
* tests/torture.at (AC_SUBST: variable name validation): New test.
Reported by Andreas Schwab.

ChangeLog
lib/autoconf/general.m4
tests/mktests.sh
tests/torture.at

index 4c96f1e430085c6dfc07239370e5bdd3309c9672..3527824f826a7577df1576b1988b3eaac87e1c81 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-06-12  Noah Misch  <noah@cs.caltech.edu>
+
+       * lib/autoconf/general.m4 (AC_SUBST): Raise a fatal error if VARIABLE is
+       not a valid shell variable name.
+       * tests/mktests.sh (ac_exclude_list): Add AC_ARG_VAR.
+       * tests/torture.at (AC_SUBST: variable name validation): New test.
+       Reported by Andreas Schwab.
+
 2007-06-04  Noah Misch  <noah@cs.caltech.edu>
 
        * doc/autoconf.texi (AC_F77_MAIN): Give a specific usage example that
index 689e09c17356469735a7d85691fffbab05ff5804..e512ae6fa3e7c069e81613080fbb70aeba6e195e 100644 (file)
@@ -2040,7 +2040,9 @@ m4_define([AC_SUBST_TRACE])
 # empty value, not an empty second argument.
 #
 m4_define([AC_SUBST],
-[AC_SUBST_TRACE([$1])dnl
+[m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$, [],
+  [AC_FATAL([$0: `$1' is not a valid shell variable name])])dnl
+AC_SUBST_TRACE([$1])dnl
 m4_pattern_allow([^$1$])dnl
 m4_ifvaln([$2], [$1=$2])[]dnl
 m4_append_uniq([_AC_SUBST_VARS], [$1], [
index cc63aaf9ee009728dafcabdd8db808492941471a..892b85bdd540bcefa9fdf7f8d2fbb41d76fb66d9 100755 (executable)
@@ -87,6 +87,7 @@ ac_exclude_list='
        /^AC_(CANONICALIZE|PREFIX_PROGRAM|PREREQ)$/ {next}
        /^AC_(SEARCH_LIBS|REPLACE_FUNCS)$/ {next}
        /^AC_(CACHE_CHECK|COMPUTE)_INT$/ {next}
+       /^AC_ARG_VAR$/ {next}
 
        # Performed in the semantics tests.
        /^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|(TARGET_)?TOOL|TYPE)S?$/ {next}
index 8a714a0ef9b284a603d460d16176a5f6d073740e..7381e8b036c8dd1f37bdcaa28532f094cf8769df 100644 (file)
@@ -744,6 +744,36 @@ two
 AT_CLEANUP
 
 
+## ------------------------------------ ##
+## AC_SUBST: variable name validation.  ##
+## ------------------------------------ ##
+
+AT_SETUP([AC_SUBST: variable name validation])
+
+AT_CONFIGURE_AC([[AC_SUBST(, [])
+AC_CONFIG_FILES([Makefile])
+]])
+AT_DATA([Makefile.in], [[
+]])
+mv -f configure.ac configure.tmpl
+
+# Invalid names.
+for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
+  sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
+  AT_CHECK_AUTOCONF([], [1], [], [ignore])
+done
+
+# Valid names.
+for var in ab a4 'a@@&t@\&t@b'; do
+  sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
+  AT_CHECK_AUTOCONF
+  AT_CHECK_AUTOHEADER
+  AT_CHECK_CONFIGURE
+done
+
+AT_CLEANUP
+
+
 ## ------------------------ ##
 ## datarootdir workaround.  ##
 ## ------------------------ ##