1
0
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:
Swastik Baranwal 2020-11-29 14:09:50 +05:30 committed by GitHub
parent 49a083fe79
commit 3afa606154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -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"')

View File

@ -0,0 +1,6 @@
fn main() {
raw := r'\x00'
cstr := c'foo'
println(raw)
println(cstr)
}