Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-11-20
05:13 • Closed ticket [3588366fff]: string range bug plus 8 other changes artifact: c3318af449 user: dkf
2012-11-19
04:47 • Ticket [3588366fff]: 4 changes artifact: 026e73b260 user: egavilan
04:32 • Ticket [3588366fff]: 1 change artifact: 336406e1f0 user: dgp
04:08 • Ticket [3588366fff]: 1 change artifact: 468bab3a53 user: nijtmans
04:08 • Ticket [3588366fff]: 4 changes artifact: f0d6493995 user: nijtmans
2012-11-18
20:47 • New ticket [3588366fff]. artifact: 428a8485e3 user: egavilan

string range bug

Closed / Fixed3588366fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2012-11-18 20:47:52
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
nijtmansplain2012-11-19 04:08:03
Has to do with "string range" bytecode compilation?
nijtmans Ticket [3588366fff]: 1 change [History diff]2012-11-19 04:08:04
dgp Ticket [3588366fff]: 1 change [History diff]2012-11-19 04:32:08
egavilanplain2012-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;
        }

        /*
dkfplain2012-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.
Log in (anonymous is fine) to add a comment.