9boot: truncate long lines instead of producing partial lines from console/plan9.ini

This commit is contained in:
cinap_lenrek 2012-12-03 16:52:14 +01:00
parent ee251568fb
commit 52b9a06896

View file

@ -105,7 +105,7 @@ readline(void *f, char buf[64])
do{ do{
if(!f) if(!f)
putc('>'); putc('>');
while(p < buf + 64-1){ for(;;){
if(!f){ if(!f){
putc(*p = getc()); putc(*p = getc());
if(*p == '\r') if(*p == '\r')
@ -116,10 +116,18 @@ readline(void *f, char buf[64])
} }
}else if(read(f, p, 1) <= 0) }else if(read(f, p, 1) <= 0)
return 0; return 0;
if(p == buf && strchr(white, *p))
continue;
if(strchr(crnl, *p)) if(strchr(crnl, *p))
break; break;
if(p == buf && strchr(white, *p))
continue; /* whitespace on start of line */
if(p >= buf + 64-1){
if(!f){
putc('\b');
putc(' ');
putc('\b');
}
continue; /* line full do not advance */
}
p++; p++;
} }
while(p > buf && strchr(white, p[-1])) while(p > buf && strchr(white, p[-1]))