+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.
@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})
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
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
[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=$(( $[]* ))
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)
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
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