[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: some issues in the latest Autoconf
From: |
Eric Blake |
Subject: |
Re: some issues in the latest Autoconf |
Date: |
Mon, 8 Oct 2007 20:19:03 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes:
> | @@ -1,48 +1,48 @@
> | - --an-option some text
> | + --an-option some text
Off-by-one error when I converted the time-consuming m4_for to a faster
m4_format in m4_text_wrap; I didn't correctly account for the inclusiveness of
the bounds. Fixed thusly (along with another fix to avoid negative width -
without this fix, growing a really long AT_SETUP string by one character also
added another unnecessary space).
And this thread is all the more reason why I'm pleased with Paolo's attempts to
speed up autotest - I've been slacking running the entire suite for some of my
recent patches, due to the several hours that it takes on cygwin; any
improvement to trim this down makes it more likely that I'll wait out the
entire testsuite, rather than having to check in these after-the-fact
regression patches.
From: Eric Blake <address@hidden>
Date: Mon, 8 Oct 2007 14:09:22 -0600
Subject: [PATCH] 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.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 11 ++++++++++-
lib/autotest/general.m4 | 2 +-
lib/m4sugar/m4sugar.m4 | 38 +++++++++++++++++++++++++++++++-------
tests/autotest.at | 13 ++++++++-----
4 files changed, 50 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6d613c1..894b67a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,18 @@
2007-10-08 Eric Blake <address@hidden>
+ 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 <address@hidden>
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 707c7db..9215350 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -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
])
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 5385b3f..952794a 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -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))])
+
## ------------------------ ##
diff --git a/tests/autotest.at b/tests/autotest.at
index adef6ce..c84cfce 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -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])
## ----------------- ##
--
1.5.3.2