summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdMZ.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-05-17 16:43:39 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-05-17 16:43:39 (GMT)
commit3b49a014f14205d8e72cf0e346a6ede46ef6b426 (patch)
tree2bf3254513bc97e0c00830ddcb14b4f28a659ddc /generic/tclCmdMZ.c
parent1e55ed351f4f2db6a9c633227fd691df7eb7b347 (diff)
parent70e6283bef9733ca12935627fda82f732e5cabd9 (diff)
downloadtcl-3b49a014f14205d8e72cf0e346a6ede46ef6b426.zip
tcl-3b49a014f14205d8e72cf0e346a6ede46ef6b426.tar.gz
tcl-3b49a014f14205d8e72cf0e346a6ede46ef6b426.tar.bz2
* generic/tclCmdMZ.c (Tcl_SwitchObjCmd): [Bug 3106532]: Corrected
resulting indexes from -indexvar option to be usable with [string range]; this was always the intention (and is consistent with [regexp -indices] too). ***POTENTIAL INCOMPATIBILITY*** Uses of [switch -regexp -indexvar] that previously compensated for the wrong offsets (by subtracting 1 from the end indices) now do not need to do so as the value is correct.
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r--generic/tclCmdMZ.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index c5bb72d..7e94d9f 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -3758,8 +3758,12 @@ TclNRSwitchObjCmd(
if (indexVarObj != NULL) {
Tcl_Obj *rangeObjAry[2];
- rangeObjAry[0] = Tcl_NewLongObj(info.matches[j].start);
- rangeObjAry[1] = Tcl_NewLongObj(info.matches[j].end);
+ if (info.matches[j].end > 0) {
+ rangeObjAry[0] = Tcl_NewLongObj(info.matches[j].start);
+ rangeObjAry[1] = Tcl_NewLongObj(info.matches[j].end-1);
+ } else {
+ rangeObjAry[0] = rangeObjAry[1] = Tcl_NewIntObj(-1);
+ }
/*
* Never fails; the object is always clean at this point.