To: vim_dev@googlegroups.com Subject: Patch 8.2.1624 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1624 Problem: Vim9: cannot pass "true" to split(), str2nr() and strchars(). Solution: Use tv_get_bool_chk(). (closes #6884, closes #6885, closes #6886) Files: src/evalfunc.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.1623/src/evalfunc.c 2020-09-05 22:45:31.564748920 +0200 --- src/evalfunc.c 2020-09-06 16:08:35.437664227 +0200 *************** *** 7884,7890 **** if (pat == NULL) typeerr = TRUE; if (argvars[2].v_type != VAR_UNKNOWN) ! keepempty = (int)tv_get_number_chk(&argvars[2], &typeerr); } if (pat == NULL || *pat == NUL) pat = (char_u *)"[\\x01- ]\\+"; --- 7884,7890 ---- if (pat == NULL) typeerr = TRUE; if (argvars[2].v_type != VAR_UNKNOWN) ! keepempty = (int)tv_get_bool_chk(&argvars[2], &typeerr); } if (pat == NULL || *pat == NUL) pat = (char_u *)"[\\x01- ]\\+"; *************** *** 8030,8036 **** emsg(_(e_invarg)); return; } ! if (argvars[2].v_type != VAR_UNKNOWN && tv_get_number(&argvars[2])) what |= STR2NR_QUOTE; } --- 8030,8036 ---- emsg(_(e_invarg)); return; } ! if (argvars[2].v_type != VAR_UNKNOWN && tv_get_bool(&argvars[2])) what |= STR2NR_QUOTE; } *************** *** 8155,8166 **** f_strchars(typval_T *argvars, typval_T *rettv) { char_u *s = tv_get_string(&argvars[0]); ! int skipcc = 0; varnumber_T len = 0; int (*func_mb_ptr2char_adv)(char_u **pp); if (argvars[1].v_type != VAR_UNKNOWN) ! skipcc = (int)tv_get_number_chk(&argvars[1], NULL); if (skipcc < 0 || skipcc > 1) emsg(_(e_invarg)); else --- 8155,8166 ---- f_strchars(typval_T *argvars, typval_T *rettv) { char_u *s = tv_get_string(&argvars[0]); ! int skipcc = FALSE; varnumber_T len = 0; int (*func_mb_ptr2char_adv)(char_u **pp); if (argvars[1].v_type != VAR_UNKNOWN) ! skipcc = (int)tv_get_bool(&argvars[1]); if (skipcc < 0 || skipcc > 1) emsg(_(e_invarg)); else *** ../vim-8.2.1623/src/testdir/test_vim9_func.vim 2020-09-06 15:58:33.383154915 +0200 --- src/testdir/test_vim9_func.vim 2020-09-06 16:05:00.242204122 +0200 *************** *** 1636,1641 **** --- 1636,1653 ---- endif enddef + def Test_split() + split(' aa bb ', '\W\+', true)->assert_equal(['', 'aa', 'bb', '']) + enddef + + def Test_str2nr() + str2nr("1'000'000", 10, true)->assert_equal(1000000) + enddef + + def Test_strchars() + strchars("A\u20dd", true)->assert_equal(1) + enddef + def Test_synID() new setline(1, "text") *** ../vim-8.2.1623/src/version.c 2020-09-06 15:58:33.383154915 +0200 --- src/version.c 2020-09-06 16:01:12.102768602 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1624, /**/ -- Proofread carefully to see if you any words out. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///