Skip to content

Commit 14113fd

Browse files
yegappanbrammool
authored andcommitted
patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Problem: FOR_ALL_ macros are defined in an unexpected file. Solution: Move FOR_ALL_ macros to macros.h. Add FOR_ALL_HASHTAB_ITEMS. (Yegappan Lakshmanan, closes #12109)
1 parent 663ee88 commit 14113fd

31 files changed

Lines changed: 126 additions & 109 deletions

src/dict.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ hashtab_free_contents(hashtab_T *ht)
128128
// Lock the hashtab, we don't want it to resize while freeing items.
129129
hash_lock(ht);
130130
todo = (int)ht->ht_used;
131-
for (hi = ht->ht_array; todo > 0; ++hi)
131+
FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
132132
{
133133
if (!HASHITEM_EMPTY(hi))
134134
{
@@ -781,7 +781,7 @@ dict2string(typval_T *tv, int copyID, int restore_copyID)
781781
ga_append(&ga, '{');
782782

783783
todo = (int)d->dv_hashtab.ht_used;
784-
for (hi = d->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi)
784+
FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
785785
{
786786
if (!HASHITEM_EMPTY(hi))
787787
{
@@ -1114,7 +1114,8 @@ dict_extend(dict_T *d1, dict_T *d2, char_u *action, char *func_name)
11141114
type = NULL;
11151115

11161116
todo = (int)d2->dv_hashtab.ht_used;
1117-
for (hashitem_T *hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
1117+
hashitem_T *hi2;
1118+
FOR_ALL_HASHTAB_ITEMS(&d2->dv_hashtab, hi2, todo)
11181119
{
11191120
if (!HASHITEM_EMPTY(hi2))
11201121
{
@@ -1203,7 +1204,7 @@ dict_equal(
12031204
return FALSE;
12041205

12051206
todo = (int)d1->dv_hashtab.ht_used;
1206-
for (hi = d1->dv_hashtab.ht_array; todo > 0; ++hi)
1207+
FOR_ALL_HASHTAB_ITEMS(&d1->dv_hashtab, hi, todo)
12071208
{
12081209
if (!HASHITEM_EMPTY(hi))
12091210
{
@@ -1233,7 +1234,7 @@ dict_count(dict_T *d, typval_T *needle, int ic)
12331234
return 0;
12341235

12351236
todo = (int)d->dv_hashtab.ht_used;
1236-
for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
1237+
FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
12371238
{
12381239
if (!HASHITEM_EMPTY(hi))
12391240
{
@@ -1369,7 +1370,7 @@ dict_filter_map(
13691370
ht = &d->dv_hashtab;
13701371
hash_lock(ht);
13711372
todo = (int)ht->ht_used;
1372-
for (hi = ht->ht_array; todo > 0; ++hi)
1373+
FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
13731374
{
13741375
if (!HASHITEM_EMPTY(hi))
13751376
{
@@ -1502,7 +1503,7 @@ dict2list(typval_T *argvars, typval_T *rettv, dict2list_T what)
15021503
return;
15031504

15041505
todo = (int)d->dv_hashtab.ht_used;
1505-
for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
1506+
FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
15061507
{
15071508
if (!HASHITEM_EMPTY(hi))
15081509
{
@@ -1587,7 +1588,7 @@ dict_set_items_ro(dict_T *di)
15871588
hashitem_T *hi;
15881589

15891590
// Set readonly
1590-
for (hi = di->dv_hashtab.ht_array; todo > 0 ; ++hi)
1591+
FOR_ALL_HASHTAB_ITEMS(&di->dv_hashtab, hi, todo)
15911592
{
15921593
if (HASHITEM_EMPTY(hi))
15931594
continue;

src/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,7 @@ valid_diff(diff_T *diff)
26502650
{
26512651
diff_T *dp;
26522652

2653-
for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
2653+
FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
26542654
if (dp == diff)
26552655
return TRUE;
26562656
return FALSE;

src/eval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5415,7 +5415,7 @@ set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack)
54155415
// it is added to ht_stack, if it contains a list it is added to
54165416
// list_stack.
54175417
todo = (int)cur_ht->ht_used;
5418-
for (hi = cur_ht->ht_array; todo > 0; ++hi)
5418+
FOR_ALL_HASHTAB_ITEMS(cur_ht, hi, todo)
54195419
if (!HASHITEM_EMPTY(hi))
54205420
{
54215421
--todo;

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7825,7 +7825,7 @@ max_min(typval_T *argvars, typval_T *rettv, int domax)
78257825
if (d != NULL)
78267826
{
78277827
todo = (int)d->dv_hashtab.ht_used;
7828-
for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
7828+
FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
78297829
{
78307830
if (!HASHITEM_EMPTY(hi))
78317831
{

src/evalvars.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,7 @@ item_lock(typval_T *tv, int deep, int lock, int check_refcount)
23172317
{
23182318
// recursive: lock/unlock the items the List contains
23192319
todo = (int)d->dv_hashtab.ht_used;
2320-
for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
2320+
FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
23212321
{
23222322
if (!HASHITEM_EMPTY(hi))
23232323
{
@@ -3571,7 +3571,7 @@ vars_clear_ext(hashtab_T *ht, int free_val)
35713571

35723572
hash_lock(ht);
35733573
todo = (int)ht->ht_used;
3574-
for (hi = ht->ht_array; todo > 0; ++hi)
3574+
FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
35753575
{
35763576
if (!HASHITEM_EMPTY(hi))
35773577
{

src/globals.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -873,10 +873,6 @@ EXTERN vimmenu_T *root_menu INIT(= NULL);
873873
* overruling of menus that the user already defined.
874874
*/
875875
EXTERN int sys_menu INIT(= FALSE);
876-
877-
#define FOR_ALL_MENUS(m) for ((m) = root_menu; (m) != NULL; (m) = (m)->next)
878-
#define FOR_ALL_CHILD_MENUS(p, c) \
879-
for ((c) = (p)->children; (c) != NULL; (c) = (c)->next)
880876
#endif
881877

882878
#ifdef FEAT_GUI
@@ -968,27 +964,6 @@ EXTERN win_T *lastwin; // last window
968964
EXTERN win_T *prevwin INIT(= NULL); // previous window
969965
#define ONE_WINDOW (firstwin == lastwin)
970966
#define W_NEXT(wp) ((wp)->w_next)
971-
#define FOR_ALL_WINDOWS(wp) for ((wp) = firstwin; (wp) != NULL; (wp) = (wp)->w_next)
972-
#define FOR_ALL_FRAMES(frp, first_frame) \
973-
for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next)
974-
#define FOR_ALL_TABPAGES(tp) for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next)
975-
#define FOR_ALL_WINDOWS_IN_TAB(tp, wp) \
976-
for ((wp) = ((tp) == NULL || (tp) == curtab) \
977-
? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
978-
/*
979-
* When using this macro "break" only breaks out of the inner loop. Use "goto"
980-
* to break out of the tabpage loop.
981-
*/
982-
#define FOR_ALL_TAB_WINDOWS(tp, wp) \
983-
for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
984-
for ((wp) = ((tp) == curtab) \
985-
? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
986-
987-
#define FOR_ALL_POPUPWINS(wp) \
988-
for ((wp) = first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
989-
#define FOR_ALL_POPUPWINS_IN_TAB(tp, wp) \
990-
for ((wp) = (tp)->tp_first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
991-
992967

993968
EXTERN win_T *curwin; // currently active window
994969

@@ -1050,16 +1025,6 @@ EXTERN buf_T *firstbuf INIT(= NULL); // first buffer
10501025
EXTERN buf_T *lastbuf INIT(= NULL); // last buffer
10511026
EXTERN buf_T *curbuf INIT(= NULL); // currently active buffer
10521027

1053-
#define FOR_ALL_BUFFERS(buf) \
1054-
for ((buf) = firstbuf; (buf) != NULL; (buf) = (buf)->b_next)
1055-
1056-
#define FOR_ALL_BUF_WININFO(buf, wip) \
1057-
for ((wip) = (buf)->b_wininfo; (wip) != NULL; (wip) = (wip)->wi_next)
1058-
1059-
// Iterate through all the signs placed in a buffer
1060-
#define FOR_ALL_SIGNS_IN_BUF(buf, sign) \
1061-
for ((sign) = (buf)->b_signlist; (sign) != NULL; (sign) = (sign)->se_next)
1062-
10631028
// Flag that is set when switching off 'swapfile'. It means that all blocks
10641029
// are to be loaded into memory. Shouldn't be global...
10651030
EXTERN int mf_dont_release INIT(= FALSE); // don't release blocks
@@ -1874,9 +1839,6 @@ EXTERN disptick_T display_tick INIT(= 0);
18741839
// Line in which spell checking wasn't highlighted because it touched the
18751840
// cursor position in Insert mode.
18761841
EXTERN linenr_T spell_redraw_lnum INIT(= 0);
1877-
1878-
#define FOR_ALL_SPELL_LANGS(slang) \
1879-
for ((slang) = first_lang; (slang) != NULL; (slang) = (slang)->sl_next)
18801842
#endif
18811843

18821844
#ifdef FEAT_CONCEAL
@@ -2015,11 +1977,6 @@ EXTERN char *ch_part_names[]
20151977

20161978
// Whether a redraw is needed for appending a line to a buffer.
20171979
EXTERN int channel_need_redraw INIT(= FALSE);
2018-
2019-
# define FOR_ALL_CHANNELS(ch) \
2020-
for ((ch) = first_channel; (ch) != NULL; (ch) = (ch)->ch_next)
2021-
# define FOR_ALL_JOBS(job) \
2022-
for ((job) = first_job; (job) != NULL; (job) = (job)->jv_next)
20231980
#endif
20241981

20251982
#ifdef FEAT_EVAL
@@ -2032,14 +1989,6 @@ EXTERN int did_repeated_msg INIT(= 0);
20321989
# define REPEATED_MSG_SAFESTATE 2
20331990
#endif
20341991

2035-
#if defined(FEAT_DIFF)
2036-
#define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \
2037-
for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next)
2038-
#endif
2039-
2040-
#define FOR_ALL_LIST_ITEMS(l, li) \
2041-
for ((li) = (l) == NULL ? NULL : (l)->lv_first; (li) != NULL; (li) = (li)->li_next)
2042-
20431992
// While executing a regexp and set to OPTION_MAGIC_ON or OPTION_MAGIC_OFF this
20441993
// overrules p_magic. Otherwise set to OPTION_MAGIC_NOT_SET.
20451994
EXTERN optmagic_T magic_overruled INIT(= OPTION_MAGIC_NOT_SET);

src/hashtab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ hash_clear_all(hashtab_T *ht, int off)
108108
hashitem_T *hi;
109109

110110
todo = (long)ht->ht_used;
111-
for (hi = ht->ht_array; todo > 0; ++hi)
111+
FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
112112
{
113113
if (!HASHITEM_EMPTY(hi))
114114
{

src/if_mzsch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3067,7 +3067,7 @@ vim_to_mzscheme_impl(typval_T *vim_value, int depth, Scheme_Hash_Table *visited)
30673067
hashitem_T *hi;
30683068
dictitem_T *di;
30693069

3070-
for (hi = ht->ht_array; todo > 0; ++hi)
3070+
FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
30713071
{
30723072
if (!HASHITEM_EMPTY(hi))
30733073
{

src/if_ruby.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ vim_to_ruby(typval_T *tv)
11471147
hashitem_T *hi;
11481148
dictitem_T *di;
11491149

1150-
for (hi = ht->ht_array; todo > 0; ++hi)
1150+
FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
11511151
{
11521152
if (!HASHITEM_EMPTY(hi))
11531153
{

src/job.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
140140
return OK;
141141

142142
todo = (int)dict->dv_hashtab.ht_used;
143-
for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
143+
FOR_ALL_HASHTAB_ITEMS(&dict->dv_hashtab, hi, todo)
144144
if (!HASHITEM_EMPTY(hi))
145145
{
146146
item = &dict_lookup(hi)->di_tv;

0 commit comments

Comments
 (0)