bugfixes: macros; splitFile; strutils.split; iterator.method

This commit is contained in:
rumpf_a@web.de 2009-10-27 22:28:02 +01:00
commit d5acb88ccc
31 changed files with 177 additions and 95 deletions

View file

@ -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.