0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

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 #5339)
This commit is contained in:
Bram Moolenaar
2020-04-02 18:50:46 +02:00
parent f10806b250
commit aeea72151c
34 changed files with 176 additions and 141 deletions

View File

@@ -235,6 +235,10 @@ struct AutoPatCmd_S
static AutoPatCmd *active_apc_list = NULL; // stack of active autocommands
// Macro to loop over all the patterns for an autocmd event
#define FOR_ALL_AUTOCMD_PATTERNS(event, ap) \
for ((ap) = first_autopat[(int)(event)]; (ap) != NULL; (ap) = (ap)->next)
/*
* augroups stores a list of autocmd group names.
*/
@@ -456,7 +460,7 @@ aubuflocal_remove(buf_T *buf)
for (event = (event_T)0; (int)event < (int)NUM_EVENTS;
event = (event_T)((int)event + 1))
// loop over all autocommand patterns
for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
FOR_ALL_AUTOCMD_PATTERNS(event, ap)
if (ap->buflocal_nr == buf->b_fnum)
{
au_remove_pat(ap);
@@ -519,7 +523,7 @@ au_del_group(char_u *name)
for (event = (event_T)0; (int)event < (int)NUM_EVENTS;
event = (event_T)((int)event + 1))
{
for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
FOR_ALL_AUTOCMD_PATTERNS(event, ap)
if (ap->group == i && ap->pat != NULL)
{
give_warning((char_u *)_("W19: Deleting augroup that is still in use"), TRUE);
@@ -1041,7 +1045,7 @@ do_autocmd_event(
*/
if (*pat == NUL)
{
for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
FOR_ALL_AUTOCMD_PATTERNS(event, ap)
{
if (forceit) // delete the AutoPat, if it's in the current group
{
@@ -2400,7 +2404,7 @@ has_autocmd(event_T event, char_u *sfname, buf_T *buf)
forward_slash(fname);
#endif
for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
FOR_ALL_AUTOCMD_PATTERNS(event, ap)
if (ap->pat != NULL && ap->cmds != NULL
&& (ap->buflocal_nr == 0
? match_file_pat(NULL, &ap->reg_prog,