diff options
author | Russ Cox <rsc@swtch.com> | 2015-11-10 10:25:17 -0500 |
---|---|---|
committer | Russ Cox <rsc@google.com> | 2015-11-10 15:34:06 +0000 |
commit | 0d2dfbc84f42317fab5bc247355868d86613f3b0 (patch) | |
tree | d3264825088bb31c6fc0daa660862296947e63f8 /src/cmd/9term | |
parent | 8ee5da7cf764bf5685c137264cd4d6a03f12ba89 (diff) | |
download | plan9port-0d2dfbc84f42317fab5bc247355868d86613f3b0.tar.gz plan9port-0d2dfbc84f42317fab5bc247355868d86613f3b0.tar.bz2 plan9port-0d2dfbc84f42317fab5bc247355868d86613f3b0.zip |
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>
Diffstat (limited to 'src/cmd/9term')
-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; |