commit 56e1b89

wf  ·  2026-04-14 16:59:05 +0000 UTC
parent 8102d4f
Fix erroneous newline logic
2 files changed,  +7, -7
M ipc.c
+2, -2
 1@@ -123,8 +123,8 @@ ipc_msg(const struct command *cmd, int argc, char **argv) {
 2 
 3 		while (*msg == ' ') msg++;
 4 
 5-		if (msg != NULL)
 6-			printf("%s\n", msg);
 7+		if (strcmp(msg, "") != 0)
 8+			printf("%s", msg);
 9 		return (int)ret;
10 	}
11 
M ipc.c
+5, -5
 1@@ -309,7 +309,7 @@ ipc_get_geometry(char **arg) {
 2 
 3 	struct swc_rectangle geom;
 4 	if (swc_window_get_geometry(wm.cur->win, &geom)) {
 5-		snprintf(s.msg, MAXSIZE * sizeof(char), "%d %d %u %u", geom.x, geom.y, geom.width, geom.height);  
 6+		snprintf(s.msg, MAXSIZE * sizeof(char), "%d %d %u %u\n", geom.x, geom.y, geom.width, geom.height);  
 7 	}
 8 
 9 	s.ok = true;
10@@ -325,7 +325,7 @@ ipc_get_pid(char **arg) {
11 		return (status){ false, "" };
12 
13 	pid_t pid = swc_window_get_pid(wm.cur->win);
14-	snprintf(s.msg, MAXSIZE * sizeof(char), "%d", pid);
15+	snprintf(s.msg, MAXSIZE * sizeof(char), "%d\n", pid);
16 
17 	s.ok = true;
18 	return s;
19@@ -339,7 +339,7 @@ ipc_get_title(char **arg) {
20 	if (!wm.cur)
21 		return (status){ false, "" };
22 
23-	snprintf(s.msg, MAXSIZE * sizeof(char), "%s", wm.cur->win->title);
24+	snprintf(s.msg, MAXSIZE * sizeof(char), "%s\n", wm.cur->win->title);
25 
26 	s.ok = true;
27 	return s;
28@@ -353,7 +353,7 @@ ipc_get_app_id(char **arg) {
29 	if (!wm.cur)
30 		return (status){ false, "" };
31 
32-	snprintf(s.msg, MAXSIZE * sizeof(char), "%s", wm.cur->win->app_id);
33+	snprintf(s.msg, MAXSIZE * sizeof(char), "%s\n", wm.cur->win->app_id);
34 
35 	s.ok = true;
36 	return s;
37@@ -364,7 +364,7 @@ ipc_get_workspace(char **arg) {
38 	status s = {0};
39 
40 	UNUSED(arg);
41-	snprintf(s.msg, MAXSIZE * sizeof(char), "%d", wm.ws);
42+	snprintf(s.msg, MAXSIZE * sizeof(char), "%d\n", wm.ws);
43 
44 	s.ok = true;
45 	return s;