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.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2010-03-01 17:17:40 -07:00
parent 73720645e9
commit 64954f9188
4 changed files with 28 additions and 6 deletions

View File

@ -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

4
NEWS
View File

@ -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.*.

View 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}

View 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 = `-'])