Skip to content

Commit d61efa5

Browse files
committed
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 *".
1 parent 5ac50de commit d61efa5

24 files changed

+193
-202
lines changed

src/autocmd.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete)
28332833
}
28342834
}
28352835

2836-
group_name = dict_get_string(event_dict, (char_u *)"group", TRUE);
2836+
group_name = dict_get_string(event_dict, "group", TRUE);
28372837
if (group_name == NULL || *group_name == NUL)
28382838
// if the autocmd group name is not specified, then use the current
28392839
// autocmd group
@@ -2868,7 +2868,7 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete)
28682868
{
28692869
varnumber_T bnum;
28702870

2871-
bnum = dict_get_number_def(event_dict, (char_u *)"bufnr", -1);
2871+
bnum = dict_get_number_def(event_dict, "bufnr", -1);
28722872
if (bnum == -1)
28732873
continue;
28742874

@@ -2908,13 +2908,13 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete)
29082908
pat = (char_u *)"";
29092909
}
29102910

2911-
once = dict_get_bool(event_dict, (char_u *)"once", FALSE);
2912-
nested = dict_get_bool(event_dict, (char_u *)"nested", FALSE);
2911+
once = dict_get_bool(event_dict, "once", FALSE);
2912+
nested = dict_get_bool(event_dict, "nested", FALSE);
29132913
// if 'replace' is true, then remove all the commands associated with
29142914
// this autocmd event/group and add the new command.
2915-
replace = dict_get_bool(event_dict, (char_u *)"replace", FALSE);
2915+
replace = dict_get_bool(event_dict, "replace", FALSE);
29162916

