| Ticket UUID: | 3588366 | ||
| Title: | string range bug | ||
| Type: | Bug | Created on: | 2012-11-18 20:47:52 |
| Submitter: | egavilan | Assigned to: | dkf |
| Subsystem: | 47. Bytecode Compiler | Severity: | |
| Priority: | 9 Immediate | Last modified: | 2012-11-20 05:13:58 |
| Status: | Closed | Closed by: | dkf |
| Resolution: | Fixed | Closed on: | 2012-11-19 22:13:58 |
| Version: | current: 8.6.0 | ||
| Description: | ||||
In trunk: % string range .sbar 0 end-5 . % It should have been the empty string according to docs. The bug was introduced in fossil check-in 8e20d1a93ffebebf7e904c556944868a6ea692b7 | ||||
| User Comments: | ||||
nijtmans added on 2012-11-19 04:08:03:
Has to do with "string range" bytecode compilation? egavilan added on 2012-11-19 04:47:20:
Yes. The compiled path has a bug. I've tracked it down to generic/tclExecute.c, line 4865.
The following patch fixes the issue:
Index: generic/tclExecute.c
==================================================================
--- generic/tclExecute.c
+++ generic/tclExecute.c
@@ -4960,13 +4960,10 @@
} else if (fromIdx >= length) {
fromIdx = length;
}
if (toIdx < -1) {
toIdx += 1 + length;
- if (toIdx < 0) {
- toIdx = 0;
- }
} else if (toIdx >= length) {
toIdx = length - 1;
}
/*
dkf added on 2012-11-20 05:13:58:
allow_comments - 1 Problem was due to me getting the end-relative arithmetic wrong (it's almost but not quite simple, and it's almost but not quite the same in [lrange]). Added tests and fixed things (your patch is the right thing). Thanks. | ||||
