parser/cgen: fix order of escape replacements
parent
b750f1d1bb
commit
597811093c
|
@ -2595,8 +2595,8 @@ fn (p mut Parser) char_expr() {
|
||||||
fn format_str(_str string) string {
|
fn format_str(_str string) string {
|
||||||
// TODO don't call replace 3 times for every string, do this in scanner.v
|
// TODO don't call replace 3 times for every string, do this in scanner.v
|
||||||
return _str.replace_each(['"', '\\"',
|
return _str.replace_each(['"', '\\"',
|
||||||
'\n', '\\n',
|
'\r\n', '\\n',
|
||||||
'\r\n', '\\n'])
|
'\n', '\\n'])
|
||||||
}
|
}
|
||||||
|
|
||||||
// m := map[string]int{}
|
// m := map[string]int{}
|
||||||
|
|
|
@ -810,8 +810,8 @@ fn (g mut Gen) expr(node ast.Expr) {
|
||||||
// In C calls we have to generate C strings
|
// In C calls we have to generate C strings
|
||||||
// `C.printf("hi")` => `printf("hi");`
|
// `C.printf("hi")` => `printf("hi");`
|
||||||
escaped_val := it.val.replace_each(['"', '\\"',
|
escaped_val := it.val.replace_each(['"', '\\"',
|
||||||
'\n', '\\n',
|
'\r\n', '\\n',
|
||||||
'\r\n', '\\n'])
|
'\n', '\\n'])
|
||||||
if g.is_c_call {
|
if g.is_c_call {
|
||||||
g.write('"$escaped_val"')
|
g.write('"$escaped_val"')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue