To: vim_dev@googlegroups.com Subject: Patch 8.2.2948 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///