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-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
# 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], [
/^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}
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. ##
## ------------------------ ##