From 478d7c3c1dc347d5b04db03ccd346fac9d3014c7 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 15 Sep 2023 13:28:30 +1000 Subject: [PATCH] export do_comm_call and use it from TYPE_pane and TYPE_comm This simplifies the inline code for do_call_val(), and includes pane and comm calls in the backtrace from LOG_BT() Signed-off-by: NeilBrown --- DOC/TODO.md | 2 +- core-keymap.c | 11 ++++++++--- core-pane.h | 26 ++++++-------------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/DOC/TODO.md b/DOC/TODO.md index 59f408a3..c48117d0 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -117,7 +117,7 @@ Core features hitting a python error - there will be no active view so the screen will be meaningless. I need to properly abort and auto-choose a new pane. -- [ ] LOG_BT() doesn't see TYPE_pane and TYPE_comm calls. +- [X] LOG_BT() doesn't see TYPE_pane and TYPE_comm calls. - [ ] LOG should take a pane arg, and not use any static vars. - [ ] reduce size of $(nm O/*.o | grep ' b ' | grep -v '_map$') - [X] give every pane a link to root/editor main and use that diff --git a/core-keymap.c b/core-keymap.c index 703ca2b1..fdcd0cf1 100644 --- a/core-keymap.c +++ b/core-keymap.c @@ -435,14 +435,19 @@ void LOG_BT(void) LOG("End Backtrace"); } -static int do_comm_call(struct command *comm safe, - const struct cmd_info *ci safe) +int do_comm_call(struct command *comm safe, const struct cmd_info *ci safe) { struct backtrace bt; int ret; + if (ci->home->damaged & DAMAGED_DEAD) + return Efail; if (times_up_fast(ci->home)) return Efail; + if ((ci->home->damaged & DAMAGED_CLOSED) && + !comm->closed_ok) + return Efallthrough; + if (backtrace_depth > 100) { backtrace_depth = 0; LOG("Recursion limit of 100 reached"); @@ -569,7 +574,7 @@ int key_handle(const struct cmd_info *ci safe) vci->home = p; vci->comm = p->handle; /* Don't add this to the call stack as it - * should simple call the desired function and + * should simply call the desired function and * that will appear on the call stack. */ ret = p->handle->func(ci); diff --git a/core-pane.h b/core-pane.h index 907cc1b1..b726acb3 100644 --- a/core-pane.h +++ b/core-pane.h @@ -106,6 +106,7 @@ static inline void pane_put(struct pane *p safe) pane_free(p); } +int do_comm_call(struct command *comm safe, const struct cmd_info *ci safe); static inline int do_call_val(enum target_type type, struct pane *home, struct command *comm2a, const char *key safe, struct pane *focus safe, @@ -136,32 +137,17 @@ static inline int do_call_val(enum target_type type, struct pane *home, ret = key_handle(&ci); break; case TYPE_pane: - if (!home->handle || (home->damaged & DAMAGED_DEAD)) - return Efail; - if (times_up_fast(focus)) - return Efail; - if (home) - ci.home = home; - if ((home->damaged & DAMAGED_CLOSED) && - !home->handle->closed_ok) - /* This pane cannot accept anything but - * close_ok commands. - */ - return Efallthrough; - ci.comm = home->handle; - ret = ci.comm->func(&ci); + ci.home = home; + if (home->handle) + ci.comm = home->handle; + ret = do_comm_call(ci.comm, &ci); break; case TYPE_comm: - if (times_up_fast(focus)) - return Efail; if (home) ci.home = home; - if (ci.home->damaged & DAMAGED_CLOSED && - !comm2a->closed_ok) - return Efallthrough; ci.comm = comm2a; ci.comm2 = comm2b; - ret = ci.comm->func(&ci); + ret = do_comm_call(ci.comm, &ci); break; } return ret; -- 2.39.5