|
From: | Eric Blake |
Subject: | Re: [PATCH 5/5] m4sh: assume ${a:-b} support |
Date: | Thu, 26 Aug 2010 12:03:21 -0600 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2 |
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 address@hidden +1-801-349-2682 Libvirt virtualization library http://libvirt.org
[Prev in Thread] | Current Thread | [Next in Thread] |