[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: m4_cond [was: [RFA] autotest speedup]
From: |
Eric Blake |
Subject: |
Re: m4_cond [was: [RFA] autotest speedup] |
Date: |
Mon, 8 Oct 2007 16:59:56 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Eric Blake <ebb9 <at> byu.net> writes:
> As it is, m4sugar is woefully underdocumented in the manual. So I added
> m4_cond and a couple others in the process.
>
> Provide better short-circuiting operation.
> * lib/m4sugar/m4sugar.m4 (m4_cond, m4_newline): New macros.
> (m4_text_wrap): Use it. Also avoid useless m4_for.
> @@ -1696,15 +1739,14 @@ m4_pushdef([m4_Width], m4_default([$4], 79))dnl
> + [m4_define([m4_Cursor], m4_len(m4_Prefix))[]dnl
> +m4_format(%m4_eval(m4_len(m4_Prefix) - 1 - m4_qlen(m4_defn([m4_Prefix1])))
[s],
> + [])])[]dnl
Oops - this broke the latest m4 git checkout. If m4_len(m4_Prefix) - 1 -
m4_qlen(m4_defn([m4_Prefix1])) is exactly 0, this results in m4_format(%0s),
and newer versions of m4 correctly warn (it would make m4 try to invoke the
undefined printf("%0s")). Also, I intend on making m4 1.4.11 warn if m4_format
is called with too few arguments for the number of arguments designated by %
specifiers (whereas it now silently uses 0 or "" for the missing arguments as
appropriate).
Applying this, since m4_format([%*s],0,) is well-defined:
2007-10-08 Eric Blake <address@hidden>
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
enough arguments are provided.
---
From: Eric Blake <address@hidden>
Date: Mon, 8 Oct 2007 10:46:21 -0600
Subject: [PATCH] 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
enough arguments are provided.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 12 ++++++++++--
lib/autotest/general.m4 | 4 ++--
lib/m4sugar/m4sugar.m4 | 3 ++-
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 159ba5b..6d613c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,15 @@
+2007-10-08 Eric Blake <address@hidden>
+
+ 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
+ enough arguments are provided.
+
2007-10-06 Paolo Bonzini <address@hidden>
- * doc/autoconf.texi (Shell portability): Document shell function
- portability.
+ * doc/autoconf.texi (Shell portability): Document shell function
+ portability.
2007-10-06 Paolo Bonzini <address@hidden>
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index df74838..707c7db 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -1257,8 +1257,8 @@ m4_divert_push([TESTS])dnl
AT_ordinal ) @%:@ AT_ordinal. m4_defn([AT_line]): m4_defn([AT_description])
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_ordinal)$at_desc"]dnl
-["m4_format(%m4_eval(47 - m4_qlen(m4_defn([AT_description])))[s])"])
+ $at_quiet AS_ECHO_N([m4_format(["%3d: $at_desc%*s"], AT_ordinal,
+ 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 1da5220..5385b3f 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -1745,7 +1745,8 @@ m4_Prefix],
[m4_eval(m4_qlen(m4_defn([m4_Prefix1])) < m4_len(m4_Prefix))],
[0], [],
[m4_define([m4_Cursor], m4_len(m4_Prefix))[]dnl
-m4_format(%m4_eval(m4_len(m4_Prefix) - 1 - m4_qlen(m4_defn([m4_Prefix1])))[s],
+m4_format([%*s],
+ m4_eval(m4_len(m4_Prefix) - 1 - 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
--
1.5.3.2