
Check for ctrl-c in lil_parse. This works out to around every time a function or command is called. We also check at the beginning of lil_eval_expr so that constructs like
while {1} {}
get interrupted. Since there are no non-trivial commands in that example, lil_parse never gets to its ctrlc check. However, we do need to evaluate the loop expression, so that's a good place to put a check.
Signed-off-by: Sean Anderson seanga2@gmail.com ---
common/cli_lil.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/common/cli_lil.c b/common/cli_lil.c index c19a25b2bf..50e314a643 100644 --- a/common/cli_lil.c +++ b/common/cli_lil.c @@ -10,6 +10,7 @@
#include <common.h> #include <cli_lil.h> +#include <console.h> #include <ctype.h> #include <stdlib.h> #include <stdio.h> @@ -1117,6 +1118,11 @@ struct lil_value *lil_parse(struct lil *lil, const char *code, size_t codelen, lil_free_value(val); val = NULL;
+ if (ctrlc()) { + lil_set_error(lil, LIL_ERR_INTR, "interrupted"); + goto cleanup; + } + words = substitute(lil); if (!words || lil->err) goto cleanup; @@ -1671,6 +1677,11 @@ struct lil_value *lil_eval_expr(struct lil *lil, struct lil_value *code) { struct expreval ee;
+ if (ctrlc()) { + lil_set_error(lil, LIL_ERR_INTR, "interrupted"); + return NULL; + } + code = lil_subst_to_value(lil, code); if (lil->err) return NULL;