deprecated system.copy: use system.substr instead
This commit is contained in:
parent
32241aa9fe
commit
3e9dcc8be5
31 changed files with 122 additions and 109 deletions
|
|
@ -736,7 +736,7 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {.
|
|||
var (a, b) = c.matches[p.index]
|
||||
var n: TPeg
|
||||
n.kind = succ(pkTerminal, ord(p.kind)-ord(pkBackRef))
|
||||
n.term = s.copy(a, b)
|
||||
n.term = s.substr(a, b)
|
||||
result = rawMatch(s, n, start, c)
|
||||
of pkStartAnchor:
|
||||
if c.origStart == start: result = 0
|
||||
|
|
@ -754,7 +754,7 @@ proc match*(s: string, pattern: TPeg, matches: var openarray[string],
|
|||
result = rawMatch(s, pattern, start, c) == len(s) - start
|
||||
if result:
|
||||
for i in 0..c.ml-1:
|
||||
matches[i] = copy(s, c.matches[i][0], c.matches[i][1])
|
||||
matches[i] = substr(s, c.matches[i][0], c.matches[i][1])
|
||||
|
||||
proc match*(s: string, pattern: TPeg,
|
||||
start = 0): bool {.nosideEffect, rtl, extern: "npegs$1".} =
|
||||
|
|
@ -774,7 +774,7 @@ proc matchLen*(s: string, pattern: TPeg, matches: var openarray[string],
|
|||
result = rawMatch(s, pattern, start, c)
|
||||
if result >= 0:
|
||||
for i in 0..c.ml-1:
|
||||
matches[i] = copy(s, c.matches[i][0], c.matches[i][1])
|
||||
matches[i] = substr(s, c.matches[i][0], c.matches[i][1])
|
||||
|
||||
proc matchLen*(s: string, pattern: TPeg,
|
||||
start = 0): int {.nosideEffect, rtl, extern: "npegs$1".} =
|
||||
|
|
@ -903,7 +903,7 @@ proc replacef*(s: string, sub: TPeg, by: string): string {.
|
|||
else:
|
||||
addf(result, by, caps)
|
||||
inc(i, x)
|
||||
add(result, copy(s, i))
|
||||
add(result, substr(s, i))
|
||||
|
||||
proc replace*(s: string, sub: TPeg, by = ""): string {.
|
||||
nosideEffect, rtl, extern: "npegs$1".} =
|
||||
|
|
@ -920,7 +920,7 @@ proc replace*(s: string, sub: TPeg, by = ""): string {.
|
|||
else:
|
||||
addf(result, by, caps)
|
||||
inc(i, x)
|
||||
add(result, copy(s, i))
|
||||
add(result, substr(s, i))
|
||||
|
||||
proc parallelReplace*(s: string, subs: openArray[
|
||||
tuple[pattern: TPeg, repl: string]]): string {.
|
||||
|
|
@ -941,7 +941,7 @@ proc parallelReplace*(s: string, subs: openArray[
|
|||
add(result, s[i])
|
||||
inc(i)
|
||||
# copy the rest:
|
||||
add(result, copy(s, i))
|
||||
add(result, substr(s, i))
|
||||
|
||||
proc transformFile*(infile, outfile: string,
|
||||
subs: openArray[tuple[pattern: TPeg, repl: string]]) {.
|
||||
|
|
@ -990,7 +990,7 @@ iterator split*(s: string, sep: TPeg): string =
|
|||
x = matchLen(s, sep, last)
|
||||
if x > 0: break
|
||||
if first < last:
|
||||
yield copy(s, first, last-1)
|
||||
yield substr(s, first, last-1)
|
||||
|
||||
proc split*(s: string, sep: TPeg): seq[string] {.
|
||||
nosideEffect, rtl, extern: "npegs$1".} =
|
||||
|
|
@ -1688,7 +1688,7 @@ when isMainModule:
|
|||
assert rawMatch(s, expr.rule, 0, c) == len(s)
|
||||
var a = ""
|
||||
for i in 0..c.ml-1:
|
||||
a.add(copy(s, c.matches[i][0], c.matches[i][1]))
|
||||
a.add(substr(s, c.matches[i][0], c.matches[i][1]))
|
||||
assert a == "abcdef"
|
||||
#echo expr.rule
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue