home · contact · privacy
Server: Read in former "config" data as normal server god commands.
[plomrogue] / src / client / wincontrol.c
index 816934a425e17a7d4d1851bdebc81f13fcb92658..c42516fd1f895180a68ebb89d7b91c27292a05ad 100644 (file)
@@ -7,10 +7,9 @@
 #include <stdio.h> /* sprintf() */
 #include <stdlib.h> /* free() */
 #include <string.h> /* memcpy(), memset(), strchr(), strlen() */
-#include "../common/rexit.h" /* exit_err() */
+#include "../common/rexit.h" /* exit_err(), exit_trouble() */
 #include "../common/try_malloc.h" /* try_malloc() */
-#include "../common/yx_uint16.h" /* struct yx_uint16 */
-#include "windows.h" /* struct Win, get_win_by_id(), get_win_pos_in_order() */
+#include "windows.h" /* Win,yx_uint16, get_win_by_id(),get_win_pos_in_order() */
 #include "world.h" /* global world */
 
 
@@ -109,9 +108,7 @@ static void place_win(struct Win * w)
          * top, fit w's top left corner to that predecessor's top right corner.
          */
         struct Win * w_top = w_prev;
-        for (;
-             w_top->start.y != 0 + sep;
-             w_top = get_win_before(w_top->id));
+        for (; w_top->start.y != 0 + sep; w_top = get_win_before(w_top->id));
         w->start.x = w_top->start.x + w_top->frame_size.x + sep;
 
         /* If enough space is found below w's predecessor, fit w's top left
@@ -203,7 +200,8 @@ static void suspend_win(struct Win * w)
     char next_char = world.winDB.order[i + 1];
     world.winDB.order[i] = '\0';
     char * second_part = &world.winDB.order[i + 1];
-    sprintf(new_order, "%s%s", world.winDB.order, second_part);
+    int test = sprintf(new_order, "%s%s", world.winDB.order, second_part);
+    exit_trouble(test < 0, f_name, "sprintf()");
     free(world.winDB.order);
     world.winDB.order = new_order;
     world.winDB.active = world.winDB.order[i];
@@ -331,10 +329,11 @@ extern void resize_active_win(char change)
 
 extern void shift_active_win(char dir)
 {
+    char * f_name = "shift_active_win()";
     uint8_t len_order = strlen(world.winDB.order);
     if (1 < len_order)
     {
-        char tmp[len_order + 1];
+        char * tmp = try_malloc(len_order + 1, f_name);
         tmp[len_order] = '\0';
         uint8_t pos = get_win_pos_in_order(world.winDB.active);
         if ('f' == dir)
@@ -365,6 +364,7 @@ extern void shift_active_win(char dir)
                 world.winDB.order[pos - 1] = world.winDB.active;
             }
         }
+        free(tmp);
         update_wins(get_win_by_id(world.winDB.order[0]));
     }
 }