[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04-cleanup-builtins-tracing.patch
From: |
Akim Demaille |
Subject: |
04-cleanup-builtins-tracing.patch |
Date: |
03 Aug 2001 11:16:44 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Academic Rigor) |
Index: ChangeLog
from Akim Demaille <address@hidden>
Clean up the handling of the M4 builtins tracing exception.
* bin/autom4te.in (Request::request): Don't complete M4 builtins
trace requests.
(@m4_builtins): Rename as...
(@m4_builtin): this.
(%m4_builtin_alternate_name): New.
(&parse_args): Complete the trace requests with alternate names.
(&handle_traces): Hence no longer do it here.
(&trace_requests): Remove, unused.
Index: bin/autom4te.in
--- bin/autom4te.in Thu, 02 Aug 2001 00:45:09 +0200 akim (ace/c/10_autom4te.i
1.14 644)
+++ bin/autom4te.in Thu, 02 Aug 2001 17:17:35 +0200 akim (ace/c/10_autom4te.i
1.14 644)
@@ -129,12 +129,7 @@ sub request
{
if (! exists ${$obj->macro}{$_})
{
- # FIXME: This is too rough an approximation: we should have
- # a means to select only M4 builtins, but @m4_builtins is not
- # visible here.
- s/^m4_//;
${$obj->macro}{$_} = 1;
- ${$obj->macro}{"m4_$_"} = 1;
$obj->valid (0);
}
}
@@ -270,9 +265,63 @@ sub load
$m4 .= ' --nesting-limit=1024'
if " $m4 " !~ / (--nesting-limit|-L) /;
-# @M4_BUILTINS -- M4 builtins and a useful comment.
-my @m4_builtins = `echo dumpdef | $m4 2>&1 >/dev/null`;
-map { s/:.*//;s/\W// } @m4_builtins;
+
+# @M4_BUILTIN -- M4 builtins and a useful comment.
+my @m4_builtin = `echo dumpdef | $m4 2>&1 >/dev/null`;
+map { s/:.*//;s/\W// } @m4_builtin;
+
+
+# %M4_BUILTIN_ALTERNATE_NAME
+# --------------------------
+# The builtins are renamed, e.g., `define' is renamed `m4_define'.
+# So map `define' to `m4_define' and conversely.
+# Some macros don't follow this scheme: be sure to properly map to their
+# alternate name too.
+#
+# This is because GNU M4 1.4's tracing of builtins is buggy. When run on
+# this input:
+#
+# | divert(-1)
+# | changequote([, ])
+# | define([m4_eval], defn([eval]))
+# | eval(1)
+# | m4_eval(2)
+# | undefine([eval])
+# | m4_eval(3)
+#
+# it behaves this way:
+#
+# | % m4 input.m4 -da -t eval
+# | m4trace: -1- eval(1)
+# | m4trace: -1- m4_eval(2)
+# | m4trace: -1- m4_eval(3)
+# | %
+#
+# Conversely:
+#
+# | % m4 input.m4 -da -t m4_eval
+# | %
+#
+# So we will merge them, i.e. tracing `BUILTIN' or tracing
+# `m4_BUILTIN' will be the same: tracing both, but honoring the
+# *last* trace specification.
+#
+# FIXME: This is not enough: in the output `$0' will be `BUILTIN'
+# sometimes and `m4_BUILTIN' at others. We should return a unique name,
+# the one specified by the user.
+#
+# FIXME: To be absolutely rigorous, I would say that given that we
+# _redefine_ divert (instead of _copying_ it), divert and the like
+# should not be part of this list.
+my %m4_builtin_alternate_name;
address@hidden"$_", "m4_$_"} = ("m4_$_", "$_")
+ foreach (grep { !/m4wrap|m4exit|dnl|ifelse|__.*__/ } @m4_builtin);
address@hidden"ifelse", "m4_if"} = ("m4_if", "ifelse");
address@hidden"m4exit", "m4_exit"} = ("m4_exit", "m4exit");
address@hidden"m4wrap", "m4_wrap"} = ("m4_wrap", "m4wrap");
+
+
+
## ---------- ##
@@ -409,10 +458,12 @@ sub parse_args ()
{
/^([^:]+)(?::(.*))?$/ms;
$trace{$1} = defined $2 ? $2 : '$f:$l:$n:$%';
+ $trace{$m4_builtin_alternate_name{$1}} = $trace{$1}
+ if exists $m4_builtin_alternate_name{$1};
}
# We don't want to depend upon m4's --include to find the top level
- # files. Try to get a canonical name, as it's a key for caching.
+ # files. Try to get a canonical name, as it's part of the key for caching.
for (my $i = 0; $i < $#ARGV; ++$i)
{
$ARGV[$i] = find_file ($ARGV[$i]);
@@ -420,12 +471,12 @@ sub parse_args ()
}
-# handle_m4 ($REQ, @TRACE)
+# handle_m4 ($REQ, @MACRO)
# ------------------------
-# Run m4 on the input files, and save the traces on the @TRACE macros.
+# Run m4 on the input files, and save the traces on the @MACRO.
sub handle_m4 ($@)
{
- my ($req, @trace) = @_;
+ my ($req, @macro) = @_;
# Find the files. We don't want to depend upon m4's --include.
# *.m4f files have to be reloaded.
@@ -454,7 +505,7 @@ sub handle_m4 ($@)
. " --define m4_warnings=$m4_warnings"
. ' --debug=aflq'
. " --error-output=$me.cache/" . $req->cache
- . join (' --trace=', '', @trace)
+ . join (' --trace=', '', sort @macro)
. join (' --include=', '', @include)
. $files
. " >$tmp/output");
@@ -575,30 +626,6 @@ sub handle_output ($)
## --------------------- ##
-# %REQUEST
-# trace_requests (%TRACE)
-# -----------------------
-sub trace_requests
-{
- my (%trace) = @_;
- my %res;
-
- for my $macro (keys %trace)
- {
- $res{$macro} = 1;
- $macro =~ s/^m4_//;
- # See &handle_traces for an explanation for this paragraph.
- if (grep /^$macro$/, @m4_builtins)
- {
- $res{$macro} = 1;
- $res{"m4_$macro"} = 1;
- }
- }
-
- return %res;
-}
-
-
# $M4_MACRO
# trace_format_to_m4 ($FORMAT)
# ----------------------------
@@ -682,46 +709,6 @@ sub handle_traces ($$%)
{
my ($req, $output, %trace) = @_;
- # GNU M4 1.4's tracing of builtins is buggy. When run on this input:
- #
- # | divert(-1)
- # | changequote([, ])
- # | define([m4_eval], defn([eval]))
- # | eval(1)
- # | m4_eval(2)
- # | undefine([eval])
- # | m4_eval(3)
- #
- # it behaves this way:
- #
- # | % m4 input.m4 -da -t eval
- # | m4trace: -1- eval(1)
- # | m4trace: -1- m4_eval(2)
- # | m4trace: -1- m4_eval(3)
- # | %
- #
- # Conversely:
- #
- # | % m4 input.m4 -da -t m4_eval
- # | %
- #
- # So we will merge them, i.e. tracing `BUILTIN' or tracing
- # `m4_BUILTIN' will be the same: tracing both, but honoring the
- # *last* trace specification.
- # FIXME: This is not enough: in the output `$0' will be `BUILTIN'
- # sometimes and `m4_BUILTIN' at others. We should return a unique name,
- # the one specified by the user.
- foreach my $macro (keys %trace)
- {
- my $format = $trace{$macro};
- $macro =~ s/^m4_//;
- if (grep /^$macro$/, @m4_builtins)
- {
- $trace{$macro} = $format;
- $trace{"m4_$macro"} = $format;
- }
- }
-
verbose "formatting traces for `$output': ", join (', ', sort keys %trace);
# Processing the traces.
@@ -781,11 +768,11 @@ sub handle_traces ($$%)
# the `at_' name space.
print $trace_m4 "# Copy the builtins.\n";
- map { print $trace_m4 "define([at_$_], defn([$_]))\n" } @m4_builtins;
+ map { print $trace_m4 "define([at_$_], defn([$_]))\n" } @m4_builtin;
print $trace_m4 "\n";
print $trace_m4 "# Disable them.\n";
- map { print $trace_m4 "at_undefine([$_])\n" } @m4_builtins;
+ map { print $trace_m4 "at_undefine([$_])\n" } @m4_builtin;
print $trace_m4 "\n";
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 04-cleanup-builtins-tracing.patch,
Akim Demaille <=