1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix Windows line ending bug

This commit is contained in:
Alexander Medvednikov 2019-07-04 21:51:59 +02:00
parent 9b0bb2f72c
commit cc77d8cdd2

View File

@ -2109,16 +2109,6 @@ fn (p mut Parser) char_expr() {
p.next()
}
fn format_str(str string) string {
str = str.replace('"', '\\"')
$if windows {
str = str.replace('\r\n', '\\n')
}
$else {
str = str.replace('\n', '\\n')
}
return str
}
fn (p mut Parser) typ_to_fmt(typ string) string {
t := p.table.find_type(typ)
@ -2143,6 +2133,15 @@ fn (p mut Parser) typ_to_fmt(typ string) string {
return ''
}
fn format_str(str string) string {
str = str.replace('"', '\\"')
$if windows {
str = str.replace('\r\n', '\\n')
}
str = str.replace('\n', '\\n')
return str
}
fn (p mut Parser) string_expr() {
// println('STRING EXPR')
str := p.lit
@ -2156,7 +2155,7 @@ fn (p mut Parser) string_expr() {
p.gen('"$f"')
}
else {
p.gen('tos2("$f")')// TODO dont call strlen here
p.gen('tos2("$f")')
}
p.next()
return