Mercurial > vim
comparison src/ex_cmds2.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 | 172131507c85 |
children | 8c2553beff0f |
comparison
equal
deleted
inserted
replaced
9648:227649fd4301 | 9649:fd9727ae3c49 |
---|---|
1719 { | 1719 { |
1720 buf_T *buf; | 1720 buf_T *buf; |
1721 | 1721 |
1722 if (!(p_aw || p_awa) || !p_write) | 1722 if (!(p_aw || p_awa) || !p_write) |
1723 return; | 1723 return; |
1724 for (buf = firstbuf; buf; buf = buf->b_next) | 1724 FOR_ALL_BUFFERS(buf) |
1725 if (bufIsChanged(buf) && !buf->b_p_ro) | 1725 if (bufIsChanged(buf) && !buf->b_p_ro) |
1726 { | 1726 { |
1727 #ifdef FEAT_AUTOCMD | 1727 #ifdef FEAT_AUTOCMD |
1728 bufref_T bufref; | 1728 bufref_T bufref; |
1729 | 1729 |
1762 { | 1762 { |
1763 buf_T *buf2; | 1763 buf_T *buf2; |
1764 int count = 0; | 1764 int count = 0; |
1765 | 1765 |
1766 if (flags & CCGD_ALLBUF) | 1766 if (flags & CCGD_ALLBUF) |
1767 for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) | 1767 FOR_ALL_BUFFERS(buf2) |
1768 if (bufIsChanged(buf2) | 1768 if (bufIsChanged(buf2) |
1769 && (buf2->b_ffname != NULL | 1769 && (buf2->b_ffname != NULL |
1770 # ifdef FEAT_BROWSE | 1770 # ifdef FEAT_BROWSE |
1771 || cmdmod.browse | 1771 || cmdmod.browse |
1772 # endif | 1772 # endif |
1866 /* | 1866 /* |
1867 * Write all modified files that can be written. | 1867 * Write all modified files that can be written. |
1868 * Skip readonly buffers, these need to be confirmed | 1868 * Skip readonly buffers, these need to be confirmed |
1869 * individually. | 1869 * individually. |
1870 */ | 1870 */ |
1871 for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) | 1871 FOR_ALL_BUFFERS(buf2) |
1872 { | 1872 { |
1873 if (bufIsChanged(buf2) | 1873 if (bufIsChanged(buf2) |
1874 && (buf2->b_ffname != NULL | 1874 && (buf2->b_ffname != NULL |
1875 #ifdef FEAT_BROWSE | 1875 #ifdef FEAT_BROWSE |
1876 || cmdmod.browse | 1876 || cmdmod.browse |
1902 else if (ret == VIM_DISCARDALL) | 1902 else if (ret == VIM_DISCARDALL) |
1903 { | 1903 { |
1904 /* | 1904 /* |
1905 * mark all buffers as unchanged | 1905 * mark all buffers as unchanged |
1906 */ | 1906 */ |
1907 for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) | 1907 FOR_ALL_BUFFERS(buf2) |
1908 unchanged(buf2, TRUE); | 1908 unchanged(buf2, TRUE); |
1909 } | 1909 } |
1910 } | 1910 } |
1911 #endif | 1911 #endif |
1912 | 1912 |
1962 #ifdef FEAT_WINDOWS | 1962 #ifdef FEAT_WINDOWS |
1963 tabpage_T *tp; | 1963 tabpage_T *tp; |
1964 win_T *wp; | 1964 win_T *wp; |
1965 #endif | 1965 #endif |
1966 | 1966 |
1967 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 1967 FOR_ALL_BUFFERS(buf) |
1968 ++bufcount; | 1968 ++bufcount; |
1969 | 1969 |
1970 if (bufcount == 0) | 1970 if (bufcount == 0) |
1971 return FALSE; | 1971 return FALSE; |
1972 | 1972 |
1981 FOR_ALL_WINDOWS(wp) | 1981 FOR_ALL_WINDOWS(wp) |
1982 if (wp->w_buffer != curbuf) | 1982 if (wp->w_buffer != curbuf) |
1983 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); | 1983 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); |
1984 | 1984 |
1985 /* buf in other tab */ | 1985 /* buf in other tab */ |
1986 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) | 1986 FOR_ALL_TABPAGES(tp) |
1987 if (tp != curtab) | 1987 if (tp != curtab) |
1988 for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) | 1988 for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) |
1989 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); | 1989 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); |
1990 #endif | 1990 #endif |
1991 /* any other buf */ | 1991 /* any other buf */ |
1992 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 1992 FOR_ALL_BUFFERS(buf) |
1993 add_bufnum(bufnrs, &bufnum, buf->b_fnum); | 1993 add_bufnum(bufnrs, &bufnum, buf->b_fnum); |
1994 | 1994 |
1995 for (i = 0; i < bufnum; ++i) | 1995 for (i = 0; i < bufnum; ++i) |
1996 { | 1996 { |
1997 buf = buflist_findnr(bufnrs[i]); | 1997 buf = buflist_findnr(bufnrs[i]); |
2922 { | 2922 { |
2923 /* Done? */ | 2923 /* Done? */ |
2924 if (next_fnum < 0 || next_fnum > eap->line2) | 2924 if (next_fnum < 0 || next_fnum > eap->line2) |
2925 break; | 2925 break; |
2926 /* Check if the buffer still exists. */ | 2926 /* Check if the buffer still exists. */ |
2927 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 2927 FOR_ALL_BUFFERS(buf) |
2928 if (buf->b_fnum == next_fnum) | 2928 if (buf->b_fnum == next_fnum) |
2929 break; | 2929 break; |
2930 if (buf == NULL) | 2930 if (buf == NULL) |
2931 break; | 2931 break; |
2932 | 2932 |