argv_ref patch 23: allow tracing of indirect macros

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Next round of porting.  A while ago, I noticed an entry in the autoconf
TODO file that mentioned an m4 bug
(http://lists.gnu.org/archive/html/m4-discuss/2007-09/msg00000.html).
With a little bit of shuffling when macro tracing prints output, it was
rather easy to make indir now trace its macros.  This change (along with
stage 22) alters how trace output appears, but I have tested that it
didn't break autoconf, which is one of the projects that wants to parse
trace output.  The changes include:
| -dc now prints two lines, not three, per macro (the second and third
line were always adjacent anyway prior to this patch)
| -de now prints something even when a macro results in a builtin token or
empty string
| debugmode(V)debugmode no longer truncates the tracing output of the
second invocation, where the mode was reduced mid-expansion
| the documentation is improved and test cases added, so that it becomes
harder to change behavior down the road without detecting the change.

On the other hand, I think there are still some things that should be
considered before 1.6:
| -db could be added, which enables \ escaping of output so that tracing
never includes raw newlines or terminal control characters
| on the master branch, -dc shows the macro definition that will be used
prior to collecting the arguments, this is probably worth porting to 1.6
| is it worth making traceon(defn(`define')) legal, in which case
builtin(`define',...) would trace the builtin define?

There is a slight memory penalty (the argv struct is a bit larger), but
less munging of global variables, so the overall speed really didn't
change.  A future patch will also make m4_error/m4_warn use the call
context that tracing now uses, for even less global variable munging.

2008-05-09  Eric Blake  <[email protected]>

~        Stage 23: allow tracing of indirect macro calls.
~        Track all trace information as part of the argv struct, rather
~        than temporarily resetting global state.  Teach indir to trace
~        macros that it invokes.
~        Memory impact: slight penalty, due to larger argv struct.
~        Speed impact: none noticed.
	* src/m4.h (struct call_info): New struct.
	(trace_prepre, trace_pre, trace_post, push_string_finish)
	(input_print, call_macro): Alter signatures.
	(arg_info): New prototype.
	(input_block): Delete...
	* src/input.c (input_block): ...and make typedef local again.
	(push_string_init): Initialize length.
	(push_string_finish, input_print): Change signature, so that
	printing can be done before finalization.
	* src/macro.c (struct macro_arguments): Add info member.
	(collect_arguments, make_argv_ref): Manage new field.
	(expand_macro): Change call context management.  Move tracing...
	(call_macro): ...here, and remove redundant parameter.
	(arg_info): New function.
	* src/debug.c (trace_format): Delete unused modifiers.
	(trace_header, trace_flush, trace_prepre, trace_pre, trace_post):
	Change signatures for stacked trace messages, and for using call
	context.
	* src/builtin.c (m4_builtin, m4_indir): Update callers.
	* src/m4.c (usage): Update debugmode flag summary.
	* doc/m4.texinfo (Defn): Update examples to match new behavior.
	(Trace): Mention new capability of indir.
	(Debug Levels): Enhance text for 'c' and 'x', update examples.
	(Incompatibilities): Mention risk of parsing trace output.
	* examples/null.m4: Enhance test.
	* examples/null.err: Update expected output.
	* NEWS: Mention these changes.
	Reported by Akim Demaille in the autoconf TODO file in 2000.

- --
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

iEYEARECAAYFAkgkQJ0ACgkQ84KuGfSFAYCv4wCaAxON5wUs6GcLmj+Bh0p47RC+
6oEAoJ9zuTV435RnzSPqiiqHlLhLT65Q
=41bk
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch346 (text/plain, 90.3 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.