Skip to content

Commit

Permalink
fix findAll
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed Apr 3, 2020
1 parent 51e044b commit 153bf4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
9 changes: 4 additions & 5 deletions nregex.nimble
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Package

version = "0.0.3"
version = "0.0.4"
author = "Esteban Castro Borsani (@nitely)"
description = "A DFA based regex engine"
license = "MIT"
srcDir = "src"
skipDirs = @["tests"]
skipDirs = @["tests", "docs"]

requires "nim >= 1.0.4"
requires "unicodedb >= 0.7.2"
Expand All @@ -15,9 +15,8 @@ task test, "Test":
exec "nim c -r -o:bin/nregex src/nregex.nim"
exec "nim c -r tests/tests.nim"
exec "nim c -r -d:forceRegexAtRuntime tests/tests.nim"
# VM register limit error, works on devel,
# well almost due to https://github.com/nim-lang/Nim/issues/13310
#exec "nim c -d:runTestAtCT tests/tests.nim"
#when (NimMajor, NimMinor) >= (1, 1):
# exec "nim c -d:runTestAtCT --maxLoopIterationsVM:1000000000 tests/tests.nim"
exec "nim js -r -o:bin/nregex.js --styleCheck:off src/nregex.nim"
exec "nim js -r --styleCheck:off tests/tests.nim"
exec "nim js -r --styleCheck:off -d:forceRegexAtRuntime tests/tests.nim"
Expand Down
13 changes: 6 additions & 7 deletions src/nregex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,13 @@ iterator findAll*(
var c: Rune
var m: RegexMatch
while i < len(s):
if find(s, pattern, m, i):
if i < m.boundaries.b+1:
i = m.boundaries.b+1
else:
fastRuneAt(s, i, c, true)
yield m
else:
if not find(s, pattern, m, i):
break
if i < m.boundaries.b+1:
i = m.boundaries.b+1
else: # empty match
fastRuneAt(s, i, c, true)
yield m

func findAll*(
s: string,
Expand Down
2 changes: 1 addition & 1 deletion src/nregex/private/nodematch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func isAnyAscii(r: Rune): bool {.inline.} =
(r.int <= int8.high and
r != lineBreakRune)

func swapCase(r: Rune): Rune =
func swapCase*(r: Rune): Rune =
result = r.toLower()
if result != r:
return
Expand Down

0 comments on commit 153bf4f

Please sign in to comment.