mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 01:46:29 +00:00
vim-patch:9.0.1522: some functions give two error messages
Problem: Some functions give two error messages.
Solution: Do not give a second error message. (closes vim/vim#12352)
e4098457ab
It seems that tv_get_bool() is actually not exactly the same as
tv_get_number(), so change it to a function instead.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -1502,7 +1502,8 @@ char *strrep(const char *src, const char *what, const char *rep)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void byteidx(typval_T *argvars, typval_T *rettv, int comp)
|
||||
/// Implementation of "byteidx()" and "byteidxcomp()" functions
|
||||
static void byteidx_common(typval_T *argvars, typval_T *rettv, int comp)
|
||||
{
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
@@ -1516,7 +1517,9 @@ static void byteidx(typval_T *argvars, typval_T *rettv, int comp)
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1550,13 +1553,13 @@ static void byteidx(typval_T *argvars, typval_T *rettv, int comp)
|
||||
/// "byteidx()" function
|
||||
void f_byteidx(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
byteidx(argvars, rettv, false);
|
||||
byteidx_common(argvars, rettv, false);
|
||||
}
|
||||
|
||||
/// "byteidxcomp()" function
|
||||
void f_byteidxcomp(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
byteidx(argvars, rettv, true);
|
||||
byteidx_common(argvars, rettv, true);
|
||||
}
|
||||
|
||||
/// "charidx()" function
|
||||
@@ -1770,7 +1773,9 @@ void f_strchars(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
skipcc = (int)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);
|
||||
}
|
||||
@@ -1842,7 +1847,9 @@ void f_strcharpart(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
&& argvars[3].v_type != VAR_UNKNOWN) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user