0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0523: loops are repeated

Problem:    Loops are repeated.
Solution:   Use FOR_ALL_ macros. (Yegappan Lakshmanan, closes #5882)
This commit is contained in:
Bram Moolenaar
2020-04-06 22:13:01 +02:00
parent ee4e0c1e9a
commit 00d253e2b2
19 changed files with 72 additions and 44 deletions

View File

@@ -256,6 +256,9 @@ static reg_extmatch_T *next_match_extmatch = NULL;
#define INVALID_STATE(ssp) ((ssp)->ga_itemsize == 0)
#define VALID_STATE(ssp) ((ssp)->ga_itemsize != 0)
#define FOR_ALL_SYNSTATES(sb, sst) \
for ((sst) = (sb)->b_sst_first; (sst) != NULL; (sst) = (sst)->sst_next)
/*
* The current state (within the line) of the recognition engine.
* When current_state.ga_itemsize is 0 the current state is invalid.
@@ -438,7 +441,7 @@ syntax_start(win_T *wp, linenr_T lnum)
if (INVALID_STATE(&current_state) && syn_block->b_sst_array != NULL)
{
// Find last valid saved state before start_lnum.
for (p = syn_block->b_sst_first; p != NULL; p = p->sst_next)
FOR_ALL_SYNSTATES(syn_block, p)
{
if (p->sst_lnum > lnum)
break;
@@ -1044,7 +1047,7 @@ syn_stack_free_block(synblock_T *block)
if (block->b_sst_array != NULL)
{
for (p = block->b_sst_first; p != NULL; p = p->sst_next)
FOR_ALL_SYNSTATES(block, p)
clear_syn_state(p);
VIM_CLEAR(block->b_sst_array);
block->b_sst_first = NULL;
@@ -1353,7 +1356,7 @@ store_current_state(void)
else
{
// find the entry just before this one to adjust sst_next
for (p = syn_block->b_sst_first; p != NULL; p = p->sst_next)
FOR_ALL_SYNSTATES(syn_block, p)
if (p->sst_next == sp)
break;
if (p != NULL) // just in case