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

builtin: fix string interpolation when compiling with -nofloat

This commit is contained in:
Alexander Medvednikov 2021-09-13 18:40:32 +03:00
parent c99281709b
commit 8fc0b486a2
2 changed files with 36 additions and 32 deletions

View File

@ -414,14 +414,16 @@ fn (data StrIntpData) get_fmt_format(mut sb strings.Builder) {
.si_g32 { .si_g32 {
// println("HERE: g32") // println("HERE: g32")
if use_default_str { if use_default_str {
mut f := data.d.d_f32.strg() $if !nofloat ? {
if upper_case { mut f := data.d.d_f32.strg()
tmp := f if upper_case {
f = f.to_upper() tmp := f
tmp.free() f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
} }
sb.write_string(f)
f.free()
} else { } else {
// Manage +/-0 // Manage +/-0
if data.d.d_f32 == strconv.single_plus_zero { if data.d.d_f32 == strconv.single_plus_zero {
@ -482,14 +484,16 @@ fn (data StrIntpData) get_fmt_format(mut sb strings.Builder) {
.si_g64 { .si_g64 {
// println("HERE: g64") // println("HERE: g64")
if use_default_str { if use_default_str {
mut f := data.d.d_f64.strg() $if !nofloat ? {
if upper_case { mut f := data.d.d_f64.strg()
tmp := f if upper_case {
f = f.to_upper() tmp := f
tmp.free() f = f.to_upper()
tmp.free()
}
sb.write_string(f)
f.free()
} }
sb.write_string(f)
f.free()
} else { } else {
// Manage +/-0 // Manage +/-0
if data.d.d_f64 == strconv.double_plus_zero { if data.d.d_f64 == strconv.double_plus_zero {

View File

@ -290,36 +290,36 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
} }
'boehm_full' { 'boehm_full' {
res.gc_mode = .boehm_full res.gc_mode = .boehm_full
parse_define(mut res, 'gcboehm') res.parse_define('gcboehm')
parse_define(mut res, 'gcboehm_full') res.parse_define('gcboehm_full')
} }
'boehm_incr' { 'boehm_incr' {
res.gc_mode = .boehm_incr res.gc_mode = .boehm_incr
parse_define(mut res, 'gcboehm') res.parse_define('gcboehm')
parse_define(mut res, 'gcboehm_incr') res.parse_define('gcboehm_incr')
} }
'boehm_full_opt' { 'boehm_full_opt' {
res.gc_mode = .boehm_full_opt res.gc_mode = .boehm_full_opt
parse_define(mut res, 'gcboehm') res.parse_define('gcboehm')
parse_define(mut res, 'gcboehm_full') res.parse_define('gcboehm_full')
parse_define(mut res, 'gcboehm_opt') res.parse_define('gcboehm_opt')
} }
'boehm_incr_opt' { 'boehm_incr_opt' {
res.gc_mode = .boehm_incr_opt res.gc_mode = .boehm_incr_opt
parse_define(mut res, 'gcboehm') res.parse_define('gcboehm')
parse_define(mut res, 'gcboehm_incr') res.parse_define('gcboehm_incr')
parse_define(mut res, 'gcboehm_opt') res.parse_define('gcboehm_opt')
} }
'boehm' { 'boehm' {
res.gc_mode = .boehm_full_opt // default mode res.gc_mode = .boehm_full_opt // default mode
parse_define(mut res, 'gcboehm') res.parse_define('gcboehm')
parse_define(mut res, 'gcboehm_full') res.parse_define('gcboehm_full')
parse_define(mut res, 'gcboehm_opt') res.parse_define('gcboehm_opt')
} }
'boehm_leak' { 'boehm_leak' {
res.gc_mode = .boehm_leak res.gc_mode = .boehm_leak
parse_define(mut res, 'gcboehm') res.parse_define('gcboehm')
parse_define(mut res, 'gcboehm_leak') res.parse_define('gcboehm_leak')
} }
else { else {
eprintln('unknown garbage collection mode `-gc $gc_mode`, supported modes are:`') eprintln('unknown garbage collection mode `-gc $gc_mode`, supported modes are:`')
@ -529,7 +529,7 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
'-d', '-define' { '-d', '-define' {
if current_args.len > 1 { if current_args.len > 1 {
define := current_args[1] define := current_args[1]
parse_define(mut res, define) res.parse_define(define)
} }
i++ i++
} }
@ -631,7 +631,7 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
} }
} }
if res.is_debug { if res.is_debug {
parse_define(mut res, 'debug') res.parse_define('debug')
} }
// res.use_cache = true // res.use_cache = true
@ -818,7 +818,7 @@ pub fn get_host_arch() Arch {
return Arch(C.__V_architecture) return Arch(C.__V_architecture)
} }
fn parse_define(mut prefs Preferences, define string) { fn (mut prefs Preferences) parse_define(define string) {
define_parts := define.split('=') define_parts := define.split('=')
if !(prefs.is_debug && define == 'debug') { if !(prefs.is_debug && define == 'debug') {
prefs.build_options << '-d $define' prefs.build_options << '-d $define'