To: vim_dev@googlegroups.com Subject: Patch 8.2.0500 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0500 Problem: Using the same loop in many places. Solution: Define more FOR_ALL macros. (Yegappan Lakshmanan, closes #5339) Files: src/arglist.c, src/autocmd.c, src/buffer.c, src/change.c, src/channel.c, src/cmdexpand.c, src/diff.c, src/eval.c, src/evalbuffer.c, src/evalfunc.c, src/evalvars.c, src/evalwindow.c, src/ex_cmds2.c, src/filepath.c, src/globals.h, src/gui.c, src/if_py_both.h, src/if_ruby.c, src/insexpand.c, src/list.c, src/misc2.c, src/netbeans.c, src/popupwin.c, src/quickfix.c, src/screen.c, src/sign.c, src/spell.c, src/spellfile.c, src/spellsuggest.c, src/tag.c, src/terminal.c, src/userfunc.c, src/window.c *** ../vim-8.2.0499/src/arglist.c 2020-02-01 23:04:20.120422629 +0100 --- src/arglist.c 2020-04-02 18:38:45.110510356 +0200 *************** *** 1046,1052 **** // Move the already present window to below the current window if (curwin->w_arg_idx != i) { ! for (wpnext = firstwin; wpnext != NULL; wpnext = wpnext->w_next) { if (wpnext->w_arg_idx == i) { --- 1046,1052 ---- // Move the already present window to below the current window if (curwin->w_arg_idx != i) { ! FOR_ALL_WINDOWS(wpnext) { if (wpnext->w_arg_idx == i) { *** ../vim-8.2.0499/src/autocmd.c 2020-01-26 22:43:27.484098902 +0100 --- src/autocmd.c 2020-04-02 18:42:55.505574595 +0200 *************** *** 235,240 **** --- 235,244 ---- static AutoPatCmd *active_apc_list = NULL; // stack of active autocommands + // Macro to loop over all the patterns for an autocmd event + #define FOR_ALL_AUTOCMD_PATTERNS(event, ap) \ + for ((ap) = first_autopat[(int)(event)]; (ap) != NULL; (ap) = (ap)->next) + /* * augroups stores a list of autocmd group names. */ *************** *** 456,462 **** for (event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) // loop over all autocommand patterns ! for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next) if (ap->buflocal_nr == buf->b_fnum) { au_remove_pat(ap); --- 460,466 ---- for (event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) // loop over all autocommand patterns ! FOR_ALL_AUTOCMD_PATTERNS(event, ap) if (ap->buflocal_nr == buf->b_fnum) { au_remove_pat(ap); *************** *** 519,525 **** for (event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) { ! for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next) if (ap->group == i && ap->pat != NULL) { give_warning((char_u *)_("W19: Deleting augroup that is still in use"), TRUE); --- 523,529 ---- for (event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) { ! FOR_ALL_AUTOCMD_PATTERNS(event, ap) if (ap->group == i && ap->pat != NULL) { give_warning((char_u *)_("W19: Deleting augroup that is still in use"), TRUE); *************** *** 1041,1047 **** */ if (*pat == NUL) { ! for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next) { if (forceit) // delete the AutoPat, if it's in the current group { --- 1045,1051 ---- */ if (*pat == NUL) { ! FOR_ALL_AUTOCMD_PATTERNS(event, ap) { if (forceit) // delete the AutoPat, if it's in the current group { *************** *** 2400,2406 **** forward_slash(fname); #endif ! for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next) if (ap->pat != NULL && ap->cmds != NULL && (ap->buflocal_nr == 0 ? match_file_pat(NULL, &ap->reg_prog, --- 2404,2410 ---- forward_slash(fname); #endif ! FOR_ALL_AUTOCMD_PATTERNS(event, ap) if (ap->pat != NULL && ap->cmds != NULL && (ap->buflocal_nr == 0 ? match_file_pat(NULL, &ap->reg_prog, *** ../vim-8.2.0499/src/buffer.c 2020-03-27 20:58:33.345005916 +0100 --- src/buffer.c 2020-04-02 18:38:45.110510356 +0200 *************** *** 2911,2917 **** { wininfo_T *wip; ! for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) if (wip->wi_win == win) break; if (wip == NULL) --- 2911,2917 ---- { wininfo_T *wip; ! FOR_ALL_BUF_WININFO(buf, wip) if (wip->wi_win == win) break; if (wip == NULL) *************** *** 3004,3010 **** { wininfo_T *wip; ! for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) if (wip->wi_win == curwin #ifdef FEAT_DIFF && (!skip_diff_buffer || !wininfo_other_tab_diff(wip)) --- 3004,3010 ---- { wininfo_T *wip; ! FOR_ALL_BUF_WININFO(buf, wip) if (wip->wi_win == curwin #ifdef FEAT_DIFF && (!skip_diff_buffer || !wininfo_other_tab_diff(wip)) *************** *** 3019,3025 **** #ifdef FEAT_DIFF if (skip_diff_buffer) { ! for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) if (!wininfo_other_tab_diff(wip)) break; } --- 3019,3025 ---- #ifdef FEAT_DIFF if (skip_diff_buffer) { ! FOR_ALL_BUF_WININFO(buf, wip) if (!wininfo_other_tab_diff(wip)) break; } *************** *** 3132,3138 **** if (vim_strchr(eap->arg, 't')) { ga_init2(&buflist, sizeof(buf_T *), 50); ! for (buf = firstbuf; buf != NULL; buf = buf->b_next) { if (ga_grow(&buflist, 1) == OK) ((buf_T **)buflist.ga_data)[buflist.ga_len++] = buf; --- 3132,3138 ---- if (vim_strchr(eap->arg, 't')) { ga_init2(&buflist, sizeof(buf_T *), 50); ! FOR_ALL_BUFFERS(buf) { if (ga_grow(&buflist, 1) == OK) ((buf_T **)buflist.ga_data)[buflist.ga_len++] = buf; *** ../vim-8.2.0499/src/change.c 2020-02-26 22:05:57.094386589 +0100 --- src/change.c 2020-04-02 18:38:45.110510356 +0200 *************** *** 172,179 **** linenr_T prev_lnum; linenr_T prev_lnume; ! for (li = buf->b_recorded_changes->lv_first; li != NULL; ! li = li->li_next) { prev_lnum = (linenr_T)dict_get_number( li->li_tv.vval.v_dict, (char_u *)"lnum"); --- 172,178 ---- linenr_T prev_lnum; linenr_T prev_lnume; ! 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"); *************** *** 362,369 **** argv[0].v_type = VAR_NUMBER; argv[0].vval.v_number = buf->b_fnum; // a:bufnr ! ! for (li = buf->b_recorded_changes->lv_first; li != NULL; li = li->li_next) { varnumber_T lnum; --- 361,367 ---- argv[0].v_type = VAR_NUMBER; argv[0].vval.v_number = buf->b_fnum; // a:bufnr ! FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li) { varnumber_T lnum; *** ../vim-8.2.0499/src/channel.c 2020-03-28 18:06:25.751664246 +0100 --- src/channel.c 2020-04-02 18:45:02.641089649 +0200 *************** *** 61,66 **** --- 61,72 ---- static ch_part_T channel_part_read(channel_T *channel); static void free_job_options(jobopt_T *opt); + #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) + // Whether a redraw is needed for appending a line to a buffer. static int channel_need_redraw = FALSE; *************** *** 476,482 **** // point. ++safe_to_invoke_callback; ! for (ch = first_channel; ch != NULL; ch = ch->ch_next) if (!channel_still_useful(ch) && (ch->ch_copyID & mask) != (copyID & mask)) { --- 482,488 ---- // point. ++safe_to_invoke_callback; ! FOR_ALL_CHANNELS(ch) if (!channel_still_useful(ch) && (ch->ch_copyID & mask) != (copyID & mask)) { *************** *** 520,527 **** ch_part_T part; if (fd != INVALID_FD) ! for (channel = first_channel; channel != NULL; ! channel = channel->ch_next) { for (part = PART_SOCK; part < PART_IN; ++part) if (channel->ch_part[part].ch_fd == fd) --- 526,532 ---- ch_part_T part; if (fd != INVALID_FD) ! FOR_ALL_CHANNELS(channel) { for (part = PART_SOCK; part < PART_IN; ++part) if (channel->ch_part[part].ch_fd == fd) *************** *** 662,668 **** { channel_T *channel; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) channel_gui_register(channel); } --- 667,673 ---- { channel_T *channel; ! FOR_ALL_CHANNELS(channel) channel_gui_register(channel); } *************** *** 1569,1575 **** channel_T *channel; ch_part_T part; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) for (part = PART_SOCK; part < PART_COUNT; ++part) { chanpart_T *ch_part = &channel->ch_part[part]; --- 1574,1580 ---- channel_T *channel; ch_part_T part; ! FOR_ALL_CHANNELS(channel) for (part = PART_SOCK; part < PART_COUNT; ++part) { chanpart_T *ch_part = &channel->ch_part[part]; *************** *** 1610,1616 **** { channel_T *channel; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) channel_write_input(channel); } --- 1615,1621 ---- { channel_T *channel; ! FOR_ALL_CHANNELS(channel) channel_write_input(channel); } *************** *** 1625,1631 **** // There could be more than one channel for the buffer, loop over all of // them. ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) { chanpart_T *in_part = &channel->ch_part[PART_IN]; linenr_T lnum; --- 1630,1636 ---- // There could be more than one channel for the buffer, loop over all of // them. ! FOR_ALL_CHANNELS(channel) { chanpart_T *in_part = &channel->ch_part[PART_IN]; linenr_T lnum; *************** *** 2604,2610 **** // Find channels reading from this buffer and adjust their // next-to-read line number. buffer->b_write_to_channel = TRUE; ! for (ch = first_channel; ch != NULL; ch = ch->ch_next) { chanpart_T *in_part = &ch->ch_part[PART_IN]; --- 2609,2615 ---- // Find channels reading from this buffer and adjust their // next-to-read line number. buffer->b_write_to_channel = TRUE; ! FOR_ALL_CHANNELS(ch) { chanpart_T *in_part = &ch->ch_part[PART_IN]; *************** *** 3180,3186 **** channel_T *channel; ch_log(NULL, "channel_free_all()"); ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) channel_clear(channel); } #endif --- 3185,3191 ---- channel_T *channel; ch_log(NULL, "channel_free_all()"); ! FOR_ALL_CHANNELS(channel) channel_clear(channel); } #endif *************** *** 3202,3208 **** int maxfd = maxfd_arg; channel_T *ch; ! for (ch = first_channel; ch != NULL; ch = ch->ch_next) { chanpart_T *in_part = &ch->ch_part[PART_IN]; --- 3207,3213 ---- int maxfd = maxfd_arg; channel_T *ch; ! FOR_ALL_CHANNELS(ch) { chanpart_T *in_part = &ch->ch_part[PART_IN]; *************** *** 3227,3233 **** int nfd = nfd_in; channel_T *ch; ! for (ch = first_channel; ch != NULL; ch = ch->ch_next) { chanpart_T *in_part = &ch->ch_part[PART_IN]; --- 3232,3238 ---- int nfd = nfd_in; channel_T *ch; ! FOR_ALL_CHANNELS(ch) { chanpart_T *in_part = &ch->ch_part[PART_IN]; *************** *** 3821,3827 **** ch_part_T part; sock_T fd; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) { if (only_keep_open && !channel->ch_keep_open) continue; --- 3826,3832 ---- ch_part_T part; sock_T fd; ! FOR_ALL_CHANNELS(channel) { if (only_keep_open && !channel->ch_keep_open) continue; *************** *** 3854,3860 **** { channel_T *channel; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) if (channel->ch_keep_open) return TRUE; return FALSE; --- 3859,3865 ---- { channel_T *channel; ! FOR_ALL_CHANNELS(channel) if (channel->ch_keep_open) return TRUE; return FALSE; *************** *** 4234,4240 **** struct pollfd *fds = fds_in; ch_part_T part; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) { for (part = PART_SOCK; part < PART_IN; ++part) { --- 4239,4245 ---- struct pollfd *fds = fds_in; ch_part_T part; ! FOR_ALL_CHANNELS(channel) { for (part = PART_SOCK; part < PART_IN; ++part) { *************** *** 4281,4287 **** int idx; chanpart_T *in_part; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) { for (part = PART_SOCK; part < PART_IN; ++part) { --- 4286,4292 ---- int idx; chanpart_T *in_part; ! FOR_ALL_CHANNELS(channel) { for (part = PART_SOCK; part < PART_IN; ++part) { *************** *** 4332,4338 **** fd_set *wfds = wfds_in; ch_part_T part; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) { for (part = PART_SOCK; part < PART_IN; ++part) { --- 4337,4343 ---- fd_set *wfds = wfds_in; ch_part_T part; ! FOR_ALL_CHANNELS(channel) { for (part = PART_SOCK; part < PART_IN; ++part) { *************** *** 4381,4387 **** ch_part_T part; chanpart_T *in_part; ! for (channel = first_channel; channel != NULL; channel = channel->ch_next) { for (part = PART_SOCK; part < PART_IN; ++part) { --- 4386,4392 ---- ch_part_T part; chanpart_T *in_part; ! FOR_ALL_CHANNELS(channel) { for (part = PART_SOCK; part < PART_IN; ++part) { *************** *** 5471,5477 **** { job_T *job; ! for (job = first_job; job != NULL; job = job->jv_next) if (job_still_useful(job)) { ch_log(NULL, "GUI not forking because a job is running"); --- 5476,5482 ---- { job_T *job; ! FOR_ALL_JOBS(job) if (job_still_useful(job)) { ch_log(NULL, "GUI not forking because a job is running"); *************** *** 5570,5576 **** char_u *s; range_list_materialize(l); ! for (li = l->lv_first; li != NULL; li = li->li_next) { s = tv_get_string_chk(&li->li_tv); if (s == NULL) --- 5575,5581 ---- char_u *s; range_list_materialize(l); ! FOR_ALL_LIST_ITEMS(l, li) { s = tv_get_string_chk(&li->li_tv); if (s == NULL) *************** *** 5695,5701 **** int did_free = FALSE; job_T *job; ! for (job = first_job; job != NULL; job = job->jv_next) if ((job->jv_copyID & mask) != (copyID & mask) && !job_still_useful(job)) { --- 5700,5706 ---- int did_free = FALSE; job_T *job; ! FOR_ALL_JOBS(job) if ((job->jv_copyID & mask) != (copyID & mask) && !job_still_useful(job)) { *************** *** 5781,5787 **** { job_T *job; ! for (job = first_job; job != NULL; job = job->jv_next) if (job->jv_status == JOB_STARTED && job->jv_stoponexit != NULL) mch_signal_job(job, job->jv_stoponexit); } --- 5786,5792 ---- { job_T *job; ! FOR_ALL_JOBS(job) if (job->jv_status == JOB_STARTED && job->jv_stoponexit != NULL) mch_signal_job(job, job->jv_stoponexit); } *************** *** 5795,5801 **** { job_T *job; ! for (job = first_job; job != NULL; job = job->jv_next) // Only should check if the channel has been closed, if the channel is // open the job won't exit. if ((job->jv_status == JOB_STARTED && !job_channel_still_useful(job)) --- 5800,5806 ---- { job_T *job; ! FOR_ALL_JOBS(job) // Only should check if the channel has been closed, if the channel is // open the job won't exit. if ((job->jv_status == JOB_STARTED && !job_channel_still_useful(job)) *************** *** 6589,6595 **** job_T *job; typval_T tv; ! for (job = first_job; job != NULL; job = job->jv_next) { tv.v_type = VAR_JOB; tv.vval.v_job = job; --- 6594,6600 ---- job_T *job; typval_T tv; ! FOR_ALL_JOBS(job) { tv.v_type = VAR_JOB; tv.vval.v_job = job; *** ../vim-8.2.0499/src/cmdexpand.c 2020-03-01 01:05:46.195710214 +0100 --- src/cmdexpand.c 2020-04-02 18:38:45.114510343 +0200 *************** *** 2587,2593 **** ga_init2(&ga, (int)sizeof(char *), 3); // Loop over the items in the list. ! for (li = retlist->lv_first; li != NULL; li = li->li_next) { if (li->li_tv.v_type != VAR_STRING || li->li_tv.vval.v_string == NULL) continue; // Skip non-string items and empty strings --- 2587,2593 ---- ga_init2(&ga, (int)sizeof(char *), 3); // Loop over the items in the list. ! FOR_ALL_LIST_ITEMS(retlist, li) { if (li->li_tv.v_type != VAR_STRING || li->li_tv.vval.v_string == NULL) continue; // Skip non-string items and empty strings *** ../vim-8.2.0499/src/diff.c 2019-12-01 20:51:25.000000000 +0100 --- src/diff.c 2020-04-02 18:45:50.644905251 +0200 *************** *** 90,95 **** --- 90,98 ---- static int parse_diff_unified(char_u *line, linenr_T *lnum_orig, long *count_orig, linenr_T *lnum_new, long *count_new); static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf); + #define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \ + for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next) + /* * Called when deleting or unloading a buffer: No longer make a diff with it. */ *************** *** 1857,1863 **** #endif // search for a change that includes "lnum" in the list of diffblocks. ! for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; if (dp == NULL || lnum < dp->df_lnum[idx]) --- 1860,1866 ---- #endif // search for a change that includes "lnum" in the list of diffblocks. ! FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; if (dp == NULL || lnum < dp->df_lnum[idx]) *************** *** 2069,2075 **** towin->w_topfill = 0; // search for a change that includes "lnum" in the list of diffblocks. ! for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) if (lnum <= dp->df_lnum[fromidx] + dp->df_count[fromidx]) break; if (dp == NULL) --- 2072,2078 ---- towin->w_topfill = 0; // search for a change that includes "lnum" in the list of diffblocks. ! FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) if (lnum <= dp->df_lnum[fromidx] + dp->df_count[fromidx]) break; if (dp == NULL) *************** *** 2374,2380 **** } // search for a change that includes "lnum" in the list of diffblocks. ! for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; if (dp == NULL || diff_check_sanity(curtab, dp) == FAIL) --- 2377,2383 ---- } // search for a change that includes "lnum" in the list of diffblocks. ! FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; if (dp == NULL || diff_check_sanity(curtab, dp) == FAIL) *************** *** 2508,2514 **** if (curtab->tp_first_diff == NULL) return TRUE; ! for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) { // If this change is below the line there can't be any further match. if (dp->df_lnum[idx] - diff_context > lnum) --- 2511,2517 ---- if (curtab->tp_first_diff == NULL) return TRUE; ! FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) { // If this change is below the line there can't be any further match. if (dp->df_lnum[idx] - diff_context > lnum) *************** *** 3001,3007 **** if (curtab->tp_first_diff == NULL) // no diffs today return lnum1; ! for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) { if (dp->df_lnum[idx1] > lnum1) return lnum1 - baseline; --- 3004,3010 ---- if (curtab->tp_first_diff == NULL) // no diffs today return lnum1; ! FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) { if (dp->df_lnum[idx1] > lnum1) return lnum1 - baseline; *************** *** 3070,3076 **** ex_diffupdate(NULL); // update after a big change // search for a change that includes "lnum" in the list of diffblocks. ! for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; --- 3073,3079 ---- ex_diffupdate(NULL); // update after a big change // search for a change that includes "lnum" in the list of diffblocks. ! FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) break; *** ../vim-8.2.0499/src/eval.c 2020-04-01 22:10:56.432201238 +0200 --- src/eval.c 2020-04-02 18:38:45.114510343 +0200 *************** *** 3973,3983 **** abort = abort || set_ref_in_item(&aucmd_win->w_winvar.di_tv, copyID, NULL, NULL); #ifdef FEAT_PROP_POPUP ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID, NULL, NULL); FOR_ALL_TABPAGES(tp) ! for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next) abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID, NULL, NULL); #endif --- 3973,3983 ---- abort = abort || set_ref_in_item(&aucmd_win->w_winvar.di_tv, copyID, NULL, NULL); #ifdef FEAT_PROP_POPUP ! FOR_ALL_POPUPWINS(wp) abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID, NULL, NULL); FOR_ALL_TABPAGES(tp) ! FOR_ALL_POPUPWINS_IN_TAB(tp, wp) abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID, NULL, NULL); #endif *** ../vim-8.2.0499/src/evalbuffer.c 2020-03-01 14:04:42.224689018 +0100 --- src/evalbuffer.c 2020-04-02 18:38:45.114510343 +0200 *************** *** 117,123 **** { wininfo_T *wip; ! for (wip = curbuf->b_wininfo; wip != NULL; wip = wip->wi_next) { if (wip->wi_win != NULL) { --- 117,123 ---- { wininfo_T *wip; ! FOR_ALL_BUF_WININFO(curbuf, wip) { if (wip->wi_win != NULL) { *************** *** 572,582 **** windows = list_alloc(); if (windows != NULL) { ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_buffer == buf) list_append_number(windows, (varnumber_T)wp->w_id); FOR_ALL_TABPAGES(tp) ! for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_buffer == buf) list_append_number(windows, (varnumber_T)wp->w_id); --- 572,582 ---- windows = list_alloc(); if (windows != NULL) { ! FOR_ALL_POPUPWINS(wp) if (wp->w_buffer == buf) list_append_number(windows, (varnumber_T)wp->w_id); FOR_ALL_TABPAGES(tp) ! FOR_ALL_POPUPWINS_IN_TAB(tp, wp) if (wp->w_buffer == buf) list_append_number(windows, (varnumber_T)wp->w_id); *** ../vim-8.2.0499/src/evalfunc.c 2020-04-01 22:10:56.432201238 +0200 --- src/evalfunc.c 2020-04-02 18:38:45.114510343 +0200 *************** *** 2831,2838 **** if (lv_len > 0) { range_list_materialize(list); ! for (li = list->lv_first; li != NULL; ! li = li->li_next) copy_tv(&li->li_tv, &pt->pt_argv[i++]); } } --- 2831,2837 ---- if (lv_len > 0) { range_list_materialize(list); ! FOR_ALL_LIST_ITEMS(list, li) copy_tv(&li->li_tv, &pt->pt_argv[i++]); } } *************** *** 5021,5027 **** l = argvars[0].vval.v_list; range_list_materialize(l); ! for (li = l->lv_first; li != NULL; li = li->li_next) { msg_puts((char *)tv_get_string(&li->li_tv)); msg_putchar('\n'); --- 5020,5026 ---- l = argvars[0].vval.v_list; range_list_materialize(l); ! FOR_ALL_LIST_ITEMS(argvars[0].vval.v_list, li) { msg_puts((char *)tv_get_string(&li->li_tv)); msg_putchar('\n'); *** ../vim-8.2.0499/src/evalvars.c 2020-03-30 22:51:20.647982632 +0200 --- src/evalvars.c 2020-04-02 18:38:45.114510343 +0200 *************** *** 1698,1704 **** l->lv_lock &= ~VAR_LOCKED; if ((deep < 0 || deep > 1) && l->lv_first != &range_list_item) // recursive: lock/unlock the items the List contains ! for (li = l->lv_first; li != NULL; li = li->li_next) item_lock(&li->li_tv, deep - 1, lock); } break; --- 1698,1704 ---- l->lv_lock &= ~VAR_LOCKED; if ((deep < 0 || deep > 1) && l->lv_first != &range_list_item) // recursive: lock/unlock the items the List contains ! FOR_ALL_LIST_ITEMS(l, li) item_lock(&li->li_tv, deep - 1, lock); } break; *** ../vim-8.2.0499/src/evalwindow.c 2020-03-20 21:15:47.918287657 +0100 --- src/evalwindow.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 106,119 **** #ifdef FEAT_PROP_POPUP // popup windows are in separate lists FOR_ALL_TABPAGES(tp) ! for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_id == id) { if (tpp != NULL) *tpp = tp; return wp; } ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_id == id) { if (tpp != NULL) --- 106,119 ---- #ifdef FEAT_PROP_POPUP // popup windows are in separate lists FOR_ALL_TABPAGES(tp) ! FOR_ALL_POPUPWINS_IN_TAB(tp, wp) if (wp->w_id == id) { if (tpp != NULL) *tpp = tp; return wp; } ! FOR_ALL_POPUPWINS(wp) if (wp->w_id == id) { if (tpp != NULL) *************** *** 188,194 **** if (wp->w_id == nr) return wp; // check global popup windows ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_id == nr) return wp; #endif --- 188,194 ---- if (wp->w_id == nr) return wp; // check global popup windows ! FOR_ALL_POPUPWINS(wp) if (wp->w_id == nr) return wp; #endif *** ../vim-8.2.0499/src/ex_cmds2.c 2020-02-14 13:21:55.646197062 +0100 --- src/ex_cmds2.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 303,309 **** // buffers in other tabs FOR_ALL_TABPAGES(tp) if (tp != curtab) ! for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); // any other buffer --- 303,309 ---- // buffers in other tabs FOR_ALL_TABPAGES(tp) if (tp != curtab) ! FOR_ALL_WINDOWS_IN_TAB(tp, wp) add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); // any other buffer *************** *** 477,483 **** // great speed improvement. save_ei = au_event_disable(",Syntax"); ! for (buf = firstbuf; buf != NULL; buf = buf->b_next) buf->b_flags &= ~BF_SYN_SET; buf = curbuf; } --- 477,483 ---- // great speed improvement. save_ei = au_event_disable(",Syntax"); ! FOR_ALL_BUFFERS(buf) buf->b_flags &= ~BF_SYN_SET; buf = curbuf; } *** ../vim-8.2.0499/src/filepath.c 2020-03-19 13:08:41.502917820 +0100 --- src/filepath.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 1917,1923 **** if (list == NULL) return; range_list_materialize(list); ! for (li = list->lv_first; li != NULL; li = li->li_next) if (tv_get_string_chk(&li->li_tv) == NULL) return; } --- 1917,1923 ---- if (list == NULL) return; range_list_materialize(list); ! FOR_ALL_LIST_ITEMS(list, li) if (tv_get_string_chk(&li->li_tv) == NULL) return; } *** ../vim-8.2.0499/src/globals.h 2020-03-28 21:38:02.124802294 +0100 --- src/globals.h 2020-04-02 18:45:28.196991562 +0200 *************** *** 676,681 **** --- 676,686 ---- 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 *************** *** 716,721 **** --- 721,729 ---- #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) *************** *** 1469,1474 **** --- 1477,1485 ---- // 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 *************** *** 1822,1824 **** --- 1833,1838 ---- # define REPEATED_MSG_LOOKING 1 # define REPEATED_MSG_SAFESTATE 2 #endif + + #define FOR_ALL_LIST_ITEMS(l, li) \ + for ((li) = (l)->lv_first; (li) != NULL; (li) = (li)->li_next) *** ../vim-8.2.0499/src/gui.c 2020-03-28 20:44:37.554078887 +0100 --- src/gui.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 4189,4195 **** // avoid that moving components around generates events ++hold_gui_events; ! for (wp = firstwin; wp != NULL; wp = W_NEXT(wp)) { if (wp->w_buffer == NULL) // just in case continue; --- 4189,4195 ---- // avoid that moving components around generates events ++hold_gui_events; ! FOR_ALL_WINDOWS(wp) { if (wp->w_buffer == NULL) // just in case continue; *** ../vim-8.2.0499/src/if_py_both.h 2020-01-29 21:27:17.578406709 +0100 --- src/if_py_both.h 2020-04-02 18:38:45.118510327 +0200 *************** *** 786,792 **** } range_list_materialize(list); ! for (curr = list->lv_first; curr != NULL; curr = curr->li_next) { if (!(newObj = VimToPython(&curr->li_tv, depth + 1, lookup_dict))) { --- 786,792 ---- } range_list_materialize(list); ! FOR_ALL_LIST_ITEMS(list, curr) { if (!(newObj = VimToPython(&curr->li_tv, depth + 1, lookup_dict))) { *************** *** 3035,3041 **** return NULL; } curtv = argv; ! for (li = argslist->lv_first; li != NULL; li = li->li_next) copy_tv(&li->li_tv, curtv++); } list_unref(argslist); --- 3035,3041 ---- return NULL; } curtv = argv; ! FOR_ALL_LIST_ITEMS(argslist, li) copy_tv(&li->li_tv, curtv++); } list_unref(argslist); *** ../vim-8.2.0499/src/if_ruby.c 2020-03-29 20:51:03.081780739 +0200 --- src/if_ruby.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 1147,1153 **** if (list != NULL) { ! for (curr = list->lv_first; curr != NULL; curr = curr->li_next) rb_ary_push(result, vim_to_ruby(&curr->li_tv)); } } --- 1147,1153 ---- if (list != NULL) { ! FOR_ALL_LIST_ITEMS(list, curr) rb_ary_push(result, vim_to_ruby(&curr->li_tv)); } } *** ../vim-8.2.0499/src/insexpand.c 2020-01-27 22:09:35.796838619 +0100 --- src/insexpand.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 2331,2337 **** // Go through the List with matches and add each of them. range_list_materialize(list); ! for (li = list->lv_first; li != NULL; li = li->li_next) { if (ins_compl_add_tv(&li->li_tv, dir) == OK) // if dir was BACKWARD then honor it just once --- 2331,2337 ---- // Go through the List with matches and add each of them. range_list_materialize(list); ! FOR_ALL_LIST_ITEMS(list, li) { if (ins_compl_add_tv(&li->li_tv, dir) == OK) // if dir was BACKWARD then honor it just once *************** *** 2513,2519 **** { what_flag = 0; range_list_materialize(what_list); ! for (item = what_list->lv_first; item != NULL; item = item->li_next) { char_u *what = tv_get_string(&item->li_tv); --- 2513,2519 ---- { what_flag = 0; range_list_materialize(what_list); ! FOR_ALL_LIST_ITEMS(what_list, item) { char_u *what = tv_get_string(&item->li_tv); *** ../vim-8.2.0499/src/list.c 2020-03-28 21:38:02.128802283 +0100 --- src/list.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 1109,1115 **** char_u *s; range_list_materialize(list); ! for (li = list->lv_first; li != NULL; li = li->li_next) { for (s = tv_get_string(&li->li_tv); *s != NUL; ++s) { --- 1109,1115 ---- char_u *s; range_list_materialize(list); ! FOR_ALL_LIST_ITEMS(list, li) { for (s = tv_get_string(&li->li_tv); *s != NUL; ++s) { *************** *** 1207,1213 **** else char2bytes = mb_char2bytes; ! for (li = l->lv_first; li != NULL; li = li->li_next) { buf[(*char2bytes)(tv_get_number(&li->li_tv), buf)] = NUL; ga_concat(&ga, buf); --- 1207,1213 ---- else char2bytes = mb_char2bytes; ! FOR_ALL_LIST_ITEMS(l, li) { buf[(*char2bytes)(tv_get_number(&li->li_tv), buf)] = NUL; ga_concat(&ga, buf); *************** *** 1216,1222 **** } else if (ga_grow(&ga, list_len(l) + 1) == OK) { ! for (li = l->lv_first; li != NULL; li = li->li_next) ga_append(&ga, tv_get_number(&li->li_tv)); ga_append(&ga, NUL); } --- 1216,1222 ---- } else if (ga_grow(&ga, list_len(l) + 1) == OK) { ! FOR_ALL_LIST_ITEMS(l, li) ga_append(&ga, tv_get_number(&li->li_tv)); ga_append(&ga, NUL); } *************** *** 1579,1585 **** if (sort) { // sort(): ptrs will be the list to sort ! for (li = l->lv_first; li != NULL; li = li->li_next) { ptrs[i].item = li; ptrs[i].idx = i; --- 1579,1585 ---- if (sort) { // sort(): ptrs will be the list to sort ! FOR_ALL_LIST_ITEMS(l, li) { ptrs[i].item = li; ptrs[i].idx = i; *** ../vim-8.2.0499/src/misc2.c 2020-03-26 16:27:34.942445362 +0100 --- src/misc2.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 4348,4354 **** if (*argv == NULL) return FAIL; *argc = 0; ! for (li = l->lv_first; li != NULL; li = li->li_next) { s = tv_get_string_chk(&li->li_tv); if (s == NULL) --- 4348,4354 ---- if (*argv == NULL) return FAIL; *argc = 0; ! FOR_ALL_LIST_ITEMS(l, li) { s = tv_get_string_chk(&li->li_tv); if (s == NULL) *** ../vim-8.2.0499/src/netbeans.c 2019-12-05 20:01:26.000000000 +0100 --- src/netbeans.c 2020-04-02 18:38:45.118510327 +0200 *************** *** 2982,2988 **** if (!NETBEANS_OPEN) return FALSE; ! for (p = curbuf->b_signlist; p != NULL; p = p->se_next) if (p->se_id >= GUARDEDOFFSET) for (lnum = top + 1; lnum < bot; lnum++) if (lnum == p->se_lnum) --- 2982,2988 ---- if (!NETBEANS_OPEN) return FALSE; ! FOR_ALL_SIGNS_IN_BUF(curbuf, p) if (p->se_id >= GUARDEDOFFSET) for (lnum = top + 1; lnum < bot; lnum++) if (lnum == p->se_lnum) *************** *** 3095,3101 **** if (!NETBEANS_OPEN) return; ! for (p = curbuf->b_signlist; p != NULL; p = p->se_next) { if (p->se_lnum == lnum && p->se_next && p->se_next->se_lnum == lnum) { --- 3095,3101 ---- if (!NETBEANS_OPEN) return; ! FOR_ALL_SIGNS_IN_BUF(curbuf, p) { if (p->se_lnum == lnum && p->se_next && p->se_next->se_lnum == lnum) { *** ../vim-8.2.0499/src/popupwin.c 2020-03-14 15:27:52.438171444 +0100 --- src/popupwin.c 2020-04-02 18:38:45.122510313 +0200 *************** *** 835,842 **** listitem_T *li; ok = TRUE; ! for (li = di->di_tv.vval.v_list->lv_first; li != NULL; ! li = li->li_next) { if (li->li_tv.v_type != VAR_LIST || li->li_tv.vval.v_list == NULL --- 835,841 ---- listitem_T *li; ok = TRUE; ! FOR_ALL_LIST_ITEMS(di->di_tv.vval.v_list, li) { if (li->li_tv.v_type != VAR_LIST || li->li_tv.vval.v_list == NULL *************** *** 967,973 **** linenr_T lnum = 0; char_u *p; ! for (li = l->lv_first; li != NULL; li = li->li_next) if (li->li_tv.v_type == VAR_STRING) { p = li->li_tv.vval.v_string; --- 966,972 ---- linenr_T lnum = 0; char_u *p; ! FOR_ALL_LIST_ITEMS(l, li) if (li->li_tv.v_type == VAR_STRING) { p = li->li_tv.vval.v_string; *************** *** 989,995 **** dict_T *dict; // first add the text lines ! for (li = l->lv_first; li != NULL; li = li->li_next) { if (li->li_tv.v_type != VAR_DICT) { --- 988,994 ---- dict_T *dict; // first add the text lines ! FOR_ALL_LIST_ITEMS(l, li) { if (li->li_tv.v_type != VAR_DICT) { *************** *** 1022,1028 **** plist = di->di_tv.vval.v_list; if (plist != NULL) { ! for (pli = plist->lv_first; pli != NULL; pli = pli->li_next) { if (pli->li_tv.v_type != VAR_DICT) { --- 1021,1027 ---- plist = di->di_tv.vval.v_list; if (plist != NULL) { ! FOR_ALL_LIST_ITEMS(plist, pli) { if (pli->li_tv.v_type != VAR_DICT) { *************** *** 2881,2892 **** { win_T *twp; ! for (twp = tp->tp_first_popupwin; twp != NULL; twp = twp->w_next) ! if (twp->w_id == id) ! break; ! if (twp != NULL) ! break; ! ++i; } if (tp == NULL) i = -1; // must be global --- 2880,2891 ---- { win_T *twp; ! FOR_ALL_POPUPWINS_IN_TAB(tp, twp) ! if (twp->w_id == id) ! break; ! if (twp != NULL) ! break; ! ++i; } if (tp == NULL) i = -1; // must be global *************** *** 2954,2962 **** { win_T *wp; ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) wp->w_popup_handled &= ~handled_flag; ! for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) wp->w_popup_handled &= ~handled_flag; } --- 2953,2961 ---- { win_T *wp; ! FOR_ALL_POPUPWINS(wp) wp->w_popup_handled &= ~handled_flag; ! FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) wp->w_popup_handled &= ~handled_flag; } *************** *** 2975,2981 **** found_zindex = lowest ? INT_MAX : 0; found_wp = NULL; ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if ((wp->w_popup_handled & handled_flag) == 0 && (wp->w_popup_flags & POPF_HIDDEN) == 0 && (lowest ? wp->w_zindex < found_zindex --- 2974,2980 ---- found_zindex = lowest ? INT_MAX : 0; found_wp = NULL; ! FOR_ALL_POPUPWINS(wp) if ((wp->w_popup_handled & handled_flag) == 0 && (wp->w_popup_flags & POPF_HIDDEN) == 0 && (lowest ? wp->w_zindex < found_zindex *************** *** 2984,2990 **** found_zindex = wp->w_zindex; found_wp = wp; } ! for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) if ((wp->w_popup_handled & handled_flag) == 0 && (wp->w_popup_flags & POPF_HIDDEN) == 0 && (lowest ? wp->w_zindex < found_zindex --- 2983,2989 ---- found_zindex = wp->w_zindex; found_wp = wp; } ! FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) if ((wp->w_popup_handled & handled_flag) == 0 && (wp->w_popup_flags & POPF_HIDDEN) == 0 && (lowest ? wp->w_zindex < found_zindex *************** *** 3157,3163 **** return; cells = wp->w_popup_mask_cells; ! for (lio = wp->w_popup_mask->lv_first; lio != NULL; lio = lio->li_next) { int cols, cole; int lines, linee; --- 3156,3162 ---- return; cells = wp->w_popup_mask_cells; ! FOR_ALL_LIST_ITEMS(wp->w_popup_mask, lio) { int cols, cole; int lines, linee; *************** *** 3215,3221 **** int lines, linee; int col, line; ! for (lio = wp->w_popup_mask->lv_first; lio != NULL; lio = lio->li_next) { li = lio->li_tv.vval.v_list->lv_first; cols = tv_get_number(&li->li_tv); --- 3214,3220 ---- int lines, linee; int col, line; ! FOR_ALL_LIST_ITEMS(wp->w_popup_mask, lio) { li = lio->li_tv.vval.v_list->lv_first; cols = tv_get_number(&li->li_tv); *************** *** 3325,3336 **** // Check if any popup window buffer has changed and if any popup connected // to a text property has become visible. ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_popup_flags & POPF_HIDDEN) popup_mask_refresh |= check_popup_unhidden(wp); else if (popup_need_position_adjust(wp)) popup_mask_refresh = TRUE; ! for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_popup_flags & POPF_HIDDEN) popup_mask_refresh |= check_popup_unhidden(wp); else if (popup_need_position_adjust(wp)) --- 3324,3335 ---- // Check if any popup window buffer has changed and if any popup connected // to a text property has become visible. ! FOR_ALL_POPUPWINS(wp) if (wp->w_popup_flags & POPF_HIDDEN) popup_mask_refresh |= check_popup_unhidden(wp); else if (popup_need_position_adjust(wp)) popup_mask_refresh = TRUE; ! FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) if (wp->w_popup_flags & POPF_HIDDEN) popup_mask_refresh |= check_popup_unhidden(wp); else if (popup_need_position_adjust(wp)) *************** *** 3838,3844 **** win_T *wp; // Preview window popup is always local to tab page. ! for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_p_pvw) return wp; return NULL; --- 3837,3843 ---- win_T *wp; // Preview window popup is always local to tab page. ! FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) if (wp->w_p_pvw) return wp; return NULL; *************** *** 3854,3860 **** win_T *wp; // info window popup is always local to tab page. ! for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_popup_flags & POPF_INFO) return wp; return NULL; --- 3853,3859 ---- win_T *wp; // info window popup is always local to tab page. ! FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) if (wp->w_popup_flags & POPF_INFO) return wp; return NULL; *** ../vim-8.2.0499/src/quickfix.c 2020-03-14 17:21:30.667427405 +0100 --- src/quickfix.c 2020-04-02 18:38:45.122510313 +0200 *************** *** 6911,6917 **** qf_store_title(qfl, title); } ! for (li = list->lv_first; li != NULL; li = li->li_next) { if (li->li_tv.v_type != VAR_DICT) continue; // Skip non-dict items --- 6911,6917 ---- qf_store_title(qfl, title); } ! FOR_ALL_LIST_ITEMS(list, li) { if (li->li_tv.v_type != VAR_DICT) continue; // Skip non-dict items *** ../vim-8.2.0499/src/screen.c 2020-03-28 20:44:37.554078887 +0100 --- src/screen.c 2020-04-02 18:38:45.122510313 +0200 *************** *** 2572,2582 **** win_free_lsize(aucmd_win); #ifdef FEAT_PROP_POPUP // global popup windows ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) win_free_lsize(wp); // tab-local popup windows FOR_ALL_TABPAGES(tp) ! for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next) win_free_lsize(wp); #endif --- 2572,2582 ---- win_free_lsize(aucmd_win); #ifdef FEAT_PROP_POPUP // global popup windows ! FOR_ALL_POPUPWINS(wp) win_free_lsize(wp); // tab-local popup windows FOR_ALL_TABPAGES(tp) ! FOR_ALL_POPUPWINS_IN_TAB(tp, wp) win_free_lsize(wp); #endif *************** *** 2614,2620 **** outofmem = TRUE; #ifdef FEAT_PROP_POPUP // global popup windows ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (win_alloc_lines(wp) == FAIL) { outofmem = TRUE; --- 2614,2620 ---- outofmem = TRUE; #ifdef FEAT_PROP_POPUP // global popup windows ! FOR_ALL_POPUPWINS(wp) if (win_alloc_lines(wp) == FAIL) { outofmem = TRUE; *************** *** 2622,2628 **** } // tab-local popup windows FOR_ALL_TABPAGES(tp) ! for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (win_alloc_lines(wp) == FAIL) { outofmem = TRUE; --- 2622,2628 ---- } // tab-local popup windows FOR_ALL_TABPAGES(tp) ! FOR_ALL_POPUPWINS_IN_TAB(tp, wp) if (win_alloc_lines(wp) == FAIL) { outofmem = TRUE; *** ../vim-8.2.0499/src/sign.c 2020-02-19 17:12:48.907095284 +0100 --- src/sign.c 2020-04-02 18:38:45.122510313 +0200 *************** *** 57,62 **** --- 57,65 ---- # define SIGNCMD_LAST 6 }; + #define FOR_ALL_SIGNS(sp) \ + for ((sp) = first_sign; (sp) != NULL; (sp) = (sp)->sn_next) + static hashtab_T sg_table; // sign group (signgroup_T) hashtable static int next_sign_id = 1; // next sign id in the global group *************** *** 294,300 **** { sign_T *sp; ! for (sp = first_sign; sp != NULL; sp = sp->sn_next) if (sp->sn_typenr == typenr) return sp; return NULL; --- 297,303 ---- { sign_T *sp; ! FOR_ALL_SIGNS(sp) if (sp->sn_typenr == typenr) return sp; return NULL; *************** *** 308,314 **** { sign_T *sp; ! for (sp = first_sign; sp != NULL; sp = sp->sn_next) if (sp->sn_typenr == typenr) return sp->sn_name; return (char_u *)_("[Deleted]"); --- 311,317 ---- { sign_T *sp; ! FOR_ALL_SIGNS(sp) if (sp->sn_typenr == typenr) return sp->sn_name; return (char_u *)_("[Deleted]"); *************** *** 880,886 **** if (sp_prev != NULL) *sp_prev = NULL; ! for (sp = first_sign; sp != NULL; sp = sp->sn_next) { if (STRCMP(sp->sn_name, name) == 0) break; --- 883,889 ---- if (sp_prev != NULL) *sp_prev = NULL; ! FOR_ALL_SIGNS(sp) { if (STRCMP(sp->sn_name, name) == 0) break; *************** *** 1153,1159 **** if (sign_group != NULL && (*sign_group == '*' || *sign_group == '\0')) return FAIL; ! for (sp = first_sign; sp != NULL; sp = sp->sn_next) if (STRCMP(sp->sn_name, sign_name) == 0) break; if (sp == NULL) --- 1156,1162 ---- if (sign_group != NULL && (*sign_group == '*' || *sign_group == '\0')) return FAIL; ! FOR_ALL_SIGNS(sp) if (STRCMP(sp->sn_name, sign_name) == 0) break; if (sp == NULL) *************** *** 1830,1836 **** { sign_T *sp; ! for (sp = first_sign; sp != NULL; sp = sp->sn_next) if (sp->sn_icon != NULL) sp->sn_image = gui_mch_register_sign(sp->sn_icon); } --- 1833,1839 ---- { sign_T *sp; ! FOR_ALL_SIGNS(sp) if (sp->sn_icon != NULL) sp->sn_image = gui_mch_register_sign(sp->sn_icon); } *************** *** 1911,1917 **** { sign_T *sp; ! for (sp = first_sign; sp != NULL; sp = sp->sn_next) if (sp->sn_typenr == typenr) return sp->sn_image; return NULL; --- 1914,1920 ---- { sign_T *sp; ! FOR_ALL_SIGNS(sp) if (sp->sn_typenr == typenr) return sp->sn_image; return NULL; *************** *** 1950,1956 **** // Complete with name of signs already defined current_idx = 0; ! for (sp = first_sign; sp != NULL; sp = sp->sn_next) if (current_idx++ == idx) return sp->sn_name; return NULL; --- 1953,1959 ---- // Complete with name of signs already defined current_idx = 0; ! FOR_ALL_SIGNS(sp) if (current_idx++ == idx) return sp->sn_name; return NULL; *************** *** 2212,2218 **** listitem_T *li; int retval; ! for (li = l->lv_first; li != NULL; li = li->li_next) { retval = -1; if (li->li_tv.v_type == VAR_DICT) --- 2215,2221 ---- listitem_T *li; int retval; ! FOR_ALL_LIST_ITEMS(l, li) { retval = -1; if (li->li_tv.v_type == VAR_DICT) *************** *** 2547,2553 **** } // Process the List of sign attributes ! for (li = argvars[0].vval.v_list->lv_first; li != NULL; li = li->li_next) { sign_id = -1; if (li->li_tv.v_type == VAR_DICT) --- 2550,2556 ---- } // Process the List of sign attributes ! FOR_ALL_LIST_ITEMS(argvars[0].vval.v_list, li) { sign_id = -1; if (li->li_tv.v_type == VAR_DICT) *************** *** 2569,2575 **** listitem_T *li; int retval; ! for (li = l->lv_first; li != NULL; li = li->li_next) { retval = -1; name = tv_get_string_chk(&li->li_tv); --- 2572,2578 ---- listitem_T *li; int retval; ! FOR_ALL_LIST_ITEMS(l, li) { retval = -1; name = tv_get_string_chk(&li->li_tv); *************** *** 2765,2771 **** return; } ! for (li = argvars[0].vval.v_list->lv_first; li != NULL; li = li->li_next) { retval = -1; if (li->li_tv.v_type == VAR_DICT) --- 2768,2774 ---- return; } ! FOR_ALL_LIST_ITEMS(argvars[0].vval.v_list, li) { retval = -1; if (li->li_tv.v_type == VAR_DICT) *** ../vim-8.2.0499/src/spell.c 2020-02-21 21:30:33.871979710 +0100 --- src/spell.c 2020-04-02 18:38:45.122510313 +0200 *************** *** 2031,2037 **** dont_use_region = TRUE; // Check if we loaded this language before. ! for (slang = first_lang; slang != NULL; slang = slang->sl_next) if (fullpathcmp(lang, slang->sl_fname, FALSE, TRUE) == FPC_SAME) break; } --- 2031,2037 ---- dont_use_region = TRUE; // Check if we loaded this language before. ! FOR_ALL_SPELL_LANGS(slang) if (fullpathcmp(lang, slang->sl_fname, FALSE, TRUE) == FPC_SAME) break; } *************** *** 2048,2054 **** dont_use_region = TRUE; // Check if we loaded this language before. ! for (slang = first_lang; slang != NULL; slang = slang->sl_next) if (STRICMP(lang, slang->sl_name) == 0) break; } --- 2048,2054 ---- dont_use_region = TRUE; // Check if we loaded this language before. ! FOR_ALL_SPELL_LANGS(slang) if (STRICMP(lang, slang->sl_name) == 0) break; } *************** *** 2083,2089 **** /* * Loop over the languages, there can be several files for "lang". */ ! for (slang = first_lang; slang != NULL; slang = slang->sl_next) if (filename ? fullpathcmp(lang, slang->sl_fname, FALSE, TRUE) == FPC_SAME : STRICMP(lang, slang->sl_name) == 0) --- 2083,2089 ---- /* * Loop over the languages, there can be several files for "lang". */ ! FOR_ALL_SPELL_LANGS(slang) if (filename ? fullpathcmp(lang, slang->sl_fname, FALSE, TRUE) == FPC_SAME : STRICMP(lang, slang->sl_name) == 0) *************** *** 2162,2168 **** } // Check if it was loaded already. ! for (slang = first_lang; slang != NULL; slang = slang->sl_next) if (fullpathcmp(spf_name, slang->sl_fname, FALSE, TRUE) == FPC_SAME) break; --- 2162,2168 ---- } // Check if it was loaded already. ! FOR_ALL_SPELL_LANGS(slang) if (fullpathcmp(spf_name, slang->sl_fname, FALSE, TRUE) == FPC_SAME) break; *** ../vim-8.2.0499/src/spellfile.c 2020-03-23 22:12:15.496961030 +0100 --- src/spellfile.c 2020-04-02 18:38:45.122510313 +0200 *************** *** 296,301 **** --- 296,307 ---- #define CF_WORD 0x01 #define CF_UPPER 0x02 + /* + * Loop through all the siblings of a node (including the node) + */ + #define FOR_ALL_NODE_SIBLINGS(node, np) \ + for ((np) = (node); (np) != NULL; (np) = (np)->wn_sibling) + static int set_spell_finish(spelltab_T *new_st); static int write_spell_prefcond(FILE *fd, garray_T *gap); static int read_region_section(FILE *fd, slang_T *slang, int len); *************** *** 1737,1743 **** slang_T *slang; int didit = FALSE; ! for (slang = first_lang; slang != NULL; slang = slang->sl_next) { if (fullpathcmp(fname, slang->sl_fname, FALSE, TRUE) == FPC_SAME) { --- 1743,1749 ---- slang_T *slang; int didit = FALSE; ! FOR_ALL_SPELL_LANGS(slang) { if (fullpathcmp(fname, slang->sl_fname, FALSE, TRUE) == FPC_SAME) { *************** *** 2081,2087 **** { wordnode_T *np; ! for (np = node; np != NULL; np = np->wn_sibling) { np->wn_u1.index = FALSE; spell_clear_flags(np->wn_child); --- 2087,2093 ---- { wordnode_T *np; ! FOR_ALL_NODE_SIBLINGS(node, np) { np->wn_u1.index = FALSE; spell_clear_flags(np->wn_child); *************** *** 4427,4433 **** { --node->wn_refs; copyprev = prev; ! for (copyp = node; copyp != NULL; copyp = copyp->wn_sibling) { // Allocate a new node and copy the info. np = get_wordnode(spin); --- 4433,4439 ---- { --node->wn_refs; copyprev = prev; ! FOR_ALL_NODE_SIBLINGS(node, copyp) { // Allocate a new node and copy the info. np = get_wordnode(spin); *************** *** 4618,4624 **** if (--node->wn_refs == 0) { ! for (np = node; np != NULL; np = np->wn_sibling) { if (np->wn_child != NULL) cnt += deref_wordnode(spin, np->wn_child); --- 4624,4630 ---- if (--node->wn_refs == 0) { ! FOR_ALL_NODE_SIBLINGS(node, np) { if (np->wn_child != NULL) cnt += deref_wordnode(spin, np->wn_child); *************** *** 4761,4767 **** */ node->wn_u1.hashkey[0] = len; nr = 0; ! for (np = node; np != NULL; np = np->wn_sibling) { if (np->wn_byte == NUL) // end node: use wn_flags, wn_region and wn_affixID --- 4767,4773 ---- */ node->wn_u1.hashkey[0] = len; nr = 0; ! FOR_ALL_NODE_SIBLINGS(node, np) { if (np->wn_byte == NUL) // end node: use wn_flags, wn_region and wn_affixID *************** *** 5252,5258 **** wordnode_T *np; if (node != NULL) ! for (np = node; np != NULL; np = np->wn_sibling) { np->wn_u1.index = 0; np->wn_u2.wnode = NULL; --- 5258,5264 ---- wordnode_T *np; if (node != NULL) ! FOR_ALL_NODE_SIBLINGS(node, np) { np->wn_u1.index = 0; np->wn_u2.wnode = NULL; *************** *** 5296,5302 **** node->wn_u1.index = idx; // Count the number of siblings. ! for (np = node; np != NULL; np = np->wn_sibling) ++siblingcount; // Write the sibling count. --- 5302,5308 ---- node->wn_u1.index = idx; // Count the number of siblings. ! FOR_ALL_NODE_SIBLINGS(node, np) ++siblingcount; // Write the sibling count. *************** *** 5304,5310 **** putc(siblingcount, fd); // // Write each sibling byte and optionally extra info. ! for (np = node; np != NULL; np = np->wn_sibling) { if (np->wn_byte == 0) { --- 5310,5316 ---- putc(siblingcount, fd); // // Write each sibling byte and optionally extra info. ! FOR_ALL_NODE_SIBLINGS(node, np) { if (np->wn_byte == 0) { *************** *** 5392,5398 **** newindex += siblingcount + 1; // Recursively dump the children of each sibling. ! for (np = node; np != NULL; np = np->wn_sibling) if (np->wn_byte != 0 && np->wn_child->wn_u2.wnode == node) newindex = put_node(fd, np->wn_child, newindex, regionmask, prefixtree); --- 5398,5404 ---- newindex += siblingcount + 1; // Recursively dump the children of each sibling. ! FOR_ALL_NODE_SIBLINGS(node, np) if (np->wn_byte != 0 && np->wn_child->wn_u2.wnode == node) newindex = put_node(fd, np->wn_child, newindex, regionmask, prefixtree); *************** *** 5447,5453 **** * of the code for the soundfolding stuff. * It might have been done already by spell_reload_one(). */ ! for (slang = first_lang; slang != NULL; slang = slang->sl_next) if (fullpathcmp(wfname, slang->sl_fname, FALSE, TRUE) == FPC_SAME) break; if (slang == NULL) --- 5453,5459 ---- * of the code for the soundfolding stuff. * It might have been done already by spell_reload_one(). */ ! FOR_ALL_SPELL_LANGS(slang) if (fullpathcmp(wfname, slang->sl_fname, FALSE, TRUE) == FPC_SAME) break; if (slang == NULL) *************** *** 5666,5672 **** int nr; int prev_nr; ! for (p = node; p != NULL; p = p->wn_sibling) { if (p->wn_byte == NUL) { --- 5672,5678 ---- int nr; int prev_nr; ! FOR_ALL_NODE_SIBLINGS(node, p) { if (p->wn_byte == NUL) { *** ../vim-8.2.0499/src/spellsuggest.c 2020-03-15 18:15:00.150875063 +0100 --- src/spellsuggest.c 2020-04-02 18:38:45.122510313 +0200 *************** *** 887,893 **** if (list != NULL) { // Loop over the items in the list. ! for (li = list->lv_first; li != NULL; li = li->li_next) if (li->li_tv.v_type == VAR_LIST) { // Get the word and the score from the items. --- 887,893 ---- if (list != NULL) { // Loop over the items in the list. ! FOR_ALL_LIST_ITEMS(list, li) if (li->li_tv.v_type == VAR_LIST) { // Get the word and the score from the items. *** ../vim-8.2.0499/src/tag.c 2020-03-09 08:17:47.934476791 +0100 --- src/tag.c 2020-04-02 18:38:45.122510313 +0200 *************** *** 1358,1364 **** } taglist = rettv.vval.v_list; ! for (item = taglist->lv_first; item != NULL; item = item->li_next) { char_u *mfp; char_u *res_name, *res_fname, *res_cmd, *res_kind; --- 1358,1364 ---- } taglist = rettv.vval.v_list; ! FOR_ALL_LIST_ITEMS(taglist, item) { char_u *mfp; char_u *res_name, *res_fname, *res_cmd, *res_kind; *************** *** 4191,4197 **** int fnum; // Add one entry at a time to the tag stack ! for (li = l->lv_first; li != NULL; li = li->li_next) { if (li->li_tv.v_type != VAR_DICT || li->li_tv.vval.v_dict == NULL) continue; // Skip non-dict items --- 4191,4197 ---- int fnum; // Add one entry at a time to the tag stack ! FOR_ALL_LIST_ITEMS(l, li) { if (li->li_tv.v_type != VAR_DICT || li->li_tv.vval.v_dict == NULL) continue; // Skip non-dict items *** ../vim-8.2.0499/src/terminal.c 2020-03-28 22:37:10.141196670 +0100 --- src/terminal.c 2020-04-02 18:38:45.126510297 +0200 *************** *** 183,188 **** --- 183,191 ---- #define MAX_ROW 999999 // used for tl_dirty_row_end to update all rows #define KEY_BUF_LEN 200 + #define FOR_ALL_TERMS(term) \ + for ((term) = first_term; (term) != NULL; (term) = (term)->tl_next) + /* * Functions with separate implementation for MS-Windows and Unix-like systems. */ *************** *** 626,633 **** listitem_T *item; ga_init2(&ga, 1, 100); ! for (item = argvar->vval.v_list->lv_first; ! item != NULL; item = item->li_next) { char_u *s = tv_get_string_chk(&item->li_tv); char_u *p; --- 629,635 ---- listitem_T *item; ga_init2(&ga, 1, 100); ! FOR_ALL_LIST_ITEMS(argvar->vval.v_list, item) { char_u *s = tv_get_string_chk(&item->li_tv); char_u *p; *************** *** 1892,1898 **** term_T *term; int next_due = next_due_arg; ! for (term = first_term; term != NULL; term = term->tl_next) { if (term->tl_timer_set && !term->tl_normal_mode) { --- 1894,1900 ---- term_T *term; int next_due = next_due_arg; ! FOR_ALL_TERMS(term) { if (term->tl_timer_set && !term->tl_normal_mode) { *************** *** 2175,2181 **** if (l != NULL) { type = get_reg_type(c, ®len); ! for (item = l->lv_first; item != NULL; item = item->li_next) { char_u *s = tv_get_string(&item->li_tv); #ifdef MSWIN --- 2177,2183 ---- if (l != NULL) { type = get_reg_type(c, ®len); ! FOR_ALL_LIST_ITEMS(l, item) { char_u *s = tv_get_string(&item->li_tv); #ifdef MSWIN *************** *** 5701,5707 **** return; l = rettv->vval.v_list; ! for (tp = first_term; tp != NULL; tp = tp->tl_next) if (tp != NULL && tp->tl_buffer != NULL) if (list_append_number(l, (varnumber_T)tp->tl_buffer->b_fnum) == FAIL) --- 5703,5709 ---- return; l = rettv->vval.v_list; ! FOR_ALL_TERMS(tp) if (tp != NULL && tp->tl_buffer != NULL) if (list_append_number(l, (varnumber_T)tp->tl_buffer->b_fnum) == FAIL) *************** *** 6077,6083 **** { term_T *term; ! for (term = first_term; term != NULL; term = term->tl_next) if (term->tl_job == ch->ch_job) { if (term->tl_eof_chars != NULL) --- 6079,6085 ---- { term_T *term; ! FOR_ALL_TERMS(term) if (term->tl_job == ch->ch_job) { if (term->tl_eof_chars != NULL) *** ../vim-8.2.0499/src/userfunc.c 2020-04-02 18:34:28.767520143 +0200 --- src/userfunc.c 2020-04-02 18:38:45.126510297 +0200 *************** *** 792,798 **** vars_clear(&fc->l_avars.dv_hashtab); // Free the a:000 variables. ! for (li = fc->l_varlist.lv_first; li != NULL; li = li->li_next) clear_tv(&li->li_tv); free_funccal(fc); --- 792,798 ---- vars_clear(&fc->l_avars.dv_hashtab); // Free the a:000 variables. ! FOR_ALL_LIST_ITEMS(&fc->l_varlist, li) clear_tv(&li->li_tv); free_funccal(fc); *************** *** 851,857 **** free_fc = FALSE; // Make a copy of the a:000 items, since we didn't do that above. ! for (li = fc->l_varlist.lv_first; li != NULL; li = li->li_next) copy_tv(&li->li_tv, &li->li_tv); } --- 851,857 ---- free_fc = FALSE; // Make a copy of the a:000 items, since we didn't do that above. ! FOR_ALL_LIST_ITEMS(&fc->l_varlist, li) copy_tv(&li->li_tv, &li->li_tv); } *************** *** 1640,1646 **** int r = 0; range_list_materialize(l); ! for (item = l->lv_first; item != NULL; item = item->li_next) { if (argc == MAX_FUNC_ARGS - (partial == NULL ? 0 : partial->pt_argc)) { --- 1640,1646 ---- int r = 0; range_list_materialize(l); ! FOR_ALL_LIST_ITEMS(args->vval.v_list, item) { if (argc == MAX_FUNC_ARGS - (partial == NULL ? 0 : partial->pt_argc)) { *** ../vim-8.2.0499/src/window.c 2020-02-03 22:15:22.206649093 +0100 --- src/window.c 2020-04-02 18:38:45.126510297 +0200 *************** *** 1428,1437 **** #ifdef FEAT_PROP_POPUP win_T *wp; ! for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (wp == win) return TRUE; ! for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (wp == win) return TRUE; #endif --- 1428,1437 ---- #ifdef FEAT_PROP_POPUP win_T *wp; ! FOR_ALL_POPUPWINS(wp) if (wp == win) return TRUE; ! FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) if (wp == win) return TRUE; #endif *************** *** 1473,1479 **** return TRUE; } #ifdef FEAT_PROP_POPUP ! for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (wp == win) return TRUE; #endif --- 1473,1479 ---- return TRUE; } #ifdef FEAT_PROP_POPUP ! FOR_ALL_POPUPWINS_IN_TAB(tp, wp) if (wp == win) return TRUE; #endif *************** *** 2276,2282 **** { nexttp = tp->tp_next; if (tp != curtab) ! for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) if (wp->w_buffer == buf && !(wp->w_closing || wp->w_buffer->b_locked > 0)) { --- 2276,2282 ---- { nexttp = tp->tp_next; if (tp != curtab) ! FOR_ALL_WINDOWS_IN_TAB(tp, wp) if (wp->w_buffer == buf && !(wp->w_closing || wp->w_buffer->b_locked > 0)) { *************** *** 4785,4791 **** FOR_ALL_TABPAGES(tp) if (tp != curtab) { ! for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) if (wp->w_buffer == buf) break; if (wp != NULL) --- 4785,4791 ---- FOR_ALL_TABPAGES(tp) if (tp != curtab) { ! FOR_ALL_WINDOWS_IN_TAB(tp, wp) if (wp->w_buffer == buf) break; if (wp != NULL) *************** *** 4968,4974 **** // Remove the window from the b_wininfo lists, it may happen that the // freed memory is re-used for another window. FOR_ALL_BUFFERS(buf) ! for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) if (wip->wi_win == wp) wip->wi_win = NULL; --- 4968,4974 ---- // Remove the window from the b_wininfo lists, it may happen that the // freed memory is re-used for another window. FOR_ALL_BUFFERS(buf) ! FOR_ALL_BUF_WININFO(buf, wip) if (wip->wi_win == wp) wip->wi_win = NULL; *** ../vim-8.2.0499/src/version.c 2020-04-02 18:34:28.767520143 +0200 --- src/version.c 2020-04-02 18:50:10.035899565 +0200 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 500, /**/ -- ARTHUR: But if he was dying, he wouldn't bother to carve "Aaaaarrrrrrggghhh". He'd just say it. BROTHER MAYNARD: It's down there carved in stone. GALAHAD: Perhaps he was dictating. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///