Overview
| Artifact ID: | 11a1a15bb1abe2c6ebbb465a097482f4639ac0d5030cc6e14a3d164656ce124c |
|---|---|
| Ticket: | e9a2715d912d86448a2ed18b2d25788cd50769b4
Tcl 8.6.11: Incompatible Tcl_GetRange() |
| User & Date: | jan.nijtmans on 2022-03-13 01:05:59 |
Changes
- closedate changed to: "2459651.54582683"
- closer changed to: "jan.nijtmans"
- icomment:
@dgp, the defections you are mentioning are in past versions of Tcl_GetRange() right? The current implementation doesn't have those defects any more, right? What is done now is roughly: <pre> if (last < 0 || last >= length) { last = length - 1; } if (last < first) { TclNewObj(newObjPtr); return newObjPtr; } .... </pre> So, if 'last' is < 0, it will be immediately replated with length -1. If that's still negative (then length = 0, because 'first' is never negative), then last < first, so the empty string is produced: correct. Also, after this, last >= first, so last - first + 1 >= 1. This means Tcl_NewByteArrayObj() will never be called with a negative length, neither will Tcl_New(String|Unicode)Obj(). My conclusion: The current code is consistant and correct, previous versions were not. We could add some more testcases for Tcl_GetRange(), to prove everything is correct, but I would keep the code as it is now. OK? I'll close the "bug-e9a2715d91" branch, which contains the 8.6.10 code, which had the defects you mention. core-8-6-branch doesn't have those defects. Thanks! - login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"