Mercurial > vim
diff src/terminal.c @ 19888:435726a03481 v8.2.0500
patch 8.2.0500: using the same loop in many places
Commit: https://github.com/vim/vim/commit/aeea72151c31d686bcbb7b06d895006d7363585c
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 2 18:50:46 2020 +0200
patch 8.2.0500: using the same loop in many places
Problem: Using the same loop in many places.
Solution: Define more FOR_ALL macros. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5339)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 02 Apr 2020 19:00:05 +0200 |
parents | b3f956c2ed3c |
children | aadd1cae2ff5 |
line wrap: on
line diff
--- a/src/terminal.c +++ b/src/terminal.c @@ -183,6 +183,9 @@ static BOOL has_conpty = FALSE; #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,8 +629,7 @@ term_start( listitem_T *item; ga_init2(&ga, 1, 100); - for (item = argvar->vval.v_list->lv_first; - item != NULL; item = item->li_next) + FOR_ALL_LIST_ITEMS(argvar->vval.v_list, item) { char_u *s = tv_get_string_chk(&item->li_tv); char_u *p; @@ -1892,7 +1894,7 @@ term_check_timers(int next_due_arg, prof term_T *term; int next_due = next_due_arg; - for (term = first_term; term != NULL; term = term->tl_next) + FOR_ALL_TERMS(term) { if (term->tl_timer_set && !term->tl_normal_mode) { @@ -2175,7 +2177,7 @@ term_paste_register(int prev_c UNUSED) if (l != NULL) { type = get_reg_type(c, ®len); - for (item = l->lv_first; item != NULL; item = item->li_next) + FOR_ALL_LIST_ITEMS(l, item) { char_u *s = tv_get_string(&item->li_tv); #ifdef MSWIN @@ -5701,7 +5703,7 @@ f_term_list(typval_T *argvars UNUSED, ty return; l = rettv->vval.v_list; - for (tp = first_term; tp != NULL; tp = tp->tl_next) + 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,7 +6079,7 @@ term_send_eof(channel_T *ch) { term_T *term; - for (term = first_term; term != NULL; term = term->tl_next) + FOR_ALL_TERMS(term) if (term->tl_job == ch->ch_job) { if (term->tl_eof_chars != NULL)