From 755d89e32d39eb08e85a98b421909a7535051c3c Mon Sep 17 00:00:00 2001 From: Magnus Jöud Date: Wed, 14 Oct 2015 15:29:27 +0200 Subject: modified strutils.split --- lib/pure/strutils.nim | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 516ca953b..6eb87d91b 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -374,10 +374,9 @@ iterator split*(s: string, seps: set[char] = Whitespace, maxsplit: int = -1): st var first = last while last < len(s) and s[last] notin seps: inc(last) # BUGFIX! if first <= last-1: - if splits == 0: - yield substr(s, first, len(s)-1) - break + if splits == 0: last = len(s) yield substr(s, first, last-1) + if splits == 0: break dec(splits) iterator split*(s: string, sep: char, maxsplit: int = -1): string = @@ -414,10 +413,9 @@ iterator split*(s: string, sep: char, maxsplit: int = -1): string = while last <= len(s): var first = last while last < len(s) and s[last] != sep: inc(last) - if splits == 0: - yield substr(s, first, len(s)-1) - break + if splits == 0: last = len(s) yield substr(s, first, last-1) + if splits == 0: break dec(splits) inc(last) @@ -432,10 +430,9 @@ iterator split*(s: string, sep: string, maxsplit: int = -1): string = var first = last while last < len(s) and s.substr(last, last +