mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: fix eating c
in c'foo'
(#7009)
* fmt: add formatting for cstrs * fmt
This commit is contained in:
parent
49a083fe79
commit
3afa606154
@ -1031,6 +1031,8 @@ pub fn (mut f Fmt) expr(node ast.Expr) {
|
||||
ast.StringLiteral {
|
||||
if node.is_raw {
|
||||
f.write('r')
|
||||
} else if node.language == table.Language.c {
|
||||
f.write('c')
|
||||
}
|
||||
if node.val.contains("'") && !node.val.contains('"') {
|
||||
f.write('"$node.val"')
|
||||
|
6
vlib/v/fmt/tests/string_raw_and_cstr_keep.vv
Normal file
6
vlib/v/fmt/tests/string_raw_and_cstr_keep.vv
Normal file
@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
raw := r'\x00'
|
||||
cstr := c'foo'
|
||||
println(raw)
|
||||
println(cstr)
|
||||
}
|
Loading…
Reference in New Issue
Block a user