m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: branch-1_4 another round of POSIX cleanup


From: Eric Blake
Subject: Re: branch-1_4 another round of POSIX cleanup
Date: Thu, 13 Jul 2006 21:16:08 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> Lots of little semantic bugs 

including another one I just found:

$ /usr/xpg4/bin/m4
pushdef(`f',1)pushdef(`f',2)pushdef(`f',3)
popdef(`f',`f')f
1
$ m4
pushdef(`f',1)pushdef(`f',2)pushdef(`f',3)
popdef(`f',`f')f
stdin:2: m4: Warning: Excess arguments to built-in `popdef' ignored
2

POSIX requires popdef and undefine to handle multiple arguments, like this:

2006-07-13  Eric Blake  <address@hidden>

        * src/builtin.c (m4_undefine, m4_popdef): Visit all arguments, not
        just the first.
        * doc/m4.texinfo (Undefine, Pushdef): Test this.
        * NEWS: Document this change.

Index: NEWS
===================================================================
RCS file: /sources/m4/m4/NEWS,v
retrieving revision 1.1.1.1.2.35
diff -u -r1.1.1.1.2.35 NEWS
--- NEWS        13 Jul 2006 13:38:20 -0000      1.1.1.1.2.35
+++ NEWS        13 Jul 2006 21:06:10 -0000
@@ -44,6 +44,7 @@
   for compatibility with other m4 implementations.
 * The ifdef, divert, m4exit, substr, and translit macros now correctly
   ignore extra arguments.
+* The popdef and undefine macros now correctly accept multiple arguments.
 
 Version 1.4.4b - 17 June 2006, by Eric Blake  (CVS version 1.4.4a)
 
Index: src/builtin.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/builtin.c,v
retrieving revision 1.1.1.1.2.21
diff -u -r1.1.1.1.2.21 builtin.c
--- src/builtin.c       13 Jul 2006 13:38:20 -0000      1.1.1.1.2.21
+++ src/builtin.c       13 Jul 2006 21:06:10 -0000
@@ -493,9 +493,11 @@
 static void
 m4_undefine (struct obstack *obs, int argc, token_data **argv)
 {
-  if (bad_argc (argv[0], argc, 2, 2))
+  int i;
+  if (bad_argc (argv[0], argc, 2, -1))
     return;
-  lookup_symbol (ARG (1), SYMBOL_DELETE);
+  for (i = 1; i < argc; i++)
+    lookup_symbol (ARG (i), SYMBOL_DELETE);
 }
 
 static void
@@ -507,9 +509,11 @@
 static void
 m4_popdef (struct obstack *obs, int argc, token_data **argv)
 {
-  if (bad_argc (argv[0], argc, 2, 2))
+  int i;
+  if (bad_argc (argv[0], argc, 2, -1))
     return;
-  lookup_symbol (ARG (1), SYMBOL_POPDEF);
+  for (i = 1; i < argc; i++)
+    lookup_symbol (ARG (i), SYMBOL_POPDEF);
 }
 
 /*---------------------.
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.1.1.1.2.39
diff -u -r1.1.1.1.2.39 m4.texinfo
--- doc/m4.texinfo      13 Jul 2006 13:38:20 -0000      1.1.1.1.2.39
+++ doc/m4.texinfo      13 Jul 2006 21:06:10 -0000
@@ -1370,16 +1370,20 @@
 The expansion of @code{undefine} is void.
 
 @example
-foo
address@hidden
-define(`foo', `expansion text')
+foo bar blah
address@hidden bar blah
+define(`foo', `some')define(`bar', `other')define(`blah', `text')
 @result{}
-foo
address@hidden text
+foo bar blah
address@hidden other text
 undefine(`foo')
 @result{}
-foo
address@hidden
+foo bar blah
address@hidden other text
+undefine(`bar', `blah')
address@hidden
+foo bar blah
address@hidden bar blah
 @end example
 
 Undefining a macro inside that macro's expansion is safe; the macro
@@ -1508,9 +1512,17 @@
 @result{}
 foo
 @result{}Expansion two.
+pushdef(`foo', `Expansion three.')
address@hidden
+pushdef(`foo', `Expansion four.')
address@hidden
 popdef(`foo')
 @result{}
 foo
address@hidden three.
+popdef(`foo', `foo')
address@hidden
+foo
 @result{}Expansion one.
 popdef(`foo')
 @result{}







reply via email to

[Prev in Thread] Current Thread [Next in Thread]