mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
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)
19dfa276c3
This commit is contained in:
@@ -949,8 +949,7 @@ int skip_expr(char **pp, evalarg_T *const evalarg)
|
|||||||
|
|
||||||
/// Convert "tv" to a string.
|
/// Convert "tv" to a string.
|
||||||
///
|
///
|
||||||
/// @param convert when true convert a List into a sequence of lines and convert
|
/// @param convert when true convert a List into a sequence of lines.
|
||||||
/// a Float to a String.
|
|
||||||
///
|
///
|
||||||
/// @return an allocated string.
|
/// @return an allocated string.
|
||||||
static char *typval2string(typval_T *tv, bool convert)
|
static char *typval2string(typval_T *tv, bool convert)
|
||||||
@@ -967,20 +966,14 @@ static char *typval2string(typval_T *tv, bool convert)
|
|||||||
ga_append(&ga, NUL);
|
ga_append(&ga, NUL);
|
||||||
return (char *)ga.ga_data;
|
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));
|
return xstrdup(tv_get_string(tv));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Top level evaluation function, returning a string.
|
/// Top level evaluation function, returning a string.
|
||||||
///
|
///
|
||||||
/// @param convert when true convert a List into a sequence of lines and convert
|
/// @param convert when true convert a List into a sequence of lines.
|
||||||
/// a Float to a String.
|
|
||||||
///
|
///
|
||||||
/// @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)
|
char *eval_to_string(char *arg, bool convert)
|
||||||
{
|
{
|
||||||
typval_T tv;
|
typval_T tv;
|
||||||
|
Reference in New Issue
Block a user