]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix regression in m4_text_wrap from 2007-10-05.
authorEric Blake <ebb9@byu.net>
Mon, 8 Oct 2007 20:09:22 +0000 (14:09 -0600)
committerEric Blake <ebb9@byu.net>
Mon, 8 Oct 2007 20:09:22 +0000 (14:09 -0600)
* lib/m4sugar/m4sugar.m4 (m4_max, m4_min): New macros.
(m4_sign): Sort.
(m4_text_wrap): Fix off-by-one error in rewrite from m4_for to
m4_format.
* lib/autotest/general.m4 (AT_SETUP): Avoid negative width.
* tests/autotest.at (Long test title, Longer test title): Test
this fix, beyond what AS_HELP_STRING already tests.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/autotest/general.m4
lib/m4sugar/m4sugar.m4
tests/autotest.at

index 6d613c1e5396eee9c9f10f9682719c96642ece0e..894b67a416c82dbf065b46f2beed216c2cf1de1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,18 @@
 2007-10-08  Eric Blake  <ebb9@byu.net>
 
+       Fix regression in m4_text_wrap from 2007-10-05.
+       * lib/m4sugar/m4sugar.m4 (m4_max, m4_min): New macros.
+       (m4_sign): Sort.
+       (m4_text_wrap): Fix off-by-one error in rewrite from m4_for to
+       m4_format.
+       * lib/autotest/general.m4 (AT_SETUP): Avoid negative width.
+       * tests/autotest.at (Long test title, Longer test title): Test
+       this fix, beyond what AS_HELP_STRING already tests.
+
        Avoid m4 warnings on bad m4_format usage.
        * lib/m4sugar/m4sugar.m4 (m4_text_wrap): Use %*s, in case width
        evaulates to 0.
-       * lib/autotest/general.m4 (AT_ordinal): Likewise; also ensure that
+       * lib/autotest/general.m4 (AT_SETUP): Likewise; also ensure that
        enough arguments are provided.
 
 2007-10-06  Paolo Bonzini  <bonzini@gnu.org>
index 707c7db65f0fa5efaa05c175f6c1c23520d1582f..9215350d0626a713e33130af9e254641d622c71a 100644 (file)
@@ -1258,7 +1258,7 @@ m4_divert_push([TESTS])dnl
     at_setup_line='m4_defn([AT_line])'
     at_desc="AS_ESCAPE(m4_dquote(m4_defn([AT_description])))"
     $at_quiet AS_ECHO_N([m4_format(["%3d: $at_desc%*s"], AT_ordinal,
-      m4_eval(47 - m4_qlen(m4_defn([AT_description]))), [])])
+      m4_max(0, m4_eval(47 - m4_qlen(m4_defn([AT_description])))), [])])
 m4_divert_push([TEST_SCRIPT])dnl
 ])
 
index 5385b3f48cebbfa80e3414e440534a3467c68a6f..952794af2604ff74a8ab002ef00159dd1026d702 100644 (file)
@@ -1746,7 +1746,7 @@ m4_Prefix],
        [0], [],
        [m4_define([m4_Cursor], m4_len(m4_Prefix))[]dnl
 m4_format([%*s],
-         m4_eval(m4_len(m4_Prefix) - 1 - m4_qlen(m4_defn([m4_Prefix1]))),
+         m4_max(0,m4_eval(m4_len(m4_Prefix) - m4_qlen(m4_defn([m4_Prefix1])))),
          [])])[]dnl
 m4_foreach_w([m4_Word], [$1],
 [m4_define([m4_Cursor], m4_eval(m4_Cursor + m4_qlen(m4_defn([m4_Word])) + 1))dnl
@@ -1804,12 +1804,6 @@ m4_define([m4_qdelta],
 ## 10. Number processing.  ##
 ## ----------------------- ##
 
-# m4_sign(A)
-# ----------
-# The sign of the integer expression A.
-m4_define([m4_sign],
-[m4_eval((([$1]) > 0) - (([$1]) < 0))])
-
 # m4_cmp(A, B)
 # ------------
 # Compare two integer expressions.
@@ -1840,6 +1834,36 @@ m4_define([m4_list_cmp],
                 1, 1,
                 0, [$0((m4_shift$1), (m4_shift$2))])])])
 
