struils: don't use the deprecated accumulateResult

This commit is contained in:
Andreas Rumpf
2018-10-14 10:28:50 +02:00
parent 7656925140
commit 152c7d99c3

View File

@@ -495,11 +495,15 @@ iterator splitWhitespace*(s: string, maxsplit: int = -1): string =
##
oldSplit(s, Whitespace, maxsplit)
template accResult(iter: untyped) =
result = @[]
for x in iter: add(result, x)
proc splitWhitespace*(s: string, maxsplit: int = -1): seq[string] {.noSideEffect,
rtl, extern: "nsuSplitWhitespace".} =
## The same as the `splitWhitespace <#splitWhitespace.i,string,int>`_
## iterator, but is a proc that returns a sequence of substrings.
accumulateResult(splitWhitespace(s, maxsplit))
accResult(splitWhitespace(s, maxsplit))
iterator split*(s: string, sep: char, maxsplit: int = -1): string =
## Splits the string `s` into substrings using a single separator.
@@ -676,7 +680,7 @@ proc splitLines*(s: string, keepEol = false): seq[string] {.noSideEffect,
rtl, extern: "nsuSplitLines".} =
## The same as the `splitLines <#splitLines.i,string>`_ iterator, but is a
## proc that returns a sequence of substrings.
accumulateResult(splitLines(s, keepEol=keepEol))
accResult(splitLines(s, keepEol=keepEol))
proc countLines*(s: string): int {.noSideEffect,
rtl, extern: "nsuCountLines".} =
@@ -707,7 +711,7 @@ proc split*(s: string, seps: set[char] = Whitespace, maxsplit: int = -1): seq[st
runnableExamples:
doAssert "a,b;c".split({',', ';'}) == @["a", "b", "c"]
doAssert "".split({' '}) == @[""]
accumulateResult(split(s, seps, maxsplit))
accResult(split(s, seps, maxsplit))
proc split*(s: string, sep: char, maxsplit: int = -1): seq[string] {.noSideEffect,
rtl, extern: "nsuSplitChar".} =
@@ -716,7 +720,7 @@ proc split*(s: string, sep: char, maxsplit: int = -1): seq[string] {.noSideEffec
runnableExamples:
doAssert "a,b,c".split(',') == @["a", "b", "c"]
doAssert "".split(' ') == @[""]
accumulateResult(split(s, sep, maxsplit))
accResult(split(s, sep, maxsplit))
proc split*(s: string, sep: string, maxsplit: int = -1): seq[string] {.noSideEffect,
rtl, extern: "nsuSplitString".} =
@@ -733,7 +737,7 @@ proc split*(s: string, sep: string, maxsplit: int = -1): seq[string] {.noSideEff
doAssert "a largely spaced sentence".split(" ", maxsplit=1) == @["a", " largely spaced sentence"]
doAssert(sep.len > 0)
accumulateResult(split(s, sep, maxsplit))
accResult(split(s, sep, maxsplit))
proc rsplit*(s: string, seps: set[char] = Whitespace,
maxsplit: int = -1): seq[string]
@@ -755,7 +759,7 @@ proc rsplit*(s: string, seps: set[char] = Whitespace,
## .. code-block:: nim
## @["Root#Object#Method", "Index"]
##
accumulateResult(rsplit(s, seps, maxsplit))
accResult(rsplit(s, seps, maxsplit))
result.reverse()
proc rsplit*(s: string, sep: char, maxsplit: int = -1): seq[string]
@@ -777,7 +781,7 @@ proc rsplit*(s: string, sep: char, maxsplit: int = -1): seq[string]
## .. code-block:: nim
## @["Root#Object#Method", "Index"]
##
accumulateResult(rsplit(s, sep, maxsplit))
accResult(rsplit(s, sep, maxsplit))
result.reverse()
proc rsplit*(s: string, sep: string, maxsplit: int = -1): seq[string]
@@ -806,7 +810,7 @@ proc rsplit*(s: string, sep: string, maxsplit: int = -1): seq[string]
doAssert "a man a plan a canal panama".rsplit("a ") == @["", "man ", "plan ", "canal panama"]
doAssert "".rsplit("Elon Musk") == @[""]
doAssert "a largely spaced sentence".rsplit(" ") == @["a", "", "largely", "", "", "", "spaced", "sentence"]
accumulateResult(rsplit(s, sep, maxsplit))
accResult(rsplit(s, sep, maxsplit))
result.reverse()
proc toHex*(x: BiggestInt, len: Positive): string {.noSideEffect,