diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-09-17 11:05:36 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-09-17 11:07:35 +0800 |
commit | a1f0f0b2bc19f29948c3b9e6c71f3a5e80eaceea (patch) | |
tree | 14f4fe727caf2b265251af2377633b6bc491e1c3 /src/nvim/eval.c | |
parent | ac0fda2e46708f474a810e16407341c9f7b47dfe (diff) | |
download | rneovim-a1f0f0b2bc19f29948c3b9e6c71f3a5e80eaceea.tar.gz rneovim-a1f0f0b2bc19f29948c3b9e6c71f3a5e80eaceea.tar.bz2 rneovim-a1f0f0b2bc19f29948c3b9e6c71f3a5e80eaceea.zip |
vim-patch:9.0.1633: duplicate code for converting float to string
Problem: Duplicate code for converting float to string.
Solution: Use tv_get_string(). (closes vim/vim#12521)
https://github.com/vim/vim/commit/19dfa276c37dcf657922c6f9b48cf2954191e8b6
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index fed5b01538..ec90803884 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -949,8 +949,7 @@ int skip_expr(char **pp, evalarg_T *const evalarg) /// Convert "tv" to a string. /// -/// @param convert when true convert a List into a sequence of lines and convert -/// a Float to a String. +/// @param convert when true convert a List into a sequence of lines. /// /// @return an allocated string. static char *typval2string(typval_T *tv, bool convert) @@ -967,20 +966,14 @@ static char *typval2string(typval_T *tv, bool convert) ga_append(&ga, NUL); return (char *)ga.ga_data; } - if (convert && tv->v_type == VAR_FLOAT) { - char numbuf[NUMBUFLEN]; - vim_snprintf(numbuf, NUMBUFLEN, "%g", tv->vval.v_float); - return xstrdup(numbuf); - } return xstrdup(tv_get_string(tv)); } /// Top level evaluation function, returning a string. /// -/// @param convert when true convert a List into a sequence of lines and convert -/// a Float to a String. +/// @param convert when true convert a List into a sequence of lines. /// -/// @return pointer to allocated memory, or NULL for failure. +/// @return pointer to allocated memory, or NULL for failure. char *eval_to_string(char *arg, bool convert) { typval_T tv; |