The function StrConcatDot can be used now in session.c
to simplify the code.
Added "-1" to avoid overflow problems in buffers.
---
src/session.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/session.c b/src/session.c
index 2d020c7..7d1263f 100644
--- a/src/session.c
+++ b/src/session.c
@@ -176,7 +176,7 @@ static WMPropList *makeWindowState(WWindow * wwin,
WApplication * wapp)
Window win;
int i;
unsigned mask;
- char *class, *instance, *command = NULL, buffer[512];
+ char *class, *instance, *command = NULL, *buf1, buffer[512];
WMPropList *win_state, *cmd, *name, *workspace;
WMPropList *shaded, *miniaturized, *hidden, *geometry;
WMPropList *dock, *shortcut;
@@ -191,24 +191,17 @@ static WMPropList *makeWindowState(WWindow * wwin,
WApplication * wapp)
return NULL;
if (PropGetWMClass(win, &class, &instance)) {
- if (class && instance)
- snprintf(buffer, sizeof(buffer), "%s.%s", instance,
class);
- else if (instance)
- snprintf(buffer, sizeof(buffer), "%s", instance);
- else if (class)
- snprintf(buffer, sizeof(buffer), ".%s", class);
- else
- snprintf(buffer, sizeof(buffer), ".");
+ buf1 = StrConcatDot(instance, class, True);
+ snprintf(buffer, sizeof(buffer) - 1, "%s", buf1);
+ wfree(buf1);
name = WMCreatePLString(buffer);
cmd = WMCreatePLString(command);
- /*sprintf(buffer, "%d", wwin->frame->workspace+1);
- workspace = WMCreatePLString(buffer); */
workspace =
WMCreatePLString(scr->workspaces[wwin->frame->workspace]->name);
shaded = wwin->flags.shaded ? sYes : sNo;
miniaturized = wwin->flags.miniaturized ? sYes : sNo;
hidden = wwin->flags.hidden ? sYes : sNo;
- snprintf(buffer, sizeof(buffer), "%ix%i+%i+%i",
+ snprintf(buffer, sizeof(buffer) - 1, "%ix%i+%i+%i",
wwin->client.width, wwin->client.height,
wwin->frame_x, wwin->frame_y);
geometry = WMCreatePLString(buffer);
@@ -218,7 +211,7 @@ static WMPropList *makeWindowState(WWindow * wwin,
WApplication * wapp)
mask |= 1 << i;
}
- snprintf(buffer, sizeof(buffer), "%u", mask);
+ snprintf(buffer, sizeof(buffer) - 1, "%u", mask);
shortcut = WMCreatePLString(buffer);
win_state = WMCreatePLDictionary(sName, name,
--
1.7.9.1
>From f323bd3fb974dbe65b34ad88e802cdd0bf5de353 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Sat, 14 Apr 2012 11:57:29 +0200
Subject: [PATCH 09/16] WindowMaker: StrConcatDot is now used in session.c
The function StrConcatDot can be used now in session.c
to simplify the code.
Added "-1" to avoid overflow problems in buffers.
---
src/session.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/session.c b/src/session.c
index 2d020c7..7d1263f 100644
--- a/src/session.c
+++ b/src/session.c
@@ -176,7 +176,7 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
Window win;
int i;
unsigned mask;
- char *class, *instance, *command = NULL, buffer[512];
+ char *class, *instance, *command = NULL, *buf1, buffer[512];
WMPropList *win_state, *cmd, *name, *workspace;
WMPropList *shaded, *miniaturized, *hidden, *geometry;
WMPropList *dock, *shortcut;
@@ -191,24 +191,17 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
return NULL;
if (PropGetWMClass(win, &class, &instance)) {
- if (class && instance)
- snprintf(buffer, sizeof(buffer), "%s.%s", instance, class);
- else if (instance)
- snprintf(buffer, sizeof(buffer), "%s", instance);
- else if (class)
- snprintf(buffer, sizeof(buffer), ".%s", class);
- else
- snprintf(buffer, sizeof(buffer), ".");
+ buf1 = StrConcatDot(instance, class, True);
+ snprintf(buffer, sizeof(buffer) - 1, "%s", buf1);
+ wfree(buf1);
name = WMCreatePLString(buffer);
cmd = WMCreatePLString(command);
- /*sprintf(buffer, "%d", wwin->frame->workspace+1);
- workspace = WMCreatePLString(buffer); */
workspace = WMCreatePLString(scr->workspaces[wwin->frame->workspace]->name);
shaded = wwin->flags.shaded ? sYes : sNo;
miniaturized = wwin->flags.miniaturized ? sYes : sNo;
hidden = wwin->flags.hidden ? sYes : sNo;
- snprintf(buffer, sizeof(buffer), "%ix%i+%i+%i",
+ snprintf(buffer, sizeof(buffer) - 1, "%ix%i+%i+%i",
wwin->client.width, wwin->client.height, wwin->frame_x, wwin->frame_y);
geometry = WMCreatePLString(buffer);
@@ -218,7 +211,7 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
mask |= 1 << i;
}
- snprintf(buffer, sizeof(buffer), "%u", mask);
+ snprintf(buffer, sizeof(buffer) - 1, "%u", mask);
shortcut = WMCreatePLString(buffer);
win_state = WMCreatePLDictionary(sName, name,
--
1.7.9.1