projects
/
suckless
/
slstatus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3bfc3bb
)
remove newline character from run_command() output accurately
author
raiz
<raiz@firemail.cc>
Tue, 27 Dec 2016 15:57:27 +0000
(18:57 +0300)
committer
raiz
<raiz@firemail.cc>
Tue, 27 Dec 2016 15:57:27 +0000
(18:57 +0300)
slstatus.c
patch
|
blob
|
history
diff --git
a/slstatus.c
b/slstatus.c
index 73e0f2c9b22186cdcf20744162cd009ca3bd530f..329093f24c6bdced34a2566895064ba52790b927 100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-405,6
+405,7
@@
ram_used(void)
static char *
run_command(const char *cmd)
{
+ char *nlptr;
FILE *fp;
char buf[1024] = "n/a";
@@
-415,9
+416,12
@@
run_command(const char *cmd)
}
fgets(buf, sizeof(buf), fp);
pclose(fp);
-
buf[strlen(buf)] = '\0';
+ if ((nlptr = strstr(buf, "\n")) != NULL) {
+ nlptr[0] = '\0';
+ }
+
return smprintf("%s", buf);
}