mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser/cgen: fix order of escape replacements
This commit is contained in:
parent
b750f1d1bb
commit
597811093c
@ -2595,8 +2595,8 @@ fn (p mut Parser) char_expr() {
|
||||
fn format_str(_str string) string {
|
||||
// TODO don't call replace 3 times for every string, do this in scanner.v
|
||||
return _str.replace_each(['"', '\\"',
|
||||
'\n', '\\n',
|
||||
'\r\n', '\\n'])
|
||||
'\r\n', '\\n',
|
||||
'\n', '\\n'])
|
||||
}
|
||||
|
||||
// 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
|
||||
// `C.printf("hi")` => `printf("hi");`
|
||||
escaped_val := it.val.replace_each(['"', '\\"',
|
||||
'\n', '\\n',
|
||||
'\r\n', '\\n'])
|
||||
'\r\n', '\\n',
|
||||
'\n', '\\n'])
|
||||
if g.is_c_call {
|
||||
g.write('"$escaped_val"')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user