deprecated system.copy: use system.substr instead

This commit is contained in:
Araq 2011-05-14 01:13:44 +02:00
commit 3e9dcc8be5
31 changed files with 122 additions and 109 deletions

View file

@ -210,7 +210,7 @@ proc ropecg(m: BModule, frmt: TFormatStr, args: openarray[PRope]): PRope =
inc(i)
var j = i
while frmt[j] in IdentChars: inc(j)
var ident = copy(frmt, i, j-1)
var ident = substr(frmt, i, j-1)
i = j
app(result, cgsym(m, ident))
elif frmt[i] == '#' and frmt[i+1] == '$':
@ -225,7 +225,7 @@ proc ropecg(m: BModule, frmt: TFormatStr, args: openarray[PRope]): PRope =
if frmt[i] != '$' and frmt[i] != '#': inc(i)
else: break
if i - 1 >= start:
app(result, copy(frmt, start, i - 1))
app(result, substr(frmt, start, i - 1))
proc appcg(m: BModule, c: var PRope, frmt: TFormatStr,
args: openarray[PRope]) =
@ -489,9 +489,9 @@ proc libCandidates(s: string, dest: var TStringSeq) =
var le = strutils.find(s, '(')
var ri = strutils.find(s, ')', le+1)
if le >= 0 and ri > le:
var prefix = copy(s, 0, le - 1)
var suffix = copy(s, ri + 1)
for middle in split(copy(s, le + 1, ri - 1), '|'):
var prefix = substr(s, 0, le - 1)
var suffix = substr(s, ri + 1)
for middle in split(substr(s, le + 1, ri - 1), '|'):
libCandidates(prefix & middle & suffix, dest)
else:
add(dest, s)

View file

