patch 9.0.0063: too many type casts for dict_get functions

Problem:    Too many type casts for dict_get functions.
Solution:   Change the key argument from "char_u *" to "char *".
This commit is contained in:
Bram Moolenaar
2022-07-23 09:52:04 +01:00
parent 5ac50de83f
commit d61efa50f8
24 changed files with 193 additions and 202 deletions

View File

@ -2833,7 +2833,7 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete)
}
}
group_name = dict_get_string(event_dict, (char_u *)"group", TRUE);
group_name = dict_get_string(event_dict, "group", TRUE);
if (group_name == NULL || *group_name == NUL)
// if the autocmd group name is not specified, then use the current
// autocmd group
@ -2868,7 +2868,7 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete)
{
varnumber_T bnum;
bnum = dict_get_number_def(event_dict, (char_u *)"bufnr", -1);
bnum = dict_get_number_def(event_dict, "bufnr", -1);
if (bnum == -1)
continue;
@ -2908,13 +2908,13 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete)
pat = (char_u *)"";
}
once = dict_get_bool(event_dict, (char_u *)"once", FALSE);
nested = dict_get_bool(event_dict, (char_u *)"nested", FALSE);
once = dict_get_bool(event_dict, "once", FALSE);
nested = dict_get_bool(event_dict, "nested", FALSE);
// if 'replace' is true, then remove all the commands associated with
// this autocmd event/group and add the new command.
replace = dict_get_bool(event_dict, (char_u *)"replace", FALSE);
replace = dict_get_bool(event_dict, "replace", FALSE);
cmd = dict_get_string(event_dict, (char_u *)"cmd", TRUE);
cmd = dict_get_string(event_dict, "cmd", TRUE);
if (cmd == NULL)
{
if (delete)
@ -3076,8 +3076,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
// return only the autocmds in the specified group
if (dict_has_key(argvars[0].vval.v_dict, "group"))
{
name = dict_get_string(argvars[0].vval.v_dict,
(char_u *)"group", TRUE);
name = dict_get_string(argvars[0].vval.v_dict, "group", TRUE);
if (name == NULL)
return;
@ -3101,8 +3100,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
{
int i;
name = dict_get_string(argvars[0].vval.v_dict,
(char_u *)"event", TRUE);
name = dict_get_string(argvars[0].vval.v_dict, "event", TRUE);
if (name == NULL)
return;
@ -3127,8 +3125,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
// return only the autocmds for the specified pattern
if (dict_has_key(argvars[0].vval.v_dict, "pattern"))
{
pat = dict_get_string(argvars[0].vval.v_dict,
(char_u *)"pattern", TRUE);
pat = dict_get_string(argvars[0].vval.v_dict, "pattern", TRUE);
if (pat == NULL)
return;
}

View File

@ -172,9 +172,9 @@ check_recorded_changes(
FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li)
{
prev_lnum = (linenr_T)dict_get_number(
li->li_tv.vval.v_dict, (char_u *)"lnum");
li->li_tv.vval.v_dict, "lnum");
prev_lnume = (linenr_T)dict_get_number(
li->li_tv.vval.v_dict, (char_u *)"end");
li->li_tv.vval.v_dict, "end");
if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
{
// the current change is going to make the line number in
@ -384,13 +384,13 @@ invoke_listeners(buf_T *buf)
{
varnumber_T lnum;
lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"lnum");
lnum = dict_get_number(li->li_tv.vval.v_dict, "lnum");
if (start > lnum)
start = lnum;
lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"end");
lnum = dict_get_number(li->li_tv.vval.v_dict, "end");
if (end < lnum)
end = lnum;
added += dict_get_number(li->li_tv.vval.v_dict, (char_u *)"added");
added += dict_get_number(li->li_tv.vval.v_dict, "added");
}
argv[1].v_type = VAR_NUMBER;
argv[1].vval.v_number = start;

View File

@ -662,11 +662,11 @@ dict_has_key(dict_T *d, char *key)
* Returns FAIL if the entry doesn't exist or out of memory.
*/
int
dict_get_tv(dict_T *d, char_u *key, typval_T *rettv)
dict_get_tv(dict_T *d, char *key, typval_T *rettv)
{
dictitem_T *di;
di = dict_find(d, key, -1);
di = dict_find(d, (char_u *)key, -1);
if (di == NULL)
return FAIL;
copy_tv(&di->di_tv, rettv);
@ -680,12 +680,12 @@ dict_get_tv(dict_T *d, char_u *key, typval_T *rettv)
* Returns NULL if the entry doesn't exist or out of memory.
*/
char_u *
dict_get_string(dict_T *d, char_u *key, int save)
dict_get_string(dict_T *d, char *key, int save)
{
dictitem_T *di;
char_u *s;
di = dict_find(d, key, -1);
di = dict_find(d, (char_u *)key, -1);
if (di == NULL)
return NULL;
s = tv_get_string(&di->di_tv);
@ -699,7 +699,7 @@ dict_get_string(dict_T *d, char_u *key, int save)
* Returns 0 if the entry doesn't exist.
*/
varnumber_T
dict_get_number(dict_T *d, char_u *key)
dict_get_number(dict_T *d, char *key)
{
return dict_get_number_def(d, key, 0);
}
@ -709,11 +709,11 @@ dict_get_number(dict_T *d, char_u *key)
* Returns "def" if the entry doesn't exist.
*/
varnumber_T
dict_get_number_def(dict_T *d, char_u *key, int def)
dict_get_number_def(dict_T *d, char *key, int def)
{
dictitem_T *di;
di = dict_find(d, key, -1);
di = dict_find(d, (char_u *)key, -1);
if (di == NULL)
return def;
return tv_get_number(&di->di_tv);
@ -745,11 +745,11 @@ dict_get_number_check(dict_T *d, char_u *key)
* Returns "def" if the entry doesn't exist.
*/
varnumber_T
dict_get_bool(dict_T *d, char_u *key, int def)
dict_get_bool(dict_T *d, char *key, int def)
{
dictitem_T *di;
di = dict_find(d, key, -1);
di = dict_find(d, (char_u *)key, -1);
if (di == NULL)
return def;
return tv_get_bool(&di->di_tv);

View File

@ -695,9 +695,9 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv)
if (sel_d != NULL)
{
filtered = TRUE;
sel_buflisted = dict_get_bool(sel_d, (char_u *)"buflisted", FALSE);
sel_bufloaded = dict_get_bool(sel_d, (char_u *)"bufloaded", FALSE);
sel_bufmodified = dict_get_bool(sel_d, (char_u *)"bufmodified",
sel_buflisted = dict_get_bool(sel_d, "buflisted", FALSE);
sel_bufloaded = dict_get_bool(sel_d, "bufloaded", FALSE);
sel_bufmodified = dict_get_bool(sel_d, "bufmodified",
FALSE);
}
}

View File

@ -4217,8 +4217,7 @@ f_expandcmd(typval_T *argvars, typval_T *rettv)
return;
if (argvars[1].v_type == VAR_DICT
&& dict_get_bool(argvars[1].vval.v_dict, (char_u *)"errmsg",
VVAL_FALSE))
&& dict_get_bool(argvars[1].vval.v_dict, "errmsg", VVAL_FALSE))
emsgoff = FALSE;
rettv->v_type = VAR_STRING;
@ -9172,7 +9171,7 @@ f_setcharsearch(typval_T *argvars, typval_T *rettv UNUSED)
if ((d = argvars[0].vval.v_dict) != NULL)
{
csearch = dict_get_string(d, (char_u *)"char", FALSE);
csearch = dict_get_string(d, "char", FALSE);
if (csearch != NULL)
{
if (enc_utf8)
@ -9368,7 +9367,7 @@ f_setreg(typval_T *argvars, typval_T *rettv)
if (di != NULL)
regcontents = &di->di_tv;
stropt = dict_get_string(d, (char_u *)"regtype", FALSE);
stropt = dict_get_string(d, "regtype", FALSE);
if (stropt != NULL)
{
int ret = get_yank_type(&stropt, &yank_type, &block_len);
@ -9382,14 +9381,14 @@ f_setreg(typval_T *argvars, typval_T *rettv)
if (regname == '"')
{
stropt = dict_get_string(d, (char_u *)"points_to", FALSE);
stropt = dict_get_string(d, "points_to", FALSE);
if (stropt != NULL)
{
pointreg = *stropt;
regname = pointreg;
}
}
else if (dict_get_bool(d, (char_u *)"isunnamed", -1) > 0)
else if (dict_get_bool(d, "isunnamed", -1) > 0)
pointreg = regname;
}
else

View File

@ -1016,11 +1016,11 @@ f_win_splitmove(typval_T *argvars, typval_T *rettv)
}
d = argvars[2].vval.v_dict;
if (dict_get_bool(d, (char_u *)"vertical", FALSE))
if (dict_get_bool(d, "vertical", FALSE))
flags |= WSP_VERT;
if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL)
flags |= tv_get_bool(&di->di_tv) ? WSP_BELOW : WSP_ABOVE;
size = (int)dict_get_number(d, (char_u *)"size");
size = (int)dict_get_number(d, "size");
}
win_move_into_split(wp, targetwin, size, flags);
@ -1236,27 +1236,27 @@ f_winrestview(typval_T *argvars, typval_T *rettv UNUSED)
else
{
if (dict_has_key(dict, "lnum"))
curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, (char_u *)"lnum");
curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, "lnum");
if (dict_has_key(dict, "col"))
curwin->w_cursor.col = (colnr_T)dict_get_number(dict, (char_u *)"col");
curwin->w_cursor.col = (colnr_T)dict_get_number(dict, "col");
if (dict_has_key(dict, "coladd"))
curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, (char_u *)"coladd");
curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, "coladd");
if (dict_has_key(dict, "curswant"))
{
curwin->w_curswant = (colnr_T)dict_get_number(dict, (char_u *)"curswant");
curwin->w_curswant = (colnr_T)dict_get_number(dict, "curswant");
curwin->w_set_curswant = FALSE;
}
if (dict_has_key(dict, "topline"))
set_topline(curwin, (linenr_T)dict_get_number(dict, (char_u *)"topline"));
set_topline(curwin, (linenr_T)dict_get_number(dict, "topline"));
#ifdef FEAT_DIFF
if (dict_has_key(dict, "topfill"))
curwin->w_topfill = (int)dict_get_number(dict, (char_u *)"topfill");
curwin->w_topfill = (int)dict_get_number(dict, "topfill");
#endif
if (dict_has_key(dict, "leftcol"))
curwin->w_leftcol = (colnr_T)dict_get_number(dict, (char_u *)"leftcol");
curwin->w_leftcol = (colnr_T)dict_get_number(dict, "leftcol");
if (dict_has_key(dict, "skipcol"))
curwin->w_skipcol = (colnr_T)dict_get_number(dict, (char_u *)"skipcol");
curwin->w_skipcol = (colnr_T)dict_get_number(dict, "skipcol");
check_cursor();
win_new_height(curwin, curwin->w_height);

