summary refs log tree commit diff stats
path: root/src/nre.nim
diff options
context:
space:
mode:
authorOleh Prypin <blaxpirit@gmail.com>2015-04-12 15:18:16 +0300
committerOleh Prypin <blaxpirit@gmail.com>2015-04-12 15:18:16 +0300
commit02c6e7306f5ab6454136e9cbd7a2a1187e2e2902 (patch)
tree0f221709bbd5f26ee097a7b6b0a2b5d0de5ea931 /src/nre.nim
parentec1758509ca4ef24e7470ac11e54d67f4bfcd230 (diff)
downloadNim-02c6e7306f5ab6454136e9cbd7a2a1187e2e2902.tar.gz
Fix skipping an empty match at the end
Diffstat (limited to 'src/nre.nim')
-rw-r--r--src/nre.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nre.nim b/src/nre.nim
index 76a45532b..fbfe7deb1 100644
--- a/src/nre.nim
+++ b/src/nre.nim
@@ -496,6 +496,9 @@ 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
+      if offset >= strlen:
+        break
+
       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
@@ -511,9 +514,6 @@ iterator findIter*(str: string, pattern: Regex, start = 0, endpos = int.high): R
 
       yield match.get
 
-    if offset >= strlen:
-      # do while
-      break
 
 proc find*(str: string, pattern: Regex, start = 0, endpos = int.high): Option[RegexMatch] =
   ## Finds the given pattern in the string between the end and start