Add FOR_ALL_BUFFERS helper

This commit is contained in:
Wayne Rowcliffe
2014-08-02 20:19:33 -05:00
parent 44afe610f8
commit 8cf45786b1
17 changed files with 100 additions and 61 deletions

View File

@@ -5434,8 +5434,9 @@ int garbage_collect(void)
set_ref_in_ht(&SCRIPT_VARS(i), copyID);
/* buffer-local variables */
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
FOR_ALL_BUFFERS(buf) {
set_ref_in_item(&buf->b_bufvar.di_tv, copyID);
}
/* window-local variables */
FOR_ALL_TAB_WINDOWS(tp, wp)
@@ -7207,13 +7208,14 @@ static buf_T *find_buffer(typval_T *avar)
if (buf == NULL) {
/* 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)
|| bt_nofile(buf)
)
&& STRCMP(buf->b_fname, avar->vval.v_string) == 0)
break;
}
}
}
return buf;
@@ -10617,9 +10619,11 @@ static void f_last_buffer_nr(typval_T *argvars, typval_T *rettv)
int n = 0;
buf_T *buf;
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
if (n < buf->b_fnum)
FOR_ALL_BUFFERS(buf) {
if (n < buf->b_fnum) {
n = buf->b_fnum;
}
}
rettv->vval.v_number = n;
}