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: Tue, 22 Apr 2008 20:23:03 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes:

> > Sounds like we need to add a new quadrigraph for ( and ), then.  Any
> > suggestions for the two middle characters?
> 
> What about @<.@  @.>@ ?  They have the slight disadvantage that the dot
> usually needs a backslash within a regular expression.

Possible.

> 
> Thinking about it, it's clear that [ ] should have been written as
> @|:@  @:|@

How so?  C99 supports <: and :> as the digraphs for [ and ].

> 
> If you want { } too then for them I'd suggest @<-@  @->@ or @<;@  @;>@.

Thus, in order to mirror C99 digraphs, I'd suggest @<%@ and @%>@ for { and }, 
if they were needed (but they aren't special to m4, so I don't see why they are 
needed).  If anything, a quadrigraph for comma would be more useful, when it 
comes to escaping active m4 characters, although I haven't come across a use 
case for one yet.

So here's my proposed patch, which went with @{:@ and @:}@ for ( and ), written 
prior to reading your suggestion.  Apart from the final spelling, does this 
patch look sufficient?  Any other votes for the preferred spelling?

>From 7d01648794d3bfd031adef40aac1d810d7a947ba Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 22 Apr 2008 14:19:27 -0600
Subject: [PATCH] Support unbalanced () in AT_SETUP by adding two new 
quadrigraphs.

* bin/autom4te.in (handle_output): Substitute @{:@ and @:address@hidden
(handle_traces): Likewise.
* lib/m4sugar/m4sugar.m4 (m4_qlen): Account for new quadrigraphs.
* tests/autotest.at (AT_CHECK_AT_TITLE_CHAR): Add new tests.
* doc/autoconf.texi (Quadrigraphs): Document them.
(Evaluation Macros) <m4_expand>: Enhance documentation.
(Text processing Macros) <m4_text_box>: Document cases where
quadrigraphs can help for problemetic unbalanced parentheses.
(Pretty Help Strings) <AS_HELP_STRING>: Likewise.
(Writing Testsuites) <AT_SETUP>: Likewise.
Reported by Joel E. Denny.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |   15 +++++++++++++++
 bin/autom4te.in        |    4 ++++
 doc/autoconf.texi      |   34 +++++++++++++++++++++++++++-------
 lib/m4sugar/m4sugar.m4 |    3 ++-
 tests/autotest.at      |    5 +++++
 5 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9d9d04e..2cddf51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-04-22  Eric Blake  <address@hidden>
+
+       Support unbalanced () in AT_SETUP by adding two new quadrigraphs.
+       * bin/autom4te.in (handle_output): Substitute @{:@ and @:address@hidden
+       (handle_traces): Likewise.
+       * lib/m4sugar/m4sugar.m4 (m4_qlen): Account for new quadrigraphs.
+       * tests/autotest.at (AT_CHECK_AT_TITLE_CHAR): Add new tests.
+       * doc/autoconf.texi (Quadrigraphs): Document them.
+       (Evaluation Macros) <m4_expand>: Enhance documentation.
+       (Text processing Macros) <m4_text_box>: Document cases where
+       quadrigraphs can help for problemetic unbalanced parentheses.
+       (Pretty Help Strings) <AS_HELP_STRING>: Likewise.
+       (Writing Testsuites) <AT_SETUP>: Likewise.
+       Reported by Joel E. Denny.
+
 2008-04-16  Eric Blake  <address@hidden>
 
        Document pdksh exec behavior.
diff --git a/bin/autom4te.in b/bin/autom4te.in
index 1f9aee8..685df41 100644
--- a/bin/autom4te.in
+++ b/bin/autom4te.in
@@ -575,6 +575,8 @@ sub handle_output ($$)
       s/__oline__/$./g;
       s/\@<:\@/[/g;
       s/\@:>\@/]/g;
+      s/address@hidden:\@/(/g;
+      s/\@:\}\@/)/g;
       s/address@hidden|\@/\$/g;
       s/address@hidden:\@/#/g;
 
@@ -856,6 +858,8 @@ EOF
       # It makes no sense to try to transform __oline__.
       s/\@<:\@/[/g;
       s/\@:>\@/]/g;
+      s/address@hidden:\@/(/g;
+      s/\@:\}\@/)/g;
       s/address@hidden|\@/\$/g;
       s/address@hidden:\@/#/g;
       s/\@&t\@//g;
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 554d2ec..4e11c74 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -9619,13 +9619,18 @@ the one they were implemented with.
 @c @cindex @samp{@@<:@@}
 @c @cindex @samp{@@:>@@}
 @c @cindex @samp{@@%:@@}
