autoconf-commit
[Top][All Lists]
Advanced

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

[SCM] GNU Autoconf source repository branch, master, updated. v2.63-120-


From: Paolo Bonzini
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.63-120-g1415907
Date: Tue, 28 Oct 2008 17:35:46 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Autoconf source repository".

http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=1415907c2d8a008fa2e6e443c491006029f43bde

The branch, master has been updated
       via  1415907c2d8a008fa2e6e443c491006029f43bde (commit)
      from  29e6e30d37f591a3a957951c50f594c94ba719e1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1415907c2d8a008fa2e6e443c491006029f43bde
Author: Paolo Bonzini <address@hidden>
Date:   Tue Oct 28 11:27:31 2008 +0100

    add m4_stack_foreach and m4_stack_foreach_lifo
    
    * lib/m4sugar/m4sugar.m4 (_m4_stack_reverse): New from _m4_copy.
    (m4_stack_foreach, m4_stack_foreach_lifo): New.
    (m4_copy): Use m4_stack_foreach and m4_curry.
    (_m4_dumpdefs_down, _m4_dumpdefs_up): Remove.
    (m4_dumpdefs): Rewrite using m4_stack_foreach_lifo.
    * tests/m4sugar.at (m4_stack_foreach): New test.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |   10 +++++++
 lib/m4sugar/m4sugar.m4 |   68 +++++++++++++++++++++++++----------------------
 tests/m4sugar.at       |   54 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4e8fdd1..d0296c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,14 @@
 2008-10-28  Paolo Bonzini  <address@hidden>
+
+       Add m4_stack_foreach and m4_stack_foreach_lifo.
+       * lib/m4sugar/m4sugar.m4 (_m4_stack_reverse): New from _m4_copy.
+       (m4_stack_foreach, m4_stack_foreach_lifo): New.
+       (m4_copy): Use m4_stack_foreach and m4_curry.
+       (_m4_dumpdefs_down, _m4_dumpdefs_up): Remove.
+       (m4_dumpdefs): Rewrite using m4_stack_foreach_lifo.
+       * tests/m4sugar.at (m4_stack_foreach): New test.
+
+2008-10-28  Paolo Bonzini  <address@hidden>
     
        use a shell function for AC_TYPE_INTx_T
        * lib/autoconf/types.m4 (_AC_TYPE_INT_BODY, _AC_TYPE_UNSIGNED_INT_BODY):
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 22c38e8..eb5d426 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -535,19 +535,12 @@ m4_define([_m4_bpatsubsts],
 # includes one-shot initialization that is later popped to the normal
 # definition.
 #
-# The recursive worker destructively swaps the order of a stack.  We
-# use a temporary stack, and swap directions twice, using the third
-# argument to restore the original stack.
-#
-# Some macros simply can't be renamed with this method: namely,
-# anything involved in the implementation of _m4_copy.
+# Some macros simply can't be renamed with this method: namely, anything
+# involved in the implementation of m4_stack_foreach and m4_curry.
 m4_define([m4_copy],
 [m4_ifdef([$2], [m4_fatal([$0: won't overwrite defined macro: $2])],
-         [_$0([$1], [m4_tmp])_$0([m4_tmp], [$2],
-  [m4_pushdef([$1], _m4_defn([m4_tmp]))])m4_ifdef([m4_location($1)],
-  [m4_define([m4_location($2)], m4_location)])])])
-m4_define([_m4_copy],
-[m4_ifdef([$1], [m4_pushdef([$2], _m4_defn([$1]))$3[]_m4_popdef([$1])$0($@)])])
+         [m4_stack_foreach([$1], [m4_curry([m4_pushdef], 
[$2])])m4_ifdef([m4_location($1)],
+[m4_define([m4_location($2)], m4_location)])])])
 
 
 # m4_define_default(MACRO, VALUE)
@@ -603,32 +596,17 @@ m4_define([m4_defn],
        [m4_foreach([_m4_macro], address@hidden, 
[$0(_m4_defn([_m4_macro]))])])])
 
 
-# _m4_dumpdefs_up(NAME)
-# ---------------------
-m4_define([_m4_dumpdefs_up],
-[m4_ifdef([$1],
-         [m4_pushdef([_m4_dumpdefs], _m4_defn([$1]))dnl
-m4_dumpdef([$1])dnl
-_m4_popdef([$1])dnl
-_m4_dumpdefs_up([$1])])])
-
-
-# _m4_dumpdefs_down(NAME)
-# -----------------------
-m4_define([_m4_dumpdefs_down],
-[m4_ifdef([_m4_dumpdefs],
-         [m4_pushdef([$1], _m4_defn([_m4_dumpdefs]))dnl
-_m4_popdef([_m4_dumpdefs])dnl
-_m4_dumpdefs_down([$1])])])
-
-
 # m4_dumpdefs(NAME)
 # -----------------
 # Similar to `m4_dumpdef(NAME)', but if NAME was m4_pushdef'ed, display its
 # value stack (most recent displayed first).