View File

@ -4746,8 +4746,8 @@ compare_readdirex_item(const void *p1, const void *p2)
{
char_u *name1, *name2;
name1 = dict_get_string(*(dict_T**)p1, (char_u*)"name", FALSE);
name2 = dict_get_string(*(dict_T**)p2, (char_u*)"name", FALSE);
name1 = dict_get_string(*(dict_T**)p1, "name", FALSE);
name2 = dict_get_string(*(dict_T**)p2, "name", FALSE);
if (readdirex_sort == READDIR_SORT_BYTE)
return STRCMP(name1, name2);
else if (readdirex_sort == READDIR_SORT_IC)

View File

@ -1619,7 +1619,7 @@ readdirex_dict_arg(typval_T *tv, int *cmp)
}
if (dict_has_key(tv->vval.v_dict, "sort"))
compare = dict_get_string(tv->vval.v_dict, (char_u *)"sort", FALSE);
compare = dict_get_string(tv->vval.v_dict, "sort", FALSE);
else
{
semsg(_(e_dictionary_key_str_required), "sort");

View File

@ -8549,7 +8549,7 @@ test_gui_w32_sendevent(dict_T *args)
char_u *event;
INPUT inputs[1];
event = dict_get_string(args, (char_u *)"event", TRUE);
event = dict_get_string(args, "event", TRUE);
if (event == NULL)
return FALSE;
@ -8559,7 +8559,7 @@ test_gui_w32_sendevent(dict_T *args)
{
WORD vkCode;
vkCode = dict_get_number_def(args, (char_u *)"keycode", 0);
vkCode = dict_get_number_def(args, "keycode", 0);
if (vkCode <= 0 || vkCode >= 0xFF)
{
semsg(_(e_invalid_argument_nr), (long)vkCode);

View File

@ -4317,8 +4317,7 @@ hldict_attr_to_str(
p = attr_str;
for (i = 0; i < (int)ARRAY_LENGTH(hl_name_table); i++)
{
if (dict_get_bool(attrdict, (char_u *)hl_name_table[i],
VVAL_FALSE) == VVAL_TRUE)
if (dict_get_bool(attrdict, hl_name_table[i], VVAL_FALSE) == VVAL_TRUE)
{
if (p != attr_str && (size_t)(p - attr_str + 2) < len)
STRCPY(p, (char_u *)",");
@ -4398,10 +4397,10 @@ hlg_add_or_update(dict_T *dict)
if (name == NULL || *name == NUL || error)
return FALSE;
if (dict_get_bool(dict, (char_u *)"force", VVAL_FALSE) == VVAL_TRUE)
if (dict_get_bool(dict, "force", VVAL_FALSE) == VVAL_TRUE)
forceit = TRUE;
if (dict_get_bool(dict, (char_u *)"default", VVAL_FALSE) == VVAL_TRUE)
if (dict_get_bool(dict, "default", VVAL_FALSE) == VVAL_TRUE)
dodefault = TRUE;
if (dict_has_key(dict, "cleared"))
@ -4409,7 +4408,7 @@ hlg_add_or_update(dict_T *dict)
varnumber_T cleared;
// clear a highlight group
cleared = dict_get_bool(dict, (char_u *)"cleared", FALSE);
cleared = dict_get_bool(dict, "cleared", FALSE);
if (cleared == TRUE)
{
vim_snprintf((char *)hlsetBuf, HLSETBUFSZ, "clear %s", name);

View File

@ -2767,25 +2767,21 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
user_data.v_type = VAR_UNKNOWN;
if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
{
word = dict_get_string(tv->vval.v_dict, (char_u *)"word", FALSE);
cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict,
(char_u *)"abbr", FALSE);
cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict,
(char_u *)"menu", FALSE);
cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict,
(char_u *)"kind", FALSE);
cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict,
(char_u *)"info", FALSE);
dict_get_tv(tv->vval.v_dict, (char_u *)"user_data", &user_data);
if (dict_get_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL
&& dict_get_number(tv->vval.v_dict, (char_u *)"icase"))
word = dict_get_string(tv->vval.v_dict, "word", FALSE);
cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict, "abbr", FALSE);
cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict, "menu", FALSE);
cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict, "kind", FALSE);
cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict, "info", FALSE);
dict_get_tv(tv->vval.v_dict, "user_data", &user_data);
if (dict_get_string(tv->vval.v_dict, "icase", FALSE) != NULL
&& dict_get_number(tv->vval.v_dict, "icase"))
flags |= CP_ICASE;
if (dict_get_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL)
dup = dict_get_number(tv->vval.v_dict, (char_u *)"dup");
if (dict_get_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL)
empty = dict_get_number(tv->vval.v_dict, (char_u *)"empty");
if (dict_get_string(tv->vval.v_dict, (char_u *)"equal", FALSE) != NULL
&& dict_get_number(tv->vval.v_dict, (char_u *)"equal"))
if (dict_get_string(tv->vval.v_dict, "dup", FALSE) != NULL)
dup = dict_get_number(tv->vval.v_dict, "dup");
if (dict_get_string(tv->vval.v_dict, "empty", FALSE) != NULL)
empty = dict_get_number(tv->vval.v_dict, "empty");
if (dict_get_string(tv->vval.v_dict, "equal", FALSE) != NULL
&& dict_get_number(tv->vval.v_dict, "equal"))
flags |= CP_EQUAL;
}
else

