]> git.saurik.com Git - bison.git/commitdiff
Partial m4sugar merge from autoconf: m4_wrap vs. m4 1.6.
authorEric Blake <ebb9@byu.net>
Wed, 16 Jul 2008 18:47:48 +0000 (12:47 -0600)
committerEric Blake <ebb9@byu.net>
Thu, 7 Aug 2008 02:19:50 +0000 (20:19 -0600)
* data/m4sugar/m4sugar.m4 (m4_unquote, m4_wrap_lifo): New macros.
(m4_wrap): Guarantee FIFO order, in spite of m4 1.6.
(m4_init): Consolidate wrapped text into single m4_wrap.
* data/bison.m4 (b4_check_user_names_wrap): Stick with LIFO order
in wrapped text.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
data/bison.m4
data/m4sugar/m4sugar.m4

index f17e07fc63cdfe4e56e95dc3e2ab1f7b661209da..114f5e2c926bd2199b9bc2bf4fb91df158724035 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-08-06  Eric Blake  <ebb9@byu.net>
+
+       Partial m4sugar merge from autoconf: m4_wrap vs. m4 1.6.
+       * data/m4sugar/m4sugar.m4 (m4_unquote, m4_wrap_lifo): New macros.
+       (m4_wrap): Guarantee FIFO order, in spite of m4 1.6.
+       (m4_init): Consolidate wrapped text into single m4_wrap.
+       * data/bison.m4 (b4_check_user_names_wrap): Stick with LIFO order
+       in wrapped text.
+
 2008-08-05  Eric Blake  <ebb9@byu.net>
 
        Partial m4sugar merge from autoconf: builtins, version.m4.
index 8c210e8de8eb067dd3264377ae8182306a7e3122..bad629631ba107d695a50e825f94c838b21e15ed 100644 (file)
@@ -550,7 +550,7 @@ m4_define([b4_check_user_names_wrap],
                                [b4_percent_]$1[_user_]$2[s],
                                [[b4_percent_]$1[_bison_]$2[s]])])])
 
-m4_wrap([
+m4_wrap_lifo([
 b4_check_user_names_wrap([[define]], [[variable]])
 b4_check_user_names_wrap([[code]], [[qualifier]])
 ])
index 3ac4e00d7b29f714331cd60785b1adc19c39db9b..4fa54b39a9da58f49649ec89589dd54047b4caac 100644 (file)
@@ -141,7 +141,7 @@ m4_rename_m4([index])
 m4_rename_m4([indir])
 m4_rename_m4([len])
 m4_rename([m4exit], [m4_exit])
-m4_rename([m4wrap], [m4_wrap])
+m4_undefine([m4wrap])
 m4_ifdef([mkstemp],dnl added in M4 1.4.8
 [m4_rename_m4([mkstemp])
 m4_copy([m4_mkstemp], [m4_maketemp])
@@ -575,6 +575,41 @@ m4_define([m4_undefine],
 m4_builtin([undefine], $@)])
 
 
+# m4_unquote(ARGS)
+# ----------------
+# Remove one layer of quotes from each ARG, performing one level of
+# expansion.  For one argument, m4_unquote([arg]) is more efficient than
+# m4_do([arg]), but for multiple arguments, the difference is that
+# m4_unquote separates arguments with commas while m4_do concatenates.
+m4_define([m4_unquote], [$*])
+
+# _m4_wrap(PRE, POST)
+# -------------------
+# Helper macro for m4_wrap and m4_wrap_lifo.  Allows nested calls to
+# m4_wrap within wrapped text.
+# Skip m4_defn and m4_popdef for speed.
+m4_define([_m4_wrap],
+[m4_ifdef([$0_text],
+         [m4_define([$0_text], [$1]m4_builtin([defn], [$0_text])[$2])],
+         [m4_builtin([m4wrap], [m4_unquote(m4_builtin([defn],
+  [$0_text])m4_builtin([popdef], [$0_text]))])m4_define([$0_text], [$1$2])])])
+
+# m4_wrap(TEXT)
+# -------------
+# Append TEXT to the list of hooks to be executed at the end of input.
+# Whereas the order of the original may be LIFO in the underlying m4,
+# this version is always FIFO.
+m4_define([m4_wrap],
+[_m4_wrap([], [$1[]])])
+
+# m4_wrap_lifo(TEXT)
+# ------------------
+# Prepend TEXT to the list of hooks to be executed at the end of input.
+# Whereas the order of m4_wrap may be FIFO in the underlying m4, this
+# version is always LIFO.
+m4_define([m4_wrap_lifo],
+[_m4_wrap([$1[]])])
+
 ## -------------------------- ##
 ## 8. Implementing m4 loops.  ##
 ## -------------------------- ##
@@ -1783,10 +1818,11 @@ m4_define([m4_init],
 m4_pattern_forbid([^_?m4_])
 m4_pattern_forbid([^dnl$])
 
+# _m4_divert_diversion should be defined:
+m4_divert_push([KILL])
+
 # Check the divert push/pop perfect balance.
-m4_wrap([m4_ifdef([_m4_divert_diversion],
+m4_wrap([m4_divert_pop([])
+        m4_ifdef([_m4_divert_diversion],
           [m4_fatal([$0: unbalanced m4_divert_push:]_m4_divert_n_stack)])[]])
-
-m4_divert_push([KILL])
-m4_wrap([m4_divert_pop([KILL])[]])
 ])