From 30106aca3051d80cf9ebc73f0b99cf1bc8b3a03f Mon Sep 17 00:00:00 2001 From: stanton Date: Thu, 12 Aug 1999 23:14:42 +0000 Subject: * win/Makefile.in: Added COMPILE_DEBUG_FLAGS macro to make it easier to turn on compiler tracing. * tests/parse.test: * generic/tclParse.c: Fixed bug in Tcl_EvalEx where the termOffset was not being updated in cases where the evaluation returned a non TCL_OK error code. [Bug: 2535] FossilOrigin-Name: ce8026cea8c676dfd5b6c07892241003d6efe241 --- generic/tclParse.c | 14 +++++++++++++- tests/parse.test | 23 +++++++++++++---------- win/Makefile.in | 14 +++++++++++--- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/generic/tclParse.c b/generic/tclParse.c index cef7d66..56b0a05 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclParse.c,v 1.11 1999/07/30 22:19:20 hobbs Exp $ + * RCS: @(#) $Id: tclParse.c,v 1.12 1999/08/12 23:14:42 stanton Exp $ */ #include "tclInt.h" @@ -1456,7 +1456,19 @@ Tcl_EvalEx(interp, script, numBytes, flags) Tcl_DecrRefCount(objv[i]); } if (gotParse) { + p = parse.commandStart + parse.commandSize; Tcl_FreeParse(&parse); + if ((nested != 0) && (p > script) && (p[-1] == ']')) { + /* + * We get here in the special case where the TCL_BRACKET_TERM + * flag was set in the interpreter and we reached a close + * bracket in the script. Return immediately. + */ + + iPtr->termOffset = (p - 1) - script; + } else { + iPtr->termOffset = p - script; + } } if (objv != staticObjArray) { ckfree((char *) objv); diff --git a/tests/parse.test b/tests/parse.test index 9fee75f..c8e73ab 100644 --- a/tests/parse.test +++ b/tests/parse.test @@ -8,7 +8,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: parse.test,v 1.5 1999/06/26 03:54:18 jenn Exp $ +# RCS: @(#) $Id: parse.test,v 1.6 1999/08/12 23:14:43 stanton Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -361,7 +361,7 @@ test parse-10.14 {Tcl_EvalTokens, string values} { testevalex {concat x$a.$a.$a} } {x111.111.111} -test parse-11.1 {Tcl_Eval2, TCL_EVAL_GLOBAL flag} { +test parse-11.1 {Tcl_EvalEx, TCL_EVAL_GLOBAL flag} { proc x {} { set y 777 set z [testevalex "set y" global] @@ -371,33 +371,33 @@ test parse-11.1 {Tcl_Eval2, TCL_EVAL_GLOBAL flag} { set y 321 x } {321 777} -test parse-11.2 {Tcl_Eval2, error while parsing} { +test parse-11.2 {Tcl_EvalEx, error while parsing} { list [catch {testevalex {concat "abc}} msg] $msg } {1 {missing "}} -test parse-11.3 {Tcl_Eval2, error while collecting words} { +test parse-11.3 {Tcl_EvalEx, error while collecting words} { catch {unset a} list [catch {testevalex {concat xyz $a}} msg] $msg } {1 {can't read "a": no such variable}} -test parse-11.4 {Tcl_Eval2, error in Tcl_EvalObjv call} { +test parse-11.4 {Tcl_EvalEx, error in Tcl_EvalObjv call} { catch {unset a} list [catch {testevalex {_bogus_ a b c d}} msg] $msg } {1 {invalid command name "_bogus_"}} -test parse-11.5 {Tcl_Eval2, exceptional return} { +test parse-11.5 {Tcl_EvalEx, exceptional return} { list [catch {testevalex {break}} msg] $msg } {3 {}} -test parse-11.6 {Tcl_Eval2, freeing memory} { +test parse-11.6 {Tcl_EvalEx, freeing memory} { testevalex {concat a b c d e f g h i j k l m n o p q r s t u v w x y z} } {a b c d e f g h i j k l m n o p q r s t u v w x y z} -test parse-11.7 {Tcl_Eval2, multiple commands in script} { +test parse-11.7 {Tcl_EvalEx, multiple commands in script} { list [testevalex {set a b; set c d}] $a $c } {d b d} -test parse-11.8 {Tcl_Eval2, multiple commands in script} { +test parse-11.8 {Tcl_EvalEx, multiple commands in script} { list [testevalex { set a b set c d }] $a $c } {d b d} -test parse-11.9 {Tcl_Eval2, freeing memory after error} { +test parse-11.9 {Tcl_EvalEx, freeing memory after error} { catch {unset a} list [catch {testevalex {concat a b c d e f g h i j k l m n o p q r s t u v w x y z $a}} msg] $msg } {1 {can't read "a": no such variable}} @@ -728,6 +728,9 @@ test parse-15.58 {CommandComplete procedure, memory leaks} { info complete "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22" } 1 +test parse-16.1 {Tcl_EvalEx, check termOffset is set correctly for non TCL_OK cases, bug 2535} { + subst {[eval {return foo}]bar} +} foobar # cleanup catch {unset a} diff --git a/win/Makefile.in b/win/Makefile.in index 5c59636..9ac204f 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -5,7 +5,7 @@ # "autoconf" program (constructs like "@foo@" will get replaced in the # actual Makefile. # -# RCS: @(#) $Id: Makefile.in,v 1.20 1999/08/12 20:02:51 wart Exp $ +# RCS: @(#) $Id: Makefile.in,v 1.21 1999/08/12 23:14:43 stanton Exp $ VERSION = @TCL_VERSION@ @@ -79,6 +79,12 @@ CFLAGS_WARNING = @CFLAGS_WARNING@ CFLAGS_DEBUG = @CFLAGS_DEBUG@ CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@ +# To enable compilation debugging reverse the comment characters on +# one of the following lines. +COMPILE_DEBUG_FLAGS = +#COMPILE_DEBUG_FLAGS = -DTCL_COMPILE_DEBUG +#COMPILE_DEBUG_FLAGS = -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS + # The default switches for optimization or debugging LDFLAGS_DEBUG = @LDFLAGS_DEBUG@ LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@ @@ -160,13 +166,15 @@ RM = rm -f COPY = cp CC_SWITCHES = ${CFLAGS} ${CFLAGS_WARNING} ${TCL_SHLIB_CFLAGS} \ --I"${GENERIC_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" ${AC_FLAGS} +-I"${GENERIC_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" ${AC_FLAGS} \ +${COMPILE_DEBUG_FLAGS} CC_OBJNAME = @CC_OBJNAME@ CC_EXENAME = @CC_EXENAME@ STUB_CC_SWITCHES = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \ --I"${GENERIC_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" ${AC_FLAGS} +-I"${GENERIC_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" ${AC_FLAGS} \ +${COMPILE_DEBUG_FLAGS} TCLTEST_OBJS = \ tclTest.$(OBJEXT) \ -- cgit v0.12