comparison main.c @ 583:f4285a97e3e6

applied Jukka's patch preventing some cornercases and making the EOF error message correct
author arg@mig29
date Mon, 27 Nov 2006 10:29:47 +0100
parents 70472540c443
children f617c75a8405
comparison
equal deleted inserted replaced
582:70472540c443 583:f4285a97e3e6
275 } 275 }
276 if(FD_ISSET(STDIN_FILENO, &rd)) { 276 if(FD_ISSET(STDIN_FILENO, &rd)) {
277 switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) { 277 switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
278 case -1: 278 case -1:
279 strncpy(stext, strerror(errno), sizeof stext - 1); 279 strncpy(stext, strerror(errno), sizeof stext - 1);
280 stext[sizeof stext - 1] = '\0';
280 readin = False; 281 readin = False;
281 break; 282 break;
282 case 0: 283 case 0:
283 strncpy(stext, "EOF", sizeof stext); 284 strncpy(stext, "EOF", 4);
284 readin = False; 285 readin = False;
285 break; 286 break;
286 default: 287 default:
287 for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0'); 288 for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0');
288 for(p = stext + strlen(stext) - 1; p >= stext && *p != '\n'; --p); 289 for(p = stext + strlen(stext) - 1; p >= stext && *p != '\n'; --p);