2917-
cmd = dict_get_string(event_dict, (char_u *)"cmd", TRUE);
2917+
cmd = dict_get_string(event_dict, "cmd", TRUE);
29182918
if (cmd == NULL)
29192919
{
29202920
if (delete)
@@ -3076,8 +3076,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
30763076
// return only the autocmds in the specified group
30773077
if (dict_has_key(argvars[0].vval.v_dict, "group"))
30783078
{
3079-
name = dict_get_string(argvars[0].vval.v_dict,
3080-
(char_u *)"group", TRUE);
3079+
name = dict_get_string(argvars[0].vval.v_dict, "group", TRUE);
30813080
if (name == NULL)
30823081
return;
30833082

@@ -3101,8 +3100,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
31013100
{
31023101
int i;
31033102

3104-
name = dict_get_string(argvars[0].vval.v_dict,
3105-
(char_u *)"event", TRUE);
3103+
name = dict_get_string(argvars[0].vval.v_dict, "event", TRUE);
31063104
if (name == NULL)
31073105
return;
31083106

@@ -3127,8 +3125,7 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
31273125
// return only the autocmds for the specified pattern
31283126
if (dict_has_key(argvars[0].vval.v_dict, "pattern"))
31293127
{
3130-
pat = dict_get_string(argvars[0].vval.v_dict,
3131-
(char_u *)"pattern", TRUE);
3128+
pat = dict_get_string(argvars[0].vval.v_dict, "pattern", TRUE);
31323129
if (pat == NULL)
31333130
return;
31343131
}

src/change.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ check_recorded_changes(
172172
FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li)
173173
{
174174
prev_lnum = (linenr_T)dict_get_number(
175-
li->li_tv.vval.v_dict, (char_u *)"lnum");
175+
li->li_tv.vval.v_dict, "lnum");
176176
prev_lnume = (linenr_T)dict_get_number(
177-
li->li_tv.vval.v_dict, (char_u *)"end");
177+
li->li_tv.vval.v_dict, "end");
178178
if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
179179
{
180180
// the current change is going to make the line number in
@@ -384,13 +384,13 @@ invoke_listeners(buf_T *buf)
384384
{
385385
varnumber_T lnum;
386386

387-
lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"lnum");
387+
lnum = dict_get_number(li->li_tv.vval.v_dict, "lnum");
388388
if (start > lnum)
389389
start = lnum;
390-
lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"end");
390+
lnum = dict_get_number(li->li_tv.vval.v_dict, "end");
391391
if (end < lnum)
392392
end = lnum;
393-
added += dict_get_number(li->li_tv.vval.v_dict, (char_u *)"added");
393+
added += dict_get_number(li->li_tv.vval.v_dict, "added");
394394
}
395395
argv[1].v_type = VAR_NUMBER;
396396
argv[1].vval.v_number = start;

src/dict.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,11 @@ dict_has_key(dict_T *d, char *key)
662662
* Returns FAIL if the entry doesn't exist or out of memory.
663663
*/
664664
int
665-
dict_get_tv(dict_T *d, char_u *key, typval_T *rettv)
665+
dict_get_tv(dict_T *d, char *key, typval_T *rettv)
666666
{
667667
dictitem_T *di;
668668

669-
di = dict_find(d, key, -1);
669+
di = dict_find(d, (char_u *)key, -1);
670670
if (di == NULL)
671671
return FAIL;
672672
copy_tv(&di->di_tv, rettv);
@@ -680,12 +680,12 @@ dict_get_tv(dict_T *d, char_u *key, typval_T *rettv)
680680
* Returns NULL if the entry doesn't exist or out of memory.
681681
*/
682682
char_u *
683-
dict_get_string(dict_T *d, char_u *key, int save)
683+
dict_get_string(dict_T *d, char *key, int save)
684684
{
685685
dictitem_T *di;
686686
char_u *s;
687687

688-
di = dict_find(d, key, -1);
688+
di = dict_find(d, (char_u *)key, -1);
689689
if (di == NULL)
690690
return NULL;
691691
s = tv_get_string(&di->di_tv);
@@ -699,7 +699,7 @@ dict_get_string(dict_T *d, char_u *key, int save)
699699
* Returns 0 if the entry doesn't exist.
700700
*/
701701
varnumber_T
702-
dict_get_number(dict_T *d, char_u *key)
702+
dict_get_number(dict_T *d, char *key)
703703
{
704704
return dict_get_number_def(d, key, 0);
705705
}
@@ -709,11 +709,11 @@ dict_get_number(dict_T *d, char_u *key)
709709
* Returns "def" if the entry doesn't exist.
710710
*/
711711
varnumber_T
712-
dict_get_number_def(dict_T *d, char_u *key, int def)
712+
dict_get_number_def(dict_T *d, char *key, int def)
713713
{
714714
dictitem_T *di;
715715

716-
di = dict_find(d, key, -1);
716+
di = dict_find(d, (char_u *)key, -1);
717717
if (di == NULL)
718718
return def;
719719
return tv_get_number(&di->di_tv);
@@ -745,11 +745,11 @@ dict_get_number_check(dict_T *d, char_u *key)
745745
* Returns "def" if the entry doesn't exist.
746746
*/
747747
varnumber_T
748-
dict_get_bool(dict_T *d, char_u *key, int def)
748+
dict_get_bool(dict_T *d, char *key, int def)
749749
{
750750
dictitem_T *di;
751751

752-
di = dict_find(d, key, -1);
752+
di = dict_find(d, (char_u *)key, -1);
753753
if (di == NULL)
754754
return def;
755755
return tv_get_bool(&di->di_tv);

src/evalbuffer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,9 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv)
695695
if (sel_d != NULL)
696696
{
697697
filtered = TRUE;
698-
sel_buflisted = dict_get_bool(sel_d, (char_u *)"buflisted", FALSE);
699-
sel_bufloaded = dict_get_bool(sel_d, (char_u *)"bufloaded", FALSE);
700-
sel_bufmodified = dict_get_bool(sel_d, (char_u *)"bufmodified",
698+
sel_buflisted = dict_get_bool(sel_d, "buflisted", FALSE);
699+
sel_bufloaded = dict_get_bool(sel_d, "bufloaded", FALSE);
700+
sel_bufmodified = dict_get_bool(sel_d, "bufmodified",
701701
FALSE);
702702
}
703703
}

src/evalfunc.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,8 +4217,7 @@ f_expandcmd(typval_T *argvars, typval_T *rettv)
42174217
return;
42184218

42194219
if (argvars[1].v_type == VAR_DICT
4220-
&& dict_get_bool(argvars[1].vval.v_dict, (char_u *)"errmsg",
4221-
VVAL_FALSE))
4220+
&& dict_get_bool(argvars[1].vval.v_dict, "errmsg", VVAL_FALSE))
42224221
emsgoff = FALSE;
42234222

42244223
rettv->v_type = VAR_STRING;
@@ -9172,7 +9171,7 @@ f_setcharsearch(typval_T *argvars, typval_T *rettv UNUSED)
91729171

91739172
if ((d = argvars[0].vval.v_dict) != NULL)
91749173
{
9175-
csearch = dict_get_string(d, (char_u *)"char", FALSE);
9174+
csearch = dict_get_string(d, "char", FALSE);
91769175
if (csearch != NULL)
91779176
{
91789177
if (enc_utf8)
@@ -9368,7 +9367,7 @@ f_setreg(typval_T *argvars, typval_T *rettv)
93689367
if (di != NULL)
93699368
regcontents = &di->di_tv;
93709369

9371-
stropt = dict_get_string(d, (char_u *)"regtype", FALSE);
9370+
stropt = dict_get_string(d, "regtype", FALSE);
93729371
if (stropt != NULL)
93739372
{
93749373
int ret = get_yank_type(&stropt, &yank_type, &block_len);
@@ -9382,14 +9381,14 @@ f_setreg(typval_T *argvars, typval_T *rettv)
93829381

93839382
if (regname == '"')
93849383
{
9385-
stropt = dict_get_string(d, (char_u *)"points_to", FALSE);
9384+
stropt = dict_get_string(d, "points_to", FALSE);
93869385
if (stropt != NULL)
93879386
{
93889387
pointreg = *stropt;
93899388
regname = pointreg;
93909389
}
93919390
}
9392-
else if (dict_get_bool(d, (char_u *)"isunnamed", -1) > 0)
9391+
else if (dict_get_bool(d, "isunnamed", -1) > 0)
93939392
pointreg = regname;
93949393
}
93959394
else

src/evalwindow.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,11 +1016,11 @@ f_win_splitmove(typval_T *argvars, typval_T *rettv)
10161016
}
10171017

10181018
d = argvars[2].vval.v_dict;
1019-
if (dict_get_bool(d, (char_u *)"vertical", FALSE))
1019+
if (dict_get_bool(d, "vertical", FALSE))
10201020
flags |= WSP_VERT;
10211021
if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL)
10221022
flags |= tv_get_bool(&di->di_tv) ? WSP_BELOW : WSP_ABOVE;
1023-
size = (int)dict_get_number(d, (char_u *)"size");
1023+
size = (int)dict_get_number(d, "size");
10241024
}
10251025

10261026
win_move_into_split(wp, targetwin, size, flags);
@@ -1236,27 +1236,27 @@ f_winrestview(typval_T *argvars, typval_T *rettv UNUSED)
12361236
else
12371237
{
12381238
if (dict_has_key(dict, "lnum"))
1239-
curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, (char_u *)"lnum");
1239+
curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, "lnum");
12401240
if (dict_has_key(dict, "col"))
1241-
curwin->w_cursor.col = (colnr_T)dict_get_number(dict, (char_u *)"col");
1241+
curwin->w_cursor.col = (colnr_T)dict_get_number(dict, "col");
12421242
if (dict_has_key(dict, "coladd"))
1243-
curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, (char_u *)"coladd");
1243+
curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, "coladd");
12441244
if (dict_has_key(dict, "curswant"))
12451245
{
1246-
curwin->w_curswant = (colnr_T)dict_get_number(dict, (char_u *)"curswant");
1246+
curwin->w_curswant = (colnr_T)dict_get_number(dict, "curswant");
12471247
curwin->w_set_curswant = FALSE;
12481248
}
12491249

