Mercurial > vim
comparison src/evalfunc.c @ 9649:fd9727ae3c49 v7.4.2101
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 24 22:04:11 2016 +0200
patch 7.4.2101
Problem: Looping over windows, buffers and tab pages is inconsistant.
Solution: Use FOR_ALL_ macros everywhere. (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 24 Jul 2016 22:15:07 +0200 |
parents | ccbb8e393d80 |
children | 6255ff1ea003 |
comparison
equal
deleted
inserted
replaced
9648:227649fd4301 | 9649:fd9727ae3c49 |
---|---|
1437 buf = buflist_findname_exp(avar->vval.v_string); | 1437 buf = buflist_findname_exp(avar->vval.v_string); |
1438 if (buf == NULL) | 1438 if (buf == NULL) |
1439 { | 1439 { |
1440 /* No full path name match, try a match with a URL or a "nofile" | 1440 /* No full path name match, try a match with a URL or a "nofile" |
1441 * buffer, these don't use the full path. */ | 1441 * buffer, these don't use the full path. */ |
1442 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 1442 FOR_ALL_BUFFERS(buf) |
1443 if (buf->b_fname != NULL | 1443 if (buf->b_fname != NULL |
1444 && (path_with_url(buf->b_fname) | 1444 && (path_with_url(buf->b_fname) |
1445 #ifdef FEAT_QUICKFIX | 1445 #ifdef FEAT_QUICKFIX |
1446 || bt_nofile(buf) | 1446 || bt_nofile(buf) |
1447 #endif | 1447 #endif |
1595 | 1595 |
1596 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ | 1596 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ |
1597 ++emsg_off; | 1597 ++emsg_off; |
1598 buf = get_buf_tv(&argvars[0], TRUE); | 1598 buf = get_buf_tv(&argvars[0], TRUE); |
1599 #ifdef FEAT_WINDOWS | 1599 #ifdef FEAT_WINDOWS |
1600 for (wp = firstwin; wp; wp = wp->w_next) | 1600 FOR_ALL_WINDOWS(wp) |
1601 { | 1601 { |
1602 ++winnr; | 1602 ++winnr; |
1603 if (wp->w_buffer == buf) | 1603 if (wp->w_buffer == buf) |
1604 break; | 1604 break; |
1605 } | 1605 } |
6381 f_last_buffer_nr(typval_T *argvars UNUSED, typval_T *rettv) | 6381 f_last_buffer_nr(typval_T *argvars UNUSED, typval_T *rettv) |
6382 { | 6382 { |
6383 int n = 0; | 6383 int n = 0; |
6384 buf_T *buf; | 6384 buf_T *buf; |
6385 | 6385 |
6386 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 6386 FOR_ALL_BUFFERS(buf) |
6387 if (n < buf->b_fnum) | 6387 if (n < buf->b_fnum) |
6388 n = buf->b_fnum; | 6388 n = buf->b_fnum; |
6389 | 6389 |
6390 rettv->vval.v_number = n; | 6390 rettv->vval.v_number = n; |
6391 } | 6391 } |
12371 int winnr = 1; | 12371 int winnr = 1; |
12372 garray_T ga; | 12372 garray_T ga; |
12373 char_u buf[50]; | 12373 char_u buf[50]; |
12374 | 12374 |
12375 ga_init2(&ga, (int)sizeof(char), 70); | 12375 ga_init2(&ga, (int)sizeof(char), 70); |
12376 for (wp = firstwin; wp != NULL; wp = wp->w_next) | 12376 FOR_ALL_WINDOWS(wp) |
12377 { | 12377 { |
12378 sprintf((char *)buf, "%dresize %d|", winnr, wp->w_height); | 12378 sprintf((char *)buf, "%dresize %d|", winnr, wp->w_height); |
12379 ga_concat(&ga, buf); | 12379 ga_concat(&ga, buf); |
12380 sprintf((char *)buf, "vert %dresize %d|", winnr, wp->w_width); | 12380 sprintf((char *)buf, "vert %dresize %d|", winnr, wp->w_width); |
12381 ga_concat(&ga, buf); | 12381 ga_concat(&ga, buf); |