summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2002-04-05 19:26:34 (GMT)
committerdgp <dgp@users.sourceforge.net>2002-04-05 19:26:34 (GMT)
commitb1d0f3126ec21021d3ddfe55871c4e366887e0b5 (patch)
treed3e09b315235fa448b73c898e119e8b389ae0325
parent7964355d7cac82483f0b85355050cb0d919a96fb (diff)
downloadtcl-b1d0f3126ec21021d3ddfe55871c4e366887e0b5.zip
tcl-b1d0f3126ec21021d3ddfe55871c4e366887e0b5.tar.gz
tcl-b1d0f3126ec21021d3ddfe55871c4e366887e0b5.tar.bz2
* Corrected [subst] so that return codes
TCL_BREAK and TCL_CONTINUE returned by variable substitution have the same effect as when those codes are returned by command substitution. [Bug 536879]
-rw-r--r--ChangeLog8
-rw-r--r--generic/tclCmdMZ.c12
-rw-r--r--tests/subst.test14
3 files changed, 30 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c7cc7e..2c762b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-04-05 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclCmdMZ.c (Tcl_SubstObj):
+ * tests/subst.test: Corrected [subst] so that return codes
+ TCL_BREAK and TCL_CONTINUE returned by variable substitution
+ have the same effect as when those codes are returned by command
+ substitution. [Bug 536879]
+
2002-04-03 Jeff Hobbs <jeffh@ActiveState.com>
* library/tcltest/tcltest.tcl: added getMatchingFiles back (alias
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 0721ac0..63da4d3 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.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: tclCmdMZ.c,v 1.65 2002/03/29 22:47:23 hobbs Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.66 2002/04/05 19:26:35 dgp Exp $
*/
#include "tclInt.h"
@@ -2525,10 +2525,16 @@ Tcl_SubstObj(interp, objPtr, flags)
p += parse.tokenPtr->size;
code = Tcl_EvalTokensStandard(interp, parse.tokenPtr,
parse.numTokens);
- if (code != TCL_OK) {
+ if (code == TCL_ERROR) {
goto errorResult;
}
- Tcl_AppendObjToObj(resultObj, Tcl_GetObjResult(interp));
+ if (code == TCL_BREAK) {
+ Tcl_ResetResult(interp);
+ return resultObj;
+ }
+ if (code != TCL_CONTINUE) {
+ Tcl_AppendObjToObj(resultObj, Tcl_GetObjResult(interp));
+ }
Tcl_ResetResult(interp);
old = p;
} else {
diff --git a/tests/subst.test b/tests/subst.test
index f9e3e78..179e086 100644
--- a/tests/subst.test
+++ b/tests/subst.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: subst.test,v 1.10 2002/02/25 23:17:21 msofer Exp $
+# RCS: @(#) $Id: subst.test,v 1.11 2002/04/05 19:26:35 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -150,6 +150,9 @@ test subst-8.7 {return in a subst, parse error} {
test subst-8.8 {return in a subst, parse error} {
subst {foo [return {x} ; set bar baz ; set a {}" ; stuff] bar}
} {foo xset bar baz ; set a {}" ; stuff] bar}
+test subst-8.9 {return in a variable subst} {
+ subst {foo $var([return {x}]) bar}
+} {foo x bar}
test subst-9.1 {error in a subst} {
list [catch {subst {[error foo; bogus code]bar}} msg] $msg
@@ -157,6 +160,9 @@ test subst-9.1 {error in a subst} {
test subst-9.2 {error in a subst} {
list [catch {subst {[if 1 { error foo; bogus code}]bar}} msg] $msg
} {1 foo}
+test subst-9.3 {error in a variable subst} {
+ list [catch {subst {foo $var([error foo]) bar}} msg] $msg
+} {1 foo}
test subst-10.1 {break in a subst} {
subst {foo [break; bogus code] bar}
@@ -173,6 +179,9 @@ test subst-10.4 {break in a subst, parse error} {
test subst-10.5 {break in a subst, parse error} {
subst {foo [break ;set bar baz ;set a {}{} ; stuff] bar}
} {foo }
+test subst-10.6 {break in a variable subst} {
+ subst {foo $var([break]) bar}
+} {foo }
test subst-11.1 {continue in a subst} {
subst {foo [continue; bogus code] bar}
@@ -189,6 +198,9 @@ test subst-11.4 {continue in a subst, parse error} {
test subst-11.5 {continue in a subst, parse error} {
subst {foo [continue ;set bar baz ;set a {}{} ; stuff] bar}
} {foo set bar baz ;set a {}{} ; stuff] bar}
+test subst-11.6 {continue in a variable subst} {
+ subst {foo $var([continue]) bar}
+} {foo bar}
# cleanup
::tcltest::cleanupTests