summaryrefslogtreecommitdiff
path: root/src/syntax.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-06 22:13:01 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-06 22:13:01 +0200
commit00d253e2b2f435a5386582c3f857008e7ac355c2 (patch)
tree71bbea4e4c6efa593a85266e445d82377a65f454 /src/syntax.c
parentee4e0c1e9a81cb5d96e0060203a9033c2f28588e (diff)
downloadvim-git-00d253e2b2f435a5386582c3f857008e7ac355c2.tar.gz
patch 8.2.0523: loops are repeatedv8.2.0523
Problem: Loops are repeated. Solution: Use FOR_ALL_ macros. (Yegappan Lakshmanan, closes #5882)
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/syntax.c b/src/syntax.c
index c1d1b856b..b4d3afc5d 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -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