[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: faster m4_divert*,m4_cond
From: |
Eric Blake |
Subject: |
Re: faster m4_divert*,m4_cond |
Date: |
Mon, 11 Aug 2008 21:56:31 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080708 Thunderbird/2.0.0.16 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Ralf Wildenhues on 8/11/2008 9:34 PM:
|> +m4_define([_m4_cond],
|> +[m4_if(($1), [($2)], [$3],
|> + [$#], [3], [],
|> + [$#], [4], [$4],
|> + [$0(m4_shift3($@))])])
|
| Sorry, but I fail to understand this. Why does the first line of the
| m4_if put its arguments in parentheses, and why is the first argument
| not bracket-quoted? The added test doesn't seem to expose this need.
The first argument is NOT quoted because the documented semantics of
m4_cond is that each test argument is expanded once it is encountered -
the only way to do short-circuiting is to require the caller to overquote
all tests, then have m4_cond use the lack of quotes as the trigger to
actually run the tests in sequence. The added parenthesis are then
necessary for ensuring that m4_if sees only one leading argument, even if
the test expands into something with unquoted commas. Yes, I should add a
test case along the lines of the following:
In autoconf 2.62, this gives a spurious warning and wrong result:
m4_cond([a,a], [a,b], [yes], [no])
m4:stdin:3: Warning: m4_if: extra arguments ignored: 5 > 4
a,b
the fixed version gives the desired result:
m4_cond([a,b], [a,b], [yes], [no])
yes
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkihCe8ACgkQ84KuGfSFAYAbWgCgnn6sWLRJdMGgjxKbMCza2/Cx
nWQAn0bvYG3i6mc/Q8p7BBu3fAKo7uk0
=7bbT
-----END PGP SIGNATURE-----