tweaks: adjust the indentation after the previous change

Also reshuffle two declarations and improve two comments.
master
Benno Schulenberg 2018-10-24 18:12:06 +02:00
parent 0ad0dcc926
commit 2516b64046
1 changed files with 39 additions and 41 deletions

View File

@ -344,7 +344,8 @@ void parse_binding(char *ptr, bool dobind)
{ {
char *keyptr = NULL, *keycopy = NULL, *funcptr = NULL, *menuptr = NULL; char *keyptr = NULL, *keycopy = NULL, *funcptr = NULL, *menuptr = NULL;
sc *s, *newsc = NULL; sc *s, *newsc = NULL;
int menu; int menu, mask = 0;
subnfunc *f;
if (*ptr == '\0') { if (*ptr == '\0') {
rcfile_error(N_("Missing key name")); rcfile_error(N_("Missing key name"));
@ -429,10 +430,10 @@ void parse_binding(char *ptr, bool dobind)
goto free_things; goto free_things;
} }
/* When unbinding, wipe the given shortcut from the given menu. */
if (!dobind) { if (!dobind) {
/* Find and wipe the given shortcut from the given menu. */
for (s = sclist; s != NULL; s = s->next) for (s = sclist; s != NULL; s = s->next)
if ((s->menus & menu) && !strcmp(s->keystr, keycopy)) if ((s->menus & menu) && strcmp(s->keystr, keycopy) == 0)
s->menus &= ~menu; s->menus &= ~menu;
free_things: free_things:
@ -441,55 +442,52 @@ void parse_binding(char *ptr, bool dobind)
return; return;
} }
subnfunc *f; /* Tally up the menus where the function exists. */
int mask = 0; for (f = allfuncs; f != NULL; f = f->next)
if (f->func == newsc->func)
/* Tally up the menus where the function exists. */ mask = mask | f->menus;
for (f = allfuncs; f != NULL; f = f->next)
if (f->func == newsc->func)
mask = mask | f->menus;
#ifndef NANO_TINY #ifndef NANO_TINY
/* Handle the special case of the toggles. */ /* Handle the special case of the toggles. */
if (newsc->func == do_toggle_void) if (newsc->func == do_toggle_void)
mask = MMAIN; mask = MMAIN;
#endif #endif
#ifdef ENABLE_NANORC #ifdef ENABLE_NANORC
/* Handle the special case of a key defined as a string. */ /* Handle the special case of a key defined as a string. */
if (newsc->func == (functionptrtype)implant) if (newsc->func == (functionptrtype)implant)
mask = MMOST | MHELP; mask = MMOST | MHELP;
#endif #endif
/* Now limit the given menu to those where the function exists. */ /* Now limit the given menu to those where the function exists. */
menu = menu & (is_universal(newsc->func) ? MMOST : mask); menu = menu & (is_universal(newsc->func) ? MMOST : mask);
if (!menu) { if (!menu) {
if (!ISSET(RESTRICTED)) if (!ISSET(RESTRICTED))
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), rcfile_error(N_("Function '%s' does not exist in menu '%s'"),
funcptr, menuptr); funcptr, menuptr);
goto free_things; goto free_things;
} }
newsc->menus = menu; newsc->menus = menu;
assign_keyinfo(newsc, keycopy, 0); assign_keyinfo(newsc, keycopy, 0);
/* Do not allow rebinding a frequent escape-sequence starter: Esc [. */ /* Do not allow rebinding a frequent escape-sequence starter: Esc [. */
if (newsc->meta && newsc->keycode == 91) { if (newsc->meta && newsc->keycode == 91) {
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr); rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
goto free_things; goto free_things;
} }
#ifndef NANO_TINY #ifndef NANO_TINY
/* If this is a toggle, copy its sequence number. */ /* If this is a toggle, find and copy its sequence number. */
if (newsc->func == do_toggle_void) { if (newsc->func == do_toggle_void) {
for (s = sclist; s != NULL; s = s->next) for (s = sclist; s != NULL; s = s->next)
if (s->func == do_toggle_void && s->toggle == newsc->toggle) if (s->func == do_toggle_void && s->toggle == newsc->toggle)
newsc->ordinal = s->ordinal; newsc->ordinal = s->ordinal;
} else } else
newsc->ordinal = 0; newsc->ordinal = 0;
#endif #endif
/* Add the new shortcut at the start of the list. */ /* Add the new shortcut at the start of the list. */
newsc->next = sclist; newsc->next = sclist;
sclist = newsc; sclist = newsc;
} }
/* Verify that the given file exists, is not a folder nor a device. */ /* Verify that the given file exists, is not a folder nor a device. */