+#
+# This macro cheats, because it relies on the current definition of NAME
+# while the second argument of m4_stack_foreach_lifo is evaluated (which
+# would be undefined according to the API).  If m4_dumpdef is ever rewritten
+# not to use the builtin, revisit this.
 m4_define([m4_dumpdefs],
-[_m4_dumpdefs_up([$1])dnl
-_m4_dumpdefs_down([$1])])
+[m4_stack_foreach_lifo([$1], [m4_dumpdef([$1])m4_ignore])])
 
 
 # m4_popdef(NAME)
@@ -1189,6 +1167,32 @@ m4_define([m4_map_args_pair],
        [$1([$3], [$4])[]$0([$1], [$2], m4_shift(m4_shift3($@)))])])
 
 
+# m4_stack_foreach(MACRO, FUNC)
+# m4_stack_foreach_lifo(MACRO, FUNC)
+# ----------------------------------
+# Pass each stacked definition of MACRO to the one-argument macro FUNC.
+# m4_stack_foreach proceeds in FIFO order, while m4_stack_foreach_lifo
+# processes the topmost definitions first.  In addition, FUNC should
+# not push or pop definitions of MACRO, and should not expect anything about
+# the active definition of MACRO (it will not be the topmost, and may not
+# be the one passed to FUNC either).
+#
+# The recursive worker _m4_stack_reverse destructively swaps the order of a
+# stack.  We use a temporary stack, and swap directions twice.  Some macros
+# simply can't be examined with this method: namely, anything involved
+# in the implementation of _m4_stack_reverse.
+m4_define([_m4_stack_reverse],
+[m4_ifdef([$1], [m4_pushdef([$2], _m4_defn([$1]))$3[]_m4_popdef([$1])$0($@)])])
+
+m4_define([m4_stack_foreach],
+[_m4_stack_reverse([$1], [m4_tmp-$1])]dnl
+[_m4_stack_reverse([m4_tmp-$1], [$1], [$2(_m4_defn([m4_tmp-$1]))])])
+
+m4_define([m4_stack_foreach_lifo],
+[_m4_stack_reverse([$1], [m4_tmp-$1], [$2(_m4_defn([m4_tmp-$1]))])]dnl
+[_m4_stack_reverse([m4_tmp-$1], [$1])])
+
+
 ## --------------------------- ##
 ## 9. More diversion support.  ##
 ## --------------------------- ##
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 959b209..10ebbd8 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -37,6 +37,60 @@ AT_CHECK_M4SUGAR([-o-],, [$2], [$3])
 ])# AT_CHECK_M4SUGAR_TEXT
 
 
+## ------------------ ##
+## m4_stack_foreach.  ##
+## ------------------ ##
+
+AT_SETUP([m4@&address@hidden)
+
+AT_KEYWORDS([m4@&address@hidden m4@&address@hidden m4@&address@hidden)
+
+# Test the semantics of macros to walk stacked macro definitions.
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_pushdef([abc], [def])dnl
+m4_pushdef([abc], [ghi])dnl
+m4_pushdef([abc], [jkl])dnl
+m4_stack_foreach([abc], [m4_n])
+abc
+m4_stack_foreach_lifo([abc], [m4_n])
+m4_stack_foreach([abc], [m4_n])
+m4_copy([abc], [foo])dnl
+m4_stack_foreach([foo], [m4_n])
+m4_stack_foreach_lifo([foo], [m4_n])
+m4_pushdef([xyz], [123])dnl
+m4_pushdef([xyz], [456])dnl
+m4_define([doit], [[$1](m4_shift(m4_stack_foreach([xyz], [,m4_echo])))
+])dnl
+m4_stack_foreach([abc], [doit])]],
+[[def
+ghi
+jkl
+
+jkl
+jkl
+ghi
+def
+
+def
+ghi
+jkl
+
+def
+ghi
+jkl
+
+jkl
+ghi
+def
+
+def(123,456)
+ghi(123,456)
+jkl(123,456)
+]])
+
+AT_CLEANUP
+
+
 ## --------- ##
 ## m4_defn.  ##
 ## --------- ##


hooks/post-receive
--
GNU Autoconf source repository




reply via email to

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