The actual code fix adds a single conditional of when not to expand an argv
wrapper onto the argument collection stack. The bulk of this patch is making
sure we never regress on this tricky corner case again.
From: Eric Blake <[EMAIL PROTECTED]>
Date: Thu, 6 Mar 2008 17:17:37 -0700
Subject: [PATCH] Fix nested builtin(`shift',$@) regression from 2008-02-22.
* src/macro.c (make_argv_ref_token): Don't output expansion text
when making wrapper for builtin or indir.
* doc/m4.texinfo (Builtin): Test it.
* NEWS: Document the fix.
Reported by Andreas Schwab.
Signed-off-by: Eric Blake <[EMAIL PROTECTED]>
---
ChangeLog | 9 +++++++++
NEWS | 3 ++-
doc/m4.texinfo | 17 +++++++++++++++++
src/macro.c | 5 +++--
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e82fcb7..aa9745a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-03-06 Eric Blake <[EMAIL PROTECTED]>
+
+ Fix nested builtin(`shift',$@) regression from 2008-02-22.
+ * src/macro.c (make_argv_ref_token): Don't output expansion text
+ when making wrapper for builtin or indir.
+ * doc/m4.texinfo (Builtin): Test it.
+ * NEWS: Document the fix.
+ Reported by Andreas Schwab.
+
2008-03-04 Eric Blake <[EMAIL PROTECTED]>
Make GNUmakefile work with in-place builds.
diff --git a/NEWS b/NEWS
index 42922d1..7a88383 100644
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,8 @@ Foundation, Inc.
* Noteworthy changes in Version 1.4.11 (????-??-??) [stable]
Released by ????, based on git version 1.4.10b.x-*
-** No user visible changes, yet.
+** Fix regression introduced in 1.4.10b where using `builtin' or `indir'
+ to perform nested `shift' calls triggered an assertion failure.
* Noteworthy changes in Version 1.4.10b (2008-02-25) [beta]
Released by Eric Blake, based on git version 1.4.10a
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 92a8eff..7b249bd 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -2542,6 +2542,23 @@ builtin(`builtin',)
builtin(`include', `foo')dnl
@result{}bar
@end example
+
[EMAIL PROTECTED] And this example triggers a regression present in 1.4.10b.
+
[EMAIL PROTECTED]
+define(`s', `builtin(`shift', $@@)')dnl
+define(`loop', `ifelse(`$2', `', `-', `$1$2: $0(`$1', s(s($@@)))')')dnl
+loop(`1')
[EMAIL PROTECTED]
+loop(`1', `2')
[EMAIL PROTECTED]: -
+loop(`1', `2', `3')
[EMAIL PROTECTED]: 13: -
+loop(`1', `2', `3', `4')
[EMAIL PROTECTED]: 13: 14: -
+loop(`1', `2', `3', `4', `5')
[EMAIL PROTECTED]: 13: 14: 15: -
[EMAIL PROTECTED] example
@end ignore
@node Conditionals
diff --git a/src/macro.c b/src/macro.c
index 0846f8d..4558e9c 100644
--- a/src/macro.c
+++ b/src/macro.c
@@ -1303,8 +1303,9 @@ make_argv_ref_token (token_data *token, struct obstack
*obs, int level,
unsigned int i;
for (i = 0; i < argv->arraylen; i++)
{
- if (TOKEN_DATA_TYPE (argv->array[i]) == TOKEN_COMP
- && argv->array[i]->u.u_c.wrapper)
+ if ((TOKEN_DATA_TYPE (argv->array[i]) == TOKEN_COMP
+ && argv->array[i]->u.u_c.wrapper)
+ || level >= 0)
break;
if (index == 1)
{
--
1.5.4
_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches