Artifacts Associated With Ticket 218370
Ticket change [1ab685968c] (rid 123027) by nobody on 2000-10-26 00:56:47:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 4233 RFE Version: 8.3 SubmitDate: '2000-02-23' LastModified: '2000-02-23' Severity: MED Status: Closed Submitter: techsupp ChangedBy: hobbs OS: All FixedDate: '2000-10-25' ClosedDate: '2000-02-23' Name: Vince Darley ReproducibleScript: This is correct: % regexp -start 1 -lineanchor {^[a-z]*} "a\naaa" found 1 % set found aaa However if we instead use '-start 2', the regexp fails: % regexp -start 2 -lineanchor {^[a-z]*} "a\naaa" found 0 even though position 2 is in fact a suitable position for ^ to match as a lineanchor. The problem is that '-start' is implemented in too simplistic a way (and we could implement a similar '-end' with similar problems with $) -- it just passes 'string range $text $start end' to the regexp code, and turns off the ability of '^' to match the beginning of string. The best solution is to add proper support for -start (and -end IMHO) to Henry Spencer's regexp code. For a general workaround, consider: given a generic $pat, and a generic $text, if we wish to know the result of: regexp -start 2 -lineanchor -- $pat $text result Then possible workarounds need to examine whether 'string index $text 1' is a newline or not. If it is not a newline, then I think everything should work ok. If it is a newline, I think the best solution is to use: 'regexp -lineanchor -- $pat [string range $text 2 end] instead'. I'm not sure whether that actually covers all possible problems... So perhaps: if {$start > 0 && [regexp {[\r\n]} [string index $text $start]]} { regexp -lineanchor -- $pat [string range $text $start end] result } else { regexp -start $start -lineanchor -- $pat $text result } Of course if we actually want '-indices' we then have to adjust the indices in the results appropriately by the offset we are using... So a general workaround is kind of a pain! Conclusion: perhaps this should be an RFE for a more complete implementation of -start (and -end). An alternative fix would be for Tcl_RegexpObjCmd to check whether the character before the -start is a newline \r\n or not, and if it _is_, then don't turn off the ability of '^' to match the beginning of the string! I assume 'regsub' suffers from similar problems. The regexp -start doesn't do an implicit string range, it uses the facilities that HS provided for just such a feature. The effect on '^' is documented, and due to limitations in the exposed interface. -- 02/23/2000 hobbs - foundin initialized to: "obsolete: 8.3"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "43. Regexp"
- title initialized to: "regexp -start, -lineanchor don't combine well"
- type initialized to: "Bug"
Ticket change [ad7fa2f06d] (rid 101475) by welch on 2000-10-26 08:20:09:
- closedate changed to: "2000-10-26T01:20:09"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"