* 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>
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
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.*.
@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}
# 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 = `-'])