12501250
if (dict_has_key(dict, "topline"))
1251-
set_topline(curwin, (linenr_T)dict_get_number(dict, (char_u *)"topline"));
1251+
set_topline(curwin, (linenr_T)dict_get_number(dict, "topline"));
12521252
#ifdef FEAT_DIFF
12531253
if (dict_has_key(dict, "topfill"))
1254-
curwin->w_topfill = (int)dict_get_number(dict, (char_u *)"topfill");
1254+
curwin->w_topfill = (int)dict_get_number(dict, "topfill");
12551255
#endif
12561256
if (dict_has_key(dict, "leftcol"))
1257-
curwin->w_leftcol = (colnr_T)dict_get_number(dict, (char_u *)"leftcol");
1257+
curwin->w_leftcol = (colnr_T)dict_get_number(dict, "leftcol");
12581258
if (dict_has_key(dict, "skipcol"))
1259-
curwin->w_skipcol = (colnr_T)dict_get_number(dict, (char_u *)"skipcol");
1259+
curwin->w_skipcol = (colnr_T)dict_get_number(dict, "skipcol");
12601260

12611261
check_cursor();
12621262
win_new_height(curwin, curwin->w_height);

src/fileio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4746,8 +4746,8 @@ compare_readdirex_item(const void *p1, const void *p2)
47464746
{
47474747
char_u *name1, *name2;
47484748

4749-
name1 = dict_get_string(*(dict_T**)p1, (char_u*)"name", FALSE);
4750-
name2 = dict_get_string(*(dict_T**)p2, (char_u*)"name", FALSE);
4749+
name1 = dict_get_string(*(dict_T**)p1, "name", FALSE);
4750+
name2 = dict_get_string(*(dict_T**)p2, "name", FALSE);
47514751
if (readdirex_sort == READDIR_SORT_BYTE)
47524752
return STRCMP(name1, name2);
47534753
else if (readdirex_sort == READDIR_SORT_IC)

src/filepath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ readdirex_dict_arg(typval_T *tv, int *cmp)
16191619
}
16201620

