• marja's avatar
    RegExpParser: Fix Reset()ting to the end. · 978f41a1
    marja authored
    The bug would occur when we try to Reset() to a position already at the end.
    
    This happens e.g., when the regexp ends with \u. What used to happen in that
    case: 1) Advance past \ and u (to the end) (which wouldn't increase next_pos_
    enough) 2) Try to parse 4 hex digits 3) When that failed, Reset() to the
    position which should've been at the end but wasn't.
    
    To be able to properly Reset() to a position at the end, we need to allow
    next_pos_ to move beyond the end (since position() is next_pos_ - 1).
    
    Minimal repro case:
    
    var r = /foo\u/
    r.test("foou") // should be true, was false.
    
    (Note that \u not followed by 4 hex didits should be interpreted as an identity
    escape. It already worked unless \u was at the end of the regexp.)
    
    BUG=v8:3756
    LOG=NO
    
    Review URL: https://codereview.chromium.org/802313003
    
    Cr-Commit-Position: refs/heads/master@{#25838}
    978f41a1