Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Mar 31, 2021
2 parents ac5ea32 + 78423db commit b89ebdc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/impure/re.nim
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,20 @@ proc findBounds*(buf: cstring, pattern: Regex,
var
rtarray = initRtArray[cint](3)
rawMatches = rtarray.getRawData
res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, 0'i32,
res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, flags,
cast[ptr cint](rawMatches), 3)
if res < 0'i32: return (-1, 0)
return (int(rawMatches[0]), int(rawMatches[1]-1))

proc findBounds*(s: string, pattern: Regex,
start = 0): tuple[first, last: int] {.inline.} =
start = 0, flags = int32(0)): tuple[first, last: int] {.inline.} =
## returns the `first` and `last` position of `pattern` in `s`.
## If it does not match, `(-1,0)` is returned.
##
## Note: there is a speed improvement if the matches do not need to be captured.
runnableExamples:
assert findBounds("01234abc89", re"abc") == (5,7)
result = findBounds(cstring(s), pattern, start, s.len)
result = findBounds(cstring(s), pattern, start, s.len, flags)

proc matchOrFind(buf: cstring, pattern: Regex, start, bufSize: int, flags: cint): cint =
var
Expand Down

0 comments on commit b89ebdc

Please sign in to comment.