dwm-meillo

diff main.c @ 580:e9001b0f53bc

applied Jukka's stdinread patch
author arg@mig29
date Sun, 26 Nov 2006 13:31:36 +0100
parents 8cb54d02a5b6
children 601842ee4484
line diff
     1.1 --- a/main.c	Sat Nov 25 19:26:31 2006 +0100
     1.2 +++ b/main.c	Sun Nov 26 13:31:36 2006 +0100
     1.3 @@ -274,9 +274,10 @@
     1.4  				eprint("select failed\n");
     1.5  		}
     1.6  		if(FD_ISSET(STDIN_FILENO, &rd)) {
     1.7 -			switch(r = read(STDIN_FILENO, stext, sizeof(stext))) {
     1.8 +			switch(r = read(STDIN_FILENO, stext, sizeof(stext) - 1)) {
     1.9  			case -1:
    1.10  				strncpy(stext, strerror(errno), sizeof(stext));
    1.11 +				stext[sizeof(stext) - 1] = '\0';
    1.12  				readin = False;
    1.13  				break;
    1.14  			case 0:
    1.15 @@ -284,7 +285,7 @@
    1.16  				readin = False;
    1.17  				break;
    1.18  			default:
    1.19 -				stext[r-1] = 0;
    1.20 +				stext[r - (stext[r - 1] == '\n' ? 1 : 0)] = '\0';
    1.21  			}
    1.22  			drawstatus();
    1.23  		}