bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

the need for qindir [was: 2.62 AT_SETUP limitations]


From: Eric Blake
Subject: the need for qindir [was: 2.62 AT_SETUP limitations]
Date: Thu, 24 Apr 2008 06:29:33 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Akim Demaille on 4/24/2008 3:20 AM:

[dropping bug-bison, adding m4-discuss]

|> Really, the problem is
|> that there is no way to determine whether $1 is safe to expand, short of
|> expanding $1; thus, if it was not safe, you've already screwed up the
|> state of the m4 parsing.
|
| I always felt m4 lacks an "eval" macro.  Not the one for arithmetics,
| but one which would run m4 on its argument, and return the expansion
| quoted.  This is what tried to do m4_quote/m4_dquote, but it's fragile.
|
| There are really two sort of macros.  Those which really work on the
| text, and you do not want to evaluate the result.  This is where
| regexp, patsubst etc. live.  And there are the regular just-expanding
| macros.

And macros such as substr are practically worthless as is in a harsh
environment - they operate on text and return an unquoted result, which is
almost never what you want if you don't want the result immediately expanded.

|
| For the latter, a usual single-level of quotation is fine.  For the
| former, we need two.  And we have no safe means to go from one model
| to the other, between text-hacking macros and text-expanding macros.
|
| Something like a new primitive "eval and return quoted" would fill
| the gap.
|
| Well, at least that's what I believed years ago :)
|

Yes, m4 has a TODO item about adding the qindir builtin (and which I will
probably do for m4 1.6).  The original request mentioned making it robust
even in the face of unbalanced quotes inside the text, but I don't know if
I can make the m4 machinery do that.  But I can quite easily make it
behave exactly like indir except for the addition of an additional level
of quotes in the output.  Then you will have (in m4sugar quoting):

m4_define([m4_qsubstr], [m4_qindir([m4_substr], $@)])

such that

m4_define([b], [HI])
m4_substr([abc], [1], [1])
=> HI
m4_qsubstr([abc], [1], [1])
=> b

- --
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

iEYEARECAAYFAkgQfS0ACgkQ84KuGfSFAYBCIACg2VSyZFfYlLIKLN4z3QThfl87
aIQAoLRZHqhTqWFhnqsQ4QBlu4+e5Ujx
=ZGvN
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]