I cleaned up one regression of traced-but-undefined macros on 2008-08-21, but missed the fact that I introduced another one when adding the ability to warn on popping undefined macros. Only branch-1.6 has the bug, but I'm also porting the testsuite improvement to master.
From: Eric Blake <[email protected]> Date: Wed, 11 Feb 2009 08:49:43 -0700 Subject: [PATCH] Warn when popping traced but undefined macro. * src/symtab.c (lookup_symbol): Recognize traced placeholder when delete is requested. Bug introduced 2008-07-18. * doc/m4.texinfo (Trace): Test it. Signed-off-by: Eric Blake <[email protected]> --- ChangeLog | 7 +++++++ doc/m4.texinfo | 12 +++++++++++- src/symtab.c | 8 +++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b96dccc..2aa09b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-02-11 Eric Blake <[email protected]> + + Warn when popping traced but undefined macro. + * src/symtab.c (lookup_symbol): Recognize traced placeholder when + delete is requested. Bug introduced 2008-07-18. + * doc/m4.texinfo (Trace): Test it. + 2009-02-09 Eric Blake <[email protected]> Enhance index to support starting offset. diff --git a/doc/m4.texinfo b/doc/m4.texinfo index 8341cc9..b337e5e 100644 --- a/doc/m4.texinfo +++ b/doc/m4.texinfo @@ -4134,6 +4134,16 @@ Trace defn(`foo') @error{}m4:stdin:4: Warning: defn: undefined macro `foo' @result{} +undefine(`foo') +...@error{}m4:stdin:5: Warning: undefine: undefined macro `foo' +...@result{} +pushdef(`foo') +...@result{} +popdef(`foo') +...@result{} +popdef(`foo') +...@error{}m4:stdin:8: Warning: popdef: undefined macro `foo' +...@result{} define(`foo', `bar') @result{} foo @@ -4144,7 +4154,7 @@ Trace ifdef(`foo', `yes', `no') @result{}no indir(`foo') -...@error{}m4:stdin:9: Warning: indir: undefined macro `foo' +...@error{}m4:stdin:13: Warning: indir: undefined macro `foo' @result{} define(`foo', `blah') @result{} diff --git a/src/symtab.c b/src/symtab.c index a9160c8..6631e9c 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -1,7 +1,7 @@ /* GNU m4 -- A simple macro processor - Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2003, 2006, 2007, 2008 - Free Software Foundation, Inc. + Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2003, 2006, 2007, + 2008, 2009 Free Software Foundation, Inc. This file is part of GNU M4. @@ -333,7 +333,9 @@ lookup_symbol (const char *name, size_t len, symbol_lookup mode) definition is still in use, let the caller free the memory after it is done with the symbol. */ - if (!entry) + if (!entry + || (SYMBOL_TYPE (entry) == TOKEN_VOID && entry->stack == entry + && SYMBOL_TRACED (entry))) return NULL; { bool traced = false; -- 1.6.1.2 _______________________________________________ M4-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-patches
