-/* src/client/keybindings.c */
+/* src/client/keybindings.c
+ *
+ * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
+ * or any later version. For details on its copyright, license, and warranties,
+ * see the file NOTICE in the root directory of the PlomRogue source package.
+ */
#include "keybindings.h"
#include <ncurses.h> /* keycode defines, cbreak(), halfdelay(), getch() */
#include <stddef.h> /* NULL */
#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
#include <stdio.h> /* FILE, sprintf() */
+#include "../common/rexit.h" /* exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "windows.h" /* draw_all_wins() */
#include "world.h" /* global world */
{
if (keycode_given == keycode_match)
{
- sprintf(keyname, "%s", keyname_match);
+ int test = sprintf(keyname, "%s", keyname_match);
+ exit_trouble(test < 0, __func__, "sprintf");
return 1;
}
return 0;
extern char * get_keyname_to_keycode(uint16_t keycode)
{
- char * f_name = "get_name_to_keycode()";
- char * keyname = try_malloc(10, f_name); /* max keyname length + 1 */
+ char * keyname = try_malloc(10, __func__); /* max keyname length + 1 */
if (32 < keycode && keycode < 127)
{
- sprintf(keyname, "%c", keycode);
+ exit_trouble(sprintf(keyname, "%c", keycode) < 0, __func__, "sprintf");
}
else if (keycode >= KEY_F0 && keycode <= KEY_F(63))
{
uint16_t f = keycode - KEY_F0;
- sprintf(keyname, "F%d", f);
+ exit_trouble(sprintf(keyname, "F%d", f) < 0, __func__, "sprintf");;
}
else if ( try_keycode(keycode, keyname, 9, "TAB")
|| try_keycode(keycode, keyname, 10, "RETURN")
}
else
{
- sprintf(keyname, "(unknown)");
+ exit_trouble(sprintf(keyname, "(unknown)") < 0, __func__, "sprintf");
}
return keyname;
}