]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Support multiple undiverts and dumpdefs at once.
authorEric Blake <ebb9@byu.net>
Thu, 30 Oct 2008 21:51:26 +0000 (15:51 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 31 Oct 2008 16:30:31 +0000 (10:30 -0600)
* lib/m4sugar/m4sugar.m4 (m4_dumpdefs, m4_undivert): Allow extra
arguments.
* doc/autoconf.texi (Redefined M4 Macros) <m4_dumpdef>,
<m4_undivert>: Document argument list change.
* tests/m4sugar.at (m4@&t@_divert_stack, m4@&t@_dumpdef): Test
them.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/autoconf.texi
lib/m4sugar/m4sugar.m4
tests/m4sugar.at

index ef29a6e446b6f45aa3ab2d6bd19b1f02ebea8744..cf47e185030a9eb4725864713234128fa37462d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2008-10-31  Eric Blake  <ebb9@byu.net>
 
+       Support multiple undiverts and dumpdefs at once.
+       * lib/m4sugar/m4sugar.m4 (m4_dumpdefs, m4_undivert): Allow extra
+       arguments.
+       * doc/autoconf.texi (Redefined M4 Macros) <m4_dumpdef>,
+       <m4_undivert>: Document argument list change.
+       * tests/m4sugar.at (m4@&t@_divert_stack, m4@&t@_dumpdef): Test
+       them.
+
        Simplify diversion stack handling.
        * lib/m4sugar/m4sugar.m4 (m4_divert_stack): Use fewer macros, and
        avoid extra newlines.
index c50cee47d2da9bca04772822272e35f668f2615f..2a7fc4a106f8e2b609130a871862d49f454c1804 100644 (file)
@@ -10419,14 +10419,14 @@ diversion stack.
 @end defmac
 
 @defmac m4_dumpdef (@var{name}@dots{})
-@defmacx m4_dumpdefs (@var{name})
+@defmacx m4_dumpdefs (@var{name}@dots{})
 @msindex{dumpdef}
 @msindex{dumpdefs}
 @code{m4_dumpdef} is like the M4 builtin, except that this version
 requires at least one argument, output always goes to standard error
 rather than the current debug file, and an error is issued if any
 @var{name} is undefined.  @code{m4_dumpdefs} is a convenience macro that
-takes exactly one @var{name}, and calls @code{m4_dumpdef} for all of the
+calls @code{m4_dumpdef} for all of the
 @code{m4_pushdef} stack of definitions, starting with the current, and
 silently does nothing if @var{name} is undefined.
 @end defmac
@@ -10487,10 +10487,10 @@ m4_ifdef([@var{macro}], [m4_undefine([@var{macro}])])
 if you are not sure whether @var{macro} is defined.
 @end defmac
 
-@defmac m4_undivert (@var{diversion})
+@defmac m4_undivert (@var{diversion}@dots{})
 @msindex{undivert}
-Unlike the M4 builtin, only one diversion can be undiverted per
-invocation.  Also, since the M4sugar diversion stack prefers named
+Unlike the M4 builtin, at least one @var{diversion} must be specified.
+Also, since the M4sugar diversion stack prefers named
 diversions, the use of @code{m4_undivert} to include files is risky.
 @xref{Diversion support}, for more details about the use of the
 diversion stack.
index fc912e24a3e085898e1018854ef0a11ea66474f4..71533a19d3e5071a09d0ead2d9bb47c60f3fa09e 100644 (file)
@@ -610,16 +610,19 @@ m4_define([m4_dumpdef],
        [m4_map_args([$0], $@)])])
 
 
-# m4_dumpdefs(NAME)
-# -----------------
+# m4_dumpdefs(NAME...)
+# --------------------
 # Similar to `m4_dumpdef(NAME)', but if NAME was m4_pushdef'ed, display its
-# value stack (most recent displayed first).
+# value stack (most recent displayed first).  Also, this version silently
+# ignores undefined macros, rather than erroring out.
 #
 # 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).
 m4_define([m4_dumpdefs],
-[m4_stack_foreach_lifo([$1], [m4_dumpdef([$1])m4_ignore])])
+[m4_if([$#], [0], [m4_fatal([$0: missing argument])],
+       [$#], [1], [m4_stack_foreach_lifo([$1], [m4_dumpdef([$1])m4_ignore])],
+       [m4_map_args([$0], $@)])])
 
 
 # m4_popdef(NAME)
@@ -1325,12 +1328,15 @@ m4_define([m4_divert_once],
 [m4_expand_once([m4_divert_text([$1], [$2])])])
 
 
-# m4_undivert(DIVERSION-NAME)
-# ---------------------------
-# Undivert DIVERSION-NAME.  Unlike the M4 version, this only takes a single
-# diversion identifier, and should not be used to undivert files.
+# m4_undivert(DIVERSION-NAME...)
+# ------------------------------
+# Undivert DIVERSION-NAME.  Unlike the M4 version, this requires at
+# least one DIVERSION-NAME; also, due to support for named diversions,
+# this should not be used to undivert files.
 m4_define([m4_undivert],
-[m4_builtin([undivert], _m4_divert([$1]))])
+[m4_if([$#], [0], [m4_fatal([$0: missing argument])],
+       [$#], [1], [m4_builtin([undivert], _m4_divert([$1]))],
+       [m4_map_args([$0], $@)])])
 
 
 ## --------------------------------------------- ##
index 8034ced43dc79cd7b48bd70341b36d8fa168b8ef..70bb24b3a320dc1fe3290a53ae799ec20de98a7e 100644 (file)
@@ -181,8 +181,7 @@ AT_CHECK_M4SUGAR_TEXT([[m4_divert_push([KILL])
 m4_pushdef([a], [1])
 m4_pushdef([a], [2])
 m4_dumpdef([a])
-m4_dumpdefs([a])
-m4_dumpdefs([oops])
+m4_dumpdefs([oops], [a])
 m4_divert_pop([KILL])dnl
 ]], [],
 [[a:   [2]
@@ -248,14 +247,15 @@ AT_CLEANUP
 ## ----------------- ##
 
 AT_SETUP([m4@&t@_divert_stack])
+AT_KEYWORDS([m4@&t@_divert m4@&t@_divert_push m4@&t@_divert_pop
+m4@&t@_undivert])
 
 AT_CHECK_M4SUGAR_TEXT([[1.m4_divert_stack
 m4_divert_push([10])2.m4_divert_stack
 m4_divert_text([20], [3.m4_divert_stack])dnl
 m4_divert([30])4.m4_divert_stack
 m4_divert_pop([30])dnl
-5.m4_undivert([20])
-6.m4_undivert([30])
+5.m4_undivert([20], [30])
 m4_pattern_allow([^m4_divert])dnl
 ]], [[1.script.4s:2: m4@&t@_divert_push: 0
 script.4s:1: m4@&t@_divert: KILL
@@ -263,8 +263,7 @@ script.4s:1: m4@&t@_divert: KILL
 script.4s:4: m4@&t@_divert_push: 10
 script.4s:2: m4@&t@_divert_push: 0
 script.4s:1: m4@&t@_divert: KILL
-
-6.4.script.4s:6: m4@&t@_divert: 30
+4.script.4s:6: m4@&t@_divert: 30
 script.4s:2: m4@&t@_divert_push: 0
 script.4s:1: m4@&t@_divert: KILL