autoconf-patches
[Top][All Lists]
Advanced

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

Re: 15autotest-more-info-prettier.diff


From: Akim Demaille
Subject: Re: 15autotest-more-info-prettier.diff
Date: Thu, 14 Aug 2003 15:30:02 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

 > address@hidden wrote:
 >> +    $at_quiet $ECHO_N "m4_format([[%3d: %-45s]],
 >> +                  AT_ordinal, [$1])[]$ECHO_C"

 > The above line is overquoted, and should read:

 >   +                    AT_ordinal, $1)[]$ECHO_C"

 > Consider:  I want to create a test group called `divert'.

This overquotation is a workaround m4 being underquoting in its text
processing builtins.  Because of this, if you don't double quote the
format string, you get an underquoted result.  Your solution is even
more severely underquoted, since $1 will be evaluated before being
passed to m4_format.  Just imagine that I pass "dnl", or "hello,
world" (yep, with a comma), or "#foo", or ") he he", or "] ha ha", and
imagine the result (and the bug reports about Autotest).

This part is fucked up, yes, m4_text_wrap is a nightmare and cannot
indent properly with square brackets (please, see the complaints about
AC_STRING_HELP), and Autoconf is easy to break when you know it: just
tickle M4's inability to quote properly the result of some builtins.

But I can't do anything about these unless M4 provides quoting
builtins.  Just for fun, imagine the number of hours it took me to
write the following, and try to write it with properly quoting
builtins.


# m4_split(STRING, [REGEXP])
# --------------------------
#
# Split STRING into an m4 list of quoted elements.  The elements are
# quoted with [ and ].  Beginning spaces and end spaces *are kept*.
# Use m4_strip to remove them.
#
# REGEXP specifies where to split.  Default is [\t ]+.
#
# Pay attention to the m4_changequotes.  Inner m4_changequotes exist for
# obvious reasons (we want to insert square brackets).  Outer
# m4_changequotes are needed because otherwise the m4 parser, when it
# sees the closing bracket we add to the result, believes it is the
# end of the body of the macro we define.
#
# Also, notice that $1 is quoted twice, since we want the result to
# be quoted.  Then you should understand that the argument of
# patsubst is ``STRING'' (i.e., with additional `` and '').
#
# This macro is safe on active symbols, i.e.:
#   m4_define(active, ACTIVE)
#   m4_split([active active ])end
#   => [active], [active], []end

m4_changequote(<<, >>)
m4_define(<<m4_split>>,
<<m4_changequote(``, '')dnl
[dnl Can't use m4_default here instead of m4_if, because m4_default uses
dnl [ and ] as quotes.
m4_bpatsubst(````$1'''',
             m4_if(``$2'',, ``[  ]+'', ``$2''),
             ``], ['')]dnl
m4_changequote([, ])>>)
m4_changequote([, ])




reply via email to

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