Patch 9.0.1390

12 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 7, 2023, 12:14:22 PM3/7/23
to vim...@googlegroups.com

Patch 9.0.1390
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)
Files: src/dict.c, src/diff.c, src/eval.c, src/evalfunc.c,
src/evalvars.c, src/globals.h, src/hashtab.c, src/if_mzsch.c,
src/if_ruby.c, src/job.c, src/macros.h, src/mbyte.c,
src/os_unix.c, src/os_win32.c, src/popupwin.c, src/profiler.c,
src/scriptfile.c, src/session.c, src/sign.c, src/spellfile.c,
src/spellsuggest.c, src/syntax.c, src/testing.c, src/textprop.c,
src/userfunc.c, src/vim9execute.c, src/vim9script.c,
src/vim9type.c, src/viminfo.c, src/window.c


*** ../vim-9.0.1389/src/dict.c 2023-01-09 19:04:19.300528373 +0000
--- src/dict.c 2023-03-07 17:10:22.925201387 +0000
***************
*** 128,134 ****
// Lock the hashtab, we don't want it to resize while freeing items.
hash_lock(ht);
todo = (int)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 128,134 ----
// Lock the hashtab, we don't want it to resize while freeing items.
hash_lock(ht);
todo = (int)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 781,787 ****
ga_append(&ga, '{');

todo = (int)d->dv_hashtab.ht_used;
! for (hi = d->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 781,787 ----
ga_append(&ga, '{');

todo = (int)d->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 1114,1120 ****
type = NULL;

todo = (int)d2->dv_hashtab.ht_used;
! for (hashitem_T *hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
{
if (!HASHITEM_EMPTY(hi2))
{
--- 1114,1121 ----
type = NULL;

todo = (int)d2->dv_hashtab.ht_used;
! hashitem_T *hi2;
! FOR_ALL_HASHTAB_ITEMS(&d2->dv_hashtab, hi2, todo)
{
if (!HASHITEM_EMPTY(hi2))
{
***************
*** 1203,1209 ****
return FALSE;

todo = (int)d1->dv_hashtab.ht_used;
! for (hi = d1->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 1204,1210 ----
return FALSE;

todo = (int)d1->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&d1->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 1233,1239 ****
return 0;

todo = (int)d->dv_hashtab.ht_used;
! for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 1234,1240 ----
return 0;

todo = (int)d->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 1369,1375 ****
ht = &d->dv_hashtab;
hash_lock(ht);
todo = (int)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 1370,1376 ----
ht = &d->dv_hashtab;
hash_lock(ht);
todo = (int)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 1502,1508 ****
return;

todo = (int)d->dv_hashtab.ht_used;
! for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 1503,1509 ----
return;

todo = (int)d->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 1587,1593 ****
hashitem_T *hi;

// Set readonly
! for (hi = di->dv_hashtab.ht_array; todo > 0 ; ++hi)
{
if (HASHITEM_EMPTY(hi))
continue;
--- 1588,1594 ----
hashitem_T *hi;

// Set readonly
! FOR_ALL_HASHTAB_ITEMS(&di->dv_hashtab, hi, todo)
{
if (HASHITEM_EMPTY(hi))
continue;
*** ../vim-9.0.1389/src/diff.c 2023-01-22 21:14:32.613863616 +0000
--- src/diff.c 2023-03-07 17:10:22.925201387 +0000
***************
*** 2650,2656 ****
{
diff_T *dp;

! for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
if (dp == diff)
return TRUE;
return FALSE;
--- 2650,2656 ----
{
diff_T *dp;

! FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
if (dp == diff)
return TRUE;
return FALSE;
*** ../vim-9.0.1389/src/eval.c 2023-03-05 13:12:28.492767233 +0000
--- src/eval.c 2023-03-07 17:10:22.925201387 +0000
***************
*** 5415,5421 ****
// it is added to ht_stack, if it contains a list it is added to
// list_stack.
todo = (int)cur_ht->ht_used;
! for (hi = cur_ht->ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
--todo;
--- 5415,5421 ----
// it is added to ht_stack, if it contains a list it is added to
// list_stack.
todo = (int)cur_ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(cur_ht, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
--todo;
*** ../vim-9.0.1389/src/evalfunc.c 2023-02-21 12:38:46.827436713 +0000
--- src/evalfunc.c 2023-03-07 17:10:22.925201387 +0000
***************
*** 7825,7831 ****
if (d != NULL)
{
todo = (int)d->dv_hashtab.ht_used;
! for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 7825,7831 ----
if (d != NULL)
{
todo = (int)d->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/evalvars.c 2023-02-01 13:11:11.710991162 +0000
--- src/evalvars.c 2023-03-07 17:10:22.929201385 +0000
***************
*** 2317,2323 ****
{
// recursive: lock/unlock the items the List contains
todo = (int)d->dv_hashtab.ht_used;
! for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 2317,2323 ----
{
// recursive: lock/unlock the items the List contains
todo = (int)d->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 3571,3577 ****

hash_lock(ht);
todo = (int)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 3571,3577 ----

hash_lock(ht);
todo = (int)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/globals.h 2023-02-21 12:38:46.823436717 +0000
--- src/globals.h 2023-03-07 17:10:22.929201385 +0000
***************
*** 873,882 ****
* overruling of menus that the user already defined.
*/
EXTERN int sys_menu INIT(= FALSE);
-
- #define FOR_ALL_MENUS(m) for ((m) = root_menu; (m) != NULL; (m) = (m)->next)
- #define FOR_ALL_CHILD_MENUS(p, c) \
- for ((c) = (p)->children; (c) != NULL; (c) = (c)->next)
#endif

#ifdef FEAT_GUI
--- 873,878 ----
***************
*** 968,994 ****
EXTERN win_T *prevwin INIT(= NULL); // previous window
#define ONE_WINDOW (firstwin == lastwin)
#define W_NEXT(wp) ((wp)->w_next)
- #define FOR_ALL_WINDOWS(wp) for ((wp) = firstwin; (wp) != NULL; (wp) = (wp)->w_next)
- #define FOR_ALL_FRAMES(frp, first_frame) \
- for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next)
- #define FOR_ALL_TABPAGES(tp) for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next)
- #define FOR_ALL_WINDOWS_IN_TAB(tp, wp) \
- for ((wp) = ((tp) == NULL || (tp) == curtab) \
- ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
- /*
- * When using this macro "break" only breaks out of the inner loop. Use "goto"
- * to break out of the tabpage loop.
- */
- #define FOR_ALL_TAB_WINDOWS(tp, wp) \
- for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
- for ((wp) = ((tp) == curtab) \
- ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
-
- #define FOR_ALL_POPUPWINS(wp) \
- for ((wp) = first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
- #define FOR_ALL_POPUPWINS_IN_TAB(tp, wp) \
- for ((wp) = (tp)->tp_first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
-

EXTERN win_T *curwin; // currently active window

--- 964,969 ----
***************
*** 1050,1065 ****
EXTERN buf_T *lastbuf INIT(= NULL); // last buffer
EXTERN buf_T *curbuf INIT(= NULL); // currently active buffer

- #define FOR_ALL_BUFFERS(buf) \
- for ((buf) = firstbuf; (buf) != NULL; (buf) = (buf)->b_next)
-
- #define FOR_ALL_BUF_WININFO(buf, wip) \
- for ((wip) = (buf)->b_wininfo; (wip) != NULL; (wip) = (wip)->wi_next)
-
- // Iterate through all the signs placed in a buffer
- #define FOR_ALL_SIGNS_IN_BUF(buf, sign) \
- for ((sign) = (buf)->b_signlist; (sign) != NULL; (sign) = (sign)->se_next)
-
// Flag that is set when switching off 'swapfile'. It means that all blocks
// are to be loaded into memory. Shouldn't be global...
EXTERN int mf_dont_release INIT(= FALSE); // don't release blocks
--- 1025,1030 ----
***************
*** 1874,1882 ****
// Line in which spell checking wasn't highlighted because it touched the
// cursor position in Insert mode.
EXTERN linenr_T spell_redraw_lnum INIT(= 0);
-
- #define FOR_ALL_SPELL_LANGS(slang) \
- for ((slang) = first_lang; (slang) != NULL; (slang) = (slang)->sl_next)
#endif

#ifdef FEAT_CONCEAL
--- 1839,1844 ----
***************
*** 2015,2025 ****

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

#ifdef FEAT_EVAL
--- 1977,1982 ----
***************
*** 2032,2045 ****
# define REPEATED_MSG_SAFESTATE 2
#endif

- #if defined(FEAT_DIFF)
- #define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \
- for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next)
- #endif
-
- #define FOR_ALL_LIST_ITEMS(l, li) \
- for ((li) = (l) == NULL ? NULL : (l)->lv_first; (li) != NULL; (li) = (li)->li_next)
-
// While executing a regexp and set to OPTION_MAGIC_ON or OPTION_MAGIC_OFF this
// overrules p_magic. Otherwise set to OPTION_MAGIC_NOT_SET.
EXTERN optmagic_T magic_overruled INIT(= OPTION_MAGIC_NOT_SET);
--- 1989,1994 ----
*** ../vim-9.0.1389/src/hashtab.c 2022-12-26 13:51:22.169286655 +0000
--- src/hashtab.c 2023-03-07 17:10:22.929201385 +0000
***************
*** 108,114 ****
hashitem_T *hi;

todo = (long)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 108,114 ----
hashitem_T *hi;

todo = (long)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/if_mzsch.c 2023-02-22 13:14:33.514931016 +0000
--- src/if_mzsch.c 2023-03-07 17:10:22.929201385 +0000
***************
*** 3067,3073 ****
hashitem_T *hi;
dictitem_T *di;

! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 3067,3073 ----
hashitem_T *hi;
dictitem_T *di;

! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/if_ruby.c 2023-01-12 12:33:25.424525189 +0000
--- src/if_ruby.c 2023-03-07 17:10:22.929201385 +0000
***************
*** 1147,1153 ****
hashitem_T *hi;
dictitem_T *di;

! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 1147,1153 ----
hashitem_T *hi;
dictitem_T *di;

! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/job.c 2023-02-21 14:27:34.520360383 +0000
--- src/job.c 2023-03-07 17:10:22.929201385 +0000
***************
*** 140,146 ****
return OK;

todo = (int)dict->dv_hashtab.ht_used;
! for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
item = &dict_lookup(hi)->di_tv;
--- 140,146 ----
return OK;

todo = (int)dict->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&dict->dv_hashtab, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
item = &dict_lookup(hi)->di_tv;
*** ../vim-9.0.1389/src/macros.h 2023-01-22 21:14:32.621863614 +0000
--- src/macros.h 2023-03-07 17:10:22.929201385 +0000
***************
*** 396,398 ****
--- 396,451 ----

// Length of the array.
#define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))
+
+ #ifdef FEAT_MENU
+ #define FOR_ALL_MENUS(m) \
+ for ((m) = root_menu; (m) != NULL; (m) = (m)->next)
+ #define FOR_ALL_CHILD_MENUS(p, c) \
+ for ((c) = (p)->children; (c) != NULL; (c) = (c)->next)
+ #endif
+
+ #define FOR_ALL_WINDOWS(wp) \
+ for ((wp) = firstwin; (wp) != NULL; (wp) = (wp)->w_next)
+ #define FOR_ALL_FRAMES(frp, first_frame) \
+ for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next)
+ #define FOR_ALL_TABPAGES(tp) \
+ for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next)
+ #define FOR_ALL_WINDOWS_IN_TAB(tp, wp) \
+ for ((wp) = ((tp) == NULL || (tp) == curtab) \
+ ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
+ /*
+ * When using this macro "break" only breaks out of the inner loop. Use "goto"
+ * to break out of the tabpage loop.
+ */
+ #define FOR_ALL_TAB_WINDOWS(tp, wp) \
+ for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
+ for ((wp) = ((tp) == curtab) \
+ ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
+
+ #define FOR_ALL_POPUPWINS(wp) \
+ for ((wp) = first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
+ #define FOR_ALL_POPUPWINS_IN_TAB(tp, wp) \
+ for ((wp) = (tp)->tp_first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
+
+ #define FOR_ALL_BUFFERS(buf) \
+ for ((buf) = firstbuf; (buf) != NULL; (buf) = (buf)->b_next)
+
+ #define FOR_ALL_BUF_WININFO(buf, wip) \
+ for ((wip) = (buf)->b_wininfo; (wip) != NULL; (wip) = (wip)->wi_next)
+
+ // Iterate through all the signs placed in a buffer
+ #define FOR_ALL_SIGNS_IN_BUF(buf, sign) \
+ for ((sign) = (buf)->b_signlist; (sign) != NULL; (sign) = (sign)->se_next)
+
+ #ifdef FEAT_SPELL
+ #define FOR_ALL_SPELL_LANGS(slang) \
+ for ((slang) = first_lang; (slang) != NULL; (slang) = (slang)->sl_next)
+ #endif
+
+ // Iterate over all the items in a List
+ #define FOR_ALL_LIST_ITEMS(l, li) \
+ for ((li) = (l) == NULL ? NULL : (l)->lv_first; (li) != NULL; (li) = (li)->li_next)
+
+ // Iterate over all the items in a hash table
+ #define FOR_ALL_HASHTAB_ITEMS(ht, hi, todo) \
+ for ((hi) = (ht)->ht_array; (todo) > 0; ++(hi))
*** ../vim-9.0.1389/src/mbyte.c 2023-01-20 16:00:49.542341277 +0000
--- src/mbyte.c 2023-03-07 17:10:22.929201385 +0000
***************
*** 1579,1585 ****
// values of them.
//
// Note that these symbols are of varying widths, as they are symbols
! // representing differents things ranging from a simple gear icon to an
// airplane. Some of them are in fact wider than double-width, but Vim
// doesn't support non-fixed-width font, and tagging them as
// double-width is the best way to handle them.
--- 1579,1585 ----
// values of them.
//
// Note that these symbols are of varying widths, as they are symbols
! // representing different things ranging from a simple gear icon to an
// airplane. Some of them are in fact wider than double-width, but Vim
// doesn't support non-fixed-width font, and tagging them as
// double-width is the best way to handle them.
***************
*** 5647,5653 ****
// Check that all entries are a list with three numbers, the range is
// valid and the cell width is valid.
item = 0;
! for (li = l->lv_first; li != NULL; li = li->li_next)
{
listitem_T *lili;
varnumber_T n1;
--- 5647,5653 ----
// Check that all entries are a list with three numbers, the range is
// valid and the cell width is valid.
item = 0;
! FOR_ALL_LIST_ITEMS(l, li)
{
listitem_T *lili;
varnumber_T n1;
*** ../vim-9.0.1389/src/os_unix.c 2023-03-04 13:23:22.969812280 +0000
--- src/os_unix.c 2023-03-07 17:10:22.929201385 +0000
***************
*** 2335,2344 ****
{
int do_push_pop = unix_did_set_title || did_set_icon;

! // only restore the title or icon when it has been set
! mch_settitle(((which & SAVE_RESTORE_TITLE) && unix_did_set_title) ?
! (oldtitle ? oldtitle : p_titleold) : NULL,
((which & SAVE_RESTORE_ICON) && did_set_icon) ? oldicon : NULL);

if (do_push_pop)
{
--- 2335,2354 ----
{
int do_push_pop = unix_did_set_title || did_set_icon;

! // Only restore the title or icon when it has been set.
! // When using "oldtitle" make a copy, it might be freed halfway.
! char_u *title = ((which & SAVE_RESTORE_TITLE) && unix_did_set_title)
! ? (oldtitle ? oldtitle : p_titleold) : NULL;
! char_u *tofree = NULL;
! if (title == oldtitle && oldtitle != NULL)
! {
! tofree = vim_strsave(title);
! if (tofree != NULL)
! title = tofree;
! }
! mch_settitle(title,
((which & SAVE_RESTORE_ICON) && did_set_icon) ? oldicon : NULL);
+ vim_free(tofree);

if (do_push_pop)
{
***************
*** 5654,5660 ****
hashitem_T *hi;
int todo = (int)dict->dv_hashtab.ht_used;

! for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
typval_T *item = &dict_lookup(hi)->di_tv;
--- 5664,5670 ----
hashitem_T *hi;
int todo = (int)dict->dv_hashtab.ht_used;

! FOR_ALL_HASHTAB_ITEMS(&dict->dv_hashtab, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
typval_T *item = &dict_lookup(hi)->di_tv;
*** ../vim-9.0.1389/src/os_win32.c 2023-02-15 19:13:39.363474050 +0000
--- src/os_win32.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 1308,1316 ****
if (mods)
{
// If "modifiers" is explicitly set in the args, then we reset any
! // remembered modifer key state that may have been set from earlier
! // mod-key-down events, even if they are not yet unset by earlier
! // mod-key-up events.
s_dwMods = 0;
if (mods & MOD_MASK_SHIFT)
ker.dwControlKeyState |= SHIFT_PRESSED;
--- 1308,1316 ----
if (mods)
{
// If "modifiers" is explicitly set in the args, then we reset any
! // remembered modifier key state that may have been set from
! // earlier mod-key-down events, even if they are not yet unset by
! // earlier mod-key-up events.
s_dwMods = 0;
if (mods & MOD_MASK_SHIFT)
ker.dwControlKeyState |= SHIFT_PRESSED;
***************
*** 2017,2023 ****
}

// Ideally, WriteConsoleInput would be used to inject these low-level
! // events. But, this doesnt work well in the CI test environment. So
// implementing an input_record_buffer instead.
if (input_encoded)
lpEventsWritten = write_input_record_buffer(&ir, 1);
--- 2017,2023 ----
}

// Ideally, WriteConsoleInput would be used to inject these low-level
! // events. But, this doesn't work well in the CI test environment. So
// implementing an input_record_buffer instead.
if (input_encoded)
lpEventsWritten = write_input_record_buffer(&ir, 1);
***************
*** 5737,5743 ****

if (env != NULL)
{
! for (hi = env->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 5737,5743 ----

if (env != NULL)
{
! FOR_ALL_HASHTAB_ITEMS(&env->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/popupwin.c 2023-02-21 14:27:34.520360383 +0000
--- src/popupwin.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 2413,2420 ****
win_enter(owp, FALSE);
else
{
! for (owp = curtab->tp_first_popupwin; owp != NULL;
! owp = owp->w_next)
if (owp != curwin && owp->w_buffer->b_term != NULL)
break;
if (owp != NULL)
--- 2413,2419 ----
win_enter(owp, FALSE);
else
{
! FOR_ALL_POPUPWINS_IN_TAB(curtab, owp)
if (owp != curwin && owp->w_buffer->b_term != NULL)
break;
if (owp != NULL)
*** ../vim-9.0.1389/src/profiler.c 2023-01-18 18:17:43.865053454 +0000
--- src/profiler.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 335,341 ****
functbl = func_tbl_get();
todo = (int)functbl->ht_used;

! for (hi = functbl->ht_array; todo > 0; ++hi)
{
ufunc_T *fp;
int i;
--- 335,341 ----
functbl = func_tbl_get();
todo = (int)functbl->ht_used;

! FOR_ALL_HASHTAB_ITEMS(functbl, hi, todo)
{
ufunc_T *fp;
int i;
***************
*** 825,831 ****

sorttab = ALLOC_MULT(ufunc_T *, todo);

! for (hi = functbl->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 825,831 ----

sorttab = ALLOC_MULT(ufunc_T *, todo);

! FOR_ALL_HASHTAB_ITEMS(functbl, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/scriptfile.c 2023-01-27 21:03:08.899101847 +0000
--- src/scriptfile.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 1672,1678 ****
// is encountered without the "noclear" argument.
ht = &SCRIPT_VARS(sid);
todo = (int)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
--todo;
--- 1672,1678 ----
// is encountered without the "noclear" argument.
ht = &SCRIPT_VARS(sid);
todo = (int)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
--todo;
***************
*** 2063,2069 ****
// looking for functions with script ID 'sid'.
functbl = func_tbl_get();
todo = functbl->ht_used;
! for (hi = functbl->ht_array; todo > 0; ++hi)
{
ufunc_T *fp;

--- 2063,2069 ----
// looking for functions with script ID 'sid'.
functbl = func_tbl_get();
todo = functbl->ht_used;
! FOR_ALL_HASHTAB_ITEMS(functbl, hi, todo)
{
ufunc_T *fp;

*** ../vim-9.0.1389/src/session.c 2023-01-23 20:46:16.162493149 +0000
--- src/session.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 543,549 ****
char_u *p, *t;

todo = (int)gvht->ht_used;
! for (hi = gvht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 543,549 ----
char_u *p, *t;

todo = (int)gvht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(gvht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/sign.c 2023-01-23 20:46:16.166493150 +0000
--- src/sign.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 2058,2064 ****
// Complete with name of sign groups already defined
current_idx = 0;
todo = (int)sg_table.ht_used;
! for (hi = sg_table.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 2058,2064 ----
// Complete with name of sign groups already defined
current_idx = 0;
todo = (int)sg_table.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&sg_table, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/spellfile.c 2023-02-20 12:16:33.340269410 +0000
--- src/spellfile.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 3466,3472 ****
for (ht = &aff->af_pref; ; ht = &aff->af_suff)
{
todo = (int)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 3466,3472 ----
for (ht = &aff->af_pref; ; ht = &aff->af_suff)
{
todo = (int)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 5117,5123 ****
hashitem_T *hi;

todo = (int)spin->si_commonwords.ht_used;
! for (hi = spin->si_commonwords.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
l = (int)STRLEN(hi->hi_key) + 1;
--- 5117,5123 ----
hashitem_T *hi;

todo = (int)spin->si_commonwords.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&spin->si_commonwords, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
l = (int)STRLEN(hi->hi_key) + 1;
*** ../vim-9.0.1389/src/spellsuggest.c 2023-02-20 12:16:33.340269410 +0000
--- src/spellsuggest.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 3176,3182 ****
{
// Free the info about handled words.
todo = (int)slang->sl_sounddone.ht_used;
! for (hi = slang->sl_sounddone.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
vim_free(HI2SFT(hi));
--- 3176,3182 ----
{
// Free the info about handled words.
todo = (int)slang->sl_sounddone.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&slang->sl_sounddone, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
vim_free(HI2SFT(hi));
*** ../vim-9.0.1389/src/syntax.c 2023-01-27 21:03:08.899101847 +0000
--- src/syntax.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 4323,4329 ****

hash_lock(ht);
todo = (int)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 4323,4329 ----

hash_lock(ht);
todo = (int)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 4371,4377 ****
keyentry_T *kp_next;

todo = (int)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 4371,4377 ----
keyentry_T *kp_next;

todo = (int)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/testing.c 2023-01-25 21:05:35.131042802 +0000
--- src/testing.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 181,187 ****
return;

todo = (int)exp_d->dv_hashtab.ht_used;
! for (hi = exp_d->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 181,187 ----
return;

todo = (int)exp_d->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&exp_d->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 204,210 ****

// Add items only present in got_d.
todo = (int)got_d->dv_hashtab.ht_used;
! for (hi = got_d->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 204,210 ----

// Add items only present in got_d.
todo = (int)got_d->dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&got_d->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/textprop.c 2023-01-25 21:05:35.131042802 +0000
--- src/textprop.c 2023-03-07 17:10:22.933201383 +0000
***************
*** 723,729 ****
static textprop_T *text_prop_compare_props;
static buf_T *text_prop_compare_buf;

! /* Score for sorting on position of the text property: 0: above,
* 1: after (default), 2: right, 3: below (comes last)
*/
static int
--- 723,730 ----
static textprop_T *text_prop_compare_props;
static buf_T *text_prop_compare_buf;

! /*
! * Score for sorting on position of the text property: 0: above,
* 1: after (default), 2: right, 3: below (comes last)
*/
static int
***************
*** 933,939 ****
if (*array == NULL)
return NULL;
todo = (long)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 934,940 ----
if (*array == NULL)
return NULL;
todo = (long)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 1958,1964 ****
hash_remove(ht, hi, "prop type delete");
vim_free(prop);

! // currently visibile text properties will disappear
redraw_all_later(UPD_CLEAR);
changed_window_setting_buf(buf == NULL ? curbuf : buf);
}
--- 1959,1965 ----
hash_remove(ht, hi, "prop type delete");
vim_free(prop);

! // currently visible text properties will disappear
redraw_all_later(UPD_CLEAR);
changed_window_setting_buf(buf == NULL ? curbuf : buf);
}
***************
*** 2021,2027 ****
hashitem_T *hi;

todo = (long)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 2022,2028 ----
hashitem_T *hi;

todo = (long)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 2074,2080 ****
return;

todo = (long)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 2075,2081 ----
return;

todo = (long)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/userfunc.c 2023-02-21 19:55:02.795958051 +0000
--- src/userfunc.c 2023-03-07 17:10:22.937201381 +0000
***************
*** 2313,2319 ****

// Make a copy of the a: variables, since we didn't do that above.
todo = (int)fc->fc_l_avars.dv_hashtab.ht_used;
! for (hi = fc->fc_l_avars.dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 2313,2319 ----

// Make a copy of the a: variables, since we didn't do that above.
todo = (int)fc->fc_l_avars.dv_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&fc->fc_l_avars.dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
***************
*** 3296,3302 ****
while (todo > 0)
{
todo = func_hashtab.ht_used;
! for (hi = func_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
fp = HI2UF(hi);
--- 3296,3302 ----
while (todo > 0)
{
todo = func_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&func_hashtab, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
fp = HI2UF(hi);
***************
*** 3353,3359 ****
while (todo > 0)
{
todo = func_hashtab.ht_used;
! for (hi = func_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
// clear the def function index now
--- 3353,3359 ----
while (todo > 0)
{
todo = func_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&func_hashtab, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
// clear the def function index now
***************
*** 3385,3391 ****
while (func_hashtab.ht_used > skipped)
{
todo = func_hashtab.ht_used;
! for (hi = func_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
--todo;
--- 3385,3391 ----
while (func_hashtab.ht_used > skipped)
{
todo = func_hashtab.ht_used;
! FOR_ALL_HASHTAB_ITEMS(&func_hashtab, hi, todo)
if (!HASHITEM_EMPTY(hi))
{
--todo;
*** ../vim-9.0.1389/src/vim9execute.c 2023-03-02 17:38:30.019743929 +0000
--- src/vim9execute.c 2023-03-07 17:10:22.937201381 +0000
***************
*** 1052,1058 ****

if (defer_tv->v_type != VAR_LIST)
return; // no function added
! for (li = defer_tv->vval.v_list->lv_first; li != NULL; li = li->li_next)
{
list_T *l = li->li_tv.vval.v_list;
typval_T rettv;
--- 1052,1058 ----

if (defer_tv->v_type != VAR_LIST)
return; // no function added
! FOR_ALL_LIST_ITEMS(defer_tv->vval.v_list, li)
{
list_T *l = li->li_tv.vval.v_list;
typval_T rettv;
*** ../vim-9.0.1389/src/vim9script.c 2023-02-01 13:11:11.714991151 +0000
--- src/vim9script.c 2023-03-07 17:10:22.937201381 +0000
***************
*** 281,287 ****

hash_lock(ht);
todo = (int)ht->ht_used;
! for (hi = ht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 281,287 ----

hash_lock(ht);
todo = (int)ht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/vim9type.c 2023-02-21 12:38:46.827436713 +0000
--- src/vim9type.c 2023-03-07 17:10:22.937201381 +0000
***************
*** 213,219 ****
hashitem_T *hi;
dictitem_T *di;

! for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 213,219 ----
hashitem_T *hi;
dictitem_T *di;

! FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/viminfo.c 2023-01-26 11:58:39.610071592 +0000
--- src/viminfo.c 2023-03-07 17:10:22.937201381 +0000
***************
*** 1319,1325 ****
fputs(_("\n# global variables:\n"), fp);

todo = (int)gvht->ht_used;
! for (hi = gvht->ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
--- 1319,1325 ----
fputs(_("\n# global variables:\n"), fp);

todo = (int)gvht->ht_used;
! FOR_ALL_HASHTAB_ITEMS(gvht, hi, todo)
{
if (!HASHITEM_EMPTY(hi))
{
*** ../vim-9.0.1389/src/window.c 2023-02-27 17:17:57.750253721 +0000
--- src/window.c 2023-03-07 17:10:22.937201381 +0000
***************
*** 5622,5628 ****
// If there already is an entry with "wi_win" set to NULL it
// must be removed, it would never be used.
// Skip "wip" itself, otherwise Coverity complains.
! for (wip2 = buf->b_wininfo; wip2 != NULL; wip2 = wip2->wi_next)
if (wip2 != wip && wip2->wi_win == NULL)
{
if (wip2->wi_next != NULL)
--- 5622,5628 ----
// If there already is an entry with "wi_win" set to NULL it
// must be removed, it would never be used.
// Skip "wip" itself, otherwise Coverity complains.
! FOR_ALL_BUF_WININFO(buf, wip2)
if (wip2 != wip && wip2->wi_win == NULL)
{
if (wip2->wi_next != NULL)
***************
*** 7378,7384 ****

/*
* A snapshot of the window sizes, to restore them after closing the help
! * window.
* Only these fields are used:
* fr_layout
* fr_width
--- 7378,7384 ----

/*
* A snapshot of the window sizes, to restore them after closing the help
! * or other window.
* Only these fields are used:
* fr_layout
* fr_width
***************
*** 7390,7395 ****
--- 7390,7396 ----

/*
* Create a snapshot of the current frame sizes.
+ * "idx" is SNAP_HELP_IDX or SNAP_AUCMD_IDX.
*/
void
make_snapshot(int idx)
***************
*** 7473,7478 ****
--- 7474,7480 ----
* Restore a previously created snapshot, if there is any.
* This is only done if the screen size didn't change and the window layout is
* still the same.
+ * "idx" is SNAP_HELP_IDX or SNAP_AUCMD_IDX.
*/
void
restore_snapshot(
*** ../vim-9.0.1389/src/version.c 2023-03-07 15:30:46.129459752 +0000
--- src/version.c 2023-03-07 17:12:18.109148616 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1390,
/**/

--
"Women marry men hoping they will change. Men marry women hoping
they will not. So each is inevitably disappointed."
- Einstein

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yegappan Lakshmanan

unread,
Mar 8, 2023, 12:29:47 AM3/8/23
to vim...@googlegroups.com
Hi Bram,

On Tue, Mar 7, 2023 at 9:14 AM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Patch 9.0.1390
> 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)
>
>
The above change was not part of my PR. Was this included by mistake?

Regards,
Yegappan

Bram Moolenaar

unread,
Mar 8, 2023, 11:40:00 AM3/8/23
to vim...@googlegroups.com, Yegappan Lakshmanan
Sorry, that was a change I started a while ago but hadn't finished. It
somehow got included in this patch. At least it's missing a test. Let
me know if it causes any problems.

--
hundred-and-one symptoms of being an internet addict:
244. You use more than 20 passwords.
Reply all
Reply to author
Forward
0 new messages