mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 20:47:53 +00:00
fixes #8847
This commit is contained in:
@@ -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\""
|
||||
|
||||
Reference in New Issue
Block a user