bug-autoconf
[Top][All Lists]
Advanced

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

Re: 2.62 AT_SETUP limitations


From: Eric Blake
Subject: Re: 2.62 AT_SETUP limitations
Date: Wed, 23 Apr 2008 17:09:17 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Joel E. Denny <jdenny <at> ces.clemson.edu> writes:

> 
> On Tue, 22 Apr 2008, Eric Blake wrote:
> 
> > | That's my suggestion as well... except the limitation is that the argument
> > | must expand properly quoted.  In the context of M4, this limitation seems
> > | more intuitive to me than parentheses balancing.
> > 
> > But m4_dquote eats space, which ruins line length calculation.
> 
> It will not eat space in properly quoted text.  I can't find any need for 
> m4_expand if the argument meets the precondition I'm suggesting.

Let's experiment with your ideas, so that you will see why I implemented 
m4_expand:

$ m4 -I autoconf/lib m4sugar/m4sugar.m4 - <<\EOF
# example macros
m4_define([foo], [a, b])   dnl the whitespace in foo is underquoted
m4_define([bar], [[a, b]]) dnl bar is properly quoted for final output

# example expanders
m4_define([out0], [$1])              dnl raw echo
m4_define([out1], [m4_quote($1)])    dnl probably what you meant
m4_define([out2], [m4_dquote($1)])   dnl what you proposed
m4_define([out3], [m4_expand([$1])]) dnl what AT_SETUP uses

m4_divert[]dnl now produce output

#out0
out0([foo, bar])
out0([foo[, ]bar])
out0([[foo, bar]])

#out1
out1([foo, bar])
out1([foo[, ]bar])
out1([[foo, bar]])

#out2
out2([foo, bar])
out2([foo[, ]bar])
out2([[foo, bar]])

#out3
out3([foo, bar])
out3([foo[, ]bar])
out3([[foo, bar]])

#length
m4_len(out0([foo, bar]))
m4_len(out1([foo, bar]))
m4_len(out2([foo, bar]))
m4_len(out3([foo, bar]))
EOF

#out0
a, b, a, b
a, b, a, b
foo, bar

#out1
a,b,a, b
a,b, a, b
foo, bar

#out2
[a],[b],[a, b]
[a],[b, a, b]
[foo, bar]

#out3
a, b, a, b
a, b, a, b
foo, bar

#length
m4:stdin:34: Warning: m4_len: extra arguments ignored: 3 > 1
1
8
14
10

So, all of these methods handle double-quoted space just fine.  Raw echo is 
insufficient for computing the length of the expansion.  m4_quote always 
results in something that can be used for calculating the length, but ate 
spaces compared to the raw echo.  m4_dquote overquotes but still eats spaces, 
so it won't work.  That leaves m4_expand as the only option which gracefully 
expands single-quoted space identically to how a raw echo does, while still 
providing something that can be fed to m4_len as a single argument.  Thus, 
using m4_expand provides a minimal-effort QoI improvement to cater to people 
who don't know how to follow our advice of using proper quoting.  It's much 
easier to rely on a macro that preserves the space than it is to fight users 
who don't understand why the space is sometimes, but not always, eaten in the 
first place (not everyone understands at first glance why, in the 2nd out of 3 
tests for each test group, I left foo and bar single-quoted, and only double-
quoted the comma and space, particularly when other macros, like m4_echo, don't 
need the double quoting to keep the space).

And thanks to Noah, we now have a working m4_expand implementation that still 
permits quoted unbalanced () (I just hope you aren't trying to test files 
named "-=<{(" or ")}>=-" ;).

So in the meantime, I've posted a patch to bug-bison (it should show up once 
gmane lets me through) that allows you to re-enable your tests, even on 
autoconf 2.62, by overriding the definition of m4_expand with the fixed version 
that once again allows unbalanced parentheses.

-- 
Eric Blake







reply via email to

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