mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Problem: Vim9: builtin function arguments not checked at compile time. Solution: Add more argument type specs. Check arguments to test_setmouse() and test_gui_mouse_event(). (Yegappan Lakshmanan, closes #8425)
This commit is contained in:
committed by
Bram Moolenaar
parent
831bdf8622
commit
7237cab8f1
@@ -1211,6 +1211,12 @@ f_test_scrollbar(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
void
|
||||
f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
if (argvars[0].v_type != VAR_NUMBER || (argvars[1].v_type) != VAR_NUMBER)
|
||||
{
|
||||
emsg(_(e_invarg));
|
||||
return;
|
||||
}
|
||||
|
||||
mouse_row = (time_t)tv_get_number(&argvars[0]) - 1;
|
||||
mouse_col = (time_t)tv_get_number(&argvars[1]) - 1;
|
||||
}
|
||||
@@ -1219,11 +1225,27 @@ f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
f_test_gui_mouse_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
{
|
||||
#ifdef FEAT_GUI
|
||||
int button = tv_get_number(&argvars[0]);
|
||||
int row = tv_get_number(&argvars[1]);
|
||||
int col = tv_get_number(&argvars[2]);
|
||||
int repeated_click = tv_get_number(&argvars[3]);
|
||||
int_u mods = tv_get_number(&argvars[4]);
|
||||
int button;
|
||||
int row;
|
||||
int col;
|
||||
int repeated_click;
|
||||
int_u mods;
|
||||
|
||||
if (argvars[0].v_type != VAR_NUMBER
|
||||
|| (argvars[1].v_type) != VAR_NUMBER
|
||||
|| (argvars[2].v_type) != VAR_NUMBER
|
||||
|| (argvars[3].v_type) != VAR_NUMBER
|
||||
|| (argvars[4].v_type) != VAR_NUMBER)
|
||||
{
|
||||
emsg(_(e_invarg));
|
||||
return;
|
||||
}
|
||||
|
||||
button = tv_get_number(&argvars[0]);
|
||||
row = tv_get_number(&argvars[1]);
|
||||
col = tv_get_number(&argvars[2]);
|
||||
repeated_click = tv_get_number(&argvars[3]);
|
||||
mods = tv_get_number(&argvars[4]);
|
||||
|
||||
gui_send_mouse_event(button, TEXT_X(col - 1), TEXT_Y(row - 1), repeated_click, mods);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user