From: Akim Demaille Date: Wed, 1 Nov 2000 17:02:34 +0000 (+0000) Subject: GNU M4 1.4 improperly handle the traces of copies of builtins. X-Git-Tag: autoconf-2.50~492 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=701a1dde55e08adb7526135ca18cfdae41f4218c;p=thirdparty%2Fautoconf.git GNU M4 1.4 improperly handle the traces of copies of builtins. * autoconf.sh (task trace): When tracing `BUILTIN' also trace `m4_BUILTIN'. --- diff --git a/ChangeLog b/ChangeLog index 4bde3162d..c33b53b80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-11-01 Akim Demaille + + 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 Autoupdate should not depend upon foreign macros. diff --git a/TODO b/TODO index cf46994ba..416015c05 100644 --- 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 +| % ------------------------------------------------------------------------------ diff --git a/autoconf.in b/autoconf.in index dda48f9e7..b1e97b6cd 100644 --- a/autoconf.in +++ b/autoconf.in @@ -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 diff --git a/autoconf.sh b/autoconf.sh index dda48f9e7..b1e97b6cd 100644 --- a/autoconf.sh +++ b/autoconf.sh @@ -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 diff --git a/bin/autoconf.in b/bin/autoconf.in index dda48f9e7..b1e97b6cd 100644 --- a/bin/autoconf.in +++ b/bin/autoconf.in @@ -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