On 06/05/2010 05:14 AM, Bruno Haible wrote: > Hi Eric, > >> The question ... is whether AS_TR_CPP([abc]) should output a quoted >> string (which is a change in behavior, but arguably more like >> m4_toupper), or a raw string (no worse than what we have today, but >> where AS_TR_CPP([[abc]]) would work where today it doesn't). >> ... >> It's a bug fix either way, so which way do you prefer? > > Since you mentioned m4_toupper, here's a comparison of m4_toupper, > m4_tolower, AS_TR_SH, AS_TR_CPP. To get the big picture. Snip great example... > So this means that currently: > - m4_tolower and m4_toupper operate in the same way: > They expand their arg if it is unquoted, and they don't > expand their result. By the way, the behavior you observed for m4_toupper and m4_tolower is new to autoconf 2.65; prior to that they mistakenly expanded their result. The way m4 works, all unquoted args are expanded prior to invoking the macro - so there's not much interesting there (nor any way we could change that behavior). The interesting behavior comes on deciding whether the output of a macro should be subject to further expansion, when an arg was passed quoted through a macro. > - AS_TR_SH and AS_TR_CPP expand their arg if it unquoted or single-quoted. > - AS_TR_SH does not expand its result. > - AS_TR_CPP expands its result. > > The difference between m4_tolower and m4_toupper on one side and > AS_TR_SH and AS_TR_CPP on the other side - does it require single-quoting > or double-quoting to avoid argument expansion - is a bit surprising, but > may be due to the fact that m4_tolower and m4_toupper come from m4 > whereas AS_TR_SH and AS_TR_CPP follow the autoconf conventions. > I'm not asking to change that. Actually, I think changing it is the right thing to do, because all you have to do is hide the string behind a variable expansion, at which point m4 would no longer expand the result. Since the point of AS_TR_{SH,CPP} is that they are polymorphic between shell and m4 input (preferring to do the operation in m4 and hard-code the result into shell, but falling back to doing the operation in shell when it is too complex to do in m4), then they should behave the same whether the input is hidden behind a shell variable or directly exposed. That is, the two AS_TR_ methods should never expand their output directly (if you _want_ them expanded, then call m4_do(AS_TR_SH([expand_my_output])) to remove the quoting left in place by AS_TR_SH). Independently of this thread, my response[1] to your earlier request[2] to optimize AS_VAR_TEST_SET happened to fix the quoting of AS_TR_SH to behave like m4_toupper as a nice side effect. So all that remains is to add a test case and fix AS_TR_CPP to match. [1] http://lists.gnu.org/archive/html/autoconf-patches/2010-07/msg00007.html [2] http://lists.gnu.org/archive/html/autoconf-patches/2010-03/msg00001.html I will post my patch as a reply, once I run it through the testsuite to check for any regressions. > You are free to convert my sample code into a test case ;-) Thanks; between your sample code, and my existing tests for m4_toupper, I was able to construct a reasonable test. -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf