]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
GNU M4 1.4 improperly handle the traces of copies of builtins.
authorAkim Demaille <akim@epita.fr>
Wed, 1 Nov 2000 17:02:34 +0000 (17:02 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 1 Nov 2000 17:02:34 +0000 (17:02 +0000)
* autoconf.sh (task trace): When tracing `BUILTIN' also trace
`m4_BUILTIN'.

ChangeLog
TODO
autoconf.in
autoconf.sh
bin/autoconf.in

index 4bde3162daadf1d3695225237f4386b86eee9abe..c33b53b80de21c9d3fd73cb3ea444b9b2b10150e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-11-01  Akim Demaille  <akim@epita.fr>
+
+       GNU M4 1.4 improperly handle the traces of copies of builtins.
+
+       * autoconf.sh (task trace): When tracing `BUILTIN' also trace
+       `m4_BUILTIN'.
+
 2000-11-01  Akim Demaille  <akim@epita.fr>
 
        Autoupdate should not depend upon foreign macros.
diff --git a/TODO b/TODO
index cf46994ba4428a0bee6dabfd688c293d2f562b86..416015c05e53650cd834e5ba4d427282e47587b6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -131,13 +131,36 @@ error.m4, obstack.m4, ptrdiff.m4, strtod.m4, termios.m4, winsz.m4.
 
 * m4
 
-** m4
+** I18n
 The error messages for indir and dumpdef are uselessly different.  Fix
 this for translators.
 
-** m4
+** Tracing `builtin'
 F**k!  --trace FOO does not catch indir([FOO], $@)!
 
+** Tracing builtins
+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
+| %
 
 ------------------------------------------------------------------------------
 
index dda48f9e71180d841580f13f5e6bba36a078f527..b1e97b6cd5e11fe5b60470cec88068cbb9ed7655 100644 (file)
@@ -561,15 +561,63 @@ EOF
     close("cat >&2")
   }
 EOF
+
+
   # Extract both the m4 program and the m4 options from TRACES.
   eval set dummy "$traces"
   shift
   for trace
   do
     # The request may be several lines long, hence sed has to quit.
-    trace_opt="$trace_opt -t "`echo "$trace" | sed -e 's/:.*//;q'`
-    echo "$trace" | $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
-      { (exit 1); exit; }
+    macro_name=`echo "$trace" | sed 's/:.*//;q'`
+    trace_format=`echo "$trace" | sed '1s/^[^:]*://'`
+
+    # 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 render a unique name,
+    # the one specified by the user.
+    base_name=`echo "$macro_name" | sed 's/^m4_//'`
+    if echo "ifdef(\`$base_name', \`', \`m4exit(-1)')" | m4; then
+      # BASE_NAME is a builtin.
+      trace_opt="$trace_opt -t $base_name -t m4_$base_name"
+      echo "$base_name:$trace_format" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+      echo "m4_$base_name:$trace_format" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+    else
+      # MACRO_NAME is not a builtin.
+      trace_opt="$trace_opt -t $macro_name"
+      echo "$trace" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+    fi
   done
   echo "divert(0)dnl" >>$tmp/trace.m4
 
index dda48f9e71180d841580f13f5e6bba36a078f527..b1e97b6cd5e11fe5b60470cec88068cbb9ed7655 100644 (file)
@@ -561,15 +561,63 @@ EOF
     close("cat >&2")
   }
 EOF
+
+
   # Extract both the m4 program and the m4 options from TRACES.
   eval set dummy "$traces"
   shift
   for trace
   do
     # The request may be several lines long, hence sed has to quit.
-    trace_opt="$trace_opt -t "`echo "$trace" | sed -e 's/:.*//;q'`
-    echo "$trace" | $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
-      { (exit 1); exit; }
+    macro_name=`echo "$trace" | sed 's/:.*//;q'`
+    trace_format=`echo "$trace" | sed '1s/^[^:]*://'`
+
+    # 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 render a unique name,
+    # the one specified by the user.
+    base_name=`echo "$macro_name" | sed 's/^m4_//'`
+    if echo "ifdef(\`$base_name', \`', \`m4exit(-1)')" | m4; then
+      # BASE_NAME is a builtin.
+      trace_opt="$trace_opt -t $base_name -t m4_$base_name"
+      echo "$base_name:$trace_format" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+      echo "m4_$base_name:$trace_format" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+    else
+      # MACRO_NAME is not a builtin.
+      trace_opt="$trace_opt -t $macro_name"
+      echo "$trace" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+    fi
   done
   echo "divert(0)dnl" >>$tmp/trace.m4
 
index dda48f9e71180d841580f13f5e6bba36a078f527..b1e97b6cd5e11fe5b60470cec88068cbb9ed7655 100644 (file)
@@ -561,15 +561,63 @@ EOF
     close("cat >&2")
   }
 EOF
+
+
   # Extract both the m4 program and the m4 options from TRACES.
   eval set dummy "$traces"
   shift
   for trace
   do
     # The request may be several lines long, hence sed has to quit.
-    trace_opt="$trace_opt -t "`echo "$trace" | sed -e 's/:.*//;q'`
-    echo "$trace" | $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
-      { (exit 1); exit; }
+    macro_name=`echo "$trace" | sed 's/:.*//;q'`
+    trace_format=`echo "$trace" | sed '1s/^[^:]*://'`
+
+    # 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 render a unique name,
+    # the one specified by the user.
+    base_name=`echo "$macro_name" | sed 's/^m4_//'`
+    if echo "ifdef(\`$base_name', \`', \`m4exit(-1)')" | m4; then
+      # BASE_NAME is a builtin.
+      trace_opt="$trace_opt -t $base_name -t m4_$base_name"
+      echo "$base_name:$trace_format" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+      echo "m4_$base_name:$trace_format" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+    else
+      # MACRO_NAME is not a builtin.
+      trace_opt="$trace_opt -t $macro_name"
+      echo "$trace" |
+        $AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
+          { (exit 1); exit; }
+    fi
   done
   echo "divert(0)dnl" >>$tmp/trace.m4