-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 12/18/2008 4:15 PM: > m4_dumpdef([m4_dumpdef]) > > now outputs the less-than-helpful: > > m4_dumpdef: [] > > instead of the desired > > m4_dumpdef: <dumpdef> > > This is not technically a regression (since before my patch, any use of > m4_dumpdef under M4 1.4.x flat-out confused autom4te), but it would be nice > to > fix. > > For m4 1.6, where dumpdef output always goes to stderr instead of to the > debugfile (well, it will, once I check in a backported patch from the master > branch), I can make m4_dumpdef useful.
m4.git now contains a patch on branch-1.6 and newer that adds the m4_debugmode([+o]) flag to force dumpdef output to stderr regardless of the current --debugfile settings. Therefore, I'm committing this patch (no impact to m4 1.4.x users, but if you were living on the edge and testing m4.git's branch-1.6, you will need to update m4 first, but that should not be a big deal since you are already living on the edge ;) - -- Don't work too hard, make some time for fun as well! Eric Blake [email protected] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAklRuEIACgkQ84KuGfSFAYCblACePpq3AZjE7WvLkpxRsk46XYEy SZgAoNRrgXTmChZuEn1ZZH9LUYX8Q/v9 =3xC+ -----END PGP SIGNATURE-----
>From 5f85192b8081c9f6f4d6912785dad9b6a78c9f8d Mon Sep 17 00:00:00 2001 From: Eric Blake <[email protected]> Date: Tue, 23 Dec 2008 14:29:48 -0700 Subject: [PATCH] Make m4_dumpdef more useful with M4 1.6. * lib/m4sugar/m4sugar.m4 (_m4_dumpdef): New macro. (m4_init): Install it for new enough m4. * tests/m4sugar.at (m4@&t...@_dumpdef): Enhance test. * doc/autoconf.texi (Redefined M4 Macros) <m4_dumpdef>: Mention lack of sorting. Signed-off-by: Eric Blake <[email protected]> --- ChangeLog | 9 +++++++++ doc/autoconf.texi | 3 ++- lib/m4sugar/m4sugar.m4 | 20 ++++++++++++++++---- tests/m4sugar.at | 24 ++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f7a7d3a..099c19e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-12-23 Eric Blake <[email protected]> + + Make m4_dumpdef more useful with M4 1.6. + * lib/m4sugar/m4sugar.m4 (_m4_dumpdef): New macro. + (m4_init): Install it for new enough m4. + * tests/m4sugar.at (m4@&t...@_dumpdef): Enhance test. + * doc/autoconf.texi (Redefined M4 Macros) <m4_dumpdef>: Mention + lack of sorting. + 2008-12-24 Bruno Haible <[email protected]> Improve INSTALL for HP-UX. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 004ddb2..2d8d3c7 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -10558,7 +10558,8 @@ Redefined M4 Macros @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 +rather than the current debug file, no sorting is done on multiple +arguments, and an error is issued if any @var{name} is undefined. @code{m4_dumpdefs} is a convenience macro that calls @code{m4_dumpdef} for all of the @code{m4_pushdef} stack of definitions, starting with the current, and diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4 index 05e357a..f64ef16 100644 --- a/lib/m4sugar/m4sugar.m4 +++ b/lib/m4sugar/m4sugar.m4 @@ -603,13 +603,23 @@ m4_define([m4_defn], # always dumps to stderr, regardless of the current debugfile; it also # provides m4symbols as a way to grab all current macro names. But # dumpdefs is not frequently called, so we don't need to worry about -# conditionally using these newer features. +# conditionally using these newer features. Also, this version +# doesn't sort multiple arguments. +# +# If we detect m4 1.6 or newer, then provide an alternate definition, +# installed during m4_init, that allows builtins through. +# Unfortunately, there is no nice way in m4 1.4.x to dump builtins. m4_define([m4_dumpdef], [m4_if([$#], [0], [m4_fatal([$0: missing argument])], [$#], [1], [m4_ifdef([$1], [m4_errprintn( [$1: ]m4_dquote(_m4_defn([$1])))], [m4_fatal([$0: undefined macro: $1])])], [m4_map_args([$0], $@)])]) +m4_define([_m4_dumpdef], +[m4_if([$#], [0], [m4_fatal([$0: missing argument])], + [$#], [1], [m4_builtin([dumpdef], [$1])], + [m4_map_args_sep([m4_builtin([dumpdef],], [)], [], $@)])]) + # m4_dumpdefs(NAME...) # -------------------- @@ -3053,8 +3063,9 @@ m4_pattern_forbid([^_?m4_]) m4_pattern_forbid([^dnl$]) # If __m4_version__ is defined, we assume that we are being run by M4 -# 1.6 or newer, and thus that $@ recursion is linear and debugmode(d) -# is available for faster checks of dereferencing undefined macros. +# 1.6 or newer, thus $@ recursion is linear, and debugmode(+do) +# is available for faster checks of dereferencing undefined macros +# and forcing dumpdef to print to stderr regardless of debugfile. # But if it is missing, we assume we are being run by M4 1.4.x, that # $@ recursion is quadratic, and that we need foreach-based # replacement macros. Also, m4 prior to 1.4.8 loses track of location @@ -3063,8 +3074,9 @@ m4_pattern_forbid([^dnl$]) # Use the raw builtin to avoid tripping up include tracing. # Meanwhile, avoid m4_copy, since it temporarily undefines m4_defn. m4_ifdef([__m4_version__], -[m4_debugmode([+d]) +[m4_debugmode([+do]) m4_define([m4_defn], _m4_defn([_m4_defn])) +m4_define([m4_dumpdef], _m4_defn([_m4_dumpdef])) m4_define([m4_popdef], _m4_defn([_m4_popdef])) m4_define([m4_undefine], _m4_defn([_m4_undefine]))], [m4_builtin([include], [m4sugar/foreach.m4]) diff --git a/tests/m4sugar.at b/tests/m4sugar.at index 4938027..0d90ca2 100644 --- a/tests/m4sugar.at +++ b/tests/m4sugar.at @@ -194,6 +194,30 @@ a: [2] a: [1] ]]) +# Check behavior when dumping builtins. Unfortunately, when using M4 1.4.x +# (or more precisely, when __m4_version__ is undefined), builtins get +# flattened to an empty string. It takes M4 1.6 to work around this. +AT_DATA_M4SUGAR([script.4s], +[[m4_ifdef([__m4_version__], [_m4_undefine([__m4_version__])]) +m4_init +m4_dumpdef([m4_define]) +]]) + +AT_CHECK_M4SUGAR([-o-], [0], [], +[[m4_define: [] +]]) + +AT_DATA_M4SUGAR([script.4s], +[[m4_init +m4_ifdef([__m4_version__], +[m4_dumpdef([m4_define])], +[m4_errprintn([m4_define: <define>])]) +]]) + +AT_CHECK_M4SUGAR([-o-], [0], [], +[[m4_define: <define> +]]) + AT_CLEANUP -- 1.6.0.4
