X-Git-Url: https://plomlompom.com/repos/index.html?a=blobdiff_plain;f=src%2Fclient%2Fwincontrol.c;h=eb9270b411130e5f4ce38471de247a817060857c;hb=a4df5c24eca01a771060b130ed7f4c20d9f73778;hp=e1a4fbd485a9dd0df65326f6d6d03b2966ee0934;hpb=483f25751ae49c810456faf0bb7a375bc437df10;p=plomrogue
diff --git a/src/client/wincontrol.c b/src/client/wincontrol.c
index e1a4fbd..eb9270b 100644
--- a/src/client/wincontrol.c
+++ b/src/client/wincontrol.c
@@ -1,4 +1,9 @@
-/* src/client/wincontrol.c */
+/* src/client/wincontrol.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 "wincontrol.h"
#include /* getmaxx(), getmaxy(), wresize() */
@@ -7,7 +12,7 @@
#include /* sprintf() */
#include /* free() */
#include /* 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 "windows.h" /* Win,yx_uint16, get_win_by_id(),get_win_pos_in_order() */
#include "world.h" /* global world */
@@ -177,9 +182,8 @@ static void set_win_target_size(struct Win * w)
static void append_win(struct Win * w)
{
- char * f_name = "append_win()";
uint8_t old_size = strlen(world.winDB.order) + 1;
- char * new_order = try_malloc(old_size + 1, f_name);
+ char * new_order = try_malloc(old_size + 1, __func__);
memcpy(new_order, world.winDB.order, old_size - 1);
new_order[old_size - 1] = w->id;
new_order[old_size] = '\0';
@@ -193,14 +197,14 @@ static void append_win(struct Win * w)
static void suspend_win(struct Win * w)
{
- char * f_name = "suspend_win()";
uint8_t new_size = strlen(world.winDB.order);
- char * new_order = try_malloc(new_size, f_name);
+ char * new_order = try_malloc(new_size, __func__);
uint8_t i = get_win_pos_in_order(w->id);
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, __func__, "sprintf");
free(world.winDB.order);
world.winDB.order = new_order;
world.winDB.active = world.winDB.order[i];
@@ -221,7 +225,7 @@ static void suspend_win(struct Win * w)
extern void toggle_window(char id)
{
struct Win * win = get_win_by_id(id);
- if (NULL == strchr(world.winDB.order, id))
+ if (!strchr(world.winDB.order, id))
{
append_win(win);
return;
@@ -328,11 +332,10 @@ 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 = try_malloc(len_order + 1, f_name);
+ char * tmp = try_malloc(len_order + 1, __func__);
tmp[len_order] = '\0';
uint8_t pos = get_win_pos_in_order(world.winDB.active);
if ('f' == dir)