summary refs log tree commit diff stats
path: root/src/nre.nim
diff options
context:
space:
mode:
authorFlaviu Tamas <tamasflaviu@gmail.com>2015-01-16 19:22:21 -0500
committerFlaviu Tamas <tamasflaviu@gmail.com>2015-01-16 19:22:21 -0500
commit01e22abb1978f51c6a7b3698b7dce3e63ec29e8a (patch)
tree3b27d02839f69fce639fb29e10cece61b3bdee14 /src/nre.nim
parent4a67b723a0f986ab35dfe884c66ff750f2138791 (diff)
downloadNim-01e22abb1978f51c6a7b3698b7dce3e63ec29e8a.tar.gz
Fix upper bound handling
Diffstat (limited to 'src/nre.nim')
-rw-r--r--src/nre.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nre.nim b/src/nre.nim
index eb0210084..f41091009 100644
--- a/src/nre.nim
+++ b/src/nre.nim
@@ -301,10 +301,12 @@ proc matchImpl(str: string, pattern: Regex, start, endpos: int, flags: int): Reg
   result.pcreMatchBounds = newSeq[Slice[cint]](ceil(vecsize / 2).int)
   result.pcreMatchBounds.setLen(vecsize div 3)
 
+  let strlen = if endpos == -1: str.len else: endpos
+
   let execRet = pcre.exec(pattern.pcreObj,
                           pattern.pcreExtra,
                           cstring(str),
-                          cint(max(str.len, endpos)),
+                          cint(strlen),
                           cint(start),
                           cint(flags),
                           cast[ptr cint](addr result.pcreMatchBounds[0]),