Skip to content

Commit 153bf4f

Browse files
committed
fix findAll
1 parent 51e044b commit 153bf4f

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

nregex.nimble

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Package
22

3-
version = "0.0.3"
3+
version = "0.0.4"
44
author = "Esteban Castro Borsani (@nitely)"
55
description = "A DFA based regex engine"
66
license = "MIT"
77
srcDir = "src"
8-
skipDirs = @["tests"]
8+
skipDirs = @["tests", "docs"]
99

1010
requires "nim >= 1.0.4"
1111
requires "unicodedb >= 0.7.2"
@@ -15,9 +15,8 @@ task test, "Test":
1515
exec "nim c -r -o:bin/nregex src/nregex.nim"
1616
exec "nim c -r tests/tests.nim"
1717
exec "nim c -r -d:forceRegexAtRuntime tests/tests.nim"
18-
# VM register limit error, works on devel,
19-
# well almost due to https://github.com/nim-lang/Nim/issues/13310
20-
#exec "nim c -d:runTestAtCT tests/tests.nim"
18+
#when (NimMajor, NimMinor) >= (1, 1):
19+
# exec "nim c -d:runTestAtCT --maxLoopIterationsVM:1000000000 tests/tests.nim"
2120
exec "nim js -r -o:bin/nregex.js --styleCheck:off src/nregex.nim"
2221
exec "nim js -r --styleCheck:off tests/tests.nim"
2322
exec "nim js -r --styleCheck:off -d:forceRegexAtRuntime tests/tests.nim"

src/nregex.nim

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,13 @@ iterator findAll*(
409409
var c: Rune
410410
var m: RegexMatch
411411
while i < len(s):
412-
if find(s, pattern, m, i):
413-
if i < m.boundaries.b+1:
414-
i = m.boundaries.b+1
415-
else:
416-
fastRuneAt(s, i, c, true)
417-
yield m
418-
else:
412+
if not find(s, pattern, m, i):
413+
break
414+
if i < m.boundaries.b+1:
415+
i = m.boundaries.b+1
416+
else: # empty match
419417
fastRuneAt(s, i, c, true)
418+
yield m
420419

421420
func findAll*(
422421
s: string,

src/nregex/private/nodematch.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func isAnyAscii(r: Rune): bool {.inline.} =
105105
(r.int <= int8.high and
106106
r != lineBreakRune)
107107

108-
func swapCase(r: Rune): Rune =
108+
func swapCase*(r: Rune): Rune =
109109
result = r.toLower()
110110
if result != r:
111111
return

0 commit comments

Comments
 (0)