Deprecate TaintedString (#15423)
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
This commit is contained in:
parent
7b632f9ccb
commit
78a99587a4
36 changed files with 184 additions and 229 deletions
|
|
@ -28,7 +28,7 @@ block :tmp:
|
|||
try:
|
||||
var res
|
||||
try:
|
||||
res = TaintedString(newStringOfCap(80))
|
||||
res = newStringOfCap(80)
|
||||
block :tmp_1:
|
||||
while readLine(f, res):
|
||||
x_cursor = res
|
||||
|
|
|
|||
|
|
@ -774,13 +774,13 @@ block: # issue #9458
|
|||
Option[T] = object
|
||||
val: T
|
||||
has: bool
|
||||
|
||||
|
||||
Bar = object
|
||||
|
||||
proc none(T: typedesc): Option[T] =
|
||||
discard
|
||||
|
||||
proc foo[T](self: T; x: Option[Bar] = Bar.none) =
|
||||
proc foo[T](self: T; x: Option[Bar] = Bar.none) =
|
||||
discard
|
||||
|
||||
foo(1)
|
||||
|
|
@ -834,7 +834,7 @@ proc getBar(x: string): Bar =
|
|||
Bar(foo: none[seq[Foo]](),
|
||||
s: "")
|
||||
|
||||
proc fakeReadLine(): TaintedString = "hey"
|
||||
proc fakeReadLine(): string = "hey"
|
||||
|
||||
echo getBar(fakeReadLine()) # causes error
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ proc unused =
|
|||
iterator lineIter2*(filename: string): string {.closure.} =
|
||||
var f = open(filename, bufSize=8000)
|
||||
defer: close(f) # <-- commenting defer "solves" the problem
|
||||
var res = TaintedString(newStringOfCap(80))
|
||||
var res = newStringOfCap(80)
|
||||
while f.readLine(res): yield res
|
||||
|
||||
proc unusedB =
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ template raise_or_quit(exception, message: untyped) =
|
|||
|
||||
template run_custom_proc(parsed_parameter: Tparsed_parameter,
|
||||
custom_validator: Tparameter_callback,
|
||||
parameter: TaintedString) =
|
||||
parameter: string) =
|
||||
## Runs the custom validator if it is not nil.
|
||||
##
|
||||
## Pass in the string of the parameter triggering the call. If the
|
||||
|
|
@ -318,7 +318,7 @@ proc echo_help*(expected: seq[Tparameter_specification] = @[],
|
|||
|
||||
|
||||
proc parse*(expected: seq[Tparameter_specification] = @[],
|
||||
type_of_positional_parameters = PK_STRING, args: seq[TaintedString] = @[],
|
||||
type_of_positional_parameters = PK_STRING, args: seq[string] = @[],
|
||||
bad_prefixes = @["-", "--"], end_of_options = "--",
|
||||
quit_on_failure = true): Tcommandline_results =
|
||||
## Parses parameters and returns results.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import streams
|
||||
from strutils import repeat
|
||||
|
||||
proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString =
|
||||
proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): string =
|
||||
var lastChr = length
|
||||
result = s.readStr(length)
|
||||
while lastChr >= 0 and result[lastChr - 1] == padChar: dec(lastChr)
|
||||
|
|
@ -16,7 +16,7 @@ proc writePaddedStr*(s: PStream, str: string, length: int, padChar = '\0') =
|
|||
else:
|
||||
s.write(str)
|
||||
|
||||
proc readLEStr*(s: PStream): TaintedString =
|
||||
proc readLEStr*(s: PStream): string =
|
||||
var len = s.readInt16()
|
||||
result = s.readStr(len)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ disabled: "appveyor"
|
|||
|
||||
import memfiles
|
||||
var inp = memfiles.open("tests/stdlib/tmemlinesBuf.nim")
|
||||
var buffer: TaintedString = ""
|
||||
var buffer: string = ""
|
||||
var lineCount = 0
|
||||
for line in lines(inp, buffer):
|
||||
lineCount += 1
|
||||
|
|
|
|||
|
|
@ -195,15 +195,15 @@ else: # main driver
|
|||
# bugfix: windows stdin.close was a noop and led to blocking reads
|
||||
proc startProcessTest(command: string, options: set[ProcessOption] = {
|
||||
poStdErrToStdOut, poUsePath}, input = ""): tuple[
|
||||
output: TaintedString,
|
||||
output: string,
|
||||
exitCode: int] {.tags:
|
||||
[ExecIOEffect, ReadIOEffect, RootEffect], gcsafe.} =
|
||||
var p = startProcess(command, options = options + {poEvalCommand})
|
||||
var outp = outputStream(p)
|
||||
if input.len > 0: inputStream(p).write(input)
|
||||
close inputStream(p)
|
||||
result = (TaintedString"", -1)
|
||||
var line = newStringOfCap(120).TaintedString
|
||||
result = ("", -1)
|
||||
var line = newStringOfCap(120)
|
||||
while true:
|
||||
if outp.readLine(line):
|
||||
result[0].string.add(line.string)
|
||||
|
|
@ -223,7 +223,7 @@ else: # main driver
|
|||
p.inputStream.flush()
|
||||
var line = ""
|
||||
var s: seq[string]
|
||||
while p.outputStream.readLine(line.TaintedString):
|
||||
while p.outputStream.readLine(line):
|
||||
s.add line
|
||||
doAssert s == @["10"]
|
||||
|
||||
|
|
@ -235,15 +235,15 @@ else: # main driver
|
|||
deferScoped: p.close()
|
||||
do:
|
||||
var sout: seq[string]
|
||||
while p.outputStream.readLine(x.TaintedString): sout.add x
|
||||
while p.outputStream.readLine(x): sout.add x
|
||||
doAssert sout == @["start ta_out", "to stdout", "to stdout", "to stderr", "to stderr", "to stdout", "to stdout", "end ta_out"]
|
||||
block: # startProcess stderr (replaces old test `tstderr` + `ta_out`)
|
||||
var p = startProcess(output, dir, options={})
|
||||
deferScoped: p.close()
|
||||
do:
|
||||
var serr, sout: seq[string]
|
||||
while p.errorStream.readLine(x.TaintedString): serr.add x
|
||||
while p.outputStream.readLine(x.TaintedString): sout.add x
|
||||
while p.errorStream.readLine(x): serr.add x
|
||||
while p.outputStream.readLine(x): sout.add x
|
||||
doAssert serr == @["to stderr", "to stderr"]
|
||||
doAssert sout == @["start ta_out", "to stdout", "to stdout", "to stdout", "to stdout", "end ta_out"]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue