Skip to content

Commit

Permalink
lexers: fix perl pattern for horrible regex lines
Browse files Browse the repository at this point in the history
Under presently-not-precise circumstances, regex patterns longer
than a screenful can cause first_match_pos to be nil. In this
sutation, evaluating `first_match_pos - 1' will be an error, so
jump to matchless case.
  • Loading branch information
s-gilles authored and martanne committed Mar 24, 2017
1 parent d555c90 commit 9308e37
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/lexers/perl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ local literal_delimitted2 = P(function(input, index) -- for 2 delimiter sets
patt = l.delimited_range(delimiter)
end
first_match_pos = lpeg.match(patt, input, index)
if not first_match_pos then
return #input + 1
end
final_match_pos = lpeg.match(patt, input, first_match_pos - 1)
if not final_match_pos then -- using (), [], {}, or <> notation
final_match_pos = lpeg.match(l.space^0 * patt, input, first_match_pos)
Expand Down

0 comments on commit 9308e37

Please sign in to comment.