+# m4_max(A, B, ...)
+# m4_min(A, B, ...)
+# -----------------
+# Return the maximum (or minimum) of a series of integer expressions.
+#
+# M4 1.4.x doesn't provide ?:.  Hence this huge m4_eval.  Avoid m4_eval
+# if both arguments are identical, but be aware of m4_max(0xa, 10) (hence
+# the use of <=, not just <, in the second multiply).
+m4_define([m4_max],
+[m4_if([$#], [0], [m4_fatal([too few arguments to $0])],
+       [$#], [1], [$1],
+       [$#$1], [2$2], [$1],
+       [$#], [2],
+       [m4_eval((([$1]) > ([$2])) * ([$1]) + (([$1]) <= ([$2])) * ([$2]))],
+       [$0($0([$1], [$2]), m4_shift2($@))])])
+m4_define([m4_min],
+[m4_if([$#], [0], [m4_fatal([too few arguments to $0])],
+       [$#], [1], [$1],
+       [$#$1], [2$2], [$1],
+       [$#], [2],
+       [m4_eval((([$1]) < ([$2])) * ([$1]) + (([$1]) >= ([$2])) * ([$2]))],
+       [$0($0([$1], [$2]), m4_shift2($@))])])
+
+
+# m4_sign(A)
+# ----------
+# The sign of the integer expression A.
+m4_define([m4_sign],
+[m4_eval((([$1]) > 0) - (([$1]) < 0))])
+
 
 
 ## ------------------------ ##
index adef6ced9a80b786ece1a8361cbe543884048533..c84cfceea41544cd27e515b10d3c82167e7024db 100644 (file)
@@ -235,12 +235,12 @@ conf
 ## ------------------------------- ##
 
 # AT_CHECK_AT_TITLE(TITLE, TITLE-TO-TEST, EXPANDED-TITLE-TO-TEST
-#                   [XFAIL-CONDITION])
+#                   [XFAIL-CONDITION], [COLUMN = 53])
 # ---------------------------------------------------------------
 # Create a new test named TITLE that runs an Autotest test suite
 # comprised of a trivial test named TITLE-TO-TEST, which expands
 # to EXPANDED-TITLE-TO-TEST.  XFAIL-CONDITION passes verbatim to
-# AT_CHECK_AT.
+# AT_CHECK_AT.  Verify that `ok' prints at COLUMN.
 m4_define([AT_CHECK_AT_TITLE],
 [AT_CHECK_AT([$1],
 [[
@@ -258,13 +258,13 @@ AT_CHECK([:])
 AT_CLEANUP
 ]], [$4], [], [], [],
 dnl This sed script checks for two things - that the output is properly
-dnl expanded, and that the 'ok' starts on column 53.
+dnl expanded, and that the 'ok' starts on the right column.
 [AT_CHECK([[$CONFIG_SHELL ./micro-suite |
            sed -n '/^  1:/{
 h
 s/[^:]*: \(.*[^         ]\)[    ]*ok.*/\1/p
 x
-s/^.\{53\}ok.*/ok/p
+s/^.\{]]]m4_default($5, 53)[[[\}ok.*/ok/p
 }']],,
 [[$3
 ok
@@ -280,7 +280,7 @@ AT_CHECK([[sed -n 's/[^.]*\. \(.*\) ([^)]*): ok.*/\1/p' micro-suite.log]],,
 
 m4_define([AT_CHECK_AT_TITLE_CHAR],
 [AT_CHECK_AT_TITLE([$1 in a test title], [A $2 in my name],
-                   [A ]m4_ifval([$3], [[$3]], [[$2]])[ in my name], $4)])
+                   [A ]m4_ifval([$3], [[$3]], [[$2]])[ in my name], $4, $5)])
 
 AT_CHECK_AT_TITLE_CHAR([Backquote],     [`])
 AT_CHECK_AT_TITLE_CHAR([Single-quote],  ['])
@@ -302,6 +302,9 @@ AT_CHECK_AT_TITLE_CHAR([Macro with backslash],       [macro_backslash], [\])
 AT_CHECK_AT_TITLE_CHAR([Macro echoing macro], [macro_echo([macro_name])],
                        [macro_expanded])
 AT_CHECK_AT_TITLE_CHAR([Macro echoing single-quote], [macro_echo(['])], ['])
+AT_CHECK_AT_TITLE_CHAR([Long test title], [0123456789012345678901234567890123])
+AT_CHECK_AT_TITLE_CHAR([Longer test title],
+                      [01234567890123456789012345678901234], [], [], [54])
 
 
 ## ----------------- ##