]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Add tests for AS_BOX.
authorEric Blake <eblake@redhat.com>
Wed, 17 Mar 2010 00:49:07 +0000 (18:49 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 2 Jul 2010 18:10:36 +0000 (12:10 -0600)
* tests/m4sugar.at (m4@&t@_text_box): New test.
* tests/m4sh.at (AS@&t@_BOX): Likewise.
* lib/m4sugar/m4sugar.m4 (m4_text_box): Support comma.
* doc/autoconf.texi (Text processing Macros) <m4_text_box>:
Document further limitations.

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

index d835b3fe7853a84b60c1dfe651a33c5b9f822191..df9424ee012d9b6fb33303b54d4d6be5a55c3c7d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-07-02  Eric Blake  <eblake@redhat.com>
 
+       Add tests for AS_BOX.
+       * tests/m4sugar.at (m4@&t@_text_box): New test.
+       * tests/m4sh.at (AS@&t@_BOX): Likewise.
+       * lib/m4sugar/m4sugar.m4 (m4_text_box): Support comma.
+       * doc/autoconf.texi (Text processing Macros) <m4_text_box>:
+       Document further limitations.
+
        Add optional argument to AS_LITERAL_IF.
        * lib/m4sugar/m4sh.m4 (_AS_LITERAL_IF): Rewrite to generate macro
        name, without using m4_cond.
index e6d4751ad0c8ad2d2ad552b3071bdd46f37d4361..73517fd1f08458d2f02006fc82aafc0e0684c275 100644 (file)
@@ -12523,7 +12523,9 @@ quickly test if @var{string} has only whitespace, use @code{m4_ifblank}.
 @defmac m4_text_box (@var{message}, @dvar{frame, -})
 @msindex{text_box}
 Add a text box around @var{message}, using @var{frame} as the border
-character above and below the message.  The frame correctly accounts for
+character above and below the message.  The @var{frame} argument must be
+a single byte, and does not support quadrigraphs.
+The frame correctly accounts for
 the subsequent expansion of @var{message}.  For example:
 @example
 m4_define([macro], [abc])dnl
index 15fbd354c5abb2ff26231d97d611e55f9212aca6..95b7bcf7810956864fef753db43817c90d428c6e 100644 (file)
@@ -2675,11 +2675,11 @@ m4_define([_m4_text_wrap_word],
 # will post-process.
 m4_define([m4_text_box],
 [m4_pushdef([m4_Border],
-           m4_translit(m4_format([%*s], m4_decr(m4_qlen(_m4_expand([$1
+           m4_translit(m4_format([[[%*s]]], m4_decr(m4_qlen(_m4_expand([$1
 ]))), []), [ ], m4_default_quoted([$2], [-])))]dnl
-[[##] m4_Border [##]
+[[##] _m4_defn([m4_Border]) [##]
 [##] $1 [##]
-[##] m4_Border [##]_m4_popdef([m4_Border])])
+[##] _m4_defn([m4_Border]) [##]_m4_popdef([m4_Border])])
 
 
 # m4_qlen(STRING)
index 1e6eb59699f06cfde883fe2d19910d0455762c5c..f5ea7e2037c2eed702e1510c50ffc7b92e664025 100644 (file)
@@ -124,9 +124,51 @@ AT_CHECK([$CONFIG_SHELL ./script])
 AT_CLEANUP
 
 
-## ------------- ##
-## AS_BASENAME.  ##
-## ------------- ##
+## -------- ##
+## AS_BOX.  ##
+## -------- ##
+
+# Output a framed one-line message.
+AT_SETUP([AS@&t@_BOX])
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+echo
+AS_BOX([Send a simple message, to foobar@example.com])
+AS_BOX([Send a simple message, to foobar@example.com], [$])
+m4_define([msg], [$complex])
+complex='Not quite as simple |$[1]'
+AS_BOX([msg])
+AS_BOX([msg], [,])
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([sed -n '/ -\{44\} /,/ -\{44\} /p' script ]dnl
+[| sed '1 s/.*## -/## -/; 3 s/- ##.*/- ##/'], [],
+[[## -------------------------------------------- ##
+## Send a simple message, to foobar@example.com ##
+## -------------------------------------------- ##
+]])
+
+AT_CHECK([$CONFIG_SHELL ./script], [], [[
+## -------------------------------------------- ##
+## Send a simple message, to foobar@example.com ##
+## -------------------------------------------- ##
+## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
+## Send a simple message, to foobar@example.com ##
+## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
+## ----------------------- ##
+## Not quite as simple |$1 ##
+## ----------------------- ##
+## ,,,,,,,,,,,,,,,,,,,,,,, ##
+## Not quite as simple |$1 ##
+## ,,,,,,,,,,,,,,,,,,,,,,, ##
+]])
+
+AT_CLEANUP
+
 
 # Strip path from file.
 AT_SETUP([AS@&t@_BASENAME])
index 70693098edbed55bac38ef36da676675fcc4bcc6..50a7b000c7580366d593c92515b467c7457b4eee 100644 (file)
@@ -1130,6 +1130,30 @@ a
 AT_CLEANUP
 
 
+## ------------- ##
+## m4_text_box.  ##
+## ------------- ##
+
+AT_SETUP([m4@&t@_text_box])
+
+AT_CHECK_M4SUGAR_TEXT([[
+m4_text_box([a $1 @&t@b])
+m4_text_box([a $1 @&t@b], [$])
+m4_text_box([a $1 @&t@b], [,])
+]], [[
+## ------ ##
+## a $1 b ##
+## ------ ##
+## $$$$$$ ##
+## a $1 b ##
+## $$$$$$ ##
+## ,,,,,, ##
+## a $1 b ##
+## ,,,,,, ##
+]])
+
+AT_CLEANUP
+
 ## -------------- ##
 ## m4_text_wrap.  ##
 ## -------------- ##