[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/7] Optimize AS_BOX.
From: |
Eric Blake |
Subject: |
[PATCH 7/7] Optimize AS_BOX. |
Date: |
Fri, 2 Jul 2010 13:37:52 -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 <address@hidden>
---
ChangeLog | 7 +++++++
NEWS | 4 ++++
doc/autoconf.texi | 11 +++++++++++
lib/m4sugar/m4sh.m4 | 12 ++++++------
4 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 39c2477..a559c16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-07-02 Eric Blake <address@hidden>
+ 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 c5e5ded..8acc6e7 100644
--- 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.*.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 73517fd..f531ed6 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -13086,6 +13086,17 @@ Common Shell Constructs
@end defmac
@end ignore
address@hidden AS_BOX (@var{text}, @dvar{char, -})
address@hidden
+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{\},
address@hidden&}, or @samp{`}. This is useful for outputting a comment box into
+log files to separate distinct phases of script operation.
address@hidden defmac
+
@defmac AS_CASE (@var{word}, @ovar{pattern1}, @ovar{if-matched1}, @
@dots{}, @ovar{default})
@asindex{CASE}
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 8c01cc9..2a4faf3 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -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 = `-'])
--
1.7.1
- [PATCH 0/7] AS_LITERAL_IF speedups, Eric Blake, 2010/07/02
- [PATCH 1/7] Optimize AC_DEFINE., Eric Blake, 2010/07/02
- [PATCH 5/7] Add tests for AS_BOX., Eric Blake, 2010/07/02
- [PATCH 2/7] Add AS_LITERAL_WORD_IF., Eric Blake, 2010/07/02
- [PATCH 6/7] Use new AS_LITERAL_IF argument when appropriate., Eric Blake, 2010/07/02
- [PATCH 7/7] Optimize AS_BOX.,
Eric Blake <=
- [PATCH 3/7] Use AS_LITERAL_WORD_IF as appropriate., Eric Blake, 2010/07/02
- [PATCH 4/7] Add optional argument to AS_LITERAL_IF., Eric Blake, 2010/07/02