]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1633: duplicate code for converting float to string v9.0.1633
authorzeertzjq <zeertzjq@outlook.com>
Thu, 15 Jun 2023 09:56:41 +0000 (10:56 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 15 Jun 2023 09:56:41 +0000 (10:56 +0100)
Problem:    Duplicate code for converting float to string.
Solution:   Use tv_get_string(). (closes #12521)

src/eval.c
src/version.c

index 89141bfe3ee7eb5f5c73fd2ff7a6936a7f0adb5f..8660a25d508aa109c2b4072223d6bd01e6891a70 100644 (file)
@@ -570,8 +570,7 @@ skip_expr_concatenate(
 
 /*
  * Convert "tv" to a string.
- * When "convert" is TRUE convert a List into a sequence of lines and convert
- * a Float to a String.
+ * When "convert" is TRUE convert a List into a sequence of lines.
  * Returns an allocated string (NULL when out of memory).
  */
     char_u *
@@ -579,7 +578,6 @@ typval2string(typval_T *tv, int convert)
 {
     garray_T   ga;
     char_u     *retval;
-    char_u     numbuf[NUMBUFLEN];
 
     if (convert && tv->v_type == VAR_LIST)
     {
@@ -593,11 +591,6 @@ typval2string(typval_T *tv, int convert)
        ga_append(&ga, NUL);
        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
        retval = vim_strsave(tv_get_string(tv));
     return retval;
@@ -606,8 +599,7 @@ typval2string(typval_T *tv, int convert)
 /*
  * Top level evaluation function, returning a string.  Does not handle line
  * breaks.
- * When "convert" is TRUE convert a List into a sequence of lines and convert
- * a Float to a String.
+ * When "convert" is TRUE convert a List into a sequence of lines.
  * Return pointer to allocated memory, or NULL for failure.
  */
     char_u *
index ded2d6b90e42f95d2798154b2f8edde2cf1e131b..7a1c730263d115a8f957b91e1c36977422d630c8 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1633,
 /**/
     1632,
 /**/