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.add(", ")
|
||||||
## tmp.addQuoted('c')
|
## tmp.addQuoted('c')
|
||||||
## assert(tmp == """1, "string", 'c'""")
|
## assert(tmp == """1, "string", 'c'""")
|
||||||
when T is string:
|
when T is string or T is cstring:
|
||||||
s.add("\"")
|
s.add("\"")
|
||||||
for c in x:
|
for c in x:
|
||||||
# Only ASCII chars are escaped to avoid butchering
|
# Only ASCII chars are escaped to avoid butchering
|
||||||
|
|
|
||||||
|
|
@ -107,3 +107,11 @@ bar(nilstring)
|
||||||
|
|
||||||
static:
|
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