tweaks: avoid determining the key code from the key string twice
When assign_keyinfo() gets passed zero as key code, it will call keycode_from_string() to determine the key code from the string. So, remember the key code when keycode_from_string() gets called the first time to avoid the second call.master
parent
e01651cde1
commit
5130c35b85
10
src/rcfile.c
10
src/rcfile.c
|
@ -706,7 +706,7 @@ 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;
|
||||||
keystruct *s, *newsc = NULL;
|
keystruct *s, *newsc = NULL;
|
||||||
int menu, mask = 0;
|
int keycode, menu, mask = 0;
|
||||||
funcstruct *f;
|
funcstruct *f;
|
||||||
|
|
||||||
check_for_nonempty_syntax();
|
check_for_nonempty_syntax();
|
||||||
|
@ -743,7 +743,11 @@ void parse_binding(char *ptr, bool dobind)
|
||||||
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
|
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
|
||||||
jot_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
|
jot_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
|
||||||
goto free_things;
|
goto free_things;
|
||||||
} else if (keycode_from_string(keycopy) < 0) {
|
}
|
||||||
|
|
||||||
|
keycode = keycode_from_string(keycopy);
|
||||||
|
|
||||||
|
if (keycode < 0) {
|
||||||
jot_error(N_("Key name %s is invalid"), keycopy);
|
jot_error(N_("Key name %s is invalid"), keycopy);
|
||||||
goto free_things;
|
goto free_things;
|
||||||
}
|
}
|
||||||
|
@ -828,7 +832,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||||
}
|
}
|
||||||
|
|
||||||
newsc->menus = menu;
|
newsc->menus = menu;
|
||||||
assign_keyinfo(newsc, keycopy, 0);
|
assign_keyinfo(newsc, keycopy, keycode);
|
||||||
|
|
||||||
/* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
|
/* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
|
||||||
if ((!newsc->meta && newsc->keycode == ESC_CODE) ||
|
if ((!newsc->meta && newsc->keycode == ESC_CODE) ||
|
||||||
|
|
Loading…
Reference in New Issue