diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/9term/win.c | 30 | ||||
-rw-r--r-- | src/cmd/9term/wind.c | 2 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c index decfece7..97ef6d87 100644 --- a/src/cmd/9term/win.c +++ b/src/cmd/9term/win.c @@ -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); diff --git a/src/cmd/9term/wind.c b/src/cmd/9term/wind.c index 28d45cbb..b03f15fc 100644 --- a/src/cmd/9term/wind.c +++ b/src/cmd/9term/wind.c @@ -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; |