From: Noah Misch Date: Tue, 12 Jun 2007 11:36:56 +0000 (+0000) Subject: * lib/autoconf/general.m4 (AC_SUBST): Raise a fatal error if VARIABLE is X-Git-Tag: v2.62~300 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7f613e8a82bd8b968aa343c1dd673a766335671;p=thirdparty%2Fautoconf.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 4c96f1e4..3527824f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-06-12 Noah Misch + + * 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 * doc/autoconf.texi (AC_F77_MAIN): Give a specific usage example that diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 689e09c1..e512ae6f 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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], [ diff --git a/tests/mktests.sh b/tests/mktests.sh index cc63aaf9..892b85bd 100755 --- a/tests/mktests.sh +++ b/tests/mktests.sh @@ -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} diff --git a/tests/torture.at b/tests/torture.at index 8a714a0e..7381e8b0 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -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.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.ac + AT_CHECK_AUTOCONF + AT_CHECK_AUTOHEADER + AT_CHECK_CONFIGURE +done + +AT_CLEANUP + + ## ------------------------ ## ## datarootdir workaround. ## ## ------------------------ ##