aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarg@mig29 <unknown>2006-11-26 13:31:36 +0100
committerarg@mig29 <unknown>2006-11-26 13:31:36 +0100
commit27ef73507b69608c63bd7d1684b7d9987fbcce53 (patch)
tree2e54aa389d4cabee25df183a8cde01f14a1ef5f0
parent2b35fb643ec12e6f082aa78ca6a32447038d1490 (diff)
downloaddwm-27ef73507b69608c63bd7d1684b7d9987fbcce53.tar.gz
dwm-27ef73507b69608c63bd7d1684b7d9987fbcce53.tar.bz2
dwm-27ef73507b69608c63bd7d1684b7d9987fbcce53.zip
applied Jukka's stdinread patch
-rw-r--r--main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/main.c b/main.c
index 750366e..86cd3f9 100644
--- a/main.c
+++ b/main.c
@@ -274,9 +274,10 @@ main(int argc, char *argv[]) {
eprint("select failed\n");
}
if(FD_ISSET(STDIN_FILENO, &rd)) {
- switch(r = read(STDIN_FILENO, stext, sizeof(stext))) {
+ switch(r = read(STDIN_FILENO, stext, sizeof(stext) - 1)) {
case -1:
strncpy(stext, strerror(errno), sizeof(stext));
+ stext[sizeof(stext) - 1] = '\0';
readin = False;
break;
case 0:
@@ -284,7 +285,7 @@ main(int argc, char *argv[]) {
readin = False;
break;
default:
- stext[r-1] = 0;
+ stext[r - (stext[r - 1] == '\n' ? 1 : 0)] = '\0';
}
drawstatus();
}