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@&t@_bpatsubsts): Enhance test.

Signed-off-by: Eric Blake <ebb9@byu.net>
This commit is contained in:
Eric Blake 2008-07-30 09:45:21 -06:00
parent 8d81fd7f28
commit 550a531311
3 changed files with 16 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2008-07-30 Eric Blake <ebb9@byu.net>
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@&t@_bpatsubsts): Enhance test.
2008-07-29 Eric Blake <ebb9@byu.net>
Add linear m4_bpatsubsts for m4 1.4.x.

View File

@ -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],

View File

@ -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([$1$*$@], [\$\*], [$#])
]], [[11
21
22
23
good
good
good
$1$#$@
]])