]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix AS_ESCAPE usage bugs.
authorEric Blake <ebb9@byu.net>
Thu, 13 Nov 2008 19:17:01 +0000 (12:17 -0700)
committerEric Blake <ebb9@byu.net>
Thu, 13 Nov 2008 19:21:40 +0000 (12:21 -0700)
* lib/m4sugar/m4sh.m4 (_AS_VAR_APPEND_PREPARE)
(_AS_VAR_ARITH_PREPARE): Expand macros prior to adding shell
escapes.
(AS_TR_SH, AS_VAR_GET): Use _AS_ESCAPE for speed.
* doc/autoconf.texi (Polymorphic Variables) <AS_VAR_SET>: Document
caveat due to conditional AS_ESCAPE.
* tests/m4sh.at (AS@&t@_VAR basics): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/autoconf.texi
lib/m4sugar/m4sh.m4
tests/m4sh.at

index 88ea1314c82087ad0387ffff756badf774d1277a..3e9a701eb0c209ebb8a1bca270934fd93e64fa3e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-11-13  Eric Blake  <ebb9@byu.net>
+
+       Fix AS_ESCAPE usage bugs.
+       * lib/m4sugar/m4sh.m4 (_AS_VAR_APPEND_PREPARE)
+       (_AS_VAR_ARITH_PREPARE): Expand macros prior to adding shell
+       escapes.
+       (AS_TR_SH, AS_VAR_GET): Use _AS_ESCAPE for speed.
+       * doc/autoconf.texi (Polymorphic Variables) <AS_VAR_SET>: Document
+       caveat due to conditional AS_ESCAPE.
+       * tests/m4sh.at (AS@&t@_VAR basics): Enhance test.
+
 2008-11-12  Eric Blake  <ebb9@byu.net>
 
        Whitespace reduction in configure.
index 4081604f815034d64ec340f09c0061afd6b53850..07db25410c492993e4445d9d46664bfb85cf0e88 100644 (file)
@@ -12283,7 +12283,9 @@ Emit shell code to assign the contents of the polymorphic shell variable
 @var{var} to the shell expansion of @var{value}.  @var{value} is not
 subject to field splitting or file name expansion, so if command
 substitution is used, it may be done with @samp{`""`} rather than using
-an intermediate variable (@pxref{Shell Substitutions}).
+an intermediate variable (@pxref{Shell Substitutions}).  However,
+@var{value} does undergo rescanning for additional macro names; behavior
+is unspecified if late expansion results in any shell meta-characters.
 @end defmac
 
 @defmac AS_VAR_SET_IF (@var{var}, @ovar{if-set}, @ovar{if-undef})
index 2790d8a2cd03e9b702458eb0c3a6e4058e76cb14..a39f702387de3a4b915496981339fe75202d97c0 100644 (file)
@@ -1602,8 +1602,7 @@ m4_defun_init([AS_TR_SH],
 m4_dquote(m4_dquote(m4_defn([m4_cr_not_symbols2])))[[,
                                 [pp[]]]]dnl
 m4_dquote(m4_dquote(m4_for(,1,255,,[[_]])))[[)],
-             [`AS_ECHO(["m4_bpatsubst(m4_dquote(m4_expand([$1])),
-                                      [[\\`]], [\\\&])"]) | $as_tr_sh`])])
+  [`AS_ECHO(["_AS_ESCAPE(m4_dquote(m4_expand([$1])), [\`])"]) | $as_tr_sh`])])
 
 
 # _AS_TR_CPP_PREPARE
@@ -1668,7 +1667,7 @@ m4_defun([_AS_VAR_APPEND_PREPARE],
 VAR.  Take advantage of any shell optimizations that allow amortized
 linear growth over repeated appends, instead of the typical quadratic
 growth present in naive implementations.])
-AS_IF([_AS_RUN(["AS_ESCAPE([_AS_VAR_APPEND_WORKS])"])],
+AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_APPEND_WORKS))"])],
 [eval 'as_func_append ()
   {
     eval $[]1+=\$[]2
@@ -1709,7 +1708,7 @@ m4_defun([_AS_VAR_ARITH_PREPARE],
 [Perform arithmetic evaluation on the ARGs, and store the result in
 the global $as_val.  Take advantage of shells that can avoid forks.
 The arguments must be portable across $(()) and expr.])
-AS_IF([_AS_RUN(["AS_ESCAPE([_AS_VAR_ARITH_WORKS])"])],
+AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_ARITH_WORKS))"])],
 [eval 'as_func_arith ()
   {
     as_val=$(( $[]* ))
@@ -1761,8 +1760,7 @@ m4_define([AS_VAR_COPY],
 m4_define([AS_VAR_GET],
 [AS_LITERAL_IF([$1],
               [$$1],
-              [`eval 'as_val=${'m4_bpatsubst([$1], [[\\`]], [\\\&])'};dnl
-AS_ECHO(["$as_val"])'`])])
+  [`eval 'as_val=${'_AS_ESCAPE([[$1]], [\`])'};AS_ECHO(["$as_val"])'`])])
 
 
 # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
index 214b5559fb3c2c8a5407adcf47b3c850ec8201d6..a8acf56d0d3cc3222e7ef2649b9fec9a79626a77 100644 (file)
@@ -952,6 +952,7 @@ AT_KEYWORDS([AS@&t@_VAR_PUSHDEF AS@&t@_VAR_POPDEF])
 
 AT_DATA_M4SH([script.as], [[dnl
 AS_INIT
+ m4_define([with], [WITH])
 # Literals.
 dnl AS_VAR_SET_IF also covers AS_VAR_TEST_SET
 AS_VAR_SET_IF([foo], [echo oops]) && echo ok
@@ -1009,26 +1010,26 @@ m4_ifdef([tmp], [echo oops])
 
 AT_CHECK_M4SH
 AT_CHECK([./script], [], [[ok
-\a  "weird" `value` with; $fun 'characters
+\a  "weird" `value` WITH; $fun 'characters
 -
-\a  "weird" `value` with; $fun 'characters
+\a  "weird" `value` WITH; $fun 'characters
 -
 ok
 ok
 ok
 ====
 ok
-\a  "weird" `value` with; $fun 'characters
+\a  "weird" `value` WITH; $fun 'characters
 -
-\a  "weird" `value` with; $fun 'characters-
+\a  "weird" `value` WITH; $fun 'characters-
 ok
 ok
 ok
 ====
 ok
-\a  "weird" `value` with; $fun 'characters
+\a  "weird" `value` WITH; $fun 'characters
 -
-\a  "weird" `value` with; $fun 'characters-
+\a  "weird" `value` WITH; $fun 'characters-
 ok
 ok
 ok