X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fkeybindings.c;h=75fe72826a3ec15cbf642afedac05d08ea90b364;hb=0e6c855b67e0cd3def7196396f3d1f45ff85b692;hp=3ce0e440b2d319af9ff0b81d1040bc468518c10f;hpb=2409e8ab623f8ef1452508b0fb4a4293692ed6a7;p=plomrogue diff --git a/src/keybindings.c b/src/keybindings.c index 3ce0e44..75fe728 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -3,14 +3,14 @@ #include "keybindings.h" -#include /* for malloc(), free(), atoi() */ -#include /* for uint16_t */ -#include /* for keycode defines in get_keyname() */ -#include /* for strchr(), strlen(), strcmp(), memcpy()*/ -#include "windows.h" /* for draw_all_wins() and WinMeta struct */ -#include "misc.h" /* for texfile_sizes() */ -#include "main.h" /* for World struct */ -#include "rexit.h" /* for err_exit() */ +#include /* for malloc(), free(), atoi() */ +#include /* for uint16_t */ +#include /* for keycode defines in get_keyname() */ +#include /* for strchr(), strlen(), strcmp(), memcpy()*/ +#include "windows.h" /* for draw_all_wins() and WinMeta struct */ +#include "readwrite.h" /* for texfile_sizes() */ +#include "main.h" /* for World struct */ +#include "rexit.h" /* for err_exit() */ @@ -21,10 +21,10 @@ extern void init_keybindings(struct World * world) char * err = "textfile_sizes() in init_keybindings() returns error."; exit_err(textfile_sizes(file, &linemax, &lines), world, err); struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding)); - char * command = malloc(linemax); + char * command = malloc(linemax + 1); uint16_t commcount = 0; char * cmdptr; - while (fgets(command, linemax, file)) + while (fgets(command, linemax + 1, file)) { keybindings[commcount].key = atoi(command); cmdptr = strchr(command, ' ') + 1;