mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
ef1696b3e1
commit
5daa38fdb1
2
vlib/v/tests/inout/smart_quote.out
Normal file
2
vlib/v/tests/inout/smart_quote.out
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
\$
|
||||||
|
\\$
|
2
vlib/v/tests/inout/smart_quote.vv
Normal file
2
vlib/v/tests/inout/smart_quote.vv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
println('\\$')
|
||||||
|
println(r'\\$')
|
@ -76,6 +76,7 @@ pub fn smart_quote(str string, raw bool) string {
|
|||||||
}
|
}
|
||||||
if next == util.backslash {
|
if next == util.backslash {
|
||||||
// escaped backslash - keep as is
|
// escaped backslash - keep as is
|
||||||
|
current = 0
|
||||||
skip_next = true
|
skip_next = true
|
||||||
result.write_string(util.double_escape)
|
result.write_string(util.double_escape)
|
||||||
continue
|
continue
|
||||||
@ -87,6 +88,7 @@ pub fn smart_quote(str string, raw bool) string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if next in util.invalid_escapes {
|
if next in util.invalid_escapes {
|
||||||
|
current = 0
|
||||||
skip_next = true
|
skip_next = true
|
||||||
result.write_u8(next)
|
result.write_u8(next)
|
||||||
continue
|
continue
|
||||||
@ -95,6 +97,7 @@ pub fn smart_quote(str string, raw bool) string {
|
|||||||
skip_next = true
|
skip_next = true
|
||||||
result.write_u8(current)
|
result.write_u8(current)
|
||||||
result.write_u8(next)
|
result.write_u8(next)
|
||||||
|
current = 0
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,13 +123,6 @@ pub fn smart_quote(str string, raw bool) string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if current == util.backslash_r && next == util.backslash_n {
|
|
||||||
// Windows style new line \r\n
|
|
||||||
skip_next = true
|
|
||||||
result.write_u8(util.backslash)
|
|
||||||
result.write_u8(`n`)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result.write_u8(current)
|
result.write_u8(current)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user