autoconf-patches
[Top][All Lists]
Advanced

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

Re: Handling of single-quoted comma [was: m4_defn overhead]


From: Eric Blake
Subject: Re: Handling of single-quoted comma [was: m4_defn overhead]
Date: Fri, 19 Oct 2007 06:44:05 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

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

According to Eric Blake on 10/15/2007 1:12 PM:
>> Not for long.  I still have one of my pending patches [1] that allows single-
>> quoted commas in AS_HELP_STRING without eating the trailing whitespace, via 
> my 
>> new macro m4_expand (or whatever better name we can come up with).
> 
> Here goes.  In two pieces - one to fix the AT_SETUP regression, the other to 
> fix AS_HELP_STRING.

And this followup, documenting the limitations this imposes (until such
day as m4 gains a qindir or similar builtin that can handle unbalanced
text as a literal argument).  It shouldn't be too much hardship in
practice to require balanced quoting in the contexts affected here, but
does mean that m4_expand should be limited to places where text being
expanded is not arbitrary shell code.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHGKaV84KuGfSFAYARAodJAJ4jILZ4dCzzwFOcS/nWUgfcnuFtwACggtGl
ouCeWAyCw1JG0wxgpSJ4CGo=
=48bL
-----END PGP SIGNATURE-----
>From 8c73ae256cc2426a31bb9154ca1016d85e15a5ca Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 19 Oct 2007 06:35:37 -0600
Subject: [PATCH] Document m4_expand limitation.

* lib/m4sugar/m4sugar.m4 (m4_expand): Mention problem with
unbalanced parse.
* doc/autoconf.texi (Pretty Help Strings, Evaluation Macros)
(Writing Testsuites): Mention limitations inherited from
m4_expand.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |    7 +++++++
 doc/autoconf.texi      |   12 ++++++++++--
 lib/m4sugar/m4sugar.m4 |    4 ++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bd1e586..9cd6b9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2007-10-19  Eric Blake  <address@hidden>
 
+       Document m4_expand limitation.
+       * lib/m4sugar/m4sugar.m4 (m4_expand): Mention problem with
+       unbalanced parse.
+       * doc/autoconf.texi (Pretty Help Strings, Evaluation Macros)
+       (Writing Testsuites): Mention limitations inherited from
+       m4_expand.
+
        Improve AT_BANNER handling.
        * lib/autotest/general.m4 (BANNERS): New named diversion.
        (TESTS_END): Diversion no longer used.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index ff79cb0..cd04092 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10768,6 +10768,12 @@ collection rules discard the whitespace.  However, 
with @code{m4_expand},
 whitespace is discarded only if it results from unquoted commas in the
 expansion of macros contained in @var{arg}.
 
+Note that @code{m4_expand} cannot parse everything.  The expansion of
address@hidden must not contain unbalanced quotes (although quadrigraphs can
+get around this), nor unbalanced parenthesis (portable shell @code{case}
+statements are a major culprit here, but creative shell comments can get
+around this).
+
 @example
 m4_define([active], [ACT, IVE])dnl
 m4_define([active2], [[ACT, IVE]])dnl
@@ -17369,7 +17375,8 @@ Since it is not expanded, it should not be double 
quoted.
 
 The @code{AS_HELP_STRING} macro is particularly helpful when the
 @var{left-hand-side} and/or @var{right-hand-side} are composed of macro
-arguments, as shown in the following example.
+arguments, as shown in the following example.  Be aware that
address@hidden may not contain unbalanced quotes or parenthesis.
 
 @example
 AC_DEFUN([MY_ARG_WITH],
@@ -19938,7 +19945,8 @@ isolation.
 This macro starts a group of related tests, all to be executed in the
 same subshell.  It accepts a single argument, which holds a few words
 (no more than about 30 or 40 characters) quickly describing the purpose
-of the test group being started.
+of the test group being started.  @var{test-group-name} must not contain
+unbalanced quotes or parenthesis.
 @end defmac
 
 @defmac AT_KEYWORDS (@var{keywords})
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index b7ca5ea..70b9a84 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -675,6 +675,10 @@ m4_define([m4_echo], address@hidden)
 #   m4_expand([active, active2])
 #   => ACT,IVE, ACT, IVE
 #
+# Unfortunately, due to limitations in m4, ARG must contain balanced quotes
+# (use quadrigraphs) and balanced parenthesis (use creative shell comments
+# when writing shell case statements).
+#
 # Splitting a quoted ARG on `,' preserves space, but produces a quoted list.
 # Unquote the list, then expand each argument while preserving the leading
 # spaces; finally, collect each argument back into the final string.
-- 
1.5.3.2


reply via email to

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