Skip to content
Tcl Source Code History Of Ticket 218370
Login

History Of Ticket 218370

Artifacts Associated With Ticket 218370

  1. Ticket change [1ab685968c] (rid 123027) by nobody on 2000-10-26 00:56:47:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. 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
      
    4. foundin initialized to: "obsolete: 8.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "43. Regexp"
    10. title initialized to: "regexp -start, -lineanchor don't combine well"
    11. type initialized to: "Bug"
  2. Ticket change [ad7fa2f06d] (rid 101475) by welch on 2000-10-26 08:20:09:

    1. closedate changed to: "2000-10-26T01:20:09"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"