From fa52ca27f14affaf14b76bc36e16fffed5a511b9 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 6 Nov 2021 10:55:01 +1100 Subject: [PATCH] oceani: simplify loop in var_block_close() The 'step' was not in the 'for' header, which makes it harder to follow how the loop works. Also add a comment to explain where is happening when ->name->var != v. Signed-off-by: NeilBrown --- csrc/oceani.mdc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 4bd3959..0772bcf 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -1147,9 +1147,17 @@ all pending-scope variables become conditionally scoped. scope_pop(c); for (vp = &c->in_scope; - v = *vp, v && v->min_depth > c->scope_depth; - ) { - if (v->name->var == v) switch (ct) { + (v = *vp) && v->min_depth > c->scope_depth; + (v->scope == OutScope || v->name->var != v) + ? (*vp = v->in_scope, 0) + : ( vp = &v->in_scope, 0)) { + if (v->name->var != v) { + /* This is still in scope, but we haven't just + * closed the scope. + */ + continue; + } + switch (ct) { case CloseElse: case CloseParallel: /* handle PendingScope */ switch(v->scope) { @@ -1210,10 +1218,6 @@ all pending-scope variables become conditionally scoped. } break; } - if (v->scope == OutScope || v->name->var != v) - *vp = v->in_scope; - else - vp = &v->in_scope; } } -- 2.43.0