Fix the bug for real

This takes care of a stack of multiple things.
This commit is contained in:
Gavin Howard 2020-07-09 20:44:51 -06:00
parent 4ad6735b84
commit aa19025bab
Signed by: gavin
GPG Key ID: C08038BDF280D33E
1 changed files with 12 additions and 2 deletions

View File

@ -603,8 +603,18 @@ restart:
bc_parse_err(&vm.prs, BC_ERROR_PARSE_STRING);
#if BC_ENABLED
else if (BC_IS_BC && BC_ERR(BC_PARSE_NO_EXEC(&vm.prs))) {
if (BC_PARSE_TOP_FLAG(&vm.prs) == BC_PARSE_FLAG_IF_END)
bc_vm_process("else {}", true);
size_t i;
bool good = true;
for (i = 0; good && i < vm.prs.flags.len; ++i) {
uint16_t flag = *((uint16_t*) bc_vec_item(&vm.prs.flags, i));
good = ((flag & BC_PARSE_FLAG_BRACE) != BC_PARSE_FLAG_BRACE);
}
if (good) {
while (BC_PARSE_IF_END(&vm.prs)) bc_vm_process("else {}", true);
}
else bc_parse_err(&vm.prs, BC_ERROR_PARSE_BLOCK);
}
#endif // BC_ENABLED