fix Windows line ending bug

pull/1003/head
Alexander Medvednikov 2019-07-04 21:51:59 +02:00
parent 9b0bb2f72c
commit cc77d8cdd2
1 changed files with 10 additions and 11 deletions

View File

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