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
|
void
|
||||||
stdoutproc(void *v)
|
stdoutproc(void *v)
|
||||||
{
|
{
|
||||||
|
|
@ -507,6 +533,10 @@ stdoutproc(void *v)
|
||||||
n = dropcrnl(buf+npart, n);
|
n = dropcrnl(buf+npart, n);
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
n = dropcr(buf+npart, n);
|
||||||
|
if(n == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* squash NULs */
|
/* squash NULs */
|
||||||
s = memchr(buf+npart, 0, n);
|
s = memchr(buf+npart, 0, n);
|
||||||
|
|
|
||||||
|
|
@ -361,7 +361,7 @@ winctl(void *arg)
|
||||||
if(up == rp)
|
if(up == rp)
|
||||||
initial = wbswidth(w, '\r');
|
initial = wbswidth(w, '\r');
|
||||||
}else if(i == nr-1)
|
}else if(i == nr-1)
|
||||||
*up = '\n';
|
*up++ = '\n';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*up++ = *bp;
|
*up++ = *bp;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue