remove_funccal();
}
+/*
+ * Implementation of "byteidx()" and "byteidxcomp()" functions
+ */
static void
-byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED)
+byteidx_common(typval_T *argvars, typval_T *rettv, int comp UNUSED)
{
rettv->vval.v_number = -1;
utf16idx = tv_get_bool(&argvars[2]);
if (utf16idx < 0 || utf16idx > 1)
{
- semsg(_(e_using_number_as_bool_nr), utf16idx);
+ if (utf16idx != -1)
+ semsg(_(e_using_number_as_bool_nr), utf16idx);
return;
}
}
void
f_byteidx(typval_T *argvars, typval_T *rettv)
{
- byteidx(argvars, rettv, FALSE);
+ byteidx_common(argvars, rettv, FALSE);
}
/*
void
f_byteidxcomp(typval_T *argvars, typval_T *rettv)
{
- byteidx(argvars, rettv, TRUE);
+ byteidx_common(argvars, rettv, TRUE);
}
/*
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);
+ {
+ if (skipcc != -1)
+ semsg(_(e_using_number_as_bool_nr), skipcc);
+ }
else
strchar_common(argvars, rettv, skipcc);
}
skipcc = tv_get_bool(&argvars[3]);
if (skipcc < 0 || skipcc > 1)
{
- semsg(_(e_using_number_as_bool_nr), skipcc);
+ if (skipcc != -1)
+ semsg(_(e_using_number_as_bool_nr), skipcc);
return;
}
}
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()
" 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
" 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
" 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()