comparison 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
comparison
equal deleted inserted replaced
19887:d03edd8c7e2f 19888:435726a03481
181 #endif 181 #endif
182 182
183 #define MAX_ROW 999999 // used for tl_dirty_row_end to update all rows 183 #define MAX_ROW 999999 // used for tl_dirty_row_end to update all rows
184 #define KEY_BUF_LEN 200 184 #define KEY_BUF_LEN 200
185 185
186 #define FOR_ALL_TERMS(term) \
187 for ((term) = first_term; (term) != NULL; (term) = (term)->tl_next)
188
186 /* 189 /*
187 * Functions with separate implementation for MS-Windows and Unix-like systems. 190 * Functions with separate implementation for MS-Windows and Unix-like systems.
188 */ 191 */
189 static int term_and_job_init(term_T *term, typval_T *argvar, char **argv, jobopt_T *opt, jobopt_T *orig_opt); 192 static int term_and_job_init(term_T *term, typval_T *argvar, char **argv, jobopt_T *opt, jobopt_T *orig_opt);
190 static int create_pty_only(term_T *term, jobopt_T *opt); 193 static int create_pty_only(term_T *term, jobopt_T *opt);
624 { 627 {
625 garray_T ga; 628 garray_T ga;
626 listitem_T *item; 629 listitem_T *item;
627 630
628 ga_init2(&ga, 1, 100); 631 ga_init2(&ga, 1, 100);
629 for (item = argvar->vval.v_list->lv_first; 632 FOR_ALL_LIST_ITEMS(argvar->vval.v_list, item)
630 item != NULL; item = item->li_next)
631 { 633 {
632 char_u *s = tv_get_string_chk(&item->li_tv); 634 char_u *s = tv_get_string_chk(&item->li_tv);
633 char_u *p; 635 char_u *p;
634 636
635 if (s == NULL) 637 if (s == NULL)
1890 term_check_timers(int next_due_arg, proftime_T *now) 1892 term_check_timers(int next_due_arg, proftime_T *now)
1891 { 1893 {
1892 term_T *term; 1894 term_T *term;
1893 int next_due = next_due_arg; 1895 int next_due = next_due_arg;
1894 1896
1895 for (term = first_term; term != NULL; term = term->tl_next) 1897 FOR_ALL_TERMS(term)
1896 { 1898 {
1897 if (term->tl_timer_set && !term->tl_normal_mode) 1899 if (term->tl_timer_set && !term->tl_normal_mode)
1898 { 1900 {
1899 long this_due = proftime_time_left(&term->tl_timer_due, now); 1901 long this_due = proftime_time_left(&term->tl_timer_due, now);
1900 1902
2173 2175
2174 l = (list_T *)get_reg_contents(c, GREG_LIST); 2176 l = (list_T *)get_reg_contents(c, GREG_LIST);
2175 if (l != NULL) 2177 if (l != NULL)
2176 { 2178 {
2177 type = get_reg_type(c, &reglen); 2179 type = get_reg_type(c, &reglen);
2178 for (item = l->lv_first; item != NULL; item = item->li_next) 2180 FOR_ALL_LIST_ITEMS(l, item)
2179 { 2181 {
2180 char_u *s = tv_get_string(&item->li_tv); 2182 char_u *s = tv_get_string(&item->li_tv);
2181 #ifdef MSWIN 2183 #ifdef MSWIN
2182 char_u *tmp = s; 2184 char_u *tmp = s;
2183 2185
5699 5701
5700 if (rettv_list_alloc(rettv) == FAIL || first_term == NULL) 5702 if (rettv_list_alloc(rettv) == FAIL || first_term == NULL)
5701 return; 5703 return;
5702 5704
5703 l = rettv->vval.v_list; 5705 l = rettv->vval.v_list;
5704 for (tp = first_term; tp != NULL; tp = tp->tl_next) 5706 FOR_ALL_TERMS(tp)
5705 if (tp != NULL && tp->tl_buffer != NULL) 5707 if (tp != NULL && tp->tl_buffer != NULL)
5706 if (list_append_number(l, 5708 if (list_append_number(l,
5707 (varnumber_T)tp->tl_buffer->b_fnum) == FAIL) 5709 (varnumber_T)tp->tl_buffer->b_fnum) == FAIL)
5708 return; 5710 return;
5709 } 5711 }
6075 void 6077 void
6076 term_send_eof(channel_T *ch) 6078 term_send_eof(channel_T *ch)
6077 { 6079 {
6078 term_T *term; 6080 term_T *term;
6079 6081
6080 for (term = first_term; term != NULL; term = term->tl_next) 6082 FOR_ALL_TERMS(term)
6081 if (term->tl_job == ch->ch_job) 6083 if (term->tl_job == ch->ch_job)
6082 { 6084 {
6083 if (term->tl_eof_chars != NULL) 6085 if (term->tl_eof_chars != NULL)
6084 { 6086 {
6085 channel_send(ch, PART_IN, term->tl_eof_chars, 6087 channel_send(ch, PART_IN, term->tl_eof_chars,