Patch 8.2.2948
Problem:    Substitute() accepts a number but not a float expression.
Solution:   Also accept a float. (closes #8331)
Files:      src/typval.c, src/testdir/test_substitute.vim


*** ../vim-8.2.2947/src/typval.c        2021-06-05 20:51:34.737122348 +0200
--- src/typval.c        2021-06-06 12:25:37.847918926 +0200
***************
*** 462,469 ****
            break;
        case VAR_FLOAT:
  #ifdef FEAT_FLOAT
!           emsg(_(e_float_as_string));
!           break;
  #endif
        case VAR_STRING:
            if (varp->vval.v_string != NULL)
--- 462,474 ----
            break;
        case VAR_FLOAT:
  #ifdef FEAT_FLOAT
!           if (strict)
!           {
!               emsg(_(e_float_as_string));
!               break;
!           }
!           vim_snprintf((char *)buf, NUMBUFLEN, "%g", varp->vval.v_float);
!           return buf;
  #endif
        case VAR_STRING:
            if (varp->vval.v_string != NULL)
*** ../vim-8.2.2947/src/testdir/test_substitute.vim     2021-05-03 
20:01:40.805808533 +0200
--- src/testdir/test_substitute.vim     2021-06-06 12:29:49.415230217 +0200
***************
*** 1,6 ****
--- 1,7 ----
  " Tests for multi-line regexps with ":s".
  
  source shared.vim
+ source check.vim
  
  func Test_multiline_subst()
    enew!
***************
*** 453,458 ****
--- 454,466 ----
     call assert_fails("call substitute('123', '2', Replacer, 'g')", 'E118:')
  endfunc
  
+ func Test_substitute_float()
+   CheckFeature float
+ 
+   call assert_equal('number 1.23', substitute('number ', '$', { -> 1.23 }, 
''))
+   vim9 assert_equal('number 1.23', substitute('number ', '$', () => 1.23, ''))
+ endfunc
+ 
  " Tests for *sub-replace-special* and *sub-replace-expression* on :substitute.
  
  " Execute a list of :substitute command tests
*** ../vim-8.2.2947/src/version.c       2021-06-06 12:07:51.006887010 +0200
--- src/version.c       2021-06-06 12:33:21.634968493 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2948,
  /**/

-- 
Corn oil comes from corn and olive oil comes from olives, so where
does baby oil come from?

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202106061034.156AYDLk265787%40masaka.moolenaar.net.

Raspunde prin e-mail lui