From be7334acb2cf6bc9263165270b9895ff1487c65e Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Wed, 19 Mar 2003 22:24:10 +0000 Subject: * generic/tclCompile.c: * tests/compile.test: bad command count on TCL_OUT_LINE_COMPILE [Bug 705406] (Don Porter). --- ChangeLog | 6 ++++++ generic/tclCompile.c | 11 +++++++++-- tests/compile.test | 12 +++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ba6284..bc43340 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-03-19 Miguel Sofer + + * generic/tclCompile.c: + * tests/compile.test: bad command count on TCL_OUT_LINE_COMPILE + [Bug 705406] (Don Porter). + 2003-03-19 Don Porter * library/auto.tcl: Replaced [regexp] and [regsub] with diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 6812331..fb7443e 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompile.c,v 1.45 2003/03/19 16:51:42 dgp Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.46 2003/03/19 22:24:14 msofer Exp $ */ #include "tclInt.h" @@ -929,12 +929,19 @@ TclCompileScript(interp, script, numBytes, envPtr) && (cmdPtr->compileProc != NULL) && !(cmdPtr->flags & CMD_HAS_EXEC_TRACES) && !(iPtr->flags & DONT_COMPILE_CMDS_INLINE)) { + int savedNumCmds = envPtr->numCommands; + code = (*(cmdPtr->compileProc))(interp, &parse, envPtr); if (code == TCL_OK) { goto finishCommand; } else if (code == TCL_OUT_LINE_COMPILE) { - /* do nothing */ + /* + * Restore numCommands to its correct value, removing + * any commands compiled before TCL_OUT_LINE_COMPILE + * [Bug 705406] + */ + envPtr->numCommands = savedNumCmds; } else { /* an error */ /* * There was a compilation error, the last diff --git a/tests/compile.test b/tests/compile.test index 6369313..9c7347c 100644 --- a/tests/compile.test +++ b/tests/compile.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: compile.test,v 1.25 2003/03/19 16:51:43 dgp Exp $ +# RCS: @(#) $Id: compile.test,v 1.26 2003/03/19 22:24:15 msofer Exp $ package require tcltest 2 namespace import -force ::tcltest::* @@ -114,6 +114,16 @@ test compile-3.4 {TclCompileCatchCmd: bcc'ed [return] is caught} { } foo } {2} +test compile-3.5 {TclCompileCatchCmd: recover from error, [Bug 705406]} { + proc foo {} { + catch { + if {[a]} { + if b {} + } + } + } + list [catch foo msg] $msg +} {1 {invalid command name "a"}} test compile-4.1 {TclCompileForCmd: command substituted test expression} { set i 0 -- cgit v0.12