16211621
if (dict_has_key(tv->vval.v_dict, "sort"))
1622-
compare = dict_get_string(tv->vval.v_dict, (char_u *)"sort", FALSE);
1622+
compare = dict_get_string(tv->vval.v_dict, "sort", FALSE);
16231623
else
16241624
{
16251625
semsg(_(e_dictionary_key_str_required), "sort");

src/gui_w32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8549,7 +8549,7 @@ test_gui_w32_sendevent(dict_T *args)
85498549
char_u *event;
85508550
INPUT inputs[1];
85518551

8552-
event = dict_get_string(args, (char_u *)"event", TRUE);
8552+
event = dict_get_string(args, "event", TRUE);
85538553
if (event == NULL)
85548554
return FALSE;
85558555

@@ -8559,7 +8559,7 @@ test_gui_w32_sendevent(dict_T *args)
85598559
{
85608560
WORD vkCode;
85618561

8562-
vkCode = dict_get_number_def(args, (char_u *)"keycode", 0);
8562+
vkCode = dict_get_number_def(args, "keycode", 0);
85638563
if (vkCode <= 0 || vkCode >= 0xFF)
85648564
{
85658565
semsg(_(e_invalid_argument_nr), (long)vkCode);

src/highlight.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4317,8 +4317,7 @@ hldict_attr_to_str(
43174317
p = attr_str;
43184318
for (i = 0; i < (int)ARRAY_LENGTH(hl_name_table); i++)
43194319
{
4320-
if (dict_get_bool(attrdict, (char_u *)hl_name_table[i],
4321-
VVAL_FALSE) == VVAL_TRUE)
4320+
if (dict_get_bool(attrdict, hl_name_table[i], VVAL_FALSE) == VVAL_TRUE)
43224321
{
43234322
if (p != attr_str && (size_t)(p - attr_str + 2) < len)
43244323
STRCPY(p, (char_u *)",");
@@ -4398,18 +4397,18 @@ hlg_add_or_update(dict_T *dict)
43984397
if (name == NULL || *name == NUL || error)
43994398
return FALSE;
44004399

4401-
if (dict_get_bool(dict, (char_u *)"force", VVAL_FALSE) == VVAL_TRUE)
4400+
if (dict_get_bool(dict, "force", VVAL_FALSE) == VVAL_TRUE)
44024401
forceit = TRUE;
44034402

4404-
if (dict_get_bool(dict, (char_u *)"default", VVAL_FALSE) == VVAL_TRUE)
4403+
if (dict_get_bool(dict, "default", VVAL_FALSE) == VVAL_TRUE)
44054404
dodefault = TRUE;
44064405

44074406
if (dict_has_key(dict, "cleared"))
44084407
{
44094408
varnumber_T cleared;
44104409

44114410
// clear a highlight group
4412-
cleared = dict_get_bool(dict, (char_u *)"cleared", FALSE);
4411+
cleared = dict_get_bool(dict, "cleared", FALSE);
44134412
if (cleared == TRUE)
44144413
{
44154414
vim_snprintf((char *)hlsetBuf, HLSETBUFSZ, "clear %s", name);

0 commit comments

Comments
 (0)