View File

@ -2621,8 +2621,8 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
if (dict_only)
{
d = argvars[0].vval.v_dict;
which = dict_get_string(d, (char_u *)"mode", FALSE);
is_abbr = dict_get_bool(d, (char_u *)"abbr", -1);
which = dict_get_string(d, "mode", FALSE);
is_abbr = dict_get_bool(d, "abbr", -1);
if (which == NULL || is_abbr < 0)
{
emsg(_(e_entries_missing_in_mapset_dict_argument));
@ -2652,10 +2652,10 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
// Get the values in the same order as above in get_maparg().
lhs = dict_get_string(d, (char_u *)"lhs", FALSE);
lhsraw = dict_get_string(d, (char_u *)"lhsraw", FALSE);
lhsrawalt = dict_get_string(d, (char_u *)"lhsrawalt", FALSE);
rhs = dict_get_string(d, (char_u *)"rhs", FALSE);
lhs = dict_get_string(d, "lhs", FALSE);
lhsraw = dict_get_string(d, "lhsraw", FALSE);
lhsrawalt = dict_get_string(d, "lhsrawalt", FALSE);
rhs = dict_get_string(d, "rhs", FALSE);
if (lhs == NULL || lhsraw == NULL || rhs == NULL)
{
emsg(_(e_entries_missing_in_mapset_dict_argument));
@ -2665,16 +2665,16 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
rhs = replace_termcodes(rhs, &arg_buf,
REPTERM_DO_LT | REPTERM_SPECIAL, NULL);
noremap = dict_get_number(d, (char_u *)"noremap") ? REMAP_NONE: 0;
if (dict_get_number(d, (char_u *)"script") != 0)
noremap = dict_get_number(d, "noremap") ? REMAP_NONE: 0;
if (dict_get_number(d, "script") != 0)
noremap = REMAP_SCRIPT;
expr = dict_get_number(d, (char_u *)"expr") != 0;
silent = dict_get_number(d, (char_u *)"silent") != 0;
sid = dict_get_number(d, (char_u *)"sid");
scriptversion = dict_get_number(d, (char_u *)"scriptversion");
lnum = dict_get_number(d, (char_u *)"lnum");
buffer = dict_get_number(d, (char_u *)"buffer");
nowait = dict_get_number(d, (char_u *)"nowait") != 0;
expr = dict_get_number(d, "expr") != 0;
silent = dict_get_number(d, "silent") != 0;
sid = dict_get_number(d, "sid");
scriptversion = dict_get_number(d, "scriptversion");
lnum = dict_get_number(d, "lnum");
buffer = dict_get_number(d, "buffer");
nowait = dict_get_number(d, "nowait") != 0;
// mode from the dict is not used
if (buffer)

View File

@ -961,8 +961,7 @@ matchadd_dict_arg(typval_T *tv, char_u **conceal_char, win_T **win)
}
if (dict_has_key(tv->vval.v_dict, "conceal"))
*conceal_char = dict_get_string(tv->vval.v_dict,
(char_u *)"conceal", FALSE);
*conceal_char = dict_get_string(tv->vval.v_dict, "conceal", FALSE);
if ((di = dict_find(tv->vval.v_dict, (char_u *)"window", -1)) != NULL)
{
@ -1161,16 +1160,16 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
}
}
group = dict_get_string(d, (char_u *)"group", TRUE);
priority = (int)dict_get_number(d, (char_u *)"priority");
id = (int)dict_get_number(d, (char_u *)"id");
group = dict_get_string(d, "group", TRUE);
priority = (int)dict_get_number(d, "priority");
id = (int)dict_get_number(d, "id");
conceal = dict_has_key(d, "conceal")
? dict_get_string(d, (char_u *)"conceal", TRUE)
? dict_get_string(d, "conceal", TRUE)
: NULL;
if (i == 0)
{
match_add(win, group,
dict_get_string(d, (char_u *)"pattern", FALSE),
dict_get_string(d, "pattern", FALSE),
priority, id, NULL, conceal);
}
else

View File

@ -433,7 +433,7 @@ popup_add_timeout(win_T *wp, int time)
static poppos_T
get_pos_entry(dict_T *d, int give_error)
{
char_u *str = dict_get_string(d, (char_u *)"pos", FALSE);
char_u *str = dict_get_string(d, "pos", FALSE);
int nr;
if (str == NULL)
@ -458,13 +458,13 @@ apply_move_options(win_T *wp, dict_T *d)
char_u *str;
dictitem_T *di;
if ((nr = dict_get_number_def(d, (char_u *)"minwidth", -1)) >= 0)
if ((nr = dict_get_number_def(d, "minwidth", -1)) >= 0)
wp->w_minwidth = nr;
if ((nr = dict_get_number_def(d, (char_u *)"minheight", -1)) >= 0)
if ((nr = dict_get_number_def(d, "minheight", -1)) >= 0)
wp->w_minheight = nr;
if ((nr = dict_get_number_def(d, (char_u *)"maxwidth", -1)) >= 0)
if ((nr = dict_get_number_def(d, "maxwidth", -1)) >= 0)
wp->w_maxwidth = nr;
if ((nr = dict_get_number_def(d, (char_u *)"maxheight", -1)) >= 0)
if ((nr = dict_get_number_def(d, "maxheight", -1)) >= 0)
wp->w_maxheight = nr;
nr = popup_options_one(d, (char_u *)"line");
@ -475,7 +475,7 @@ apply_move_options(win_T *wp, dict_T *d)
wp->w_wantcol = nr;
nr = dict_get_bool(d, (char_u *)"fixed", -1);
nr = dict_get_bool(d, "fixed", -1);
if (nr != -1)
wp->w_popup_fixed = nr != 0;
@ -486,7 +486,7 @@ apply_move_options(win_T *wp, dict_T *d)
wp->w_popup_pos = ppt;
}
str = dict_get_string(d, (char_u *)"textprop", FALSE);
str = dict_get_string(d, "textprop", FALSE);
if (str != NULL)
{
wp->w_popup_prop_type = 0;
@ -513,7 +513,7 @@ apply_move_options(win_T *wp, dict_T *d)
di = dict_find(d, (char_u *)"textpropid", -1);
if (di != NULL)
wp->w_popup_prop_id = dict_get_number(d, (char_u *)"textpropid");
wp->w_popup_prop_id = dict_get_number(d, "textpropid");
}
/*
@ -696,27 +696,27 @@ apply_general_options(win_T *wp, dict_T *dict)
di = dict_find(dict, (char_u *)"firstline", -1);
if (di != NULL)
{
wp->w_firstline = dict_get_number(dict, (char_u *)"firstline");
wp->w_firstline = dict_get_number(dict, "firstline");
if (wp->w_firstline < 0)
wp->w_firstline = -1;
}
nr = dict_get_bool(dict, (char_u *)"scrollbar", -1);
nr = dict_get_bool(dict, "scrollbar", -1);
if (nr != -1)
wp->w_want_scrollbar = nr;
str = dict_get_string(dict, (char_u *)"title", FALSE);
str = dict_get_string(dict, "title", FALSE);
if (str != NULL)
{
vim_free(wp->w_popup_title);
wp->w_popup_title = vim_strsave(str);
}
nr = dict_get_bool(dict, (char_u *)"wrap", -1);
nr = dict_get_bool(dict, "wrap", -1);
if (nr != -1)
wp->w_p_wrap = nr != 0;
nr = dict_get_bool(dict, (char_u *)"drag", -1);
nr = dict_get_bool(dict, "drag", -1);
if (nr != -1)
{
if (nr)
@ -724,7 +724,7 @@ apply_general_options(win_T *wp, dict_T *dict)
else
wp->w_popup_flags &= ~POPF_DRAG;
}
nr = dict_get_bool(dict, (char_u *)"dragall", -1);
nr = dict_get_bool(dict, "dragall", -1);
if (nr != -1)
{
if (nr)
@ -733,7 +733,7 @@ apply_general_options(win_T *wp, dict_T *dict)
wp->w_popup_flags &= ~POPF_DRAGALL;
}
nr = dict_get_bool(dict, (char_u *)"posinvert", -1);
nr = dict_get_bool(dict, "posinvert", -1);
if (nr != -1)
{
if (nr)
@ -742,7 +742,7 @@ apply_general_options(win_T *wp, dict_T *dict)
wp->w_popup_flags &= ~POPF_POSINVERT;
}
nr = dict_get_bool(dict, (char_u *)"resize", -1);
nr = dict_get_bool(dict, "resize", -1);
if (nr != -1)
{
if (nr)
@ -775,7 +775,7 @@ apply_general_options(win_T *wp, dict_T *dict)
semsg(_(e_invalid_value_for_argument_str_str), "close", tv_get_string(&di->di_tv));
}
str = dict_get_string(dict, (char_u *)"highlight", FALSE);
str = dict_get_string(dict, "highlight", FALSE);
if (str != NULL)
{
set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
@ -861,7 +861,7 @@ apply_general_options(win_T *wp, dict_T *dict)
di = dict_find(dict, (char_u *)"zindex", -1);
if (di != NULL)
{
wp->w_zindex = dict_get_number(dict, (char_u *)"zindex");
wp->w_zindex = dict_get_number(dict, "zindex");
if (wp->w_zindex < 1)
wp->w_zindex = POPUPWIN_DEFAULT_ZINDEX;
if (wp->w_zindex > 32000)
@ -903,7 +903,7 @@ apply_general_options(win_T *wp, dict_T *dict)
#if defined(FEAT_TIMERS)
// Add timer to close the popup after some time.
nr = dict_get_number(dict, (char_u *)"time");
nr = dict_get_number(dict, "time");
if (nr > 0)
popup_add_timeout(wp, nr);
#endif
@ -922,7 +922,7 @@ apply_general_options(win_T *wp, dict_T *dict)
handle_moved_argument(wp, di, TRUE);
}
nr = dict_get_bool(dict, (char_u *)"cursorline", -1);
nr = dict_get_bool(dict, "cursorline", -1);
if (nr != -1)
{
if (nr != 0)
@ -942,7 +942,7 @@ apply_general_options(win_T *wp, dict_T *dict)
set_callback(&wp->w_filter_cb, &callback);
}
}
nr = dict_get_bool(dict, (char_u *)"mapping", -1);
nr = dict_get_bool(dict, "mapping", -1);
if (nr != -1)
{
if (nr)
@ -951,7 +951,7 @@ apply_general_options(win_T *wp, dict_T *dict)
wp->w_popup_flags &= ~POPF_MAPPING;
}
str = dict_get_string(dict, (char_u *)"filtermode", FALSE);
str = dict_get_string(dict, "filtermode", FALSE);
if (str != NULL)
{
if (STRCMP(str, "a") == 0)
@ -990,7 +990,7 @@ apply_options(win_T *wp, dict_T *dict, int create)
apply_general_options(wp, dict);
nr = dict_get_bool(dict, (char_u *)"hidden", FALSE);
nr = dict_get_bool(dict, "hidden", FALSE);
if (nr > 0)
wp->w_popup_flags |= POPF_HIDDEN | POPF_HIDDEN_FORCE;
@ -1051,8 +1051,7 @@ add_popup_dicts(buf_T *buf, list_T *l)
return;
}
dict = li->li_tv.vval.v_dict;
p = dict == NULL ? NULL
: dict_get_string(dict, (char_u *)"text", FALSE);
p = dict == NULL ? NULL : dict_get_string(dict, "text", FALSE);
ml_append_buf(buf, lnum++,
p == NULL ? (char_u *)"" : p, (colnr_T)0, TRUE);
}
@ -1086,7 +1085,7 @@ add_popup_dicts(buf_T *buf, list_T *l)
dict = pli->li_tv.vval.v_dict;
if (dict != NULL)
{
int col = dict_get_number(dict, (char_u *)"col");
int col = dict_get_number(dict, "col");
prop_add_common( lnum, col, dict, buf, NULL);
}
@ -1975,7 +1974,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
if (d != NULL)
{
if (dict_has_key(d, "tabpage"))
tabnr = (int)dict_get_number(d, (char_u *)"tabpage");
tabnr = (int)dict_get_number(d, "tabpage");
else if (type == TYPE_NOTIFICATION)
tabnr = -1; // notifications are global by default
else

View File

@ -28,12 +28,12 @@ int dict_add_dict(dict_T *d, char *key, dict_T *dict);
long dict_len(dict_T *d);
dictitem_T *dict_find(dict_T *d, char_u *key, int len);
int dict_has_key(dict_T *d, char *key);
int dict_get_tv(dict_T *d, char_u *key, typval_T *rettv);
char_u *dict_get_string(dict_T *d, char_u *key, int save);
varnumber_T dict_get_number(dict_T *d, char_u *key);
varnumber_T dict_get_number_def(dict_T *d, char_u *key, int def);
int dict_get_tv(dict_T *d, char *key, typval_T *rettv);
char_u *dict_get_string(dict_T *d, char *key, int save);
varnumber_T dict_get_number(dict_T *d, char *key);
varnumber_T dict_get_number_def(dict_T *d, char *key, int def);
varnumber_T dict_get_number_check(dict_T *d, char_u *key);
varnumber_T dict_get_bool(dict_T *d, char_u *key, int def);
varnumber_T dict_get_bool(dict_T *d, char *key, int def);
char_u *dict2string(typval_T *tv, int copyID, int restore_copyID);
char_u *get_literal_key(char_u **arg);
int eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal);

View File

@ -7209,18 +7209,18 @@ qf_add_entry_from_dict(
if (first_entry)
did_bufnr_emsg = FALSE;
filename = dict_get_string(d, (char_u *)"filename", TRUE);
module = dict_get_string(d, (char_u *)"module", TRUE);
bufnum = (int)dict_get_number(d, (char_u *)"bufnr");
lnum = (int)dict_get_number(d, (char_u *)"lnum");
end_lnum = (int)dict_get_number(d, (char_u *)"end_lnum");
col = (int)dict_get_number(d, (char_u *)"col");
end_col = (int)dict_get_number(d, (char_u *)"end_col");
vcol = (int)dict_get_number(d, (char_u *)"vcol");
nr = (int)dict_get_number(d, (char_u *)"nr");
type = dict_get_string(d, (char_u *)"type", TRUE);
pattern = dict_get_string(d, (char_u *)"pattern", TRUE);
text = dict_get_string(d, (char_u *)"text", TRUE);
filename = dict_get_string(d, "filename", TRUE);
module = dict_get_string(d, "module", TRUE);
bufnum = (int)dict_get_number(d, "bufnr");
lnum = (int)dict_get_number(d, "lnum");
end_lnum = (int)dict_get_number(d, "end_lnum");
col = (int)dict_get_number(d, "col");
end_col = (int)dict_get_number(d, "end_col");
vcol = (int)dict_get_number(d, "vcol");
nr = (int)dict_get_number(d, "nr");
type = dict_get_string(d, "type", TRUE);
pattern = dict_get_string(d, "pattern", TRUE);
text = dict_get_string(d, "text", TRUE);
if (text == NULL)
text = vim_strsave((char_u *)"");
@ -7243,7 +7243,7 @@ qf_add_entry_from_dict(
// If the 'valid' field is present it overrules the detected value.
if (dict_has_key(d, "valid"))
valid = (int)dict_get_bool(d, (char_u *)"valid", FALSE);
valid = (int)dict_get_bool(d, "valid", FALSE);
status = qf_add_entry(qfl,
NULL, // dir
@ -7419,7 +7419,7 @@ qf_setprop_title(qf_info_T *qi, int qf_idx, dict_T *what, dictitem_T *di)
return FAIL;
vim_free(qfl->qf_title);
qfl->qf_title = dict_get_string(what, (char_u *)"title", TRUE);
qfl->qf_title = dict_get_string(what, "title", TRUE);
if (qf_idx == qi->qf_curlist)
qf_update_win_titlevar(qi);

View File

@ -4115,7 +4115,7 @@ f_searchcount(typval_T *argvars, typval_T *rettv)
if (error)
return;
}
recompute = dict_get_bool(dict, (char_u *)"recompute", recompute);
recompute = dict_get_bool(dict, "recompute", recompute);
di = dict_find(dict, (char_u *)"pattern", -1);
if (di != NULL)
{
@ -4645,7 +4645,8 @@ fuzzy_match_in_list(
// For a dict, either use the specified key to lookup the string or
// use the specified callback function to get the string.
if (key != NULL)
itemstr = dict_get_string(li->li_tv.vval.v_dict, key, FALSE);
itemstr = dict_get_string(li->li_tv.vval.v_dict,
(char *)key, FALSE);
else
{
typval_T argv[2];

View File

@ -2267,7 +2267,7 @@ sign_define_from_dict(char_u *name_arg, dict_T *dict)
{
if (dict == NULL)
return -1;
name = dict_get_string(dict, (char_u *)"name", TRUE);
name = dict_get_string(dict, "name", TRUE);
}
else
name = vim_strsave(name_arg);
@ -2275,12 +2275,12 @@ sign_define_from_dict(char_u *name_arg, dict_T *dict)
goto cleanup;
if (dict != NULL)
{
icon = dict_get_string(dict, (char_u *)"icon", TRUE);
linehl = dict_get_string(dict, (char_u *)"linehl", TRUE);
text = dict_get_string(dict, (char_u *)"text", TRUE);
texthl = dict_get_string(dict, (char_u *)"texthl", TRUE);
culhl = dict_get_string(dict, (char_u *)"culhl", TRUE);
numhl = dict_get_string(dict, (char_u *)"numhl", TRUE);
icon = dict_get_string(dict, "icon", TRUE);
linehl = dict_get_string(dict, "linehl", TRUE);
text = dict_get_string(dict, "text", TRUE);
texthl = dict_get_string(dict, "texthl", TRUE);
culhl = dict_get_string(dict, "culhl", TRUE);
numhl = dict_get_string(dict, "numhl", TRUE);
}
if (sign_define_by_name(name, icon, linehl, text, texthl, culhl, numhl) == OK)
@ -2765,7 +2765,7 @@ sign_unplace_from_dict(typval_T *group_tv, dict_T *dict)
if (group_tv != NULL)
group = tv_get_string(group_tv);
else
group = dict_get_string(dict, (char_u *)"group", FALSE);
group = dict_get_string(dict, "group", FALSE);
if (group != NULL)
{
if (group[0] == '\0') // global sign group
@ -2788,7 +2788,7 @@ sign_unplace_from_dict(typval_T *group_tv, dict_T *dict)
}
if (dict_has_key(dict, "id"))
{
sign_id = dict_get_number(dict, (char_u *)"id");
sign_id = dict_get_number(dict, "id");
if (sign_id <= 0)
{
emsg(_(e_invalid_argument));

View File

@ -4589,17 +4589,16 @@ tagstack_push_items(win_T *wp, list_T *l)
continue;
if (list2fpos(&di->di_tv, &mark, &fnum, NULL, FALSE) != OK)
continue;
if ((tagname =
dict_get_string(itemdict, (char_u *)"tagname", TRUE)) == NULL)
if ((tagname = dict_get_string(itemdict, "tagname", TRUE)) == NULL)
continue;
if (mark.col > 0)
mark.col--;
tagstack_push_item(wp, tagname,
(int)dict_get_number(itemdict, (char_u *)"bufnr"),
(int)dict_get_number(itemdict, (char_u *)"matchnr") - 1,
(int)dict_get_number(itemdict, "bufnr"),
(int)dict_get_number(itemdict, "matchnr") - 1,
mark, fnum,
dict_get_string(itemdict, (char_u *)"user_data", TRUE));
dict_get_string(itemdict, "user_data", TRUE));
}
}

View File

@ -4338,9 +4338,9 @@ handle_drop_command(listitem_T *item)
dict_T *dict = opt_item->li_tv.vval.v_dict;
char_u *p;
p = dict_get_string(dict, (char_u *)"ff", FALSE);
p = dict_get_string(dict, "ff", FALSE);
if (p == NULL)
p = dict_get_string(dict, (char_u *)"fileformat", FALSE);
p = dict_get_string(dict, "fileformat", FALSE);
if (p != NULL)
{
if (check_ff_value(p) == FAIL)
@ -4348,9 +4348,9 @@ handle_drop_command(listitem_T *item)
else
ea.force_ff = *p;
}
p = dict_get_string(dict, (char_u *)"enc", FALSE);
p = dict_get_string(dict, "enc", FALSE);
if (p == NULL)
p = dict_get_string(dict, (char_u *)"encoding", FALSE);
p = dict_get_string(dict, "encoding", FALSE);
if (p != NULL)
{
ea.cmd = alloc(STRLEN(p) + 12);
@ -4362,7 +4362,7 @@ handle_drop_command(listitem_T *item)
}
}
p = dict_get_string(dict, (char_u *)"bad", FALSE);
p = dict_get_string(dict, "bad", FALSE);
if (p != NULL)
get_bad_opt(p, &ea);
@ -4995,8 +4995,8 @@ f_term_dumpwrite(typval_T *argvars, typval_T *rettv UNUSED)
d = argvars[2].vval.v_dict;
if (d != NULL)
{
max_height = dict_get_number(d, (char_u *)"rows");
max_width = dict_get_number(d, (char_u *)"columns");
max_height = dict_get_number(d, "rows");
max_width = dict_get_number(d, "columns");
}
}

View File

@ -1295,10 +1295,10 @@ test_gui_drop_files(dict_T *args UNUSED)
|| !dict_has_key(args, "modifiers"))
return FALSE;
(void)dict_get_tv(args, (char_u *)"files", &t);
row = (int)dict_get_number(args, (char_u *)"row");
col = (int)dict_get_number(args, (char_u *)"col");
mods = (int)dict_get_number(args, (char_u *)"modifiers");
(void)dict_get_tv(args, "files", &t);
row = (int)dict_get_number(args, "row");
col = (int)dict_get_number(args, "col");
mods = (int)dict_get_number(args, "modifiers");
if (t.v_type != VAR_LIST || list_len(t.vval.v_list) == 0)
return FALSE;
@ -1351,10 +1351,10 @@ test_gui_find_repl(dict_T *args)
|| !dict_has_key(args, "forward"))
return FALSE;
find_text = dict_get_string(args, (char_u *)"find_text", TRUE);
repl_text = dict_get_string(args, (char_u *)"repl_text", TRUE);
flags = (int)dict_get_number(args, (char_u *)"flags");
forward = (int)dict_get_number(args, (char_u *)"forward");
find_text = dict_get_string(args, "find_text", TRUE);
repl_text = dict_get_string(args, "repl_text", TRUE);
flags = (int)dict_get_number(args, "flags");
forward = (int)dict_get_number(args, "forward");
retval = gui_do_findrepl(flags, find_text, repl_text, forward);
vim_free(find_text);
@ -1379,19 +1379,19 @@ test_gui_mouse_event(dict_T *args)
return FALSE;
// Note: "move" is optional, requires fewer arguments
move = (int)dict_get_bool(args, (char_u *)"move", FALSE);
move = (int)dict_get_bool(args, "move", FALSE);
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");
col = (int)dict_get_number(args, (char_u *)"col");
row = (int)dict_get_number(args, "row");
col = (int)dict_get_number(args, "col");
if (move)
{
if (dict_get_bool(args, (char_u *)"cell", FALSE))
if (dict_get_bool(args, "cell", FALSE))
{
// click in the middle of the character cell
row = row * gui.char_height + gui.char_height / 2;
@ -1401,9 +1401,9 @@ test_gui_mouse_event(dict_T *args)
}
else
{
button = (int)dict_get_number(args, (char_u *)"button");
repeated_click = (int)dict_get_number(args, (char_u *)"multiclick");
mods = (int)dict_get_number(args, (char_u *)"modifiers");
button = (int)dict_get_number(args, "button");
repeated_click = (int)dict_get_number(args, "multiclick");
mods = (int)dict_get_number(args, "modifiers");
// Reset the scroll values to known values.
// XXX: Remove this when/if the scroll step is made configurable.
@ -1430,9 +1430,9 @@ test_gui_scrollbar(dict_T *args)
|| !dict_has_key(args, "dragging"))
return FALSE;
which = dict_get_string(args, (char_u *)"which", FALSE);
value = (long)dict_get_number(args, (char_u *)"value");
dragging = (int)dict_get_number(args, (char_u *)"dragging");
which = dict_get_string(args, "which", FALSE);
value = (long)dict_get_number(args, "value");
dragging = (int)dict_get_number(args, "dragging");
if (STRCMP(which, "left") == 0)
sb = &curwin->w_scrollbars[SBAR_LEFT];
@ -1463,7 +1463,7 @@ test_gui_tabline_event(dict_T *args UNUSED)
if (!dict_has_key(args, "tabnr"))
return FALSE;
tabnr = (int)dict_get_number(args, (char_u *)"tabnr");
tabnr = (int)dict_get_number(args, "tabnr");
return send_tabline_event(tabnr);
# else
@ -1482,8 +1482,8 @@ test_gui_tabmenu_event(dict_T *args UNUSED)
|| !dict_has_key(args, "item"))
return FALSE;
tabnr = (int)dict_get_number(args, (char_u *)"tabnr");
item = (int)dict_get_number(args, (char_u *)"item");
tabnr = (int)dict_get_number(args, "tabnr");
item = (int)dict_get_number(args, "item");
send_tabline_menu_event(tabnr, item);
# endif

View File

@ -336,10 +336,10 @@ f_prop_add_list(typval_T *argvars, typval_T *rettv UNUSED)
emsg(_(e_missing_property_type_name));
return;
}
type_name = dict_get_string(dict, (char_u *)"type", FALSE);
type_name = dict_get_string(dict, "type", FALSE);
if (dict_has_key(dict, "id"))
id = dict_get_number(dict, (char_u *)"id");
id = dict_get_number(dict, "id");
if (get_bufnr_from_arg(&argvars[0], &buf) == FAIL)
return;
@ -399,11 +399,11 @@ prop_add_common(
emsg(_(e_missing_property_type_name));
return;
}
type_name = dict_get_string(dict, (char_u *)"type", FALSE);
type_name = dict_get_string(dict, "type", FALSE);
if (dict_has_key(dict, "end_lnum"))
{
end_lnum = dict_get_number(dict, (char_u *)"end_lnum");
end_lnum = dict_get_number(dict, "end_lnum");
if (end_lnum < start_lnum)
{
semsg(_(e_invalid_value_for_argument_str), "end_lnum");
@ -415,7 +415,7 @@ prop_add_common(
if (dict_has_key(dict, "length"))
{
long length = dict_get_number(dict, (char_u *)"length");
long length = dict_get_number(dict, "length");
if (length < 0 || end_lnum > start_lnum)
{
@ -426,7 +426,7 @@ prop_add_common(
}
else if (dict_has_key(dict, "end_col"))
{
end_col = dict_get_number(dict, (char_u *)"end_col");
end_col = dict_get_number(dict, "end_col");
if (end_col <= 0)
{
semsg(_(e_invalid_value_for_argument_str), "end_col");
@ -439,7 +439,7 @@ prop_add_common(
end_col = 1;
if (dict_has_key(dict, "id"))
id = dict_get_number(dict, (char_u *)"id");
id = dict_get_number(dict, "id");
if (dict_arg != NULL && get_bufnr_from_arg(dict_arg, &buf) == FAIL)
return;
@ -784,23 +784,23 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
return;
}
skipstart = dict_get_bool(dict, (char_u *)"skipstart", 0);
skipstart = dict_get_bool(dict, "skipstart", 0);
if (dict_has_key(dict, "id"))
{
id = dict_get_number(dict, (char_u *)"id");
id = dict_get_number(dict, "id");
id_found = TRUE;
}
if (dict_has_key(dict, "type"))
{
char_u *name = dict_get_string(dict, (char_u *)"type", FALSE);
char_u *name = dict_get_string(dict, "type", FALSE);
proptype_T *type = lookup_prop_type(name, buf);
if (type == NULL)
return;
type_id = type->pt_id;
}
both = dict_get_bool(dict, (char_u *)"both", FALSE);
both = dict_get_bool(dict, "both", FALSE);
if (!id_found && type_id == -1)
{
emsg(_(e_need_at_least_one_of_id_or_type));
@ -1213,20 +1213,20 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
if (buf->b_ml.ml_mfp == NULL)
return;
do_all = dict_get_bool(dict, (char_u *)"all", FALSE);
do_all = dict_get_bool(dict, "all", FALSE);
if (dict_has_key(dict, "id"))
id = dict_get_number(dict, (char_u *)"id");
id = dict_get_number(dict, "id");
if (dict_has_key(dict, "type"))
{
char_u *name = dict_get_string(dict, (char_u *)"type", FALSE);
char_u *name = dict_get_string(dict, "type", FALSE);
proptype_T *type = lookup_prop_type(name, buf);
if (type == NULL)
return;
type_id = type->pt_id;
}
both = dict_get_bool(dict, (char_u *)"both", FALSE);
both = dict_get_bool(dict, "both", FALSE);
if (id == -1 && type_id == -1)
{
@ -1383,7 +1383,7 @@ prop_type_set(typval_T *argvars, int add)
char_u *highlight;
int hl_id = 0;
highlight = dict_get_string(dict, (char_u *)"highlight", FALSE);
highlight = dict_get_string(dict, "highlight", FALSE);
if (highlight != NULL && *highlight != NUL)
hl_id = syn_name2id(highlight);
if (hl_id <= 0)

View File

@ -863,7 +863,7 @@ f_timer_start(typval_T *argvars, typval_T *rettv)
return;
}
if (dict_has_key(dict, "repeat"))
repeat = dict_get_number(dict, (char_u *)"repeat");
repeat = dict_get_number(dict, "repeat");
}
callback = get_callback(&argvars[1]);

View File

@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
63,
/**/
62,
/**/