From 73e28dcc6125f616cf1f2d56443d22428a79e434 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 17 Sep 2022 21:08:33 +0100 Subject: patch 9.0.0491: no good reason to build without the float feature Problem: No good reason to build without the float feature. Solution: Remove configure check for float and "#ifdef FEAT_FLOAT". --- src/auto/configure | 42 ----- src/config.h.in | 1 - src/configure.ac | 26 +-- src/dict.c | 2 - src/errors.h | 19 +- src/eval.c | 65 +------ src/evalfunc.c | 65 +++---- src/ex_cmds.c | 22 +-- src/feature.h | 5 +- src/float.c | 2 +- src/gui_gtk_x11.c | 2 +- src/gui_x11.c | 2 +- src/if_lua.c | 7 - src/if_mzsch.c | 4 - src/if_py_both.h | 6 - src/if_ruby.c | 4 - src/json.c | 25 +-- src/list.c | 8 - src/locale.c | 4 +- src/macros.h | 2 +- src/message_test.c | 2 - src/os_mac_conv.c | 2 +- src/os_vms_conf.h | 1 - src/profiler.c | 10 +- src/session.c | 2 - src/strings.c | 22 +-- src/structs.h | 2 - src/syntax.c | 6 +- src/testdir/runtest.vim | 4 +- src/testdir/test_assert.vim | 28 ++- src/testdir/test_blob.vim | 4 +- src/testdir/test_cscope.vim | 36 ++-- src/testdir/test_eval_stuff.vim | 18 +- src/testdir/test_execute_func.vim | 8 +- src/testdir/test_expr.vim | 244 ++++++++++++------------ src/testdir/test_float_func.vim | 1 - src/testdir/test_functions.vim | 36 ++-- src/testdir/test_glob2regpat.vim | 6 +- src/testdir/test_json.vim | 56 +++--- src/testdir/test_listdict.vim | 34 ++-- src/testdir/test_lua.vim | 1 - src/testdir/test_messages.vim | 8 +- src/testdir/test_method.vim | 1 - src/testdir/test_perl.vim | 6 +- src/testdir/test_python2.vim | 5 +- src/testdir/test_python3.vim | 23 +-- src/testdir/test_random.vim | 4 +- src/testdir/test_reltime.vim | 1 - src/testdir/test_ruby.vim | 6 +- src/testdir/test_sort.vim | 57 +++--- src/testdir/test_substitute.vim | 2 - src/testdir/test_terminal.vim | 4 +- src/testdir/test_true_false.vim | 5 +- src/testdir/test_user_func.vim | 8 +- src/testdir/test_vim9_assign.vim | 58 +++--- src/testdir/test_vim9_builtin.vim | 26 +-- src/testdir/test_vim9_disassemble.vim | 74 ++++---- src/testdir/test_vim9_expr.vim | 342 ++++++++++++++-------------------- src/testdir/test_vimscript.vim | 152 +++++++-------- src/testing.c | 2 - src/time.c | 10 +- src/typval.c | 18 -- src/version.c | 6 +- src/vim9.h | 2 - src/vim9compile.c | 4 - src/vim9execute.c | 24 --- src/vim9expr.c | 2 - src/vim9instr.c | 14 +- src/vim9type.c | 6 - src/viminfo.c | 4 - 70 files changed, 600 insertions(+), 1110 deletions(-) (limited to 'src') diff --git a/src/auto/configure b/src/auto/configure index 18836113be..8c770c8012 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -13379,48 +13379,6 @@ _ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strtod() and other floating point functions" >&5 -$as_echo_n "checking for strtod() and other floating point functions... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef HAVE_MATH_H -# include -#endif -#if STDC_HEADERS -# include -# include -#endif - -int -main () -{ -char *s; double d; - d = strtod("1.1", &s); - d = fabs(1.11); - d = ceil(1.11); - d = floor(1.11); - d = log10(1.11); - d = pow(1.11, 2.22); - d = sqrt(1.11); - d = sin(1.11); - d = cos(1.11); - d = atan(1.11); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; }; $as_echo "#define HAVE_FLOAT_FUNCS 1" >>confdefs.h - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for isinf()" >&5 $as_echo_n "checking for isinf()... " >&6; } diff --git a/src/config.h.in b/src/config.h.in index 5f0d6aef2a..875d9afd54 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -157,7 +157,6 @@ #undef HAVE_FCHDIR #undef HAVE_FCHOWN #undef HAVE_FCHMOD -#undef HAVE_FLOAT_FUNCS #undef HAVE_FSEEKO #undef HAVE_FSYNC #undef HAVE_FTRUNCATE diff --git a/src/configure.ac b/src/configure.ac index 76eb56327c..b688032d00 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -3952,32 +3952,8 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NL_LANGINFO_CODESET), AC_MSG_RESULT(no)) -dnl Need various functions for floating point support. Only enable -dnl floating point when they are all present. +dnl Floating point support may require the "m" library AC_CHECK_LIB(m, strtod) -AC_MSG_CHECKING([for strtod() and other floating point functions]) -AC_LINK_IFELSE([AC_LANG_PROGRAM([ -#ifdef HAVE_MATH_H -# include -#endif -#if STDC_HEADERS -# include -# include -#endif -], [char *s; double d; - d = strtod("1.1", &s); - d = fabs(1.11); - d = ceil(1.11); - d = floor(1.11); - d = log10(1.11); - d = pow(1.11, 2.22); - d = sqrt(1.11); - d = sin(1.11); - d = cos(1.11); - d = atan(1.11); - ])], - AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS), - AC_MSG_RESULT(no)) dnl isinf() and isnan() need to include header files and may need -lm. AC_MSG_CHECKING([for isinf()]) diff --git a/src/dict.c b/src/dict.c index fa54c60c41..1cb3e89a8d 100644 --- a/src/dict.c +++ b/src/dict.c @@ -984,13 +984,11 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) } if (evaluate) { -#ifdef FEAT_FLOAT if (tvkey.v_type == VAR_FLOAT) { tvkey.vval.v_string = typval_tostring(&tvkey, TRUE); tvkey.v_type = VAR_STRING; } -#endif key = tv_get_string_buf_chk(&tvkey, buf); if (key == NULL) { diff --git a/src/errors.h b/src/errors.h index 944dc43c5d..e293876528 100644 --- a/src/errors.h +++ b/src/errors.h @@ -895,7 +895,7 @@ EXTERN char e_cannot_execute_shell_with_f_option[] INIT(= N_("E360: Cannot execute shell with -f option")); #endif // E361 unused -#if defined(FEAT_EVAL) && defined(FEAT_FLOAT) +#if defined(FEAT_EVAL) EXTERN char e_using_boolean_value_as_float[] INIT(= N_("E362: Using a boolean value as a Float")); #endif @@ -2044,17 +2044,13 @@ EXTERN char e_cannot_use_percent_with_float[] // xgettext:no-c-format INIT(= N_("E804: Cannot use '%' with Float")); #endif -#ifdef FEAT_FLOAT EXTERN char e_using_float_as_number[] INIT(= N_("E805: Using a Float as a Number")); EXTERN char e_using_float_as_string[] INIT(= N_("E806: Using a Float as a String")); -#endif -#ifdef FEAT_FLOAT EXTERN char e_expected_float_argument_for_printf[] INIT(= N_("E807: Expected Float argument for printf()")); -#endif -#if defined(FEAT_EVAL) && defined(FEAT_FLOAT) +#if defined(FEAT_EVAL) EXTERN char e_number_or_float_required[] INIT(= N_("E808: Number or Float required")); #endif @@ -2290,7 +2286,6 @@ EXTERN char e_number_required[] EXTERN char e_trailing_char_after_rsb_str_str[] INIT(= N_("E890: Trailing char after ']': %s]%s")); #endif -#ifdef FEAT_FLOAT EXTERN char e_using_funcref_as_float[] INIT(= N_("E891: Using a Funcref as a Float")); EXTERN char e_using_string_as_float[] @@ -2299,7 +2294,6 @@ EXTERN char e_using_list_as_float[] INIT(= N_("E893: Using a List as a Float")); EXTERN char e_using_dictionary_as_float[] INIT(= N_("E894: Using a Dictionary as a Float")); -#endif #ifdef FEAT_MZSCHEME EXTERN char e_sorry_this_command_is_disabled_the_mzscheme_racket_base_module_could_not_be_loaded[] INIT(= N_("E895: Sorry, this command is disabled, the MzScheme's racket/base module could not be loaded.")); @@ -2340,10 +2334,8 @@ EXTERN char e_received_unknown_command_str[] EXTERN char e_not_an_open_channel[] INIT(= N_("E906: Not an open channel")); #endif -#ifdef FEAT_FLOAT EXTERN char e_using_special_value_as_float[] INIT(= N_("E907: Using a special value as a Float")); -#endif #ifdef FEAT_EVAL EXTERN char e_using_invalid_value_as_string_str[] INIT(= N_("E908: Using an invalid value as a String: %s")); @@ -2537,10 +2529,8 @@ EXTERN char e_blob_literal_should_have_an_even_number_of_hex_characters[] INIT(= N_("E973: Blob literal should have an even number of hex characters")); EXTERN char e_using_blob_as_number[] INIT(= N_("E974: Using a Blob as a Number")); -# ifdef FEAT_FLOAT EXTERN char e_using_blob_as_float[] INIT(= N_("E975: Using a Blob as a Float")); -# endif EXTERN char e_using_blob_as_string[] INIT(= N_("E976: Using a Blob as a String")); EXTERN char e_can_only_compare_blob_with_blob[] @@ -2775,10 +2765,7 @@ EXTERN char e_no_white_space_allowed_after_dot[] INIT(= N_("E1074: No white space allowed after dot")); EXTERN char e_namespace_not_supported_str[] INIT(= N_("E1075: Namespace not supported: %s")); -# ifndef FEAT_FLOAT -EXTERN char e_this_vim_is_not_compiled_with_float_support[] - INIT(= N_("E1076: This Vim is not compiled with float support")); -# endif +// E1076 was deleted EXTERN char e_missing_argument_type_for_str[] INIT(= N_("E1077: Missing argument type for %s")); #endif diff --git a/src/eval.c b/src/eval.c index 3209d08dcc..948faa2ee5 100644 --- a/src/eval.c +++ b/src/eval.c @@ -525,9 +525,7 @@ typval2string(typval_T *tv, int convert) { garray_T ga; char_u *retval; -#ifdef FEAT_FLOAT char_u numbuf[NUMBUFLEN]; -#endif if (convert && tv->v_type == VAR_LIST) { @@ -541,13 +539,11 @@ typval2string(typval_T *tv, int convert) ga_append(&ga, NUL); retval = (char_u *)ga.ga_data; } -#ifdef FEAT_FLOAT else if (convert && tv->v_type == VAR_FLOAT) { vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv->vval.v_float); retval = vim_strsave(numbuf); } -#endif else retval = vim_strsave(tv_get_string(tv)); return retval; @@ -1683,7 +1679,6 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) { // nr += nr , nr -= nr , nr *=nr , nr /= nr , nr %= nr n = tv_get_number(tv1); -#ifdef FEAT_FLOAT if (tv2->v_type == VAR_FLOAT) { float_T f = n; @@ -1702,7 +1697,6 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) tv1->vval.v_float = f; } else -#endif { switch (*op) { @@ -1734,7 +1728,6 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) return failed ? FAIL : OK; case VAR_FLOAT: -#ifdef FEAT_FLOAT { float_T f; @@ -1755,7 +1748,6 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op) case '/': tv1->vval.v_float /= f; break; } } -#endif return OK; } } @@ -3238,9 +3230,7 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg) } if ((op != '+' || (rettv->v_type != VAR_LIST && rettv->v_type != VAR_BLOB)) -#ifdef FEAT_FLOAT && (op == '.' || rettv->v_type != VAR_FLOAT) -#endif && evaluate) { int error = FALSE; @@ -3293,14 +3283,12 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg) || var2.v_type == VAR_JOB)) semsg(_(e_using_invalid_value_as_string_str), vartype_name(var2.v_type)); -#ifdef FEAT_FLOAT else if (vim9script && var2.v_type == VAR_FLOAT) { vim_snprintf((char *)buf2, NUMBUFLEN, "%g", var2.vval.v_float); s2 = buf2; } -#endif else s2 = tv_get_string_buf_chk(&var2, buf2); if (s2 == NULL) // type error ? @@ -3327,8 +3315,7 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg) { int error = FALSE; varnumber_T n1, n2; -#ifdef FEAT_FLOAT - float_T f1 = 0, f2 = 0; + float_T f1 = 0, f2 = 0; if (rettv->v_type == VAR_FLOAT) { @@ -3336,7 +3323,6 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg) n1 = 0; } else -#endif { n1 = tv_get_number_chk(rettv, &error); if (error) @@ -3349,19 +3335,15 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg) clear_tv(&var2); return FAIL; } -#ifdef FEAT_FLOAT if (var2.v_type == VAR_FLOAT) f1 = n1; -#endif } -#ifdef FEAT_FLOAT if (var2.v_type == VAR_FLOAT) { f2 = var2.vval.v_float; n2 = 0; } else -#endif { n2 = tv_get_number_chk(&var2, &error); if (error) @@ -3370,14 +3352,11 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg) clear_tv(&var2); return FAIL; } -#ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) f2 = n2; -#endif } clear_tv(rettv); -#ifdef FEAT_FLOAT // If there is a float on either side the result is a float. if (rettv->v_type == VAR_FLOAT || var2.v_type == VAR_FLOAT) { @@ -3389,7 +3368,6 @@ eval6(char_u **arg, typval_T *rettv, evalarg_T *evalarg) rettv->vval.v_float = f1; } else -#endif { if (op == '+') n1 = n1 + n2; @@ -3423,9 +3401,7 @@ eval7( evalarg_T *evalarg, int want_string) // after "." operator { -#ifdef FEAT_FLOAT int use_float = FALSE; -#endif /* * Get the first expression. @@ -3444,9 +3420,7 @@ eval7( char_u *p; int op; varnumber_T n1, n2; -#ifdef FEAT_FLOAT float_T f1, f2; -#endif int error; // "*=", "/=" and "%=" are assignments @@ -3469,14 +3443,11 @@ eval7( *arg = p; } -#ifdef FEAT_FLOAT f1 = 0; f2 = 0; -#endif error = FALSE; if (evaluate) { -#ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) { f1 = rettv->vval.v_float; @@ -3484,7 +3455,6 @@ eval7( n1 = 0; } else -#endif n1 = tv_get_number_chk(rettv, &error); clear_tv(rettv); if (error) @@ -3508,7 +3478,6 @@ eval7( if (evaluate) { -#ifdef FEAT_FLOAT if (var2.v_type == VAR_FLOAT) { if (!use_float) @@ -3520,30 +3489,26 @@ eval7( n2 = 0; } else -#endif { n2 = tv_get_number_chk(&var2, &error); clear_tv(&var2); if (error) return FAIL; -#ifdef FEAT_FLOAT if (use_float) f2 = n2; -#endif } /* * Compute the result. * When either side is a float the result is a float. */ -#ifdef FEAT_FLOAT if (use_float) { if (op == '*') f1 = f1 * f2; else if (op == '/') { -# ifdef VMS +#ifdef VMS // VMS crashes on divide by zero, work around it if (f2 == 0.0) { @@ -3556,11 +3521,11 @@ eval7( } else f1 = f1 / f2; -# else +#else // We rely on the floating point library to handle divide // by zero to result in "inf" and not a crash. f1 = f1 / f2; -# endif +#endif } else { @@ -3571,7 +3536,6 @@ eval7( rettv->vval.v_float = f1; } else -#endif { int failed = FALSE; @@ -3858,11 +3822,7 @@ eval9( return FAIL; end_leader = *arg; - if (**arg == '.' && (!isdigit(*(*arg + 1)) -#ifdef FEAT_FLOAT - || in_old_script(2) -#endif - )) + if (**arg == '.' && (!isdigit(*(*arg + 1)) || in_old_script(2))) { semsg(_(e_invalid_expression_str), *arg); ++*arg; @@ -4129,13 +4089,11 @@ eval9_leader( varnumber_T val = 0; vartype_T type = rettv->v_type; int vim9script = in_vim9script(); -#ifdef FEAT_FLOAT float_T f = 0.0; if (rettv->v_type == VAR_FLOAT) f = rettv->vval.v_float; else -#endif { while (VIM_ISWHITE(end_leader[-1])) --end_leader; @@ -4161,7 +4119,6 @@ eval9_leader( ++end_leader; break; } -#ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) { if (vim9script) @@ -4173,7 +4130,6 @@ eval9_leader( f = !f; } else -#endif { val = !val; type = VAR_BOOL; @@ -4181,25 +4137,21 @@ eval9_leader( } else if (*end_leader == '-') { -#ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) f = -f; else -#endif { val = -val; type = VAR_NUMBER; } } } -#ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) { clear_tv(rettv); rettv->vval.v_float = f; } else -#endif { clear_tv(rettv); if (vim9script) @@ -4500,7 +4452,6 @@ eval_index( { int error = FALSE; -#ifdef FEAT_FLOAT // allow for indexing with float if (vim9script && rettv->v_type == VAR_DICT && var1.v_type == VAR_FLOAT) @@ -4508,7 +4459,7 @@ eval_index( var1.vval.v_string = typval_tostring(&var1, TRUE); var1.v_type = VAR_STRING; } -#endif + if (vim9script && rettv->v_type == VAR_LIST) tv_get_number_chk(&var1, &error); else @@ -4599,11 +4550,9 @@ check_can_index(typval_T *rettv, int evaluate, int verbose) emsg(_(e_cannot_index_a_funcref)); return FAIL; case VAR_FLOAT: -#ifdef FEAT_FLOAT if (verbose) emsg(_(e_using_float_as_string)); return FAIL; -#endif case VAR_BOOL: case VAR_SPECIAL: case VAR_JOB: @@ -5696,12 +5645,10 @@ echo_string_core( break; case VAR_FLOAT: -#ifdef FEAT_FLOAT *tofree = NULL; vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv->vval.v_float); r = numbuf; break; -#endif case VAR_BOOL: case VAR_SPECIAL: diff --git a/src/evalfunc.c b/src/evalfunc.c index cab3213469..f808d19706 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1512,12 +1512,7 @@ typedef struct #define FEARG_3 3 // base is the third argument #define FEARG_4 4 // base is the fourth argument -#ifdef FEAT_FLOAT -# define FLOAT_FUNC(name) name -#else -# define FLOAT_FUNC(name) NULL -#endif -#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H) +#if defined(HAVE_MATH_H) # define MATH_FUNC(name) name #else # define MATH_FUNC(name) NULL @@ -1556,9 +1551,9 @@ typedef struct static funcentry_T global_functions[] = { {"abs", 1, 1, FEARG_1, arg1_float_or_nr, - ret_any, FLOAT_FUNC(f_abs)}, + ret_any, f_abs}, {"acos", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_acos)}, + ret_float, f_acos}, {"add", 2, 2, FEARG_1, arg2_listblob_item, ret_first_arg, f_add}, {"and", 2, 2, FEARG_1, arg2_number, @@ -1576,7 +1571,7 @@ static funcentry_T global_functions[] = {"argv", 0, 2, 0, arg2_number, ret_argv, f_argv}, {"asin", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_asin)}, + ret_float, f_asin}, {"assert_beeps", 1, 1, FEARG_1, arg1_string, ret_number_bool, f_assert_beeps}, {"assert_equal", 2, 3, FEARG_2, NULL, @@ -1604,9 +1599,9 @@ static funcentry_T global_functions[] = {"assert_true", 1, 2, FEARG_1, NULL, ret_number_bool, f_assert_true}, {"atan", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_atan)}, + ret_float, f_atan}, {"atan2", 2, 2, FEARG_1, arg2_float_or_nr, - ret_float, FLOAT_FUNC(f_atan2)}, + ret_float, f_atan2}, {"autocmd_add", 1, 1, FEARG_1, arg1_list_any, ret_number_bool, f_autocmd_add}, {"autocmd_delete", 1, 1, FEARG_1, arg1_list_any, @@ -1676,7 +1671,7 @@ static funcentry_T global_functions[] = {"call", 2, 3, FEARG_1, arg3_any_list_dict, ret_any, f_call}, {"ceil", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_ceil)}, + ret_float, f_ceil}, {"ch_canread", 1, 1, FEARG_1, arg1_chan_or_job, ret_number_bool, JOB_FUNC(f_ch_canread)}, {"ch_close", 1, 1, FEARG_1, arg1_chan_or_job, @@ -1744,9 +1739,9 @@ static funcentry_T global_functions[] = {"copy", 1, 1, FEARG_1, NULL, ret_copy, f_copy}, {"cos", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_cos)}, + ret_float, f_cos}, {"cosh", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_cosh)}, + ret_float, f_cosh}, {"count", 2, 4, FEARG_1, arg24_count, ret_number, f_count}, {"cscope_connection",0,3, 0, arg3_number_string_string, @@ -1804,7 +1799,7 @@ static funcentry_T global_functions[] = {"exists_compiled", 1, 1, FEARG_1, arg1_string, ret_number_bool, f_exists_compiled}, {"exp", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_exp)}, + ret_float, f_exp}, {"expand", 1, 3, FEARG_1, arg3_string_bool_bool, ret_any, f_expand}, {"expandcmd", 1, 2, FEARG_1, arg2_string_dict, @@ -1832,11 +1827,11 @@ static funcentry_T global_functions[] = {"flattennew", 1, 2, FEARG_1, arg2_list_any_number, ret_list_any, f_flattennew}, {"float2nr", 1, 1, FEARG_1, arg1_float_or_nr, - ret_number, FLOAT_FUNC(f_float2nr)}, + ret_number, f_float2nr}, {"floor", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_floor)}, + ret_float, f_floor}, {"fmod", 2, 2, FEARG_1, arg2_float_or_nr, - ret_float, FLOAT_FUNC(f_fmod)}, + ret_float, f_fmod}, {"fnameescape", 1, 1, FEARG_1, arg1_string, ret_string, f_fnameescape}, {"fnamemodify", 2, 2, FEARG_1, arg2_string, @@ -2088,9 +2083,9 @@ static funcentry_T global_functions[] = {"localtime", 0, 0, 0, NULL, ret_number, f_localtime}, {"log", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_log)}, + ret_float, f_log}, {"log10", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_log10)}, + ret_float, f_log10}, {"luaeval", 1, 2, FEARG_1, arg2_string_any, ret_any, #ifdef FEAT_LUA @@ -2216,7 +2211,7 @@ static funcentry_T global_functions[] = {"popup_show", 1, 1, FEARG_1, arg1_number, ret_void, PROP_FUNC(f_popup_show)}, {"pow", 2, 2, FEARG_1, arg2_float_or_nr, - ret_float, FLOAT_FUNC(f_pow)}, + ret_float, f_pow}, {"prevnonblank", 1, 1, FEARG_1, arg1_lnum, ret_number, f_prevnonblank}, {"printf", 1, 19, FEARG_2, arg119_printf, @@ -2300,7 +2295,7 @@ static funcentry_T global_functions[] = {"reltime", 0, 2, FEARG_1, arg2_list_number, ret_list_any, f_reltime}, {"reltimefloat", 1, 1, FEARG_1, arg1_list_number, - ret_float, FLOAT_FUNC(f_reltimefloat)}, + ret_float, f_reltimefloat}, {"reltimestr", 1, 1, FEARG_1, arg1_list_number, ret_string, f_reltimestr}, {"remote_expr", 2, 4, FEARG_1, arg24_remote_expr, @@ -2326,7 +2321,7 @@ static funcentry_T global_functions[] = {"reverse", 1, 1, FEARG_1, arg1_list_or_blob, ret_first_arg, f_reverse}, {"round", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_round)}, + ret_float, f_round}, {"rubyeval", 1, 1, FEARG_1, arg1_string, ret_any, #ifdef FEAT_RUBY @@ -2438,9 +2433,9 @@ static funcentry_T global_functions[] = {"simplify", 1, 1, FEARG_1, arg1_string, ret_string, f_simplify}, {"sin", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_sin)}, + ret_float, f_sin}, {"sinh", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_sinh)}, + ret_float, f_sinh}, {"slice", 2, 3, FEARG_1, arg23_slice, ret_slice, f_slice}, {"sort", 1, 3, FEARG_1, arg13_sortuniq, @@ -2462,13 +2457,13 @@ static funcentry_T global_functions[] = {"split", 1, 3, FEARG_1, arg3_string_string_bool, ret_list_string, f_split}, {"sqrt", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_sqrt)}, + ret_float, f_sqrt}, {"srand", 0, 1, FEARG_1, arg1_number, ret_list_number, f_srand}, {"state", 0, 1, FEARG_1, arg1_string, ret_string, f_state}, {"str2float", 1, 2, FEARG_1, arg2_string_bool, - ret_float, FLOAT_FUNC(f_str2float)}, + ret_float, f_str2float}, {"str2list", 1, 2, FEARG_1, arg2_string_bool, ret_list_number, f_str2list}, {"str2nr", 1, 3, FEARG_1, arg3_string_number_bool, @@ -2546,9 +2541,9 @@ static funcentry_T global_functions[] = {"taglist", 1, 2, FEARG_1, arg2_string, ret_list_dict_any, f_taglist}, {"tan", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_tan)}, + ret_float, f_tan}, {"tanh", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_tanh)}, + ret_float, f_tanh}, {"tempname", 0, 0, 0, NULL, ret_string, f_tempname}, {"term_dumpdiff", 2, 3, FEARG_1, arg3_string_string_dict, @@ -2680,7 +2675,7 @@ static funcentry_T global_functions[] = {"trim", 1, 3, FEARG_1, arg3_string_string_number, ret_string, f_trim}, {"trunc", 1, 1, FEARG_1, arg1_float_or_nr, - ret_float, FLOAT_FUNC(f_trunc)}, + ret_float, f_trunc}, {"type", 1, 1, FEARG_1, NULL, ret_number, f_type}, {"typename", 1, 1, FEARG_1, NULL, @@ -3670,10 +3665,8 @@ f_empty(typval_T *argvars, typval_T *rettv) n = argvars[0].vval.v_number == 0; break; case VAR_FLOAT: -#ifdef FEAT_FLOAT n = argvars[0].vval.v_float == 0.0; break; -#endif case VAR_LIST: n = argvars[0].vval.v_list == NULL || argvars[0].vval.v_list->lv_len == 0; @@ -5644,13 +5637,7 @@ f_has(typval_T *argvars, typval_T *rettv) 0 #endif }, - {"float", -#ifdef FEAT_FLOAT - 1 -#else - 0 -#endif - }, + {"float", 1}, {"folding", #ifdef FEAT_FOLDING 1 diff --git a/src/ex_cmds.c b/src/ex_cmds.c index ebcd441c81..9fdbe955e0 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -14,9 +14,7 @@ #include "vim.h" #include "version.h" -#ifdef FEAT_FLOAT -# include -#endif +#include static int linelen(int *has_tab); static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, int do_in, int do_out); @@ -275,9 +273,7 @@ static int sort_lc; // sort using locale static int sort_ic; // ignore case static int sort_nr; // sort on number static int sort_rx; // sort on regex instead of skipping it -#ifdef FEAT_FLOAT static int sort_flt; // sort on floating number -#endif static int sort_abort; // flag to indicate if sorting has been interrupted @@ -296,9 +292,7 @@ typedef struct varnumber_T value; // value if sorting by integer int is_number; // TRUE when line contains a number } num; -#ifdef FEAT_FLOAT float_T value_flt; // value if sorting by float -#endif } st_u; } sorti_T; @@ -334,11 +328,9 @@ sort_compare(const void *s1, const void *s2) result = l1.st_u.num.value == l2.st_u.num.value ? 0 : l1.st_u.num.value > l2.st_u.num.value ? 1 : -1; } -#ifdef FEAT_FLOAT else if (sort_flt) result = l1.st_u.value_flt == l2.st_u.value_flt ? 0 : l1.st_u.value_flt > l2.st_u.value_flt ? 1 : -1; -#endif else { // We need to copy one line into "sortbuf1", because there is no @@ -399,9 +391,7 @@ ex_sort(exarg_T *eap) goto sortend; sort_abort = sort_ic = sort_lc = sort_rx = sort_nr = 0; -#ifdef FEAT_FLOAT sort_flt = 0; -#endif for (p = eap->arg; *p != NUL; ++p) { @@ -418,13 +408,11 @@ ex_sort(exarg_T *eap) sort_nr = 1; ++format_found; } -#ifdef FEAT_FLOAT else if (*p == 'f') { sort_flt = 1; ++format_found; } -#endif else if (*p == 'b') { sort_what = STR2NR_BIN + STR2NR_FORCE; @@ -521,11 +509,7 @@ ex_sort(exarg_T *eap) if (regmatch.regprog != NULL) end_col = 0; - if (sort_nr -#ifdef FEAT_FLOAT - || sort_flt -#endif - ) + if (sort_nr || sort_flt) { // Make sure vim_str2nr doesn't read any digits past the end // of the match, by temporarily terminating the string there @@ -558,7 +542,6 @@ ex_sort(exarg_T *eap) NULL, 0, FALSE); } } -#ifdef FEAT_FLOAT else { s = skipwhite(p); @@ -572,7 +555,6 @@ ex_sort(exarg_T *eap) nrs[lnum - eap->line1].st_u.value_flt = strtod((char *)s, NULL); } -#endif *s2 = c; } else diff --git a/src/feature.h b/src/feature.h index 26296d337e..5eacd5e953 100644 --- a/src/feature.h +++ b/src/feature.h @@ -121,6 +121,7 @@ * +wildignore 'wildignore' and 'backupskip' options * +wildmenu 'wildmenu' option * +builtin_terms all builtin termcap entries included + * +float Floating point variables. * * Obsolete: * +tag_old_static Old style static tags: "file:tag file ..". @@ -251,13 +252,9 @@ /* * +eval Built-in script language and expression evaluation, * ":let", ":if", etc. - * +float Floating point variables. */ #ifdef FEAT_NORMAL # define FEAT_EVAL -# if defined(HAVE_FLOAT_FUNCS) || defined(MSWIN) || defined(MACOS_X) -# define FEAT_FLOAT -# endif #endif #ifdef FEAT_EVAL diff --git a/src/float.c b/src/float.c index aa7d697c6f..04bb8a121e 100644 --- a/src/float.c +++ b/src/float.c @@ -14,7 +14,7 @@ #include "vim.h" -#if (defined(FEAT_EVAL) && defined(FEAT_FLOAT)) || defined(PROTO) +#if defined(FEAT_EVAL) || defined(PROTO) #ifdef VMS # include diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 21a6ed1090..3cdf22260a 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -3598,7 +3598,7 @@ gui_mch_init(void) { gnome_program_init(VIMPACKAGE, VIM_VERSION_SHORT, LIBGNOMEUI_MODULE, gui_argc, gui_argv, NULL); -# if defined(FEAT_FLOAT) && defined(LC_NUMERIC) +# if defined(LC_NUMERIC) { char *p = setlocale(LC_NUMERIC, NULL); diff --git a/src/gui_x11.c b/src/gui_x11.c index 7293ac4900..fa81875437 100644 --- a/src/gui_x11.c +++ b/src/gui_x11.c @@ -1184,7 +1184,7 @@ gui_mch_init_check(void) cmdline_options, XtNumber(cmdline_options), CARDINAL &gui_argc, gui_argv); -# if defined(FEAT_FLOAT) && defined(LC_NUMERIC) +# if defined(LC_NUMERIC) { // The call to XtOpenDisplay() may have set the locale from the // environment. Set LC_NUMERIC to "C" to make sure that strtod() uses a diff --git a/src/if_lua.c b/src/if_lua.c index 4463ac0693..4900534b4c 100644 --- a/src/if_lua.c +++ b/src/if_lua.c @@ -559,11 +559,9 @@ luaV_pushtypval(lua_State *L, typval_T *tv) case VAR_NUMBER: lua_pushinteger(L, (int) tv->vval.v_number); break; -#ifdef FEAT_FLOAT case VAR_FLOAT: lua_pushnumber(L, (lua_Number) tv->vval.v_float); break; -#endif case VAR_LIST: luaV_pushlist(L, tv->vval.v_list); break; @@ -619,7 +617,6 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv) tv->vval.v_string = vim_strsave((char_u *) lua_tostring(L, pos)); break; case LUA_TNUMBER: -#ifdef FEAT_FLOAT { const lua_Number n = lua_tonumber(L, pos); @@ -635,10 +632,6 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv) tv->vval.v_number = (varnumber_T)n; } } -#else - tv->v_type = VAR_NUMBER; - tv->vval.v_number = (varnumber_T) lua_tointeger(L, pos); -#endif break; case LUA_TFUNCTION: { diff --git a/src/if_mzsch.c b/src/if_mzsch.c index 0c100fe26a..8788fb3034 100644 --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -3009,13 +3009,11 @@ vim_to_mzscheme_impl(typval_T *vim_value, int depth, Scheme_Hash_Table *visited) result = scheme_make_integer((long)vim_value->vval.v_number); MZ_GC_CHECK(); } -# ifdef FEAT_FLOAT else if (vim_value->v_type == VAR_FLOAT) { result = scheme_make_double((double)vim_value->vval.v_float); MZ_GC_CHECK(); } -# endif else if (vim_value->v_type == VAR_LIST) { list_T *list = vim_value->vval.v_list; @@ -3208,13 +3206,11 @@ mzscheme_to_vim_impl(Scheme_Object *obj, typval_T *tv, int depth, tv->v_type = VAR_BOOL; tv->vval.v_number = SCHEME_TRUEP(obj); } -# ifdef FEAT_FLOAT else if (SCHEME_DBLP(obj)) { tv->v_type = VAR_FLOAT; tv->vval.v_float = SCHEME_DBL_VAL(obj); } -# endif else if (SCHEME_BYTE_STRINGP(obj)) { tv->v_type = VAR_STRING; diff --git a/src/if_py_both.h b/src/if_py_both.h index b7276c53db..2857cc705a 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -761,7 +761,6 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict) sprintf(buf, "%ld", (long)our_tv->vval.v_number); ret = PyString_FromString((char *)buf); } -#ifdef FEAT_FLOAT else if (our_tv->v_type == VAR_FLOAT) { char buf[NUMBUFLEN]; @@ -769,7 +768,6 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict) sprintf(buf, "%f", our_tv->vval.v_float); ret = PyString_FromString((char *)buf); } -#endif else if (our_tv->v_type == VAR_LIST) { list_T *list = our_tv->vval.v_list; @@ -6329,13 +6327,11 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict) } else if (PyDict_Check(obj)) return convert_dl(obj, tv, pydict_to_tv, lookup_dict); -#ifdef FEAT_FLOAT else if (PyFloat_Check(obj)) { tv->v_type = VAR_FLOAT; tv->vval.v_float = (float_T) PyFloat_AsDouble(obj); } -#endif else if (PyObject_HasAttrString(obj, "keys")) return convert_dl(obj, tv, pymap_to_tv, lookup_dict); // PyObject_GetIter can create built-in iterator for any sequence object @@ -6388,9 +6384,7 @@ ConvertToPyObject(typval_T *tv) case VAR_NUMBER: return PyLong_FromLong((long) tv->vval.v_number); case VAR_FLOAT: -#ifdef FEAT_FLOAT return PyFloat_FromDouble((double) tv->vval.v_float); -#endif case VAR_LIST: return NEW_LIST(tv->vval.v_list); case VAR_DICT: diff --git a/src/if_ruby.c b/src/if_ruby.c index 3a92fa8cf9..7632cbf054 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -1221,12 +1221,10 @@ vim_to_ruby(typval_T *tv) { result = INT2NUM(tv->vval.v_number); } -# ifdef FEAT_FLOAT else if (tv->v_type == VAR_FLOAT) { result = rb_float_new(tv->vval.v_float); } -# endif else if (tv->v_type == VAR_LIST) { list_T *list = tv->vval.v_list; @@ -1932,12 +1930,10 @@ ruby_convert_to_vim_value(VALUE val, typval_T *rettv) rettv->v_type = VAR_NUMBER; rettv->vval.v_number = (varnumber_T)NUM2LONG(val); break; -#ifdef FEAT_FLOAT case T_FLOAT: rettv->v_type = VAR_FLOAT; rettv->vval.v_float = (float_T)NUM2DBL(val); break; -#endif default: val = rb_obj_as_string(val); // FALLTHROUGH diff --git a/src/json.c b/src/json.c index 47bf9904a3..80120acb30 100644 --- a/src/json.c +++ b/src/json.c @@ -409,8 +409,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options) break; case VAR_FLOAT: -#ifdef FEAT_FLOAT -# if defined(HAVE_MATH_H) +#if defined(HAVE_MATH_H) if (isnan(val->vval.v_float)) ga_concat(gap, (char_u *)"NaN"); else if (isinf(val->vval.v_float)) @@ -421,14 +420,13 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options) ga_concat(gap, (char_u *)"Infinity"); } else -# endif +#endif { vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", val->vval.v_float); ga_concat(gap, numbuf); } break; -#endif case VAR_UNKNOWN: case VAR_ANY: case VAR_VOID: @@ -861,7 +859,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options) } } sp = skipdigits(sp); -#ifdef FEAT_FLOAT if (*sp == '.' || *sp == 'e' || *sp == 'E') { if (cur_item == NULL) @@ -878,7 +875,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options) } } else -#endif { varnumber_T nr; @@ -934,7 +930,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options) retval = OK; break; } -#ifdef FEAT_FLOAT if (STRNICMP((char *)p, "NaN", 3) == 0) { reader->js_used += 3; @@ -968,19 +963,19 @@ json_decode_item(js_read_T *reader, typval_T *res, int options) retval = OK; break; } -#endif // check for truncated name len = (int)(reader->js_end - (reader->js_buf + reader->js_used)); if ( (len < 5 && STRNICMP((char *)p, "false", len) == 0) -#ifdef FEAT_FLOAT - || (len < 9 && STRNICMP((char *)p, "-Infinity", len) == 0) - || (len < 8 && STRNICMP((char *)p, "Infinity", len) == 0) + || (len < 9 + && STRNICMP((char *)p, "-Infinity", len) == 0) + || (len < 8 + && STRNICMP((char *)p, "Infinity", len) == 0) || (len < 3 && STRNICMP((char *)p, "NaN", len) == 0) -#endif - || (len < 4 && (STRNICMP((char *)p, "true", len) == 0 - || STRNICMP((char *)p, "null", len) == 0))) + || (len < 4 + && (STRNICMP((char *)p, "true", len) == 0 + || STRNICMP((char *)p, "null", len) == 0))) retval = MAYBE; else @@ -998,7 +993,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options) if (top_item != NULL && top_item->jd_type == JSON_OBJECT_KEY && cur_item != NULL) { -#ifdef FEAT_FLOAT if (cur_item->v_type == VAR_FLOAT) { // cannot use a float as a key @@ -1006,7 +1000,6 @@ json_decode_item(js_read_T *reader, typval_T *res, int options) retval = FAIL; goto theend; } -#endif top_item->jd_key = tv_get_string_buf_chk(cur_item, key_buf); if (top_item->jd_key == NULL) { diff --git a/src/list.c b/src/list.c index c9697e0514..a0af50953c 100644 --- a/src/list.c +++ b/src/list.c @@ -1876,9 +1876,7 @@ typedef struct int item_compare_lc; int item_compare_numeric; int item_compare_numbers; -#ifdef FEAT_FLOAT int item_compare_float; -#endif char_u *item_compare_func; partial_T *item_compare_partial; dict_T *item_compare_selfdict; @@ -1915,7 +1913,6 @@ item_compare(const void *s1, const void *s2) return v1 == v2 ? 0 : v1 > v2 ? 1 : -1; } -#ifdef FEAT_FLOAT if (sortinfo->item_compare_float) { float_T v1 = tv_get_float(tv1); @@ -1923,7 +1920,6 @@ item_compare(const void *s1, const void *s2) return v1 == v2 ? 0 : v1 > v2 ? 1 : -1; } -#endif // tv2string() puts quotes around a string and allocates memory. Don't do // that for string variables. Use a single quote when comparing with a @@ -2160,9 +2156,7 @@ parse_sort_uniq_args(typval_T *argvars, sortinfo_T *info) info->item_compare_lc = FALSE; info->item_compare_numeric = FALSE; info->item_compare_numbers = FALSE; -#ifdef FEAT_FLOAT info->item_compare_float = FALSE; -#endif info->item_compare_func = NULL; info->item_compare_partial = NULL; info->item_compare_selfdict = NULL; @@ -2215,13 +2209,11 @@ parse_sort_uniq_args(typval_T *argvars, sortinfo_T *info) info->item_compare_func = NULL; info->item_compare_numbers = TRUE; } -#ifdef FEAT_FLOAT else if (STRCMP(info->item_compare_func, "f") == 0) { info->item_compare_func = NULL; info->item_compare_float = TRUE; } -#endif else if (STRCMP(info->item_compare_func, "i") == 0) { info->item_compare_func = NULL; diff --git a/src/locale.c b/src/locale.c index 1c72c43e4a..d0378ffb50 100644 --- a/src/locale.c +++ b/src/locale.c @@ -225,7 +225,7 @@ init_locale(void) // Tell Gtk not to change our locale settings. gtk_disable_setlocale(); # endif -# if defined(FEAT_FLOAT) && defined(LC_NUMERIC) +# if defined(LC_NUMERIC) // Make sure strtod() uses a decimal point, not a comma. setlocale(LC_NUMERIC, "C"); # endif @@ -333,7 +333,7 @@ ex_language(exarg_T *eap) # endif { loc = setlocale(what, (char *)name); -# if defined(FEAT_FLOAT) && defined(LC_NUMERIC) +# if defined(LC_NUMERIC) // Make sure strtod() uses a decimal point, not a comma. setlocale(LC_NUMERIC, "C"); # endif diff --git a/src/macros.h b/src/macros.h index aa61d900ff..16aab2e6e1 100644 --- a/src/macros.h +++ b/src/macros.h @@ -261,7 +261,7 @@ # define MESSAGE_QUEUE #endif -#if defined(FEAT_EVAL) && defined(FEAT_FLOAT) +#if defined(FEAT_EVAL) # include # if defined(HAVE_MATH_H) // for isnan() and isinf() diff --git a/src/message_test.c b/src/message_test.c index 940c1cc0b0..6f71aff920 100644 --- a/src/message_test.c +++ b/src/message_test.c @@ -211,7 +211,6 @@ test_vim_snprintf(void) assert(bsize == 0 || STRNCMP(buf, "001100", bsize_int) == 0); assert(bsize == 0 || buf[MIN(n, bsize_int)] == '\0'); -#ifdef FEAT_FLOAT n = vim_snprintf(buf, bsize, "%f", 1.234); assert(n == 8); assert(bsize == 0 || STRNCMP(buf, "1.234000", bsize_int) == 0); @@ -241,7 +240,6 @@ test_vim_snprintf(void) assert(n == 9); assert(bsize == 0 || STRNCMP(buf, "-0.000000", bsize_int) == 0); assert(bsize == 0 || buf[MIN(n, bsize_int)] == '\0'); -#endif n = vim_snprintf(buf, bsize, "%s", "漢語"); assert(n == 6); diff --git a/src/os_mac_conv.c b/src/os_mac_conv.c index 211b235313..a699ce0d93 100644 --- a/src/os_mac_conv.c +++ b/src/os_mac_conv.c @@ -585,7 +585,7 @@ mac_lang_init(void) # ifdef HAVE_LOCALE_H setlocale(LC_ALL, ""); # endif -# if defined(FEAT_FLOAT) && defined(LC_NUMERIC) +# if defined(LC_NUMERIC) // Make sure strtod() uses a decimal point, not a comma. setlocale(LC_NUMERIC, "C"); # endif diff --git a/src/os_vms_conf.h b/src/os_vms_conf.h index 8a933b6972..7de117c704 100644 --- a/src/os_vms_conf.h +++ b/src/os_vms_conf.h @@ -110,7 +110,6 @@ #define HAVE_SETENV #define HAVE_SETJMP_H #define HAVE_MATH_H -#define HAVE_FLOAT_FUNCS #define HAVE_GETTIMEOFDAY #define HAVE_PWD_H #define HAVE_NETDB_H diff --git a/src/profiler.c b/src/profiler.c index 9c9fa9dbc2..03348dff33 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -90,23 +90,21 @@ profile_msg(proftime_T *tm) return buf; } -# if defined(FEAT_FLOAT) || defined(PROTO) /* * Return a float that represents the time in "tm". */ float_T profile_float(proftime_T *tm) { -# ifdef MSWIN +# ifdef MSWIN LARGE_INTEGER fr; QueryPerformanceFrequency(&fr); return (float_T)tm->QuadPart / (float_T)fr.QuadPart; -# else +# else return (float_T)tm->tv_sec + (float_T)tm->tv_usec / 1000000.0; -# endif -} # endif +} /* * Put the time "msec" past now in "tm". @@ -173,7 +171,7 @@ profile_zero(proftime_T *tm) # endif // FEAT_PROFILE || FEAT_RELTIME -#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_FLOAT) && defined(FEAT_PROFILE) +#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_PROFILE) # if defined(HAVE_MATH_H) # include # endif diff --git a/src/session.c b/src/session.c index ddf5d21d11..b65f5ae770 100644 --- a/src/session.c +++ b/src/session.c @@ -577,7 +577,6 @@ store_session_globals(FILE *fd) } vim_free(p); } -#ifdef FEAT_FLOAT else if (this_var->di_tv.v_type == VAR_FLOAT && var_flavour(this_var->di_key) == VAR_FLAVOUR_SESSION) { @@ -594,7 +593,6 @@ store_session_globals(FILE *fd) || put_eol(fd) == FAIL) return FAIL; } -#endif } } return OK; diff --git a/src/strings.c b/src/strings.c index 55ee69ab11..3befb86eae 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1895,7 +1895,6 @@ tv_str(typval_T *tvs, int *idxp, char_u **tofree) return s; } -# ifdef FEAT_FLOAT /* * Get float argument from "idxp" entry in "tvs". First entry is 1. */ @@ -1919,11 +1918,9 @@ tv_float(typval_T *tvs, int *idxp) } return f; } -# endif #endif -#ifdef FEAT_FLOAT /* * Return the representation of infinity for printf() function: * "-inf", "inf", "+inf", " inf", "-INF", "INF", "+INF" or " INF". @@ -1945,7 +1942,6 @@ infinity_str(int positive, idx += 4; return table[idx]; } -#endif /* * This code was included to provide a portable vsnprintf() and snprintf(). @@ -2079,13 +2075,9 @@ vim_vsnprintf_typval( char length_modifier = '\0'; // temporary buffer for simple numeric->string conversion -# if defined(FEAT_FLOAT) -# define TMP_LEN 350 // On my system 1e308 is the biggest number possible. +# define TMP_LEN 350 // On my system 1e308 is the biggest number possible. // That sounds reasonable to use as the maximum // printable. -# else -# define TMP_LEN 66 -# endif char tmp[TMP_LEN]; // string address in case of string argument @@ -2637,7 +2629,6 @@ vim_vsnprintf_typval( break; } -# ifdef FEAT_FLOAT case 'f': case 'F': case 'e': @@ -2653,9 +2644,9 @@ vim_vsnprintf_typval( int remove_trailing_zeroes = FALSE; f = -# if defined(FEAT_EVAL) +# if defined(FEAT_EVAL) tvs != NULL ? tv_float(tvs, &arg_idx) : -# endif +# endif va_arg(ap, double); abs_f = f < 0 ? -f : f; @@ -2672,11 +2663,11 @@ vim_vsnprintf_typval( } if ((fmt_spec == 'f' || fmt_spec == 'F') && -# ifdef VAX +# ifdef VAX abs_f > 1.0e38 -# else +# else abs_f > 1.0e307 -# endif +# endif ) { // Avoid a buffer overflow @@ -2801,7 +2792,6 @@ vim_vsnprintf_typval( str_arg = tmp; break; } -# endif default: // unrecognized conversion specifier, keep format string diff --git a/src/structs.h b/src/structs.h index f7901ebe88..c532dde443 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1460,9 +1460,7 @@ typedef struct union { varnumber_T v_number; // number value -#ifdef FEAT_FLOAT float_T v_float; // floating number value -#endif char_u *v_string; // string value (can be NULL!) list_T *v_list; // list value (can be NULL!) dict_T *v_dict; // dict value (can be NULL!) diff --git a/src/syntax.c b/src/syntax.c index c68e001be9..ea8d541de0 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -6694,7 +6694,7 @@ syntime_report(void) { int idx; synpat_T *spp; -# if defined(FEAT_RELTIME) && defined(FEAT_FLOAT) +# if defined(FEAT_RELTIME) proftime_T tm; # endif int len; @@ -6724,7 +6724,7 @@ syntime_report(void) p->match = spp->sp_time.match; total_count += spp->sp_time.count; p->slowest = spp->sp_time.slowest; -# if defined(FEAT_RELTIME) && defined(FEAT_FLOAT) +# if defined(FEAT_RELTIME) profile_divide(&spp->sp_time.total, spp->sp_time.count, &tm); p->average = tm; # endif @@ -6758,10 +6758,8 @@ syntime_report(void) msg_puts(profile_msg(&p->slowest)); msg_puts(" "); msg_advance(38); -# ifdef FEAT_FLOAT msg_puts(profile_msg(&p->average)); msg_puts(" "); -# endif msg_advance(50); msg_outtrans(highlight_group_name(p->id - 1)); msg_puts(" "); diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index 68c3dd3eff..1946282f8a 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -283,11 +283,11 @@ func RunTheTest(test) if has('reltime') let message ..= repeat(' ', 50 - len(message)) let time = reltime(func_start) - if has('float') && reltimefloat(time) > 0.1 + if reltimefloat(time) > 0.1 let message = s:t_bold .. message endif let message ..= ' in ' .. reltimestr(time) .. ' seconds' - if has('float') && reltimefloat(time) > 0.1 + if reltimefloat(time) > 0.1 let message ..= s:t_normal endif endif diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim index 5d4abaa8a9..b666c011e3 100644 --- a/src/testdir/test_assert.vim +++ b/src/testdir/test_assert.vim @@ -352,21 +352,19 @@ func Test_assert_inrange() call assert_fails('call assert_inrange(1, 1)', 'E119:') - if has('float') - call assert_equal(0, assert_inrange(7.0, 7, 7)) - call assert_equal(0, assert_inrange(7, 7.0, 7)) - call assert_equal(0, assert_inrange(7, 7, 7.0)) - call assert_equal(0, assert_inrange(5, 7, 5.0)) - call assert_equal(0, assert_inrange(5, 7, 6.0)) - call assert_equal(0, assert_inrange(5, 7, 7.0)) - - call assert_equal(1, assert_inrange(5, 7, 4.0)) - call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0]) - call remove(v:errors, 0) - call assert_equal(1, assert_inrange(5, 7, 8.0)) - call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0]) - call remove(v:errors, 0) - endif + call assert_equal(0, assert_inrange(7.0, 7, 7)) + call assert_equal(0, assert_inrange(7, 7.0, 7)) + call assert_equal(0, assert_inrange(7, 7, 7.0)) + call assert_equal(0, assert_inrange(5, 7, 5.0)) + call assert_equal(0, assert_inrange(5, 7, 6.0)) + call assert_equal(0, assert_inrange(5, 7, 7.0)) + + call assert_equal(1, assert_inrange(5, 7, 4.0)) + call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0]) + call remove(v:errors, 0) + call assert_equal(1, assert_inrange(5, 7, 8.0)) + call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0]) + call remove(v:errors, 0) endfunc func Test_assert_with_msg() diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim index b0239fd610..ce8c3d09f7 100644 --- a/src/testdir/test_blob.vim +++ b/src/testdir/test_blob.vim @@ -669,9 +669,7 @@ func Test_blob_lock() endfunc func Test_blob_sort() - if has('float') - call v9.CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') - endif + call v9.CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') call v9.CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') endfunc diff --git a/src/testdir/test_cscope.vim b/src/testdir/test_cscope.vim index d70103ca2d..d29949c4e4 100644 --- a/src/testdir/test_cscope.vim +++ b/src/testdir/test_cscope.vim @@ -122,25 +122,23 @@ func Test_cscopeWithCscopeConnections() call assert_fails('cs find', 'E560:') call assert_fails('cs find x', 'E560:') - if has('float') - " Test: Find places where this symbol is assigned a value - " this needs a cscope >= 15.8 - " unfortunately, Travis has cscope version 15.7 - let cscope_version = systemlist('cscope --version')[0] - let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) - if cs_version >= 15.8 - for cmd in ['cs find a item', 'cs find 9 item'] - let a = execute(cmd) - call assert_equal(['', '(1 of 4): <> item = LALLOC_CLEAR_ONE(mf_hashitem_T);'], split(a, '\n', 1)) - call assert_equal(' item = LALLOC_CLEAR_ONE(mf_hashitem_T);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) - endfor - endif + " Test: Find places where this symbol is assigned a value + " this needs a cscope >= 15.8 + " unfortunately, Travis has cscope version 15.7 + let cscope_version = systemlist('cscope --version')[0] + let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) + if cs_version >= 15.8 + for cmd in ['cs find a item', 'cs find 9 item'] + let a = execute(cmd) + call assert_equal(['', '(1 of 4): <> item = LALLOC_CLEAR_ONE(mf_hashitem_T);'], split(a, '\n', 1)) + call assert_equal(' item = LALLOC_CLEAR_ONE(mf_hashitem_T);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + endfor endif " Test: leading whitespace is not removed for cscope find text diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim index 7d8421b725..33ab45fcd4 100644 --- a/src/testdir/test_eval_stuff.vim +++ b/src/testdir/test_eval_stuff.vim @@ -240,11 +240,9 @@ func Test_string_concatenation() let a..=b call assert_equal('ab', a) - if has('float') - let a = 'A' - let b = 1.234 - call assert_equal('A1.234', a .. b) - endif + let a = 'A' + let b = 1.234 + call assert_equal('A1.234', a .. b) endfunc " Test fix for issue #4507 @@ -266,10 +264,8 @@ func Test_string_concat_scriptversion2() call assert_fails('let a .= b', 'E985:') call assert_fails('let vers = 1.2.3', 'E488:') - if has('float') - let f = .5 - call assert_equal(0.5, f) - endif + let f = .5 + call assert_equal(0.5, f) endfunc scriptversion 1 @@ -283,9 +279,7 @@ func Test_string_concat_scriptversion1() let vers = 1.2.3 call assert_equal('123', vers) - if has('float') - call assert_fails('let f = .5', 'E15:') - endif + call assert_fails('let f = .5', 'E15:') endfunc scriptversion 3 diff --git a/src/testdir/test_execute_func.vim b/src/testdir/test_execute_func.vim index 3a8580e98d..b25f211f8b 100644 --- a/src/testdir/test_execute_func.vim +++ b/src/testdir/test_execute_func.vim @@ -38,11 +38,9 @@ func Test_execute_string() call assert_equal("\nsomething", execute('echo "something"', 'silent')) call assert_equal("\nsomething", execute('echo "something"', 'silent!')) call assert_equal("", execute('burp', 'silent!')) - if has('float') - call assert_fails('call execute(3.4)', 'E492:') - call assert_equal("\nx", execute("echo \"x\"", 3.4)) - call v9.CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1174:']) - endif + call assert_fails('call execute(3.4)', 'E492:') + call assert_equal("\nx", execute("echo \"x\"", 3.4)) + call v9.CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1174:']) endfunc func Test_execute_list() diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 3cd2a0d0da..8e2345d7f4 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -77,9 +77,7 @@ func Test_op_falsy() call assert_equal(0z00, 0z00 ?? 456) call assert_equal([1], [1] ?? 456) call assert_equal({'one': 1}, {'one': 1} ?? 456) - if has('float') - call assert_equal(0.1, 0.1 ?? 456) - endif + call assert_equal(0.1, 0.1 ?? 456) call assert_equal(456, v:false ?? 456) call assert_equal(456, 0 ?? 456) @@ -87,9 +85,7 @@ func Test_op_falsy() call assert_equal(456, 0z ?? 456) call assert_equal(456, [] ?? 456) call assert_equal(456, {} ?? 456) - if has('float') - call assert_equal(456, 0.0 ?? 456) - endif + call assert_equal(456, 0.0 ?? 456) END call v9.CheckLegacyAndVim9Success(lines) endfunc @@ -200,10 +196,8 @@ func Test_compare_with_null() call assert_false(s:value == v:null) let s:value = 0 call assert_true(s:value == v:null) - if has('float') - let s:value = 0.0 - call assert_true(s:value == v:null) - endif + let s:value = 0.0 + call assert_true(s:value == v:null) let s:value = '' call assert_false(s:value == v:null) let s:value = 0z @@ -467,116 +461,114 @@ func Test_printf_misc() endfunc func Test_printf_float() - if has('float') - let lines =<< trim END - call assert_equal('1.000000', printf('%f', 1)) - call assert_equal('1.230000', printf('%f', 1.23)) - call assert_equal('1.230000', printf('%F', 1.23)) - call assert_equal('9999999.9', printf('%g', 9999999.9)) - call assert_equal('9999999.9', printf('%G', 9999999.9)) - call assert_equal('1.00000001e7', printf('%.8g', 10000000.1)) - call assert_equal('1.00000001E7', printf('%.8G', 10000000.1)) - call assert_equal('1.230000e+00', printf('%e', 1.23)) - call assert_equal('1.230000E+00', printf('%E', 1.23)) - call assert_equal('1.200000e-02', printf('%e', 0.012)) - call assert_equal('-1.200000e-02', printf('%e', -0.012)) - call assert_equal('0.33', printf('%.2f', 1.0 / 3.0)) - call assert_equal(' 0.33', printf('%6.2f', 1.0 / 3.0)) - call assert_equal(' -0.33', printf('%6.2f', -1.0 / 3.0)) - call assert_equal('000.33', printf('%06.2f', 1.0 / 3.0)) - call assert_equal('-00.33', printf('%06.2f', -1.0 / 3.0)) - call assert_equal('-00.33', printf('%+06.2f', -1.0 / 3.0)) - call assert_equal('+00.33', printf('%+06.2f', 1.0 / 3.0)) - call assert_equal(' 00.33', printf('% 06.2f', 1.0 / 3.0)) - call assert_equal('000.33', printf('%06.2g', 1.0 / 3.0)) - call assert_equal('-00.33', printf('%06.2g', -1.0 / 3.0)) - call assert_equal('0.33', printf('%3.2f', 1.0 / 3.0)) - call assert_equal('003.33e-01', printf('%010.2e', 1.0 / 3.0)) - call assert_equal(' 03.33e-01', printf('% 010.2e', 1.0 / 3.0)) - call assert_equal('+03.33e-01', printf('%+010.2e', 1.0 / 3.0)) - call assert_equal('-03.33e-01', printf('%010.2e', -1.0 / 3.0)) - - #" When precision is 0, the dot should be omitted. - call assert_equal(' 2', printf('%3.f', 7.0 / 3.0)) - call assert_equal(' 2', printf('%3.g', 7.0 / 3.0)) - call assert_equal(' 2e+00', printf('%7.e', 7.0 / 3.0)) - - #" Float zero can be signed. - call assert_equal('+0.000000', printf('%+f', 0.0)) - call assert_equal('0.000000', printf('%f', 1.0 / (1.0 / 0.0))) - call assert_equal('-0.000000', printf('%f', 1.0 / (-1.0 / 0.0))) - call assert_equal('0.0', printf('%s', 1.0 / (1.0 / 0.0))) - call assert_equal('-0.0', printf('%s', 1.0 / (-1.0 / 0.0))) - call assert_equal('0.0', printf('%S', 1.0 / (1.0 / 0.0))) - call assert_equal('-0.0', printf('%S', 1.0 / (-1.0 / 0.0))) - - #" Float infinity can be signed. - call assert_equal('inf', printf('%f', 1.0 / 0.0)) - call assert_equal('-inf', printf('%f', -1.0 / 0.0)) - call assert_equal('inf', printf('%g', 1.0 / 0.0)) - call assert_equal('-inf', printf('%g', -1.0 / 0.0)) - call assert_equal('inf', printf('%e', 1.0 / 0.0)) - call assert_equal('-inf', printf('%e', -1.0 / 0.0)) - call assert_equal('INF', printf('%F', 1.0 / 0.0)) - call assert_equal('-INF', printf('%F', -1.0 / 0.0)) - call assert_equal('INF', printf('%E', 1.0 / 0.0)) - call assert_equal('-INF', printf('%E', -1.0 / 0.0)) - call assert_equal('INF', printf('%E', 1.0 / 0.0)) - call assert_equal('-INF', printf('%G', -1.0 / 0.0)) - call assert_equal('+inf', printf('%+f', 1.0 / 0.0)) - call assert_equal('-inf', printf('%+f', -1.0 / 0.0)) - call assert_equal(' inf', printf('% f', 1.0 / 0.0)) - call assert_equal(' inf', printf('%6f', 1.0 / 0.0)) - call assert_equal(' -inf', printf('%6f', -1.0 / 0.0)) - call assert_equal(' inf', printf('%6g', 1.0 / 0.0)) - call assert_equal(' -inf', printf('%6g', -1.0 / 0.0)) - call assert_equal(' +inf', printf('%+6f', 1.0 / 0.0)) - call assert_equal(' inf', printf('% 6f', 1.0 / 0.0)) - call assert_equal(' +inf', printf('%+06f', 1.0 / 0.0)) - call assert_equal('inf ', printf('%-6f', 1.0 / 0.0)) - call assert_equal('-inf ', printf('%-6f', -1.0 / 0.0)) - call assert_equal('+inf ', printf('%-+6f', 1.0 / 0.0)) - call assert_equal(' inf ', printf('%- 6f', 1.0 / 0.0)) - call assert_equal('-INF ', printf('%-6F', -1.0 / 0.0)) - call assert_equal('+INF ', printf('%-+6F', 1.0 / 0.0)) - call assert_equal(' INF ', printf('%- 6F', 1.0 / 0.0)) - call assert_equal('INF ', printf('%-6G', 1.0 / 0.0)) - call assert_equal('-INF ', printf('%-6G', -1.0 / 0.0)) - call assert_equal('INF ', printf('%-6E', 1.0 / 0.0)) - call assert_equal('-INF ', printf('%-6E', -1.0 / 0.0)) - call assert_equal('inf', printf('%s', 1.0 / 0.0)) - call assert_equal('-inf', printf('%s', -1.0 / 0.0)) - - #" Test special case where max precision is truncated at 340. - call assert_equal('1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.330f', 1.0)) - call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.340f', 1.0)) - call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.350f', 1.0)) - - #" Float nan (not a number) has no sign. - call assert_equal('nan', printf('%f', sqrt(-1.0))) - call assert_equal('nan', printf('%f', 0.0 / 0.0)) - call assert_equal('nan', printf('%f', -0.0 / 0.0)) - call assert_equal('nan', printf('%g', 0.0 / 0.0)) - call assert_equal('nan', printf('%e', 0.0 / 0.0)) - call assert_equal('NAN', printf('%F', 0.0 / 0.0)) - call assert_equal('NAN', printf('%G', 0.0 / 0.0)) - call assert_equal('NAN', printf('%E', 0.0 / 0.0)) - call assert_equal('NAN', printf('%F', -0.0 / 0.0)) - call assert_equal('NAN', printf('%G', -0.0 / 0.0)) - call assert_equal('NAN', printf('%E', -0.0 / 0.0)) - call assert_equal(' nan', printf('%6f', 0.0 / 0.0)) - call assert_equal(' nan', printf('%06f', 0.0 / 0.0)) - call assert_equal('nan ', printf('%-6f', 0.0 / 0.0)) - call assert_equal('nan ', printf('%- 6f', 0.0 / 0.0)) - call assert_equal('nan', printf('%s', 0.0 / 0.0)) - call assert_equal('nan', printf('%s', -0.0 / 0.0)) - call assert_equal('nan', printf('%S', 0.0 / 0.0)) - call assert_equal('nan', printf('%S', -0.0 / 0.0)) - END - call v9.CheckLegacyAndVim9Success(lines) - - call v9.CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:') - endif + let lines =<< trim END + call assert_equal('1.000000', printf('%f', 1)) + call assert_equal('1.230000', printf('%f', 1.23)) + call assert_equal('1.230000', printf('%F', 1.23)) + call assert_equal('9999999.9', printf('%g', 9999999.9)) + call assert_equal('9999999.9', printf('%G', 9999999.9)) + call assert_equal('1.00000001e7', printf('%.8g', 10000000.1)) + call assert_equal('1.00000001E7', printf('%.8G', 10000000.1)) + call assert_equal('1.230000e+00', printf('%e', 1.23)) + call assert_equal('1.230000E+00', printf('%E', 1.23)) + call assert_equal('1.200000e-02', printf('%e', 0.012)) + call assert_equal('-1.200000e-02', printf('%e', -0.012)) + call assert_equal('0.33', printf('%.2f', 1.0 / 3.0)) + call assert_equal(' 0.33', printf('%6.2f', 1.0 / 3.0)) + call assert_equal(' -0.33', printf('%6.2f', -1.0 / 3.0)) + call assert_equal('000.33', printf('%06.2f', 1.0 / 3.0)) + call assert_equal('-00.33', printf('%06.2f', -1.0 / 3.0)) + call assert_equal('-00.33', printf('%+06.2f', -1.0 / 3.0)) + call assert_equal('+00.33', printf('%+06.2f', 1.0 / 3.0)) + call assert_equal(' 00.33', printf('% 06.2f', 1.0 / 3.0)) + call assert_equal('000.33', printf('%06.2g', 1.0 / 3.0)) + call assert_equal('-00.33', printf('%06.2g', -1.0 / 3.0)) + call assert_equal('0.33', printf('%3.2f', 1.0 / 3.0)) + call assert_equal('003.33e-01', printf('%010.2e', 1.0 / 3.0)) + call assert_equal(' 03.33e-01', printf('% 010.2e', 1.0 / 3.0)) + call assert_equal('+03.33e-01', printf('%+010.2e', 1.0 / 3.0)) + call assert_equal('-03.33e-01', printf('%010.2e', -1.0 / 3.0)) + + #" When precision is 0, the dot should be omitted. + call assert_equal(' 2', printf('%3.f', 7.0 / 3.0)) + call assert_equal(' 2', printf('%3.g', 7.0 / 3.0)) + call assert_equal(' 2e+00', printf('%7.e', 7.0 / 3.0)) + + #" Float zero can be signed. + call assert_equal('+0.000000', printf('%+f', 0.0)) + cal