-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I introduced a latent bug in push_token in my argv_ref patch Stage 14 in
February, where I did not break the pointer from a cloned chain back into
the original chain when inlining the final element of the chain.  As long
as nothing accessed the chain until after push_string_finish, the stale
pointer was eventually corrected without anyone dereferencing it.  But
this bug then triggered a regression in Stage 23 in May, where trace was
changed to read the unfinished change, and thus the inlined link of the
chain appeared twice instead of once in trace output (the duplicate output
came from following the cloned chain back into the original chain,
followed by printing the inlined text).  Fixed as follows.  (Isn't it
strange how one line fixes the bug, and the bulk of the patch is merely
insurance that it doesn't relapse?)

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

iEYEARECAAYFAkiQaAIACgkQ84KuGfSFAYArTACghj14D95x8/JsXAxRk5o8WLdq
Jz4AnRKE3wiYEjUzLCuyp3ZVUmjqaXTV
=meMg
-----END PGP SIGNATURE-----
>From c9d53ab9bcef0cb04d59f5797e6f20159150b75d Mon Sep 17 00:00:00 2001
From: Eric Blake <[EMAIL PROTECTED]>
Date: Wed, 30 Jul 2008 07:08:29 -0600
Subject: [PATCH] Fix regression in trace output, introduced 2008-05-09.

* src/input.c (push_token): When cloning chains, break pointer
back to original chain; latent bug from 2008-02-02 that did not
cause misbehavior until trace output read unfinished chain.
* doc/m4.texinfo (Trace): Add test for this.

Signed-off-by: Eric Blake <[EMAIL PROTECTED]>
---
 ChangeLog      |    8 ++++++++
 doc/m4.texinfo |   16 ++++++++++++++++
 src/input.c    |    1 +
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 47449f2..d4f182e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-07-30  Eric Blake  <[EMAIL PROTECTED]>
+
+       Fix regression in trace output, introduced 2008-05-09.
+       * src/input.c (push_token): When cloning chains, break pointer
+       back to original chain; latent bug from 2008-02-02 that did not
+       cause misbehavior until trace output read unfinished chain.
+       * doc/m4.texinfo (Trace): Add test for this.
+
 2008-07-28  Eric Blake  <[EMAIL PROTECTED]>
 
        Optimize iteration examples.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index f8b3998..abacef9 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -3854,6 +3854,22 @@ indir(`my_defn', indir(`shift', `', `foo'))
 @result{}bar
 @end example
 
[EMAIL PROTECTED]
[EMAIL PROTECTED] not worth including in the manual, but this tests a trace code
[EMAIL PROTECTED] path that was temporarily broken
[EMAIL PROTECTED] options: -de --trace ifelse
[EMAIL PROTECTED]
+$ @kbd{m4 -de --trace ifelse}
+define(`e', `ifelse(`$1', `$2', `ifelse(`$1', `$2', `e(shift($@@))')')')
[EMAIL PROTECTED]
+e(`1', `1')
[EMAIL PROTECTED]: -1- ifelse -> ifelse(`1', `1', `e(shift(`1',`1'))')
[EMAIL PROTECTED]: -1- ifelse -> e(shift(`1',`1'))
[EMAIL PROTECTED]: -1- ifelse ->@w{ }
[EMAIL PROTECTED]
[EMAIL PROTECTED] example
[EMAIL PROTECTED] ignore
+
 @node Debug Levels
 @section Controlling debugging output
 
diff --git a/src/input.c b/src/input.c
index 18271cd..0d08215 100644
--- a/src/input.c
+++ b/src/input.c
@@ -472,6 +472,7 @@ push_token (token_data *token, int level, bool inuse)
             destructively modifies the chain it is parsing.  */
          chain = (token_chain *) obstack_copy (current_input, src_chain,
                                                sizeof *chain);
+         chain->next = NULL;
          if (chain->type == CHAIN_STR && chain->u.u_s.level == -1)
            {
              if (chain->u.u_s.len <= INPUT_INLINE_THRESHOLD || !inuse)
-- 
1.5.6.4

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches

Reply via email to