Skip to content

Commit 19dfa27

Browse files
zeertzjqbrammool
authored andcommitted
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)
1 parent 166cd7b commit 19dfa27

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

src/eval.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,16 +570,14 @@ skip_expr_concatenate(
570570

571571
/*
572572
* Convert "tv" to a string.
573-
* When "convert" is TRUE convert a List into a sequence of lines and convert
574-
* a Float to a String.
573+
* When "convert" is TRUE convert a List into a sequence of lines.
575574
* Returns an allocated string (NULL when out of memory).
576575
*/
577576
char_u *
578577
typval2string(typval_T *tv, int convert)
579578
{
580579
garray_T ga;
581580
char_u *retval;
582-
char_u numbuf[NUMBUFLEN];
583581

584582
if (convert && tv->v_type == VAR_LIST)
585583
{
@@ -593,11 +591,6 @@ typval2string(typval_T *tv, int convert)
593591
ga_append(&ga, NUL);
594592
retval = (char_u *)ga.ga_data;
595593
}
596-
else if (convert && tv->v_type == VAR_FLOAT)
597-
{
598-
vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv->vval.v_float);
599-
retval = vim_strsave(numbuf);
600-
}
601594
else
602595
retval = vim_strsave(tv_get_string(tv));
603596
return retval;
@@ -606,8 +599,7 @@ typval2string(typval_T *tv, int convert)
606599
/*
607600
* Top level evaluation function, returning a string. Does not handle line
608601
* breaks.
609-
* When "convert" is TRUE convert a List into a sequence of lines and convert
610-
* a Float to a String.
602+
* When "convert" is TRUE convert a List into a sequence of lines.
611603
* Return pointer to allocated memory, or NULL for failure.
612604
*/
613605
char_u *

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1633,
698700
/**/
699701
1632,
700702
/**/

0 commit comments

Comments
 (0)