mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
9term, win: better \r handling (thanks, git)
Change-Id: I75563b911b54d8957d2d004b9c27d0a2f8f043b3 Reviewed-on: https://plan9port-review.googlesource.com/1390 Reviewed-by: Russ Cox <rsc@google.com>
This commit is contained in:
parent
8ee5da7cf7
commit
0d2dfbc84f
2 changed files with 31 additions and 1 deletions
|
@ -479,6 +479,32 @@ stdinproc(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
dropcr(char *p, int n)
|
||||
{
|
||||
int i;
|
||||
char *w, *r;
|
||||
|
||||
r = p;
|
||||
w = p;
|
||||
for(i=0; i<n; i++) {
|
||||
switch(*r) {
|
||||
case '\b':
|
||||
if(w > p)
|
||||
w--;
|
||||
break;
|
||||
case '\r':
|
||||
*w++ = '\n';
|
||||
break;
|
||||
default:
|
||||
*w++ = *r;
|
||||
break;
|
||||
}
|
||||
r++;
|
||||
}
|
||||
return w-p;
|
||||
}
|
||||
|
||||
void
|
||||
stdoutproc(void *v)
|
||||
{
|
||||
|
@ -507,6 +533,10 @@ stdoutproc(void *v)
|
|||
n = dropcrnl(buf+npart, n);
|
||||
if(n == 0)
|
||||
continue;
|
||||
|
||||
n = dropcr(buf+npart, n);
|
||||
if(n == 0)
|
||||
continue;
|
||||
|
||||
/* squash NULs */
|
||||
s = memchr(buf+npart, 0, n);
|
||||
|
|
|
@ -361,7 +361,7 @@ winctl(void *arg)
|
|||
if(up == rp)
|
||||
initial = wbswidth(w, '\r');
|
||||
}else if(i == nr-1)
|
||||
*up = '\n';
|
||||
*up++ = '\n';
|
||||
break;
|
||||
default:
|
||||
*up++ = *bp;
|
||||
|
|
Loading…
Reference in a new issue