From: Eric Blake Date: Thu, 13 Nov 2008 19:17:01 +0000 (-0700) Subject: Fix AS_ESCAPE usage bugs. X-Git-Tag: v2.63b~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a0a363042aeb07664d893568074ff5897905a35;p=thirdparty%2Fautoconf.git 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) : Document caveat due to conditional AS_ESCAPE. * tests/m4sh.at (AS@&t@_VAR basics): Enhance test. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 88ea1314c..3e9a701eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-11-13 Eric Blake + + 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) : Document + caveat due to conditional AS_ESCAPE. + * tests/m4sh.at (AS@&t@_VAR basics): Enhance test. + 2008-11-12 Eric Blake Whitespace reduction in configure. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 4081604f8..07db25410 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -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}) diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 2790d8a2c..a39f70238 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -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) diff --git a/tests/m4sh.at b/tests/m4sh.at index 214b5559f..a8acf56d0 100644 --- a/tests/m4sh.at +++ b/tests/m4sh.at @@ -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