From 8fc0b486a2317ca5c1f527b9eaee23191b4a22b2 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 13 Sep 2021 18:40:32 +0300 Subject: [PATCH] builtin: fix string interpolation when compiling with -nofloat --- vlib/builtin/string_interpolation.v | 32 ++++++++++++++----------- vlib/v/pref/pref.v | 36 ++++++++++++++--------------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/vlib/builtin/string_interpolation.v b/vlib/builtin/string_interpolation.v index 8e6c23b8e8..0f3b219d8b 100644 --- a/vlib/builtin/string_interpolation.v +++ b/vlib/builtin/string_interpolation.v @@ -414,14 +414,16 @@ fn (data StrIntpData) get_fmt_format(mut sb strings.Builder) { .si_g32 { // println("HERE: g32") if use_default_str { - mut f := data.d.d_f32.strg() - if upper_case { - tmp := f - f = f.to_upper() - tmp.free() + $if !nofloat ? { + mut f := data.d.d_f32.strg() + if upper_case { + tmp := f + f = f.to_upper() + tmp.free() + } + sb.write_string(f) + f.free() } - sb.write_string(f) - f.free() } else { // Manage +/-0 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 { // println("HERE: g64") if use_default_str { - mut f := data.d.d_f64.strg() - if upper_case { - tmp := f - f = f.to_upper() - tmp.free() + $if !nofloat ? { + mut f := data.d.d_f64.strg() + if upper_case { + tmp := f + f = f.to_upper() + tmp.free() + } + sb.write_string(f) + f.free() } - sb.write_string(f) - f.free() } else { // Manage +/-0 if data.d.d_f64 == strconv.double_plus_zero { diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 12b551598c..29a13fa857 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -290,36 +290,36 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences } 'boehm_full' { res.gc_mode = .boehm_full - parse_define(mut res, 'gcboehm') - parse_define(mut res, 'gcboehm_full') + res.parse_define('gcboehm') + res.parse_define('gcboehm_full') } 'boehm_incr' { res.gc_mode = .boehm_incr - parse_define(mut res, 'gcboehm') - parse_define(mut res, 'gcboehm_incr') + res.parse_define('gcboehm') + res.parse_define('gcboehm_incr') } 'boehm_full_opt' { res.gc_mode = .boehm_full_opt - parse_define(mut res, 'gcboehm') - parse_define(mut res, 'gcboehm_full') - parse_define(mut res, 'gcboehm_opt') + res.parse_define('gcboehm') + res.parse_define('gcboehm_full') + res.parse_define('gcboehm_opt') } 'boehm_incr_opt' { res.gc_mode = .boehm_incr_opt - parse_define(mut res, 'gcboehm') - parse_define(mut res, 'gcboehm_incr') - parse_define(mut res, 'gcboehm_opt') + res.parse_define('gcboehm') + res.parse_define('gcboehm_incr') + res.parse_define('gcboehm_opt') } 'boehm' { res.gc_mode = .boehm_full_opt // default mode - parse_define(mut res, 'gcboehm') - parse_define(mut res, 'gcboehm_full') - parse_define(mut res, 'gcboehm_opt') + res.parse_define('gcboehm') + res.parse_define('gcboehm_full') + res.parse_define('gcboehm_opt') } 'boehm_leak' { res.gc_mode = .boehm_leak - parse_define(mut res, 'gcboehm') - parse_define(mut res, 'gcboehm_leak') + res.parse_define('gcboehm') + res.parse_define('gcboehm_leak') } else { 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' { if current_args.len > 1 { define := current_args[1] - parse_define(mut res, define) + res.parse_define(define) } i++ } @@ -631,7 +631,7 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences } } if res.is_debug { - parse_define(mut res, 'debug') + res.parse_define('debug') } // res.use_cache = true @@ -818,7 +818,7 @@ pub fn get_host_arch() Arch { 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('=') if !(prefs.is_debug && define == 'debug') { prefs.build_options << '-d $define'