[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: more m4sugar tweaks
From: |
Eric Blake |
Subject: |
Re: more m4sugar tweaks |
Date: |
Wed, 30 Jul 2008 15:51:44 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Eric Blake <ebb9 <at> byu.net> writes:
>
> 3. m4_bpatsubsts didn't match the documentation if given exactly two
> arguments, and was quadratic for m4 1.4.x. I finally figured out how to
> make it linear (leaving just m4_cond and m4_bmatch to go).
That last patch was half-baked. I committed the wrong version, and am
correcting it as follows:
>From 550a531311a58a3ac7f9274e66e8b9a3540ba2e0 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 30 Jul 2008 09:45:21 -0600
Subject: [PATCH] Fix bugs in previous version of m4_bpatsubsts.
* lib/m4sugar/foreach.m4 (_m4_bpatsubsts): Don't expand $1, and
allow concatenation with subsequent text.
* tests/m4sugar.at (m4@&address@hidden): Enhance test.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 7 +++++++
lib/m4sugar/foreach.m4 | 6 +++---
tests/m4sugar.at | 7 ++++++-
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5f348b3..5ff6e00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-07-30 Eric Blake <address@hidden>
+
+ Fix bugs in previous version of m4_bpatsubsts.
+ * lib/m4sugar/foreach.m4 (_m4_bpatsubsts): Don't expand $1, and
+ allow concatenation with subsequent text.
+ * tests/m4sugar.at (m4@&address@hidden): Enhance test.
+
2008-07-29 Eric Blake <address@hidden>
Add linear m4_bpatsubsts for m4 1.4.x.
diff --git a/lib/m4sugar/foreach.m4 b/lib/m4sugar/foreach.m4
index 015e0be..3109a8f 100644
--- a/lib/m4sugar/foreach.m4
+++ b/lib/m4sugar/foreach.m4
@@ -137,11 +137,11 @@ m4_define([_m4_case_],
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$2], [$3]))m4_define([_m4_p],
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$4], [$5]))m4_define
([_m4_p],...
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$m-1], [$m]))m4_unquote(
-# _m4_defn([_m4_p]))[]_m4_popdef([_m4_p])
+# _m4_defn([_m4_p])_m4_popdef([_m4_p]))
m4_define([_m4_bpatsubsts],
[m4_define([_m4_p], m4_pushdef([_m4_p])[m4_define([_m4_p],
- [$1])]_m4_for([_m4_p], [3], [$#], [2], [$0_(m4_decr(_m4_p),
- _m4_p)])[m4_unquote(_m4_defn([_m4_p]))[]_m4_popdef([_m4_p])])_m4_p($@)])
+ ]m4_dquote([$]1)[)]_m4_for([_m4_p], [3], [$#], [2], [$0_(m4_decr(_m4_p),
+ _m4_p)])[m4_unquote(_m4_defn([_m4_p])_m4_popdef([_m4_p]))])_m4_p($@)])
m4_define([_m4_bpatsubsts_],
[[m4_define([_m4_p],
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index a1c0bd0..516881e 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -532,14 +532,19 @@ AT_CHECK_M4SUGAR_TEXT(
m4_bpatsubsts([11], [\(.\)1], [\12])
m4_bpatsubsts([11], [^..$], [], [1], [2])
m4_bpatsubsts([11], [\(.\)1], [\12], [1], [3])
-m4_define([a], [oops])m4_define([AB], [good])dnl
+m4_define([a], [oops])m4_define([c], [oops])dnl
+m4_define([AB], [good])m4_define([bc], [good])dnl
m4_bpatsubsts([abc], [a], [A], [b], [B], [c])
+m4_bpatsubsts([ab], [a])c
+m4_bpatsubsts([ab], [c], [C], [a])c
m4_bpatsubsts(address@hidden, [\$\*], [$#])
]], [[11
21
22
23
good
+good
+good
$1$#$@
]])
--
1.5.6.4