mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
Support for the printf optimisation for windows and wide strings
This commit is contained in:

committed by
Alexander Medvednikov

parent
3794129c91
commit
acd28fa495
@ -2398,9 +2398,19 @@ fn (p mut Parser) string_expr() {
|
||||
cur_line := p.cgen.cur_line.trim_space()
|
||||
if cur_line.contains('println (') && p.tok != .plus &&
|
||||
!cur_line.contains('string_add') && !cur_line.contains('eprintln') {
|
||||
p.cgen.resetln(cur_line.replace('println (', 'printf('))
|
||||
p.gen('$format\\n$args')
|
||||
return
|
||||
if p.os == .windows || p.os == .msvc {
|
||||
p.cgen.resetln(cur_line.replace('println (', 'wprintf( TEXT('))// .replace('%.*s', '%.*S'))
|
||||
|
||||
// Emily: HACKY HACK
|
||||
real_format := format.replace('%.*s', '%.*S')
|
||||
real_args := args.right(1)
|
||||
p.gen('$real_format\\n")$real_args')
|
||||
} else {
|
||||
p.cgen.resetln(cur_line.replace('println (', 'printf('))
|
||||
p.gen('$format\\n$args')
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
// '$age'! means the user wants this to be a tmp string (uses global buffer, no allocation,
|
||||
// won't be used again)
|
||||
|
Reference in New Issue
Block a user