diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-08-19 23:49:25 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-08-19 23:49:25 -0400 |
commit | e1c330a486c184152cb48d637c6d04caba5290bd (patch) | |
tree | b2379cae30ea446456681d1dc62d80ef95345f69 /src/nvim/eval.c | |
parent | 0b7bff5bb71ddc2e9c41863ec41b9aea74d0fe75 (diff) | |
parent | 888a31ba454cf9c054527a26459c112593efa54b (diff) | |
download | rneovim-e1c330a486c184152cb48d637c6d04caba5290bd.tar.gz rneovim-e1c330a486c184152cb48d637c6d04caba5290bd.tar.bz2 rneovim-e1c330a486c184152cb48d637c6d04caba5290bd.zip |
Merge pull request #1024 from war1025/dev/for_all_buffers
Add FOR_ALL_BUFFERS helper
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 5bda9fcd3f..1cef91785c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5405,7 +5405,6 @@ static int list_join(garray_T *gap, list_T *l, char_u *sep, int echo_style, int int garbage_collect(void) { int copyID; - buf_T *buf; win_T *wp; funccall_T *fc, **pfc; int did_free; @@ -5440,8 +5439,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) @@ -7223,13 +7223,16 @@ 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) - if (buf->b_fname != NULL - && (path_with_url(buf->b_fname) - || bt_nofile(buf) + FOR_ALL_BUFFERS(bp) { + if (bp->b_fname != NULL + && (path_with_url(bp->b_fname) + || bt_nofile(bp) ) - && STRCMP(buf->b_fname, avar->vval.v_string) == 0) + && STRCMP(bp->b_fname, avar->vval.v_string) == 0) { + buf = bp; break; + } + } } } return buf; @@ -10635,11 +10638,12 @@ static void f_keys(typval_T *argvars, typval_T *rettv) 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; } |