]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Support unbalanced () in AT_SETUP by adding two new quadrigraphs.
authorEric Blake <ebb9@byu.net>
Tue, 22 Apr 2008 20:19:27 +0000 (14:19 -0600)
committerEric Blake <ebb9@byu.net>
Tue, 22 Apr 2008 22:28:14 +0000 (16:28 -0600)
* bin/autom4te.in (handle_output): Substitute @{:@ and @:}@.
(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.
(Limitations of Builtins) <case>: Consolidate text on unbalanced
parentheses, and add an example of creative comments.
* NEWS: Document the addition.
Reported by Joel E. Denny.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
NEWS
bin/autom4te.in
doc/autoconf.texi
lib/m4sugar/m4sugar.m4
tests/autotest.at

index 9d9d04e1a46aabf3d8ce4dfabd1a9fbc20efd3d1..8dd130cd4cca226405853c33f8b6d985a2643c46 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2008-04-22  Eric Blake  <ebb9@byu.net>
+
+       Support unbalanced () in AT_SETUP by adding two new quadrigraphs.
+       * bin/autom4te.in (handle_output): Substitute @{:@ and @:}@.
+       (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.
+       (Limitations of Builtins) <case>: Consolidate text on unbalanced
+       parentheses, and add an example of creative comments.
+       * NEWS: Document the addition.
+       Reported by Joel E. Denny.
+
 2008-04-16  Eric Blake  <ebb9@byu.net>
 
        Document pdksh exec behavior.
diff --git a/NEWS b/NEWS
index 9396ac0de60eb37b5b864c5b83d33efb634a22c9..a50759d81b50815ceb6b4c565cf8212ac3e6a850 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU Autoconf NEWS - User visible changes.
 
 * Major changes in Autoconf 2.62a (2008-??-??)
 
+** Two new quadrigraphs have been introduced: @{:@ for (, and @:}@ for ),
+   allowing the output of unbalanced parantheses in contexts such as
+   AS_HELP_STRING or AT_SETUP that must determine the length of
+   expanded text.
+
 \f
 * Major changes in Autoconf 2.62 (2008-04-05) [stable]
   Released by Eric Blake, based on git versions 2.61a.*.
index 1f9aee8d9c83bc86b48804f191bef2299a04991b..685df41a327210b1ed8836a1998f557bfa73016a 100644 (file)
@@ -575,6 +575,8 @@ sub handle_output ($$)
       s/__oline__/$./g;
       s/\@<:\@/[/g;
       s/\@:>\@/]/g;
+      s/\@\{:\@/(/g;
+      s/\@:\}\@/)/g;
       s/\@S\|\@/\$/g;
       s/\@%:\@/#/g;
 
@@ -856,6 +858,8 @@ EOF
       # It makes no sense to try to transform __oline__.
       s/\@<:\@/[/g;
       s/\@:>\@/]/g;
+      s/\@\{:\@/(/g;
+      s/\@:\}\@/)/g;
       s/\@S\|\@/\$/g;
       s/\@%:\@/#/g;
       s/\@&t\@//g;
index 554d2ec86e34fb25f18a5f9c7b4f2415f5665eca..6f72302d0dc2d48c448ea99c466fe6776af5fb4b 100644 (file)
@@ -9619,13 +9619,18 @@ the one they were implemented with.
 @c @cindex @samp{@@<:@@}
 @c @cindex @samp{@@:>@@}
 @c @cindex @samp{@@%:@@}
+@c @cindex @samp{@@@{:@@}
+@c @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
+@code{m4_text_box}, @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 one of the following
 @samp{$}
 @item @@%:@@
 @samp{#}
+@item @@@{:@@
+@samp{(}
+@item @@:@}@@
+@samp{)}
 @item @@&t@@
 Expands to nothing.
 @end table
@@ -10887,12 +10896,6 @@ collection rules discard the whitespace.  However, with @code{m4_expand},
 whitespace is preserved, even after the expansion of macros contained in
 @var{arg}.
 
-Note that @code{m4_expand} cannot parse everything.  The expansion of
-@var{arg} 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).
-
 @example
 m4_define([active], [ACT, IVE])dnl
 m4_define([active2], [[ACT, IVE]])dnl
@@ -10905,6 +10908,21 @@ m4_quote(active2, active2)
 m4_expand([active2, active2])
 @result{}ACT, IVE, ACT, IVE
 @end example
+
+Note that @code{m4_expand} cannot parse everything.  The expansion of
+@var{arg} must not contain literal unbalanced quotes or parentheses;
+however, quadrigraphs can be used to generate unbalanced output.
+
+@example
+m4_define([pattern], [[!@@<:@@]])dnl
+m4_define([bar], [BAR])dnl
+m4_expand([case $foo in
+  m4_defn([pattern])@@:@}@@ bar ;;
+esac])
+@result{}case $foo in
+@result{}  [![]) BAR ;;
+@result{}esac
+@end example
 @end defmac
 
 @defmac m4_ignore (@dots{})
@@ -11183,6 +11201,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}, @
@@ -13754,13 +13775,32 @@ parentheses like this:
 
 @example
 case $file_name in
-(*.c) echo "C source code";;
+  (*.c) echo "C source code";;
 esac
 @end example
 
 @noindent
 but the @code{(} in this example is not portable to many Bourne
-shell implementations.  It can be omitted safely.
+shell implementations, which is a pity for those of us using tools that
+rely on balanced parentheses.  For instance, with Solaris
+@command{/bin/sh}:
+
+@example
+$ @kbd{case foo in (foo) echo foo;; esac}
+@error{}syntax error: `(' unexpected
+@end example
+
+@noindent
+The leading @samp{(} can be omitted safely.  In contexts where
+unbalanced parentheses cause other problems, such as when using a case
+statement as an argument to an Autoconf macro, you can also resort to
+creative shell comments to supply the balance:
+
+@example
+case $file_name in #(
+  *.c) echo "C source code";;
+esac
+@end example
 
 Zsh handles pattern fragments derived from parameter expansions or
 command substitutions as though quoted:
@@ -13830,15 +13870,6 @@ ash-0.3.8 $ @kbd{case foo in esac;}
 @error{}Syntax error: ";" unexpected (expecting ")")
 @end example
 
-Many shells still do not support parenthesized cases, which is a pity
-for those of us using tools that rely on balanced parentheses.  For
-instance, Solaris @command{/bin/sh}:
-
-@example
-$ @kbd{case foo in (foo) echo foo;; esac}
-@error{}syntax error: `(' unexpected
-@end example
-
 
 @item @command{cd}
 @c ---------------
@@ -17690,7 +17721,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.  Be aware that
-@var{left-hand-side} may not contain unbalanced quotes or parentheses.
+@var{left-hand-side} may not contain unbalanced quotes or parentheses,
+although quadrigraphs can be used.
 
 @example
 AC_DEFUN([MY_ARG_WITH],
@@ -20280,7 +20312,7 @@ 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.  @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})
index ae7ce4dabd1555c310d159dbc6634c87229e48b2..841ce727343b1cc0b507962ebb81f9e8a0f8798a 100644 (file)
@@ -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], [@]), [-1], [m4_len([$1])],
-       [m4_len(m4_bpatsubst([[$1]], [@\(\(<:\|:>\|S|\|%:\)\(@\)\|&t@\)],
+       [m4_len(m4_bpatsubst([[$1]],
+                           [@\(\(<:\|:>\|S|\|%:\|\{:\|:\}\)\(@\)\|&t@\)],
                            [\3]))])])
 
 
index e6dc862421c236436cec7e6a8cb98c91075d884f..27948aac321e2f58cc64acea897a81342ad3a1ce 100644 (file)
@@ -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],    [@{@&t@:@], [(])
+AT_CHECK_AT_TITLE_CHAR([Right paren],   [@:@&t@}@], [)])
 
 AT_CHECK_AT_TITLE_CHAR([Quoted Macro], [[macro_name]], [macro_name])
 AT_CHECK_AT_TITLE_CHAR([Macro],        [macro_name],   [macro_expanded])