← Commit list

563d93c9a

Denys Vlasenko
Denys Vlasenko
2018-12-16
SUCCESS Duration: 151s

Subject

bc: simplify zbc_parse_break_or_continue(), logic is the same

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

miscutils/bc.c+10 -11
@@ -4358,20 +4358,19 @@ static BC_STATUS zbc_parse_break_or_continue(BcParse *p, BcLexType type)
{
BcStatus s;
size_t i;
- BcInstPtr *ip;
if (type == BC_LEX_KEY_BREAK) {
- if (p->exits.len == 0) RETURN_STATUS(bc_error_bad_token());
-
- i = p->exits.len - 1;
- ip = bc_vec_item(&p->exits, i);
-
- while (!ip->func && i < p->exits.len)
- ip = bc_vec_item(&p->exits, i--);
- if (i >= p->exits.len && !ip->func)
- RETURN_STATUS(bc_error_bad_token());
+ BcInstPtr *ipp;
- i = ip->idx;
+ i = p->exits.len;
+ for (;;) {
+ if (i == 0) // none of the enclosing blocks is a loop
+ RETURN_STATUS(bc_error_bad_token());
+ ipp = bc_vec_item(&p->exits, --i);
+ if (ipp->func != 0)
+ break;
+ }
+ i = ipp->idx;
}
else
i = *((size_t *) bc_vec_top(&p->conds));