To: vim_dev@googlegroups.com Subject: Patch 9.0.1522 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1522 Problem: Some functions give two error messages. Solution: Do not give a second error message. (closes #12352) Files: src/strings.c, src/testdir/test_functions.vim, src/testdir/test_expr.vim *** ../vim-9.0.1521/src/strings.c 2023-05-06 14:08:10.139045046 +0100 --- src/strings.c 2023-05-07 18:52:03.424775413 +0100 *************** *** 1044,1051 **** remove_funccal(); } static void ! byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED) { rettv->vval.v_number = -1; --- 1044,1054 ---- remove_funccal(); } + /* + * Implementation of "byteidx()" and "byteidxcomp()" functions + */ static void ! byteidx_common(typval_T *argvars, typval_T *rettv, int comp UNUSED) { rettv->vval.v_number = -1; *************** *** 1065,1071 **** utf16idx = tv_get_bool(&argvars[2]); if (utf16idx < 0 || utf16idx > 1) { ! semsg(_(e_using_number_as_bool_nr), utf16idx); return; } } --- 1068,1075 ---- utf16idx = tv_get_bool(&argvars[2]); if (utf16idx < 0 || utf16idx > 1) { ! if (utf16idx != -1) ! semsg(_(e_using_number_as_bool_nr), utf16idx); return; } } *************** *** 1100,1106 **** void f_byteidx(typval_T *argvars, typval_T *rettv) { ! byteidx(argvars, rettv, FALSE); } /* --- 1104,1110 ---- void f_byteidx(typval_T *argvars, typval_T *rettv) { ! byteidx_common(argvars, rettv, FALSE); } /* *************** *** 1109,1115 **** void f_byteidxcomp(typval_T *argvars, typval_T *rettv) { ! byteidx(argvars, rettv, TRUE); } /* --- 1113,1119 ---- void f_byteidxcomp(typval_T *argvars, typval_T *rettv) { ! byteidx_common(argvars, rettv, TRUE); } /* *************** *** 1419,1425 **** if (argvars[1].v_type != VAR_UNKNOWN) skipcc = tv_get_bool(&argvars[1]); if (skipcc < 0 || skipcc > 1) ! semsg(_(e_using_number_as_bool_nr), skipcc); else strchar_common(argvars, rettv, skipcc); } --- 1423,1432 ---- if (argvars[1].v_type != VAR_UNKNOWN) skipcc = tv_get_bool(&argvars[1]); if (skipcc < 0 || skipcc > 1) ! { ! if (skipcc != -1) ! semsg(_(e_using_number_as_bool_nr), skipcc); ! } else strchar_common(argvars, rettv, skipcc); } *************** *** 1529,1535 **** skipcc = tv_get_bool(&argvars[3]); if (skipcc < 0 || skipcc > 1) { ! semsg(_(e_using_number_as_bool_nr), skipcc); return; } } --- 1536,1543 ---- skipcc = tv_get_bool(&argvars[3]); if (skipcc < 0 || skipcc > 1) { ! if (skipcc != -1) ! semsg(_(e_using_number_as_bool_nr), skipcc); return; } } *** ../vim-9.0.1521/src/testdir/test_functions.vim 2023-05-06 14:08:10.139045046 +0100 --- src/testdir/test_functions.vim 2023-05-07 18:48:29.070332608 +0100 *************** *** 1224,1229 **** --- 1224,1230 ---- " error cases call assert_fails("call byteidx([], 0)", 'E730:') call assert_fails("call byteidx('abc', [])", 'E745:') + call assert_fails("call byteidx('abc', 0, {})", ['E728:', 'E728:']) endfunc " Test for byteidxcomp() using a character index *************** *** 1263,1268 **** --- 1264,1270 ---- " error cases call assert_fails("call byteidxcomp([], 0)", 'E730:') call assert_fails("call byteidxcomp('abc', [])", 'E745:') + call assert_fails("call byteidxcomp('abc', 0, {})", ['E728:', 'E728:']) endfunc " Test for byteidx() using a UTF-16 index *************** *** 1623,1628 **** --- 1625,1631 ---- " error cases call assert_equal(-1, utf16idx(test_null_string(), 0, v:true, v:true)) call assert_fails('let l = utf16idx("ab", 0, v:false, [])', 'E1212:') + call assert_fails('echo strchars("", {})', ['E728:', 'E728:']) endfunc " Test for strutf16len() *** ../vim-9.0.1521/src/testdir/test_expr.vim 2023-04-30 15:29:52.553140524 +0100 --- src/testdir/test_expr.vim 2023-05-07 18:50:45.553290089 +0100 *************** *** 160,165 **** --- 160,167 ---- call assert_equal('edit', "editor"[-10 : 3]) END call v9.CheckLegacyAndVim9Success(lines) + + call assert_fails('echo strcharpart("", 0, 0, {})', ['E728:', 'E728:']) endfunc func Test_getreg_empty_list() *** ../vim-9.0.1521/src/version.c 2023-05-07 17:39:19.807633903 +0100 --- src/version.c 2023-05-07 18:09:01.512406162 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1522, /**/ -- "How is your new girlfriend?" "90-60-90 man!" "What, pale purple?" /// 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 ///