mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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 #12521)
This commit is contained in:
12
src/eval.c
12
src/eval.c
@@ -570,8 +570,7 @@ skip_expr_concatenate(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert "tv" to a string.
|
* Convert "tv" to a string.
|
||||||
* When "convert" is TRUE convert a List into a sequence of lines and convert
|
* When "convert" is TRUE convert a List into a sequence of lines.
|
||||||
* a Float to a String.
|
|
||||||
* Returns an allocated string (NULL when out of memory).
|
* Returns an allocated string (NULL when out of memory).
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
@@ -579,7 +578,6 @@ typval2string(typval_T *tv, int convert)
|
|||||||
{
|
{
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
char_u *retval;
|
char_u *retval;
|
||||||
char_u numbuf[NUMBUFLEN];
|
|
||||||
|
|
||||||
if (convert && tv->v_type == VAR_LIST)
|
if (convert && tv->v_type == VAR_LIST)
|
||||||
{
|
{
|
||||||
@@ -593,11 +591,6 @@ typval2string(typval_T *tv, int convert)
|
|||||||
ga_append(&ga, NUL);
|
ga_append(&ga, NUL);
|
||||||
retval = (char_u *)ga.ga_data;
|
retval = (char_u *)ga.ga_data;
|
||||||
}
|
}
|
||||||
else if (convert && tv->v_type == VAR_FLOAT)
|
|
||||||
{
|
|
||||||
vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv->vval.v_float);
|
|
||||||
retval = vim_strsave(numbuf);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
retval = vim_strsave(tv_get_string(tv));
|
retval = vim_strsave(tv_get_string(tv));
|
||||||
return retval;
|
return retval;
|
||||||
@@ -606,8 +599,7 @@ typval2string(typval_T *tv, int convert)
|
|||||||
/*
|
/*
|
||||||
* Top level evaluation function, returning a string. Does not handle line
|
* Top level evaluation function, returning a string. Does not handle line
|
||||||
* breaks.
|
* breaks.
|
||||||
* When "convert" is TRUE convert a List into a sequence of lines and convert
|
* When "convert" is 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_u *
|
char_u *
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1633,
|
||||||
/**/
|
/**/
|
||||||
1632,
|
1632,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user