diff options
author | Andreas Rumpf <andreas@andreas-desktop> | 2010-03-20 11:00:30 +0100 |
---|---|---|
committer | Andreas Rumpf <andreas@andreas-desktop> | 2010-03-20 11:00:30 +0100 |
commit | 7d6de1cf90858700733091b9a592b2fac7549af5 (patch) | |
tree | 167b22158117fd736deeeb0584884c4b5a059a40 /lib/pure/strutils.nim | |
parent | c5d8a5c1da9618d65ff08cb0ab6b084e07493b49 (diff) | |
download | Nim-7d6de1cf90858700733091b9a592b2fac7549af5.tar.gz |
Bugfix: strutils.delete
Diffstat (limited to 'lib/pure/strutils.nim')
-rwxr-xr-x | lib/pure/strutils.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 301f82c1f..6854999e3 100755 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -655,13 +655,13 @@ proc delete*(s: var string, first, last: int) = ## Deletes in `s` the characters at position `first`..`last`. This modifies ## `s` itself, it does not return a copy. var i = first - # example: "abc___uvwxyz\0" (___ is to be deleted) - # --> first == 3, last == 5 - # s[first..] = s[last+1..] - while last+i+1 < len(s): - s[i] = s[last+i+1] + var j = last+1 + var newLen = len(s)-j+i + while i < newLen: + s[i] = s[j] inc(i) - setlen(s, len(s)-(last-first+1)) + inc(j) + setlen(s, newLen) proc replaceStr(s, sub, by: string): string = return replace(s, sub, by) proc replaceStr(s: string, sub, by: char): string = return replace(s, sub, by) |