Commit f2c72bf7 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

binding: always initialize some keycode variables to a standard value

Also when somehow key_defined() is missing.

This fixes https://savannah.gnu.org/bugs/?49614

.
Reported-by: default avatarMike Frysinger <vapier@gentoo.org>
No related merge requests found
Showing with 6 additions and 8 deletions
+6 -8
...@@ -1553,18 +1553,18 @@ void terminal_init(void) ...@@ -1553,18 +1553,18 @@ void terminal_init(void)
#endif #endif
} }
#ifdef HAVE_KEY_DEFINED
/* Ask ncurses for a keycode, or assign a default one. */ /* Ask ncurses for a keycode, or assign a default one. */
int get_keycode(const char *keyname, const int standard) int get_keycode(const char *keyname, const int standard)
{ {
#ifdef HAVE_KEY_DEFINED
const char *keyvalue = tigetstr(keyname); const char *keyvalue = tigetstr(keyname);
if (keyvalue == 0 || keyvalue == (char *)-1) if (keyvalue != 0 && keyvalue != (char *)-1)
return standard;
else
return key_defined(keyvalue); return key_defined(keyvalue);
} else
#endif #endif
return standard;
}
/* Say that an unbound key was struck, and if possible which one. */ /* Say that an unbound key was struck, and if possible which one. */
void unbound_key(int code) void unbound_key(int code)
...@@ -2580,14 +2580,12 @@ int main(int argc, char **argv) ...@@ -2580,14 +2580,12 @@ int main(int argc, char **argv)
interface_color_pair[FUNCTION_TAG] = A_NORMAL; interface_color_pair[FUNCTION_TAG] = A_NORMAL;
#endif #endif
#ifdef HAVE_KEY_DEFINED
/* Ask ncurses for the key codes for Control+Left/Right/Up/Down. */ /* Ask ncurses for the key codes for Control+Left/Right/Up/Down. */
controlleft = get_keycode("kLFT5", CONTROL_LEFT); controlleft = get_keycode("kLFT5", CONTROL_LEFT);
controlright = get_keycode("kRIT5", CONTROL_RIGHT); controlright = get_keycode("kRIT5", CONTROL_RIGHT);
controlup = get_keycode("kUP5", CONTROL_UP); controlup = get_keycode("kUP5", CONTROL_UP);
controldown = get_keycode("kDN5", CONTROL_DOWN); controldown = get_keycode("kDN5", CONTROL_DOWN);
#endif #ifndef NANO_TINY
#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED)
/* Ask for the codes for Shift+Control+Left/Right/Up/Down. */ /* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT); shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
shiftcontrolright = get_keycode("kRIT6", SHIFT_CONTROL_RIGHT); shiftcontrolright = get_keycode("kRIT6", SHIFT_CONTROL_RIGHT);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment