@@ -112,10 +112,13 @@ showCStr s = '"' : foldr ((++) . showChar) "\"" s
112 showChar '"' = "\\\""
112 showChar '"' = "\\\""
113 showChar '\\' = "\\\\"
113 showChar '\\' = "\\\\"
114 showChar c
114 showChar c
115+ -- Note: we need the double quotes around the codes because otherwise
116+ -- "\n3" would get encoded as "\x0a3", which is incorrect.
117+ -- Instead, we opt for "\x0a""3" and let the C compiler deal with it.
115− | ord c < 0x10 = "\\x0" ++ showHex (ord c) ""
118+ | ord c < 0x10 = "\"\"\\x0" ++ showHex (ord c) "\"\""
116− | ord c < 0x20 = "\\x" ++ showHex (ord c) ""
119+ | ord c < 0x20 = "\"\"\\x" ++ showHex (ord c) "\"\""
117 | ord c < 0x7f = [c] -- 0x7f = \DEL
120 | ord c < 0x7f = [c] -- 0x7f = \DEL
118− | ord c < 0x100 = "\\x" ++ showHex (ord c) ""
121+ | ord c < 0x100 = "\"\"\\x" ++ showHex (ord c) "\"\""
119 | otherwise = error $ "non-8-bit character in string literal: " ++ show c
122 | otherwise = error $ "non-8-bit character in string literal: " ++ show c
121bcc :: Int -> BC -> String
124bcc :: Int -> BC -> String