@ -172,7 +172,7 @@ proc splitSwitch(switch: string, cmd, arg: var string, pass: TCmdLinePass,
else: break
inc(i)
if i >= len(switch): arg = ""
elif switch[i] in {':', '=', '['}: arg = copy(switch, i + 1)
elif switch[i] in {':', '=', '['}: arg = substr(switch, i + 1)
else: InvalidCmdLineOption(pass, switch, info)
proc ProcessOnOffSwitch(op: TOptions, arg: string, pass: TCmdlinePass,
@ -215,7 +215,7 @@ proc ProcessSpecificNote(arg: string, state: TSpecialWord, pass: TCmdlinePass,
var x = findStr(msgs.WarningsToStr, id)
if x >= 0: n = TNoteKind(x + ord(warnMin))
else: InvalidCmdLineOption(pass, arg, info)
case whichKeyword(copy(arg, i))
case whichKeyword(substr(arg, i))
of wOn: incl(gNotes, n)
of wOff: excl(gNotes, n)
else: LocalError(info, errOnOrOffExpectedButXFound, arg)

View file

@ -156,7 +156,7 @@ proc ropeFormatNamedVars(frmt: TFormatStr, varnames: openarray[string],
while i < L:
if (frmt[i] != '$'): inc(i)
else: break
if i - 1 >= start: app(result, copy(frmt, start, i - 1))
if i - 1 >= start: app(result, substr(frmt, start, i - 1))
proc addXmlChar(dest: var string, c: Char) =
case c
@ -581,10 +581,10 @@ proc renderCodeBlock(d: PDoc, n: PRstNode): PRope =
case g.kind
of gtEof: break
of gtNone, gtWhitespace:
app(result, copy(m.text, g.start + 0, g.length + g.start - 1 + 0))
app(result, substr(m.text, g.start + 0, g.length + g.start - 1))
else:
dispA(result, "<span class=\"$2\">$1</span>", "\\span$2{$1}", [
toRope(esc(copy(m.text, g.start + 0, g.length + g.start - 1 + 0))),
toRope(esc(substr(m.text, g.start + 0, g.length + g.start - 1))),
toRope(tokenClassToStr[g.kind])])
deinitGeneralTokenizer(g)
if result != nil:

View file

@ -93,14 +93,14 @@ proc parseLine(p: var TTmplParser) =
of wIf, wWhen, wTry, wWhile, wFor, wBlock, wCase, wProc, wIterator,
wConverter, wMacro, wTemplate, wMethod:
LLStreamWrite(p.outp, repeatChar(p.indent))
LLStreamWrite(p.outp, copy(p.x, d))
LLStreamWrite(p.outp, substr(p.x, d))
inc(p.indent, 2)
of wElif, wOf, wElse, wExcept, wFinally:
LLStreamWrite(p.outp, repeatChar(p.indent - 2))
LLStreamWrite(p.outp, copy(p.x, d))
LLStreamWrite(p.outp, substr(p.x, d))
else:
LLStreamWrite(p.outp, repeatChar(p.indent))
LLStreamWrite(p.outp, copy(p.x, d))
LLStreamWrite(p.outp, substr(p.x, d))
p.state = psDirective
else:
# data line

View file

@ -216,7 +216,7 @@ proc LLStreamReadAll(s: PLLStream): string =
result = ""
of llsString:
if s.rd == 0: result = s.s
else: result = copy(s.s, s.rd + 0)
else: result = substr(s.s, s.rd)
s.rd = len(s.s)
of llsFile:
result = newString(bufSize)

View file

@ -33,8 +33,8 @@ proc ProcessCmdLine(pass: TCmdLinePass, command, filename: var string) =
# we fix this here
var bracketLe = strutils.find(p.key, '[')
if bracketLe >= 0:
var key = copy(p.key, 0, bracketLe - 1)
var val = copy(p.key, bracketLe + 1) & ':' & p.val
var key = substr(p.key, 0, bracketLe - 1)
var val = substr(p.key, bracketLe + 1) & ':' & p.val
ProcessSwitch(key, val, pass, cmdLineInfo)
else:
ProcessSwitch(p.key, p.val, pass, cmdLineInfo)

View file

@ -153,13 +153,13 @@ proc `%`(f: string, t: PStringTable, flags: TFormatFlags = {}): string =
of '{':
var j = i + 1
while (j <= len(f) + 0 - 1) and (f[j] != '}'): inc(j)
var key = copy(f, i + 2 + 0 - 1, j - 1 + 0 - 1)
var key = substr(f, i + 2 + 0 - 1, j - 1 + 0 - 1)
add(result, getValue(t, flags, key))
i = j + 1
of 'a'..'z', 'A'..'Z', '\x80'..'\xFF', '_':
var j = i + 1
while (j <= len(f) + 0 - 1) and (f[j] in PatternChars): inc(j)
var key = copy(f, i + 1 + 0 - 1, j - 1 + 0 - 1)
var key = substr(f, i + 1 + 0 - 1, j - 1 + 0 - 1)
add(result, getValue(t, flags, key))
i = j
else:
@ -168,4 +168,4 @@ proc `%`(f: string, t: PStringTable, flags: TFormatFlags = {}): string =
else:
add(result, f[i])
inc(i)

View file

@ -138,19 +138,19 @@ proc shortenDir(dir: string): string =
# returns the interesting part of a dir
var prefix = getPrefixDir() & dirSep
if startsWith(dir, prefix):
return copy(dir, len(prefix))
return substr(dir, len(prefix))
prefix = getCurrentDir() & dirSep
if startsWith(dir, prefix):
return copy(dir, len(prefix))
return substr(dir, len(prefix))
prefix = projectPath & dirSep #writeln(output, prefix);
#writeln(output, dir);
if startsWith(dir, prefix):
return copy(dir, len(prefix))
return substr(dir, len(prefix))
result = dir
proc removeTrailingDirSep*(path: string): string =
if (len(path) > 0) and (path[len(path) - 1] == dirSep):
result = copy(path, 0, len(path) - 2)
result = substr(path, 0, len(path) - 2)
else:
result = path

View file

@ -119,7 +119,7 @@ proc processMagic(c: PContext, n: PNode, s: PSym) =
# treat them as imported, instead of modifing a lot of working code
# BUGFIX: magic does not imply ``lfNoDecl`` anymore!
for m in countup(low(TMagic), high(TMagic)):
if copy($m, 1) == v:
if substr($m, 1) == v:
s.magic = m
return
Message(n.info, warnUnknownMagic, v)
@ -333,12 +333,12 @@ proc semAsmOrEmit*(con: PContext, n: PNode, marker: char): PNode =
var a = 0
while true:
var b = strutils.find(str, marker, a)
var sub = if b < 0: copy(str, a) else: copy(str, a, b - 1)
var sub = if b < 0: substr(str, a) else: substr(str, a, b - 1)
if sub != "": addSon(result, newStrNode(nkStrLit, sub))
if b < 0: break
var c = strutils.find(str, marker, b + 1)
if c < 0: sub = copy(str, b + 1)
else: sub = copy(str, b + 1, c - 1)
if c < 0: sub = substr(str, b + 1)
else: sub = substr(str, b + 1, c - 1)
if sub != "":
var e = SymtabGet(con.tab, getIdent(sub))
if e != nil:

View file

@ -1106,7 +1106,7 @@ proc getNextTok(r: var TSrcGen, kind: var TTokType, literal: var string) =
if r.idx < len(r.tokens):
kind = r.tokens[r.idx].kind
var length = r.tokens[r.idx].length
literal = copy(r.buf, r.pos + 0, r.pos + 0 + length - 1)
literal = substr(r.buf, r.pos + 0, r.pos + 0 + length - 1)
inc(r.pos, length)
inc(r.idx)
else:

View file

@ -328,7 +328,7 @@ proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
if (frmt[i] != '$'): inc(i)
else: break
if i - 1 >= start:
app(result, copy(frmt, start, i - 1))
app(result, substr(frmt, start, i - 1))
assert(RopeInvariant(result))
proc appf(c: var PRope, frmt: TFormatStr, args: openarray[PRope]) =

View file

@ -189,9 +189,9 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode =
of mBoolToStr:
if getOrdValue(a) == 0: result = newStrNodeT("false", n)
else: result = newStrNodeT("true", n)
of mCopyStr: result = newStrNodeT(copy(getStr(a), int(getOrdValue(b))), n)
of mCopyStr: result = newStrNodeT(substr(getStr(a), int(getOrdValue(b))), n)
of mCopyStrLast:
result = newStrNodeT(copy(getStr(a), int(getOrdValue(b)),
result = newStrNodeT(substr(getStr(a), int(getOrdValue(b)),
int(getOrdValue(c))), n)
of mFloatToStr: result = newStrNodeT($(getFloat(a)), n)
of mCStrToStr, mCharToStr: result = newStrNodeT(getStrOrChar(a), n)

View file

@ -14,7 +14,7 @@ import
ast, astalgo, semdata, types, msgs, renderer, lookups, semtypinst,
magicsys
type
type
TCandidateState* = enum
csEmpty, csMatch, csNoMatch
TCandidate* {.final.} = object
@ -222,7 +222,7 @@ proc typeRel(mapping: var TIdTable, f, a: PType): TTypeRelation =
of tyFloat64: result = handleFloatRange(f, a)
of tyFloat128: result = handleFloatRange(f, a)
of tyVar:
if (a.kind == f.kind): result = typeRel(mapping, base(f), base(a))
if a.kind == f.kind: result = typeRel(mapping, base(f), base(a))
else: result = typeRel(mapping, base(f), a)
of tyArray, tyArrayConstr:
# tyArrayConstr cannot happen really, but

View file

@ -98,7 +98,7 @@ proc parsePipe(filename: string, inputStream: PLLStream): PNode =
inc(i, 2)
while line[i] in WhiteSpace: inc(i)
var q: TParser
OpenParser(q, filename, LLStreamOpen(copy(line, i)))
OpenParser(q, filename, LLStreamOpen(substr(line, i)))
result = parser.parseAll(q)
CloseParser(q)
LLStreamClose(s)