diff --git a/src/cmd/tcs/tcs.c b/src/cmd/tcs/tcs.c index d7d18e41..6722bb6b 100644 --- a/src/cmd/tcs/tcs.c +++ b/src/cmd/tcs/tcs.c @@ -187,17 +187,19 @@ swab2(char *b, int n) void unicode_in(int fd, long *notused, struct convert *out) { + u16int ubuf[N]; Rune buf[N]; - int n; + int i, n; int swabme; USED(notused); - if(read(fd, (char *)buf, 2) != 2) + if(read(fd, (char *)ubuf, 2) != 2) return; ninput += 2; - switch(buf[0]) + switch(ubuf[0]) { default: + buf[0] = ubuf[0]; OUT(out, buf, 1); case 0xFEFF: swabme = 0; @@ -206,10 +208,12 @@ unicode_in(int fd, long *notused, struct convert *out) swabme = 1; break; } - while((n = read(fd, (char *)buf, 2*N)) > 0){ + while((n = read(fd, (char *)ubuf, 2*N)) > 0){ ninput += n; if(swabme) - swab2((char *)buf, n); + swab2((char *)ubuf, n); + for(i=0; i 0){ + while((n = read(fd, (char *)ubuf, 2*N)) > 0){ ninput += n; - p = (uchar*)buf; + p = (uchar*)ubuf; for(i=0; i 0){ + while((n = read(fd, (char *)ubuf, 2*N)) > 0){ ninput += n; - p = (uchar*)buf; + p = (uchar*)ubuf; for(i=0; i