autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] Simplify handling of autotest tracing


From: Eric Blake
Subject: Re: [PATCH v2] Simplify handling of autotest tracing
Date: Mon, 13 Jul 2009 16:47:56 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> Ouch - we lost the fact that this is known at m4 time to be safe to trace.
> It turns out that using dnl was the culprit; that meant we were comparing
> [    -1] to [-1], instead of m4 eating the leading whitespace and comparing
> [-1] to [-1].

My attempts to simply use 'autom4te --trace' to learn the above fact were 
hampered by the fact that autom4te was eating leading space.  I had made the 
following trivial patch for debugging purposes, then added --trace=my_if, but I 
still couldn't see the bug, because it was not obvious that whitespace 
differences were the culprit.

diff --git i/lib/autotest/general.m4 w/lib/autotest/general.m4
index 6032796..5f7a95d 100644
--- i/lib/autotest/general.m4
+++ w/lib/autotest/general.m4
@@ -2013,7 +2013,7 @@ m4_cond([m4_eval(m4_index([$1], [`]) >= 0)], [1],
        [m4_eval(m4_index([$1], m4_newline) >= 0)], [1],
                [[an embedded newline]],
        []))]dnl No reason.
-[m4_if(m4_index(_m4_defn([at_reason]), [a]), [0],]dnl
+[my_if(m4_index(_m4_defn([at_reason]), [a]), [0],]dnl
 dnl We know at build time that tracing COMMANDS is never safe.
 [[at_fn_check_prepare_notrace '_m4_defn([at_reason])'],
        m4_index([$1], [$]), [-1],]dnl
@@ -2022,6 +2022,7 @@ dnl We know at build time that tracing COMMANDS is always 
safe.
 dnl COMMANDS may contain parameter expansions; expand them at runtime.
 [[at_fn_check_prepare_dynamic "AS_ESCAPE([[$1]], [`\"])"])[]]dnl
 [_m4_popdef([at_reason])])
+m4_copy([m4_if],[my_if])




So, does this patch look sane, which makes the default $% mechanism of autom4te 
tracing not eat quite as much whitespace?  In my particular debugging session, 
it would have made the difference more obvious (ultimately, I found the problem 
because I tried --trace=my_if':$@' after the plain --trace=my_if didn't show 
any obvious problems, but with this patch, it would have been immediately 
obvious).  And it has the added benefit of making $% tracing faster by two 
fewer regex per traced macro.


From: Eric Blake <address@hidden>
Date: Mon, 13 Jul 2009 10:35:32 -0600
Subject: [PATCH] Don't hide leading space in autom4te --trace output.

* bin/autom4te.in (handle_traces): Don't flatten leading and
trailing space, since tracing spacing bugs can be useful.
* tests/tools.at (autom4te --trace and whitespace): New test.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog       |    5 +++++
 bin/autom4te.in |    5 +----
 tests/tools.at  |   12 ++++++++++++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f5434bd..9ea8e4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-07-13  Eric Blake  <address@hidden>

+       Don't hide leading space in autom4te --trace output.
+       * bin/autom4te.in (handle_traces): Don't flatten leading and
+       trailing space, since tracing spacing bugs can be useful.
+       * tests/tools.at (autom4te --trace and whitespace): New test.
+
        Fix previous patch.
        * lib/autotest/general.m4 (at_fn_check_prepare_notrace): Use
        proper m4 quoting.
diff --git a/bin/autom4te.in b/bin/autom4te.in
index cf425bb..33acb03 100644
--- a/bin/autom4te.in
+++ b/bin/autom4te.in
@@ -750,10 +750,7 @@ sub handle_traces ($$%)
   # Note that the second pattern is `newline, tab or space'.  Don't lose
   # the tab!
   define([at_flatten],
-  [at_patsubst(at_patsubst(at_patsubst(at_patsubst([[[[$1]]]], [\\\n]),
-                                      [[\n\t ]+], [ ]),
-                          [ *\(.\)$], [\1]),
-              [^ *\(.*\)], [[\1]])])
+  [at_patsubst(at_patsubst([[[$1]]], [\\\n]), [[\n\t ]+], [ ])])

   define([at_args],    [at_shift(at_shift(at_shift(at_shift(at_shift($@)))))])
   define([at_at],      [_$0([$1], at_args($@))])
diff --git a/tests/tools.at b/tests/tools.at
index c4016cc..89028bd 100644
--- a/tests/tools.at
+++ b/tests/tools.at
@@ -226,6 +226,18 @@ AT_CHECK_AUTOM4TE([-t 'TR A CE' -t 'TR(A)CE' file.m4])
 AT_CLEANUP


+AT_SETUP([autom4te --trace and whitespace])
+
+AT_DATA([file.m4],
+[[m4@&address@hidden([  a  b  ], [c])
+]])
+AT_CHECK_AUTOM4TE([--language=m4sugar -t 'm4@&address@hidden' file.m4], [0],
+[[file.m4:1:m4@&address@hidden: a b :c
+]])
+
+AT_CLEANUP
+
+
 ## ------------------ ##
 ## autoconf --trace.  ##
 ## ------------------ ##
-- 
1.6.3.2







reply via email to

[Prev in Thread] Current Thread [Next in Thread]