]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Optimize AS_BOX.
authorEric Blake <eblake@redhat.com>
Tue, 2 Mar 2010 00:17:40 +0000 (17:17 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 2 Jul 2010 18:11:17 +0000 (12:11 -0600)
* lib/m4sugar/m4sh.m4 (AS_BOX): Use less m4 time.
(_AS_BOX_LITERAL): Use fewer forks in the common case.
* doc/autoconf.texi (Common Shell Constructs) <AS_BOX>: Document
the macro.
* NEWS: Mention it.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
NEWS
doc/autoconf.texi
lib/m4sugar/m4sh.m4

index 39c24777fe6e775438356f1e58e4479862e28fb9..a559c167b83c8754cb29a5f01ba5108b74905ad7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-07-02  Eric Blake  <eblake@redhat.com>
 
+       Optimize AS_BOX.
+       * lib/m4sugar/m4sh.m4 (AS_BOX): Use less m4 time.
+       (_AS_BOX_LITERAL): Use fewer forks in the common case.
+       * doc/autoconf.texi (Common Shell Constructs) <AS_BOX>: Document
+       the macro.
+       * NEWS: Mention it.
+
        Use new AS_LITERAL_IF argument when appropriate.
        * lib/m4sugar/m4sh.m4 (AS_VAR_SET): Reduce m4 overhead.
        (AS_VAR_IF, AS_VAR_TEST_SET): Provide shorter variant for simple
diff --git a/NEWS b/NEWS
index c5e5ded2ca3ea6117a14f18e100b0672f956c27a..8acc6e7a316cdcc87567af8ba185a6cd11a5db89 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,10 @@ GNU Autoconf NEWS - User visible changes.
    Furthermore, a new macro, AS_LITERAL_WORD_IF, adds an additional
    level of checking that no whitespace occurs in literals.
 
+** The following macros are now documented:
+   AS_BOX
+
+
 * Major changes in Autoconf 2.65 (2009-11-21) [stable]
   Released by Eric Blake, based on git versions 2.64.*.
 
index 73517fd1f08458d2f02006fc82aafc0e0684c275..f531ed6e17d2051e273128a838def7941b666cf4 100644 (file)
@@ -13086,6 +13086,17 @@ if @code{$file} is @samp{/one/two/three}, the command
 @end defmac
 @end ignore
 
+@defmac AS_BOX (@var{text}, @dvar{char, -})
+@asindex{BOX}
+Expand into shell code that will output @var{text} surrounded by a box
+with @var{char} in the top and bottom border.  @var{text} should not
+contain a newline, but may contain shell expansions valid for unquoted
+here-documents.  @var{char} defaults to @samp{-}, but can be any
+character except @samp{/}, @samp{'}, @samp{"}, @samp{\},
+@samp{&}, or @samp{`}.  This is useful for outputting a comment box into
+log files to separate distinct phases of script operation.
+@end defmac
+
 @defmac AS_CASE (@var{word}, @ovar{pattern1}, @ovar{if-matched1}, @
   @dots{}, @ovar{default})
 @asindex{CASE}
index 8c01cc9472be36626ac141676ece589ee0b5e58e..2a4faf37b0d11573ca41c1b26c1707b571ab5753 100644 (file)
@@ -1377,17 +1377,17 @@ as_executable_p=$as_test_x
 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
 # must not be `/').
 m4_define([AS_BOX],
-[AS_LITERAL_IF([$1],
-              [_AS_BOX_LITERAL($@)],
-              [_AS_BOX_INDIR($@)])])
+[_$0(m4_expand([$1]), [$2])])
+
+m4_define([_AS_BOX],
+[m4_if(m4_index(m4_translit([[$1]], [`\"], [$$$]), [$]),
+  [-1], [$0_LITERAL], [$0_INDIR])($@)])
 
 
 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
 # -------------------------------------------------
 m4_define([_AS_BOX_LITERAL],
-[cat <<\_ASBOX
-m4_text_box($@)
-_ASBOX])
+[AS_ECHO(["_AS_ESCAPE(m4_expand([m4_text_box($@)]), [`], [\"$])"])])
 
 
 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])