diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-05-17 16:40:38 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-05-17 16:40:38 (GMT) |
commit | f49f0d4398778f7334a25d9a419ebb1730eae6d4 (patch) | |
tree | 9189e098fb6bd51d8f37b37a01587f65375cd5b6 /generic | |
parent | f7c1d07e01e7d6675e75750276d7ef664ad68e70 (diff) | |
download | tcl-f49f0d4398778f7334a25d9a419ebb1730eae6d4.zip tcl-f49f0d4398778f7334a25d9a419ebb1730eae6d4.tar.gz tcl-f49f0d4398778f7334a25d9a419ebb1730eae6d4.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')
-rw-r--r-- | generic/tclCmdMZ.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 531e2b1..0ad77aa 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -3679,8 +3679,12 @@ Tcl_SwitchObjCmd( 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. |