From 4042efd3e88ad10620e257c25080fd16a228fbf7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 4 Feb 2020 23:45:03 -0800 Subject: repl: catch exceptions during completion. This fixes the issue that TXR exits if an exception occurs during Tab completion in the interactive listener. This could happen when loading a file fails for whatever reason, such as a corrupt or incomplete installation of the library files or whatever. * parser.c (provide_completions): Set up a catch all handler here around everything, like we already did in provide_atom. --- parser.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'parser.c') diff --git a/parser.c b/parser.c index 6f21f62e..8746f4c8 100644 --- a/parser.c +++ b/parser.c @@ -924,15 +924,17 @@ static void provide_completions(const wchar_t *data, (void) ctx; + uw_catch_begin (catch_all, exsym, exvals); + if (!ptr) - return; + goto out; while ((iswalnum(convert(wint_t, *ptr)) || wcschr(gly, *ptr)) && (sym = ptr) && ptr > data) ptr--; if (!sym) - return; + goto out; end = sym; @@ -999,6 +1001,16 @@ static void provide_completions(const wchar_t *data, sym_pfx, line_pfx, kind, if2(package, null(keyword))); } } + +out: + uw_catch (exsym, exvals) { + (void) exsym; + (void) exvals; + } + + uw_unwind; + + uw_catch_end; } static wchar_t *provide_atom(lino_t *l, const wchar_t *str, int n, void *ctx) -- cgit v1.2.3