On 08/26/2010 11:38 AM, Ralf Wildenhues wrote:
* Eric Blake wrote on Thu, Aug 26, 2010 at 01:18:21AM CEST:
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -1981,10 +1987,12 @@ m4_define([AS_VAR_GET],
# Polymorphic, and avoids sh expansion error upon interrupt or term signal.
m4_define([AS_VAR_IF],
[AS_LITERAL_WORD_IF([$1],
- [AS_IF([test "x$$1" = x""$2]],
+ [AS_IF(m4_ifval([$2], [[test "x$$1" = x$2]], [[${$1:+false} :]])],
[AS_VAR_COPY([as_val], [$1])
- AS_IF([test "x$as_val" = x""$2]],
- [AS_IF([eval test \"x\$"$1"\" = x"_AS_ESCAPE([$2], [`], [\"$])"]]),
+ AS_IF(m4_ifval([$2], [[test "x$as_val" = x$2]], [[${as_val:+false} :]])],
+ [AS_IF(m4_ifval([$2],
+ [[eval test \"x\$"$1"\" = x"_AS_ESCAPE([$2], [`], [\"$])"]],
+ [[eval \${$1:+false} :]])]),
[$3], [$4])])
This looks like it's also changing the number of times the macro
arguments are evaluated. I wonder if there is user code relying
on that ...
Thanks for the concern. But I'm confident that while m4 will encounter
the $2 text more often, it is correctly quoted such that there is no
change in the number of times that $2 will be evaluated for expansion.
For all three legs of the outer AS_LITERAL_WORD_IF, the original code
effectively boils down to a single use of [$2] as an argument to AS_IF.
In the new code, the m4_ifval is expanded in entirety prior to AS_IF;
and while $2 appears in three places in the m4_ifval, the input to
m4_ifval is double-quoted, so output is still a single-quoted [$2]
passed to AS_IF.
--
Eric Blake [email protected] +1-801-349-2682
Libvirt virtualization library http://libvirt.org