diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 20 | ||||
-rw-r--r-- | src/diff.c | 18 | ||||
-rw-r--r-- | src/edit.c | 2 | ||||
-rw-r--r-- | src/eval.c | 9 | ||||
-rw-r--r-- | src/evalfunc.c | 8 | ||||
-rw-r--r-- | src/ex_cmds.c | 12 | ||||
-rw-r--r-- | src/ex_cmds2.c | 16 | ||||
-rw-r--r-- | src/ex_docmd.c | 22 | ||||
-rw-r--r-- | src/fileio.c | 9 | ||||
-rw-r--r-- | src/globals.h | 8 | ||||
-rw-r--r-- | src/gui.c | 4 | ||||
-rw-r--r-- | src/gui_mac.c | 8 | ||||
-rw-r--r-- | src/if_lua.c | 4 | ||||
-rw-r--r-- | src/if_mzsch.c | 8 | ||||
-rw-r--r-- | src/if_perl.xs | 6 | ||||
-rw-r--r-- | src/if_ruby.c | 6 | ||||
-rw-r--r-- | src/if_tcl.c | 4 | ||||
-rw-r--r-- | src/main.c | 7 | ||||
-rw-r--r-- | src/mark.c | 4 | ||||
-rw-r--r-- | src/memfile.c | 4 | ||||
-rw-r--r-- | src/memline.c | 8 | ||||
-rw-r--r-- | src/misc1.c | 8 | ||||
-rw-r--r-- | src/move.c | 2 | ||||
-rw-r--r-- | src/netbeans.c | 4 | ||||
-rw-r--r-- | src/normal.c | 2 | ||||
-rw-r--r-- | src/option.c | 12 | ||||
-rw-r--r-- | src/quickfix.c | 2 | ||||
-rw-r--r-- | src/screen.c | 12 | ||||
-rw-r--r-- | src/spell.c | 4 | ||||
-rw-r--r-- | src/term.c | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 51 | ||||
-rw-r--r-- | src/workshop.c | 2 |
33 files changed, 148 insertions, 142 deletions
diff --git a/src/buffer.c b/src/buffer.c index 8590e2a2e9..60fb67a23b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -105,7 +105,7 @@ open_buffer( * If we can't create one for the current buffer, take another buffer */ close_buffer(NULL, curbuf, 0, FALSE); - for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next) + FOR_ALL_BUFFERS(curbuf) if (curbuf->b_ml.ml_mfp != NULL) break; /* @@ -1284,7 +1284,7 @@ do_buffer( * If deleting the last (listed) buffer, make it empty. * The last (listed) buffer cannot be unloaded. */ - for (bp = firstbuf; bp != NULL; bp = bp->b_next) + FOR_ALL_BUFFERS(bp) if (bp->b_p_bl && bp != buf) break; if (bp == NULL && buf == curbuf) @@ -1410,7 +1410,7 @@ do_buffer( buf = bp; if (buf == NULL) /* No loaded buffer, find listed one */ { - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_p_bl && buf != curbuf) break; } @@ -2406,7 +2406,7 @@ buflist_findpat( #ifdef FEAT_WINDOWS win_T *wp; - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) if (wp->w_buffer == buf) break; if (wp == NULL) @@ -2508,7 +2508,7 @@ ExpandBufnames( for (round = 1; round <= 2; ++round) { count = 0; - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (!buf->b_p_bl) /* skip unlisted buffers */ continue; @@ -2734,7 +2734,7 @@ wininfo_other_tab_diff(wininfo_T *wip) if (wip->wi_opt.wo_diff) { - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) /* return FALSE when it's a window in the current tab page, thus * the buffer was in diff mode here */ if (wip->wi_win == wp) @@ -3153,7 +3153,7 @@ buflist_slash_adjust(void) { buf_T *bp; - for (bp = firstbuf; bp != NULL; bp = bp->b_next) + FOR_ALL_BUFFERS(bp) { if (bp->b_ffname != NULL) slash_adjust(bp->b_ffname); @@ -5083,7 +5083,7 @@ ex_buffer_all(exarg_T *eap) #endif { /* Check if this buffer already has a window */ - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) if (wp->w_buffer == buf) break; /* If the buffer already has a window, move it */ @@ -5461,7 +5461,7 @@ write_viminfo_bufferlist(FILE *fp) #endif fputs(_("\n# Buffer list:\n"), fp); - for (buf = firstbuf; buf != NULL ; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (buf->b_fname == NULL || !buf->b_p_bl @@ -5847,7 +5847,7 @@ buf_delete_all_signs(void) { buf_T *buf; /* buffer we are checking for signs */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_signlist != NULL) buf_delete_signs(buf); } diff --git a/src/diff.c b/src/diff.c index 287f434bee..35e37d750b 100644 --- a/src/diff.c +++ b/src/diff.c @@ -65,7 +65,7 @@ diff_buf_delete(buf_T *buf) int i; tabpage_T *tp; - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) { i = diff_buf_idx_tp(buf, tp); if (i != DB_COUNT) @@ -92,7 +92,7 @@ diff_buf_adjust(win_T *win) { /* When there is no window showing a diff for this buffer, remove * it from the diffs. */ - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) if (wp->w_buffer == win->w_buffer && wp->w_p_diff) break; if (wp == NULL) @@ -178,7 +178,7 @@ diff_invalidate(buf_T *buf) tabpage_T *tp; int i; - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) { i = diff_buf_idx_tp(buf, tp); if (i != DB_COUNT) @@ -204,7 +204,7 @@ diff_mark_adjust( tabpage_T *tp; /* Handle all tab pages that use the current buffer in a diff. */ - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) { idx = diff_buf_idx_tp(curbuf, tp); if (idx != DB_COUNT) @@ -591,7 +591,7 @@ diff_redraw( win_T *wp; int n; - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) if (wp->w_p_diff) { redraw_win_later(wp, SOME_VALID); @@ -1198,7 +1198,7 @@ ex_diffoff(exarg_T *eap) int diffwin = FALSE; #endif - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) { if (eap->forceit ? wp->w_p_diff : wp == curwin) { @@ -1879,7 +1879,7 @@ diffopt_changed(void) /* If "icase" or "iwhite" was added or removed, need to update the diff. */ if (diff_flags != diff_flags_new) - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) tp->tp_diff_invalid = TRUE; diff_flags = diff_flags_new; @@ -2434,7 +2434,7 @@ diff_fold_update(diff_T *dp, int skip_idx) int i; win_T *wp; - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) for (i = 0; i < DB_COUNT; ++i) if (curtab->tp_diffbuf[i] == wp->w_buffer && i != skip_idx) foldUpdate(wp, dp->df_lnum[i], @@ -2450,7 +2450,7 @@ diff_mode_buf(buf_T *buf) { tabpage_T *tp; - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) if (diff_buf_idx_tp(buf, tp) != DB_COUNT) return TRUE; return FALSE; diff --git a/src/edit.c b/src/edit.c index 4bce8a30c7..a60d9229ad 100644 --- a/src/edit.c +++ b/src/edit.c @@ -4239,7 +4239,7 @@ ins_compl_get_exp(pos_T *ini) if (!compl_started) { - for (ins_buf = firstbuf; ins_buf != NULL; ins_buf = ins_buf->b_next) + FOR_ALL_BUFFERS(ins_buf) ins_buf->b_scanned = 0; found_all = FALSE; ins_buf = curbuf; diff --git a/src/eval.c b/src/eval.c index 3bc2afdb1f..6f10756abf 100644 --- a/src/eval.c +++ b/src/eval.c @@ -5253,7 +5253,7 @@ garbage_collect(int testing) abort = abort || set_ref_in_ht(&SCRIPT_VARS(i), copyID, NULL); /* buffer-local variables */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) abort = abort || set_ref_in_item(&buf->b_bufvar.di_tv, copyID, NULL, NULL); @@ -5269,7 +5269,7 @@ garbage_collect(int testing) #ifdef FEAT_WINDOWS /* tabpage-local variables */ - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) abort = abort || set_ref_in_item(&tp->tp_winvar.di_tv, copyID, NULL, NULL); #endif @@ -8303,8 +8303,8 @@ find_win_by_nr( if (nr == 0) return curwin; - for (wp = (tp == NULL || tp == curtab) ? firstwin : tp->tp_firstwin; - wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS_IN_TAB(tp, wp) + { if (nr >= LOWEST_WIN_ID) { if (wp->w_id == nr) @@ -8312,6 +8312,7 @@ find_win_by_nr( } else if (--nr <= 0) break; + } if (nr >= LOWEST_WIN_ID) return NULL; return wp; diff --git a/src/evalfunc.c b/src/evalfunc.c index ec347c1124..ae17038cce 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1439,7 +1439,7 @@ find_buffer(typval_T *avar) { /* No full path name match, try a match with a URL or a "nofile" * buffer, these don't use the full path. */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_fname != NULL && (path_with_url(buf->b_fname) #ifdef FEAT_QUICKFIX @@ -1597,7 +1597,7 @@ buf_win_common(typval_T *argvars, typval_T *rettv, int get_nr) ++emsg_off; buf = get_buf_tv(&argvars[0], TRUE); #ifdef FEAT_WINDOWS - for (wp = firstwin; wp; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) { ++winnr; if (wp->w_buffer == buf) @@ -6383,7 +6383,7 @@ f_last_buffer_nr(typval_T *argvars UNUSED, typval_T *rettv) int n = 0; buf_T *buf; - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (n < buf->b_fnum) n = buf->b_fnum; @@ -12373,7 +12373,7 @@ f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv) char_u buf[50]; ga_init2(&ga, (int)sizeof(char), 70); - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) { sprintf((char *)buf, "%dresize %d|", winnr, wp->w_height); ga_concat(&ga, buf); diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 7ec17b132c..7d8196cdc0 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -1497,7 +1497,7 @@ do_shell( && !autocmd_busy #endif && msg_silent == 0) - for (buf = firstbuf; buf; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (bufIsChanged(buf)) { #ifdef FEAT_GUI_MSWIN @@ -2345,7 +2345,7 @@ read_viminfo_up_to_marks( #endif /* Change file names to buffer numbers for fmarks. */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) fmarks_check_names(buf); return eof; @@ -3413,7 +3413,7 @@ do_wqall(exarg_T *eap) if (eap->cmdidx == CMD_xall || eap->cmdidx == CMD_wqall) exiting = TRUE; - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (bufIsChanged(buf)) { @@ -6115,7 +6115,7 @@ prepare_tagpreview( */ if (!curwin->w_p_pvw) { - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) if (wp->w_p_pvw) break; if (wp != NULL) @@ -6272,7 +6272,7 @@ ex_help(exarg_T *eap) if (cmdmod.tab != 0) wp = NULL; else - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) if (wp->w_buffer != NULL && wp->w_buffer->b_help) break; if (wp != NULL && wp->w_buffer->b_nwindows > 0) @@ -7745,7 +7745,7 @@ ex_sign(exarg_T *eap) if (idx == SIGNCMD_UNPLACE && *arg == NUL) { /* ":sign unplace {id}": remove placed sign by number */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if ((lnum = buf_delsign(buf, id)) != 0) update_debug_sign(buf, lnum); return; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index adc53529b4..83305b2407 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1721,7 +1721,7 @@ autowrite_all(void) if (!(p_aw || p_awa) || !p_write) return; - for (buf = firstbuf; buf; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (bufIsChanged(buf) && !buf->b_p_ro) { #ifdef FEAT_AUTOCMD @@ -1764,7 +1764,7 @@ check_changed(buf_T *buf, int flags) int count = 0; if (flags & CCGD_ALLBUF) - for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) + FOR_ALL_BUFFERS(buf2) if (bufIsChanged(buf2) && (buf2->b_ffname != NULL # ifdef FEAT_BROWSE @@ -1868,7 +1868,7 @@ dialog_changed( * Skip readonly buffers, these need to be confirmed * individually. */ - for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) + FOR_ALL_BUFFERS(buf2) { if (bufIsChanged(buf2) && (buf2->b_ffname != NULL @@ -1904,7 +1904,7 @@ dialog_changed( /* * mark all buffers as unchanged */ - for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) + FOR_ALL_BUFFERS(buf2) unchanged(buf2, TRUE); } } @@ -1964,7 +1964,7 @@ check_changed_any( win_T *wp; #endif - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) ++bufcount; if (bufcount == 0) @@ -1983,13 +1983,13 @@ check_changed_any( add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); /* buf in other tab */ - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + 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); #endif /* any other buf */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) add_bufnum(bufnrs, &bufnum, buf->b_fnum); for (i = 0; i < bufnum; ++i) @@ -2924,7 +2924,7 @@ ex_listdo(exarg_T *eap) if (next_fnum < 0 || next_fnum > eap->line2) break; /* Check if the buffer still exists. */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_fnum == next_fnum) break; if (buf == NULL) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 41a228d229..28de56ab05 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -1708,7 +1708,7 @@ current_win_nr(win_T *win) win_T *wp; int nr = 0; - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) { ++nr; if (wp == win) @@ -1723,7 +1723,7 @@ current_tab_nr(tabpage_T *tab) tabpage_T *tp; int nr = 0; - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) { ++nr; if (tp == tab) @@ -7273,7 +7273,7 @@ ex_close(exarg_T *eap) if (eap->addr_count == 0) ex_win_close(eap->forceit, curwin, NULL); else { - for (win = firstwin; win != NULL; win = win->w_next) + FOR_ALL_WINDOWS(win) { winnr++; if (winnr == eap->line2) @@ -7295,7 +7295,7 @@ ex_pclose(exarg_T *eap) { win_T *win; - for (win = firstwin; win != NULL; win = win->w_next) + FOR_ALL_WINDOWS(win) if (win->w_p_pvw) { ex_win_close(eap->forceit, win, NULL); @@ -7415,7 +7415,7 @@ ex_tabonly(exarg_T *eap) * up the lists. */ for (done = 0; done < 1000; ++done) { - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) if (tp->tp_topframe != topframe) { tabpage_close_other(tp, eap->forceit); @@ -7474,6 +7474,10 @@ tabpage_close_other(tabpage_T *tp, int forceit) break; } +#ifdef FEAT_AUTOCMD + apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); +#endif + redraw_tabline = TRUE; if (h != tabline_height()) shell_new_rows(); @@ -7540,7 +7544,7 @@ ex_hide(exarg_T *eap) int winnr = 0; win_T *win; - for (win = firstwin; win != NULL; win = win->w_next) + FOR_ALL_WINDOWS(win) { winnr++; if (winnr == eap->line2) @@ -8686,7 +8690,7 @@ ex_syncbind(exarg_T *eap UNUSED) if (curwin->w_p_scb) { topline = curwin->w_topline; - for (wp = firstwin; wp; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) { if (wp->w_p_scb && wp->w_buffer) { @@ -8707,7 +8711,7 @@ ex_syncbind(exarg_T *eap UNUSED) /* * Set all scrollbind windows to the same topline. */ - for (curwin = firstwin; curwin; curwin = curwin->w_next) + FOR_ALL_WINDOWS(curwin) { if (curwin->w_p_scb) { @@ -10957,7 +10961,7 @@ makeopens( return FAIL; /* Now put the other buffers into the buffer list */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (!(only_save_windows && buf->b_nwindows == 0) && !(buf->b_help && !(ssop_flags & SSOP_HELP)) diff --git a/src/fileio.c b/src/fileio.c index ea01b763f0..c4066173d2 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -6088,7 +6088,7 @@ shorten_fnames(int force) char_u *p; mch_dirname(dirname, MAXPATHL); - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (buf->b_fname != NULL #ifdef FEAT_QUICKFIX @@ -6680,7 +6680,7 @@ check_timestamps( ++no_wait_return; did_check_timestamps = TRUE; already_warned = FALSE; - for (buf = firstbuf; buf != NULL; ) + FOR_ALL_BUFFERS(buf) { /* Only check buffers in a window. */ if (buf->b_nwindows > 0) @@ -6699,7 +6699,6 @@ check_timestamps( continue; } } - buf = buf->b_next; } --no_wait_return; need_check_timestamps = FALSE; @@ -8759,7 +8758,7 @@ ex_doautoall(exarg_T *eap) * gives problems when the autocommands make changes to the list of * buffers or windows... */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (buf->b_ml.ml_mfp != NULL) { @@ -8831,7 +8830,7 @@ aucmd_prepbuf( win = curwin; else #ifdef FEAT_WINDOWS - for (win = firstwin; win != NULL; win = win->w_next) + FOR_ALL_WINDOWS(win) if (win->w_buffer == buf) break; #else diff --git a/src/globals.h b/src/globals.h index b569680a41..a3d6b4ee24 100644 --- a/src/globals.h +++ b/src/globals.h @@ -548,6 +548,10 @@ EXTERN win_T *lastwin; /* last window */ EXTERN win_T *prevwin INIT(= NULL); /* previous window */ # define W_NEXT(wp) ((wp)->w_next) # define FOR_ALL_WINDOWS(wp) for (wp = firstwin; wp != NULL; wp = wp->w_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. @@ -561,6 +565,8 @@ EXTERN win_T *prevwin INIT(= NULL); /* previous window */ # define lastwin curwin # define W_NEXT(wp) NULL # define FOR_ALL_WINDOWS(wp) wp = curwin; +# define FOR_ALL_TABPAGES(tp) for (;FALSE;) +# define FOR_ALL_WINDOWS_IN_TAB(tp, wp) wp = curwin; # define FOR_ALL_TAB_WINDOWS(tp, wp) wp = curwin; #endif @@ -595,6 +601,8 @@ EXTERN buf_T *firstbuf INIT(= NULL); /* first buffer */ 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) + /* 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 */ @@ -4082,7 +4082,7 @@ gui_drag_scrollbar(scrollbar_T *sb, long value, int still_dragging) { do_check_scrollbind(TRUE); /* need to update the window right here */ - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) if (wp->w_redr_type > 0) updateWindow(wp); setcursor(); @@ -4166,7 +4166,7 @@ gui_update_scrollbars( /* avoid that moving components around generates events */ ++hold_gui_events; - for (wp = firstwin; wp != NULL; wp = W_NEXT(wp)) + FOR_ALL_WINDOWS(wp) { if (wp->w_buffer == NULL) /* just in case */ continue; diff --git a/src/gui_mac.c b/src/gui_mac.c index b2e4d4b3f7..b78c903bea 100644 --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -633,7 +633,7 @@ Handle_KAHL_SRCH_AE( if (error) return error; - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_ml.ml_mfp != NULL && SearchData.theFile.parID == buf->b_FSSpec.parID && SearchData.theFile.name[0] == buf->b_FSSpec.name[0] @@ -725,7 +725,7 @@ Handle_KAHL_MOD_AE( #endif numFiles = 0; - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_ml.ml_mfp != NULL) { /* Add this file to the list */ @@ -807,7 +807,7 @@ Handle_KAHL_GTTX_AE( if (error) return error; - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_ml.ml_mfp != NULL) if (GetTextData.theFile.parID == buf->b_FSSpec.parID) { @@ -6422,7 +6422,7 @@ getTabCount(void) tabpage_T *tp; int numTabs = 0; - for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) + FOR_ALL_TABPAGES(tp) ++numTabs; return numTabs; } diff --git a/src/if_lua.c b/src/if_lua.c index 8d761004d3..5803d07912 100644 --- a/src/if_lua.c +++ b/src/if_lua.c @@ -1402,13 +1402,13 @@ luaV_buffer(lua_State *L) if (lua_isnumber(L, 1)) /* by number? */ { int n = lua_tointeger(L, 1); - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_fnum == n) break; } else { /* by name */ size_t l; const char *s = lua_tolstring(L, 1, &l); - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (buf->b_ffname == NULL || buf->b_sfname == NULL) { diff --git a/src/if_mzsch.c b/src/if_mzsch.c index 645548f802..daec6b0a82 100644 --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -1916,7 +1916,7 @@ get_window_count(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED #ifdef FEAT_WINDOWS win_T *w; - for (w = firstwin; w != NULL; w = w->w_next) + FOR_ALL_WINDOWS(w) #endif ++n; return scheme_make_integer(n); @@ -2197,7 +2197,7 @@ get_buffer_by_num(void *data, int argc, Scheme_Object **argv) fnum = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); - for (buf = firstbuf; buf; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_fnum == fnum) return buffer_new(buf); @@ -2220,7 +2220,7 @@ get_buffer_by_name(void *data, int argc, Scheme_Object **argv) fname = GUARANTEED_STRING_ARG(prim->name, 0); buffer = scheme_false; - for (buf = firstbuf; buf; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (buf->b_ffname == NULL || buf->b_sfname == NULL) /* empty string */ @@ -2283,7 +2283,7 @@ get_buffer_count(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED buf_T *b; int n = 0; - for (b = firstbuf; b; b = b->b_next) ++n; + FOR_ALL_BUFFERS(b) ++n; return scheme_make_integer(n); } diff --git a/src/if_perl.xs b/src/if_perl.xs index a2ff45208a..5b5023c07e 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -1534,14 +1534,14 @@ Buffers(...) if (GIMME == G_SCALAR) { i = 0; - for (vimbuf = firstbuf; vimbuf; vimbuf = vimbuf->b_next) + FOR_ALL_BUFFERS(vimbuf) ++i; XPUSHs(sv_2mortal(newSViv(i))); } else { - for (vimbuf = firstbuf; vimbuf; vimbuf = vimbuf->b_next) + FOR_ALL_BUFFERS(vimbuf) XPUSHs(newBUFrv(newSV(0), vimbuf)); } } @@ -1586,7 +1586,7 @@ Windows(...) XPUSHs(sv_2mortal(newSViv(win_count()))); else { - for (vimwin = firstwin; vimwin != NULL; vimwin = W_NEXT(vimwin)) + FOR_ALL_WINDOWS(vimwin) XPUSHs(newWINrv(newSV(0), vimwin)); } } diff --git a/src/if_ruby.c b/src/if_ruby.c index f0c441ada5..7111b993e5 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -1151,7 +1151,7 @@ static VALUE buffer_s_count(void) buf_T *b; int n = 0; - for (b = firstbuf; b != NULL; b = b->b_next) + FOR_ALL_BUFFERS(b) { /* Deleted buffers should not be counted * SegPhault - 01/07/05 */ @@ -1167,7 +1167,7 @@ static VALUE buffer_s_aref(VALUE self UNUSED, VALUE num) buf_T *b; int n = NUM2INT(num); - for (b = firstbuf; b != NULL; b = b->b_next) + FOR_ALL_BUFFERS(b) { /* Deleted buffers should not be counted * SegPhault - 01/07/05 */ @@ -1418,7 +1418,7 @@ static VALUE window_s_count(void) win_T *w; int n = 0; - for (w = firstwin; w != NULL; w = w->w_next) + FOR_ALL_WINDOWS(w) n++; return INT2NUM(n); #else diff --git a/src/if_tcl.c b/src/if_tcl.c index 3ef1544587..a1d8d1a38c 100644 --- a/src/if_tcl.c +++ b/src/if_tcl.c @@ -388,7 +388,7 @@ buffercmd( Tcl_WrongNumArgs(interp, 1, objv, "bufNumber"); return TCL_ERROR; } - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { if (buf->b_fnum == n) { @@ -416,7 +416,7 @@ buffercmd( err = TCL_ERROR; break; } - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) { name = tclgetbuffer(interp, buf); if (name == NULL) diff --git a/src/main.c b/src/main.c index ff82a9f160..926b8ab909 100644 --- a/src/main.c +++ b/src/main.c @@ -742,7 +742,7 @@ vim_main2(int argc UNUSED, char **argv UNUSED) win_T *wp; /* set options in each window for "vimdiff". */ - for (wp = firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS(wp) diff_win_options(wp, TRUE); } #endif @@ -1375,8 +1375,7 @@ getout(int exitval) for (tp = first_tabpage; tp != NULL; tp = next_tp) { next_tp = tp->tp_next; - for (wp = (tp == curtab) - ? firstwin : tp->tp_firstwin; wp != NULL; wp = wp->w_next) + FOR_ALL_WINDOWS_IN_TAB(tp, wp) { if (wp->w_buffer == NULL) /* Autocmd must have close the buffer already, skip. */ @@ -1399,7 +1398,7 @@ getout(int exitval) # endif /* Trigger BufUnload for buffers that are loaded */ - for (buf = firstbuf; buf != NULL; buf = buf->b_next) + FOR_ALL_BUFFERS(buf) if (buf->b_ml.ml_mfp != NULL) { bufref_T bufref; |