fixes #8847
This commit is contained in:
parent
dc67dd3bef
commit
fa338768a3
2 changed files with 10 additions and 2 deletions
|
|
@ -3972,7 +3972,7 @@ proc addQuoted*[T](s: var string, x: T) =
|
|||
## tmp.add(", ")
|
||||
## tmp.addQuoted('c')
|
||||
## assert(tmp == """1, "string", 'c'""")
|
||||
when T is string:
|
||||
when T is string or T is cstring:
|
||||
s.add("\"")
|
||||
for c in x:
|
||||
# Only ASCII chars are escaped to avoid butchering
|
||||
|
|
|
|||
|
|
@ -106,4 +106,12 @@ var nilstring: string
|
|||
bar(nilstring)
|
||||
|
||||
static:
|
||||
stringCompare()
|
||||
stringCompare()
|
||||
|
||||
# bug 8847
|
||||
var a2: cstring = "fo\"o2"
|
||||
|
||||
block:
|
||||
var s: string
|
||||
s.addQuoted a2
|
||||
doAssert s == "\"fo\\\"o2\""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue