mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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:
20
src/typval.c
20
src/typval.c
@@ -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;
|
||||
|
Reference in New Issue
Block a user