diff options
Diffstat (limited to 'Src/loop.c')
-rw-r--r-- | Src/loop.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Src/loop.c b/Src/loop.c index 9b0a8d79c..4daa60591 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -633,6 +633,14 @@ execcase(Estate state, int do_exec) zlong try_errflag = -1; +/** + * Corrresponding interrupt error status form `try' block. + */ + +/**/ +zlong +try_interrupt = -1; + /**/ zlong try_tryflag = 0; @@ -643,8 +651,8 @@ exectry(Estate state, int do_exec) { Wordcode end, always; int endval; - int save_retflag, save_breaks, save_contflag, try_interrupt; - zlong save_try_errflag, save_try_tryflag; + int save_retflag, save_breaks, save_contflag; + zlong save_try_errflag, save_try_tryflag, save_try_interrupt; end = state->pc + WC_TRY_SKIP(state->pc[-1]); always = state->pc + 1 + WC_TRY_SKIP(*state->pc); @@ -671,8 +679,9 @@ exectry(Estate state, int do_exec) /* The always clause. */ save_try_errflag = try_errflag; + save_try_interrupt = try_interrupt; try_errflag = (zlong)(errflag & ERRFLAG_ERROR); - try_interrupt = errflag & ERRFLAG_INT; + try_interrupt = (zlong)((errflag & ERRFLAG_INT) ? 1 : 0); /* We need to reset all errors to allow the block to execute */ errflag = 0; save_retflag = retflag; @@ -689,18 +698,12 @@ exectry(Estate state, int do_exec) errflag |= ERRFLAG_ERROR; else errflag &= ~ERRFLAG_ERROR; - /* - * TODO: currently, we always restore the interrupt - * error status. We should have a way of clearing it. - * Doing this with try_errflag (the shell variable TRY_BLOCK_ERROR) - * is probably not a good idea since currently that's documented - * such that setting it to 0 clears errors, and we don't want - * to clear interrupts as a side effect. So it probably needs - * a different variable. - */ if (try_interrupt) errflag |= ERRFLAG_INT; + else + errflag &= ~ERRFLAG_INT; try_errflag = save_try_errflag; + try_interrupt = save_try_interrupt; if (!retflag) retflag = save_retflag; if (!breaks) |