address@hidden @cindex @samp{@@@{:@@}
address@hidden @cindex @samp{@@:@}@@}
 
 When writing an Autoconf macro you may occasionally need to generate
 special characters that are difficult to express with the standard
 Autoconf quoting rules.  For example, you may need to output the regular
 expression @samp{[^[]}, which matches any character other than @samp{[}.
 This expression contains unbalanced brackets so it cannot be put easily
-into an M4 macro.
+into an M4 macro.  There are also a few macros, such as
address@hidden, @code{AS_HELP_STRING}, or @code{AT_SETUP}, which
+require balanced parentheses, regardless of the quoting, because the
+macro needs to compute the length of the expansion of its arguments.
 
 You can work around this problem by using one of the following
 @dfn{quadrigraphs}:
@@ -9639,6 +9644,10 @@ You can work around this problem by using
 @samp{$}
 @item @@%:@@
 @samp{#}
address@hidden @@@{:@@
address@hidden(}
address@hidden @@:@}@@
address@hidden)}
 @item @@&t@@
 Expands to nothing.
 @end table
@@ -10888,10 +10897,9 @@ whitespace is preserved, even after
 @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 parentheses (portable shell @code{case}
-statements are a major culprit here, but creative shell comments can get
-around this).
address@hidden must not contain unbalanced quotes or parentheses (although
+quadrigraphs can get around this; creative shell comments can also help
+avoid unbalanced parentheses in portable shell @code{case} statements).
 
 @example
 m4_define([active], [ACT, IVE])dnl
@@ -10904,6 +10912,14 @@ m4_quote(active2, active2)
 @result{}ACT, IVE,ACT, IVE
 m4_expand([active2, active2])
 @result{}ACT, IVE, ACT, IVE
+m4_expand([case $foo in #(
+  [[!@@<:@@]]bar) blah ;;
+  *@@:@}@@ baz ;;
+esac])
address@hidden $foo in #(
address@hidden  [![]) blah ;;
address@hidden  *) baz ;;
address@hidden
 @end example
 @end defmac
 
@@ -11183,6 +11199,9 @@ m4_text_box([macro])
 @result{}## abc ##
 @result{}## --- ##
 @end example
+
+The @var{message} must contain balanced quotes and parentheses, although
+quadrigraphs can be used to work around this.
 @end defmac
 
 @defmac m4_text_wrap (@var{string}, @ovar{prefix}, @
@@ -17690,7 +17709,8 @@ Since it is not expanded, it should not
 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.  Be aware that
address@hidden may not contain unbalanced quotes or parentheses.
address@hidden may not contain unbalanced quotes or parentheses,
+although quadrigraphs can be used.
 
 @example
 AC_DEFUN([MY_ARG_WITH],
@@ -20280,7 +20300,7 @@ This macro starts a group of related tests, all
 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.  @var{test-group-name} must not contain
-unbalanced quotes or parentheses.
+unbalanced quotes or parentheses, although quadrigraphs can be used.
 @end defmac
 
 @defmac AT_KEYWORDS (@var{keywords})
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index ae7ce4d..841ce72 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -2058,7 +2058,8 @@ m4_builtin([popdef], [m4_Border])dnl
 # Avoid bpatsubsts for the common case of no quadrigraphs.
 m4_define([m4_qlen],
 [m4_if(m4_index([$1], address@hidden), [-1], [m4_len([$1])],
-       [m4_len(m4_bpatsubst([[$1]], 
address@hidden(\(<:\|:>\|S|\|%:\)\(@\)\|&address@hidden)],
+       [m4_len(m4_bpatsubst([[$1]],
+                           
address@hidden(\(<:\|:>\|S|\|%:\|\{:\|:\}\)\(@\)\|&address@hidden)],
                            [\3]))])])
 
 
diff --git a/tests/autotest.at b/tests/autotest.at
index e6dc862..27948aa 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -453,9 +453,14 @@ AT_CHECK_AT_TITLE_CHAR([Double-quote],  ["])
 dnl restore font-lock: "
 AT_CHECK_AT_TITLE_CHAR([Backslash],     [\])
 AT_CHECK_AT_TITLE_CHAR([Brackets],   [[[]]], [[]])
+AT_CHECK_AT_TITLE_CHAR([Left bracket],  [@<@&t@:@], [@<:@])
+AT_CHECK_AT_TITLE_CHAR([Right bracket], [@:@&t@>@], [@:>@])
 AT_CHECK_AT_TITLE_CHAR([Pound],       [[#]], [#])
 AT_CHECK_AT_TITLE_CHAR([Quoted comma],[[,]], [,])
 AT_CHECK_AT_TITLE_CHAR([Comma],         [,], [,])
+AT_CHECK_AT_TITLE_CHAR([Parentheses],   [()])
+AT_CHECK_AT_TITLE_CHAR([Left paren],    address@hidden@&t@:@], [(])
+AT_CHECK_AT_TITLE_CHAR([Right paren],   [@:@&address@hidden@], [)])
 
 AT_CHECK_AT_TITLE_CHAR([Quoted Macro], [[macro_name]], [macro_name])
 AT_CHECK_AT_TITLE_CHAR([Macro],        [macro_name],   [macro_expanded])
-- 
1.5.5







reply via email to

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