From fa338768a3f6aac03e4c76bcfdd660716a9bf926 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 3 Sep 2018 08:37:32 +0200 Subject: [PATCH] fixes #8847 --- lib/system.nim | 2 +- tests/system/tostring.nim | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 92f51fe7e8..bfd8a31e5c 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -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 diff --git a/tests/system/tostring.nim b/tests/system/tostring.nim index 42c07c0a41..04b37f133f 100644 --- a/tests/system/tostring.nim +++ b/tests/system/tostring.nim @@ -106,4 +106,12 @@ var nilstring: string bar(nilstring) static: - stringCompare() \ No newline at end of file + stringCompare() + +# bug 8847 +var a2: cstring = "fo\"o2" + +block: + var s: string + s.addQuoted a2 + doAssert s == "\"fo\\\"o2\""