diff options
author | rumpf_a@web.de <> | 2009-10-27 22:28:02 +0100 |
---|---|---|
committer | rumpf_a@web.de <> | 2009-10-27 22:28:02 +0100 |
commit | d5acb88cccecf54bcc9a7c13f4fbaa095a8b37d4 (patch) | |
tree | da88c98e8bd063f7991d2e2cba5797351d301eba /lib/pure/strutils.nim | |
parent | 053309e60aee1eda594a4817ac8ac2fb8c18fb04 (diff) | |
download | Nim-d5acb88cccecf54bcc9a7c13f4fbaa095a8b37d4.tar.gz |
bugfixes: macros; splitFile; strutils.split; iterator.method
Diffstat (limited to 'lib/pure/strutils.nim')
-rwxr-xr-x | lib/pure/strutils.nim | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 25b495f10..d17c48740 100755 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -169,15 +169,14 @@ iterator split*(s: string, seps: set[char] = Whitespace): string = ## writeln(stdout, word) ## ## produces the same output. - var - first: int = 0 - last: int = 0 + var last = 0 assert(not ('\0' in seps)) while last < len(s): while s[last] in seps: inc(last) - first = last + var first = last while last < len(s) and s[last] not_in seps: inc(last) # BUGFIX! - yield copy(s, first, last-1) + if first <= last-1: + yield copy(s, first, last-1) iterator split*(s: string, sep: char): string = ## Splits the string `s` into substrings. |