Warns to not modify string findAll is iterating over.

This commit is contained in:
Grzegorz Adam Hankiewicz
2013-07-16 02:00:25 +02:00
parent 67cea2b9b5
commit ec6e267351

View File

@@ -201,7 +201,10 @@ proc find*(s: string, pattern: TRegEx, start = 0): int =
return rawMatches[0]
iterator findAll*(s: string, pattern: TRegEx, start = 0): string =
## yields all matching *substrings* of `s` that match `pattern`.
## Yields all matching *substrings* of `s` that match `pattern`.
##
## Note that since this is an iterator you should not modify the string you
## are iterating over: bad things could happen.
var i = int32(start)
var rawMatches: array[0..maxSubpatterns * 3 - 1, cint]
while true: