From 16577f816749859f8d169ffbdd4415ca4747e75a Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Fri, 10 Apr 2015 11:20:05 +0300 Subject: Fix zero-length matches for multibyte characters --- src/nre.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nre.nim') diff --git a/src/nre.nim b/src/nre.nim index f9c6b3509..b601d8222 100644 --- a/src/nre.nim +++ b/src/nre.nim @@ -352,16 +352,16 @@ iterator findIter*(str: string, pattern: Regex, start = 0, endpos = int.high): R if match.isNone: # either the end of the input or the string # cannot be split here - offset += 1 - if matchesCrLf and offset < (str.len - 1) and str[offset] == '\r' and str[offset + 1] == '\l': # if PCRE treats CrLf as newline, skip both at the same time - offset += 1 + offset += 2 elif unicode: # XXX what about invalid unicode? offset += str.runeLenAt(offset) assert(offset <= strlen) + else: + offset += 1 else: offset = match.get.matchBounds.b + 1 -- cgit 1.4.1-2-gfad0