summary refs log tree commit diff stats
path: root/src/nre.nim
diff options
context:
space:
mode:
authorFlaviu Tamas <tamasflaviu@gmail.com>2015-04-11 11:15:51 -0400
committerFlaviu Tamas <tamasflaviu@gmail.com>2015-04-11 11:15:51 -0400
commit4ce267c08dd8287668b99d546b3679a9b1347d43 (patch)
tree908228d346bc29720a2c91a11db5aba815f94242 /src/nre.nim
parentbc27d06e394d19661508da260bf5a10bd5eb11bc (diff)
downloadNim-4ce267c08dd8287668b99d546b3679a9b1347d43.tar.gz
Fix getinfo overflows
Diffstat (limited to 'src/nre.nim')
-rw-r--r--src/nre.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/nre.nim b/src/nre.nim
index cf99c8d5d..3ff4bade2 100644
--- a/src/nre.nim
+++ b/src/nre.nim
@@ -189,17 +189,17 @@ proc getinfo[T](pattern: Regex, opt: cint): T =
 
 # Regex accessors {{{
 proc captureCount*(pattern: Regex): int =
-  return getinfo[int](pattern, pcre.INFO_CAPTURECOUNT)
+  return getinfo[cint](pattern, pcre.INFO_CAPTURECOUNT)
 
 proc captureNameId*(pattern: Regex): Table[string, int] =
   return pattern.captureNameToId
 
 proc matchesCrLf(pattern: Regex): bool =
-  let flags = getinfo[cint](pattern, pcre.INFO_OPTIONS)
+  let flags = uint32(getinfo[culong](pattern, pcre.INFO_OPTIONS))
   let newlineFlags = flags and (pcre.NEWLINE_CRLF or
                                 pcre.NEWLINE_ANY or
                                 pcre.NEWLINE_ANYCRLF)
-  if newLineFlags > 0:
+  if newLineFlags > 0u32:
     return true
 
   # get flags from build config
@@ -464,7 +464,8 @@ iterator findIter*(str: string, pattern: Regex, start = 0, endpos = int.high): R
   ## -  ``proc findAll(...)`` returns a ``seq[string]``
   # see pcredemo for explaination
   let matchesCrLf = pattern.matchesCrLf()
-  let unicode = (getinfo[cint](pattern, pcre.INFO_OPTIONS) and pcre.UTF8) > 0
+  let unicode = uint32(getinfo[culong](pattern, pcre.INFO_OPTIONS) and
+    pcre.UTF8) > 0u32
   let strlen = if endpos == int.high: str.len else: endpos+1
 
   var offset = start