home · contact · privacy
Client: Changed window sizing algorithm to fix bug of too large negative window
[plomrogue] / src / client / wincontrol.c
index eda233b43ab762d3bdba90f6fe6e4bc486731770..5e818badd0b3d21d473b992e27ec4504defd94dc 100644 (file)
@@ -3,6 +3,7 @@
 #include "wincontrol.h"
 #include <errno.h> /* global errno */
 #include <dirent.h> /* DIR, struct dirent, opendir(), closedir(), readdir() */
+#include <stddef.h> /* NULL */
 #include <stdint.h> /* uint8_t, uint16_t, uint32_t */
 #include <stdio.h> /* FILE */
 #include <stdlib.h> /* free(), atoi() */
@@ -117,9 +118,8 @@ static void init_winconf_from_file(char id, struct WinConf * winconf)
         kb_p->next = 0;
         kb_p->key = atoi(command);
         cmdptr = strchr(command, ' ') + 1;
-        kb_p->command = try_malloc(strlen(cmdptr), context);
-        memcpy(kb_p->command, cmdptr, strlen(cmdptr) - 1);
-        kb_p->command[strlen(cmdptr) - 1] = '\0';
+        cmdptr[strlen(cmdptr) - 1] = '\0';
+        kb_p->command = get_command(cmdptr);
         loc_last_ptr = & kb_p->next;
     }
 
@@ -174,9 +174,9 @@ static void save_win_config(char id)
     struct KeyBinding * kb_p = wc->kb.kbs;
     while (0 != kb_p)
     {
-        if (strlen(kb_p->command) > linemax)
+        if (strlen(kb_p->command->dsc_short) > linemax)
         {
-            linemax = strlen(kb_p->command);
+            linemax = strlen(kb_p->command->dsc_short);
         }
         kb_p = kb_p->next;
     }
@@ -185,7 +185,7 @@ static void save_win_config(char id)
     kb_p = wc->kb.kbs;
     while (0 != kb_p)
     {
-        sprintf(kb_line, "%d %s\n", kb_p->key, kb_p->command);
+        sprintf(kb_line, "%d %s\n", kb_p->key, kb_p->command->dsc_short);
         try_fwrite(kb_line, sizeof(char), strlen(kb_line), file, f_name);
         kb_p = kb_p->next;
     }