0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.4683: verbose check with dict_find() to see if a key is present

Problem:    Verbose check with dict_find() to see if a key is present.
Solution:   Add dict_has_key(). (Yegappan Lakshmanan, closes #10074)
This commit is contained in:
Yegappan Lakshmanan
2022-04-04 15:16:54 +01:00
committed by Bram Moolenaar
parent 7a411a306f
commit 4829c1c9e9
18 changed files with 95 additions and 84 deletions

View File

@@ -1285,10 +1285,10 @@ test_gui_drop_files(dict_T *args UNUSED)
list_T *l;
listitem_T *li;
if (dict_find(args, (char_u *)"files", -1) == NULL
|| dict_find(args, (char_u *)"row", -1) == NULL
|| dict_find(args, (char_u *)"col", -1) == NULL
|| dict_find(args, (char_u *)"modifiers", -1) == NULL)
if (!dict_has_key(args, "files")
|| !dict_has_key(args, "row")
|| !dict_has_key(args, "col")
|| !dict_has_key(args, "modifiers"))
return FALSE;
(void)dict_get_tv(args, (char_u *)"files", &t);
@@ -1341,10 +1341,10 @@ test_gui_find_repl(dict_T *args)
int forward;
int retval;
if (dict_find(args, (char_u *)"find_text", -1) == NULL
|| dict_find(args, (char_u *)"repl_text", -1) == NULL
|| dict_find(args, (char_u *)"flags", -1) == NULL
|| dict_find(args, (char_u *)"forward", -1) == NULL)
if (!dict_has_key(args, "find_text")
|| !dict_has_key(args, "repl_text")
|| !dict_has_key(args, "flags")
|| !dict_has_key(args, "forward"))
return FALSE;
find_text = dict_get_string(args, (char_u *)"find_text", TRUE);
@@ -1370,16 +1370,16 @@ test_gui_mouse_event(dict_T *args)
int_u mods;
int move;
if (dict_find(args, (char_u *)"row", -1) == NULL
|| dict_find(args, (char_u *)"col", -1) == NULL)
if (!dict_has_key(args, "row")
|| !dict_has_key(args, "col"))
return FALSE;
// Note: "move" is optional, requires fewer arguments
move = (int)dict_get_bool(args, (char_u *)"move", FALSE);
if (!move && (dict_find(args, (char_u *)"button", -1) == NULL
|| dict_find(args, (char_u *)"multiclick", -1) == NULL
|| dict_find(args, (char_u *)"modifiers", -1) == NULL))
if (!move && (!dict_has_key(args, "button")
|| !dict_has_key(args, "multiclick")
|| !dict_has_key(args, "modifiers")))
return FALSE;
row = (int)dict_get_number(args, (char_u *)"row");
@@ -1408,9 +1408,9 @@ test_gui_scrollbar(dict_T *args)
int dragging;
scrollbar_T *sb = NULL;
if (dict_find(args, (char_u *)"which", -1) == NULL
|| dict_find(args, (char_u *)"value", -1) == NULL
|| dict_find(args, (char_u *)"dragging", -1) == NULL)
if (!dict_has_key(args, "which")
|| !dict_has_key(args, "value")
|| !dict_has_key(args, "dragging"))
return FALSE;
which = dict_get_string(args, (char_u *)"which", FALSE);
@@ -1443,7 +1443,7 @@ test_gui_tabline_event(dict_T *args UNUSED)
# ifdef FEAT_GUI_TABLINE
int tabnr;
if (dict_find(args, (char_u *)"tabnr", -1) == NULL)
if (!dict_has_key(args, "tabnr"))
return FALSE;
tabnr = (int)dict_get_number(args, (char_u *)"tabnr");
@@ -1461,8 +1461,8 @@ test_gui_tabmenu_event(dict_T *args UNUSED)
int tabnr;
int item;
if (dict_find(args, (char_u *)"tabnr", -1) == NULL
|| dict_find(args, (char_u *)"item", -1) == NULL)
if (!dict_has_key(args, "tabnr")
|| !dict_has_key(args, "item"))
return FALSE;
tabnr = (int)dict_get_number(args, (char_u *)"tabnr");