nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0ff949958376ac284ec8abd49e024d22bf965056
parent eb1668ce818be35cb8a1176d92c1620c47735822
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 20 Jan 2020 17:36:31 +0100

tweaks: reshuffle some lines, to avoid tallying the menus when not needed

Diffstat:
Msrc/rcfile.c | 19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/rcfile.c b/src/rcfile.c @@ -806,22 +806,25 @@ void parse_binding(char *ptr, bool dobind) if (!dobind) goto free_things; - /* Tally up the menus where the function exists. */ - for (funcstruct *f = allfuncs; f != NULL; f = f->next) - if (f->func == newsc->func) - mask = mask | f->menus; - + if (is_universal(newsc->func)) + mask = MMOST|MBROWSER; #ifndef NANO_TINY /* Handle the special case of the toggles. */ - if (newsc->func == do_toggle_void) + else if (newsc->func == do_toggle_void) mask = MMAIN; #endif /* Handle the special case of a key defined as a string. */ - if (newsc->func == (functionptrtype)implant) + else if (newsc->func == (functionptrtype)implant) mask = MMOST|MBROWSER|MHELP; + else { + /* Tally up the menus where the function exists. */ + for (funcstruct *f = allfuncs; f != NULL; f = f->next) + if (f->func == newsc->func) + mask = mask | f->menus; + } /* Now limit the given menu to those where the function exists. */ - menu = menu & (is_universal(newsc->func) ? (MMOST|MBROWSER) : mask); + menu = menu & mask; if (!menu) { if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE))