[Top][All Lists]
[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: |
Thu, 7 Jun 2007 20:45:14 -0700 |
User-agent: |
Mutt/1.5.9i |
On Sun, May 20, 2007 at 10:07:25AM +0200, Andreas Schwab wrote:
> $ cat > configure.ac <<EOF
> AC_INIT
> AC_SUBST()
> AC_CONFIG_FILES(Makefile)
> AC_OUTPUT
> EOF
> $ touch Makefile.in
> $ autoconf
> $ ./configure
> configure: creating ./config.status
> configure: error: could not make ./config.status
> While AC_SUBST() is clearly bogus this should probably be handled more
> gracefully, perhaps by rejecting it outright.
Indeed; thanks. I changed AC_SUBST to check its argument for validity as a
shell variable name. AC_ARG_VAR is similarly affected. Its old automatic test
did not fail, because the configure.ac did not have any config files. We test
AC_ARG_VAR in torture.at, so I removed the automatic test. Comments, anyone?
2007-06-07 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-07 22:22:21.000000000 -0400
@@ -2040,11 +2040,13 @@ m4_define([AC_SUBST_TRACE])
# empty value, not an empty second argument.
#
m4_define([AC_SUBST],
+[m4_bmatch(m4_bpatsubst([[$1]], [@&address@hidden), ^m4_defn([m4_re_word])$,
[AC_SUBST_TRACE([$1])dnl
m4_pattern_allow([^$1$])dnl
m4_ifvaln([$2], [$1=$2])[]dnl
m4_append_uniq([_AC_SUBST_VARS], [$1], [
-])dnl
+])],
+[AC_FATAL([$0: `$1' is not a valid shell variable name])])[]dnl
])# AC_SUBST
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. ##
## ------------------------ ##
- Re: AC_SUBST() confuses config.status creation,
Noah Misch <=