summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorarg@mig29 <unknown>2006-11-26 14:26:53 +0100
committerarg@mig29 <unknown>2006-11-26 14:26:53 +0100
commit61a1910f91fe6aba428193087d6c3ff21374ee5e (patch)
treec6406dfd44df07e2e54309f29aef093b798d3d2d /main.c
parent27ef73507b69608c63bd7d1684b7d9987fbcce53 (diff)
applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
Diffstat (limited to 'main.c')
-rw-r--r--main.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/main.c b/main.c
index 86cd3f9..f196df7 100644
--- a/main.c
+++ b/main.c
@@ -227,6 +227,7 @@ xerror(Display *dpy, XErrorEvent *ee) {
int
main(int argc, char *argv[]) {
+ char *p;
int r, xfd;
fd_set rd;
@@ -270,22 +271,23 @@ main(int argc, char *argv[]) {
if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
if(errno == EINTR)
continue;
- else
- eprint("select failed\n");
+ eprint("select failed\n");
}
if(FD_ISSET(STDIN_FILENO, &rd)) {
- switch(r = read(STDIN_FILENO, stext, sizeof(stext) - 1)) {
+ switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
case -1:
- strncpy(stext, strerror(errno), sizeof(stext));
- stext[sizeof(stext) - 1] = '\0';
+ strncpy(stext, strerror(errno), sizeof stext - 1);
readin = False;
break;
case 0:
- strncpy(stext, "EOF", sizeof(stext));
+ strncpy(stext, "EOF", sizeof stext);
readin = False;
break;
default:
stext[r - (stext[r - 1] == '\n' ? 1 : 0)] = '\0';
+ for(p = stext + strlen(stext) - 1; p > stext && *p != '\n'; --p);
+ if(p > stext)
+ strncpy(stext, p + 1, sizeof stext);
}
drawstatus();
}