diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-12 14:41:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-12 14:41:19 +0800 |
commit | 551cc3a2a3e2ee180234910cbe2ef81bd37508de (patch) | |
tree | af539897ec260bd4ac8a8db8f3544501f455a363 /src | |
parent | 3c4890d1efe7c23c0bff7bc4532f19cf03c94e04 (diff) | |
parent | 41ee7bc7dbcca4ce3d35c13450220d3bffcad15e (diff) | |
download | rneovim-551cc3a2a3e2ee180234910cbe2ef81bd37508de.tar.gz rneovim-551cc3a2a3e2ee180234910cbe2ef81bd37508de.tar.bz2 rneovim-551cc3a2a3e2ee180234910cbe2ef81bd37508de.zip |
Merge pull request #23995 from zeertzjq/vim-8.2.1524
vim-patch:8.2.{1524,2948,2949}: Float to String conversion
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval/typval.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 42e9dc8f03..a392d441cf 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -3876,7 +3876,6 @@ static const char *const str_errors[] = { [VAR_FUNC]= N_(FUNC_ERROR), [VAR_LIST]= N_("E730: Using a List as a String"), [VAR_DICT]= N_("E731: Using a Dictionary as a String"), - [VAR_FLOAT]= e_using_float_as_string, [VAR_BLOB]= N_("E976: Using a Blob as a String"), [VAR_UNKNOWN]= e_using_invalid_value_as_string, }; @@ -3899,12 +3898,12 @@ bool tv_check_str(const typval_T *const tv) case VAR_BOOL: case VAR_SPECIAL: case VAR_STRING: + case VAR_FLOAT: return true; case VAR_PARTIAL: case VAR_FUNC: case VAR_LIST: case VAR_DICT: - case VAR_FLOAT: case VAR_BLOB: case VAR_UNKNOWN: emsg(_(str_errors[tv->v_type])); @@ -4275,6 +4274,9 @@ const char *tv_get_string_buf_chk(const typval_T *const tv, char *const buf) case VAR_NUMBER: snprintf(buf, NUMBUFLEN, "%" PRIdVARNUMBER, tv->vval.v_number); // -V576 return buf; + case VAR_FLOAT: + vim_snprintf(buf, NUMBUFLEN, "%g", tv->vval.v_float); + return buf; case VAR_STRING: if (tv->vval.v_string != NULL) { return tv->vval.v_string; @@ -4290,7 +4292,6 @@ const char *tv_get_string_buf_chk(const typval_T *const tv, char *const buf) case VAR_FUNC: case VAR_LIST: case VAR_DICT: - case VAR_FLOAT: case VAR_BLOB: case VAR_UNKNOWN: emsg(_(str_errors[tv->v_type])); |