[string first] cannot assume that Unicode = non-ASCII
Closed / Fixed0d902eadd659898069ee5f2fb1c4d0764fdfe57aCreated 9 years agoUpdated 9 years ago
Descriptionhtml2017-11-04 00:41:45
The following code:
set s hello; regexp ll $s m; string first $m $shas a result of -1, which is very surprising. The problem is that regexp uses Tcl_GetRange() on objects with a unicode representation (which regexp needs for its own purposes) and that decides that the best thing is to create a pure unicode object, even though the string is within the ASCII range. Normally that wouldn't matter, but string first (properly TclStringFind()) assumes that that's an impossible situation and jumps merrily to saying that things can't match when that's totally untrue.
This was discovered by Pat Thoyts, and narrowed down to changes in the dgp-string-find branch.
Referenced by2
9d3eb006b3[0d902eadd6] Ensure that [string first] handles ASCII in Unicode correctly. check-in2017-11-04 00:45:275bc169fef7[0d902eadd6] Ensure that [string first] handles ASCII in Unicode correctly. check-in2017-11-04 00:44:14
dkf Closed ticket [0d902eadd6].
[History diff]2017-11-04 00:44:35
dgpplain2018-02-01 14:30:32
The same broken assumption is used in TclStringLast(). % set s hello; regexp ll $s m; string last $m $s -1
dgp Open ticket [0d902eadd6].
[History diff]2018-02-01 14:38:59
dgp Closed ticket [0d902eadd6].
[History diff]2018-02-06 19:44:35
Log in (anonymous is fine) to add a comment.