1
0
forked from aniani/vim

patch 8.2.2664: Vim9: not enough function arguments checked for string

Problem:    Vim9: not enough function arguments checked for string.
Solution:   Check in balloon functions.  Refactor function arguments.
This commit is contained in:
Bram Moolenaar
2021-03-27 18:59:25 +01:00
parent 79efa2e3b3
commit 32105ae88f
7 changed files with 58 additions and 29 deletions

View File

@@ -344,12 +344,12 @@ tv_get_float(typval_T *varp)
* Give an error and return FAIL unless "tv" is a string.
*/
int
check_for_string(typval_T *tv, int arg)
check_for_string_arg(typval_T *args, int idx)
{
if (tv->v_type != VAR_STRING)
if (args[idx].v_type != VAR_STRING)
{
if (arg > 0)
semsg(_(e_string_required_for_argument_nr), arg);
if (idx >= 0)
semsg(_(e_string_required_for_argument_nr), idx + 1);
else
emsg(_(e_stringreq));
return FAIL;
@@ -358,17 +358,17 @@ check_for_string(typval_T *tv, int arg)
}
/*
* Give an error and return FAIL unless "tv" is a non-empty string.
* Give an error and return FAIL unless "args[idx]" is a non-empty string.
*/
int
check_for_nonempty_string(typval_T *tv, int arg)
check_for_nonempty_string_arg(typval_T *args, int idx)
{
if (check_for_string(tv, arg) == FAIL)
if (check_for_string_arg(args, idx) == FAIL)
return FAIL;
if (tv->vval.v_string == NULL || *tv->vval.v_string == NUL)
if (args[idx].vval.v_string == NULL || *args[idx].vval.v_string == NUL)
{
if (arg > 0)
semsg(_(e_non_empty_string_required_for_argument_nr), arg);
if (idx >= 0)
semsg(_(e_non_empty_string_required_for_argument_nr), idx + 1);
else
emsg(_(e_non_empty_string_required));
return FAIL;