bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_SUBST() confuses config.status creation


From: Noah Misch
Subject: Re: AC_SUBST() confuses config.status creation
Date: Tue, 12 Jun 2007 04:41:03 -0700
User-agent: Mutt/1.5.9i

On Mon, Jun 11, 2007 at 03:48:11PM +0200, Stepan Kasal wrote:
> Applied to AC_SUBST, I'd prefer
> 
> m4_define([AC_SUBST],
> [m4_bmatch(m4_bpatsubst([[$1]], [@&address@hidden), ^m4_defn([m4_re_word])$, 
> [],
>          [AC_FATAL([$0: `$1' is not a valid shell variable name])])

> What do you think?

Yes; that's better.  I installed the patch in this form:

2007-06-12  Noah Misch  <address@hidden>

        * 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 -Nurp -X dontdiff ac-clean/lib/autoconf/general.m4 
ac-trysubst/lib/autoconf/general.m4
--- ac-clean/lib/autoconf/general.m4    2007-05-05 00:39:14.000000000 -0400
+++ ac-trysubst/lib/autoconf/general.m4 2007-06-12 07:29:32.000000000 -0400
@@ -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]], [@&address@hidden), ^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 -Nurp -X dontdiff ac-clean/tests/mktests.sh ac-trysubst/tests/mktests.sh
--- ac-clean/tests/mktests.sh   2007-05-05 00:39:14.000000000 -0400
+++ ac-trysubst/tests/mktests.sh        2007-06-07 23:03:42.000000000 -0400
@@ -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 -Nurp -X dontdiff ac-clean/tests/torture.at ac-trysubst/tests/torture.at
--- ac-clean/tests/torture.at   2007-05-05 00:39:14.000000000 -0400
+++ ac-trysubst/tests/torture.at        2007-06-07 22:30:12.000000000 -0400
@@ -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@@&address@hidden&address@hidden'; do
+  sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
+  AT_CHECK_AUTOCONF
+  AT_CHECK_AUTOHEADER
+  AT_CHECK_CONFIGURE
+done
+
+AT_CLEANUP
+
+
 ## ------------------------ ##
 ## datarootdir workaround.  ##
 ## ------------------------ ##




reply via email to

[Prev in Thread] Current Thread [Next in Thread]