summaryrefslogtreecommitdiff
path: root/sys/src/cmd/tcs/utf.c
diff options
context:
space:
mode:
authorBurnZeZ <devnull@localhost>2018-12-26 04:47:22 +0000
committerBurnZeZ <devnull@localhost>2018-12-26 04:47:22 +0000
commitc650a7db0cb5a60286c4dbd0d24423eddcb7e0e3 (patch)
treebf2e13950eacbe35b3ec6e015b28a3338687c2a5 /sys/src/cmd/tcs/utf.c
parent27921a1ba0e70a9f6c01f174d69749c689f625b5 (diff)
tcs: clean up old port code, and avoid writing 0 to stdout
Diffstat (limited to 'sys/src/cmd/tcs/utf.c')
-rw-r--r--sys/src/cmd/tcs/utf.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/sys/src/cmd/tcs/utf.c b/sys/src/cmd/tcs/utf.c
index 381c5facc..16438daf5 100644
--- a/sys/src/cmd/tcs/utf.c
+++ b/sys/src/cmd/tcs/utf.c
@@ -1,16 +1,6 @@
-#ifdef PLAN9
#include <u.h>
#include <libc.h>
#include <bio.h>
-#else
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include "plan9.h"
-#endif
#include "hdr.h"
/*
@@ -40,7 +30,7 @@ utf_in(int fd, long *, struct convert *out)
c = our_mbtowc(&l, buf+i, tot-i);
if(c == -1){
if(squawk)
- EPR "%s: bad UTF sequence near byte %ld in input\n", argv0, ninput+i);
+ warn("bad UTF sequence near byte %ld in input", ninput+i);
if(clean){
i++;
continue;
@@ -74,7 +64,8 @@ utf_out(Rune *base, int n, long *)
p += our_wctomb(p, *r);
}
noutput += p-obuf;
- write(1, obuf, p-obuf);
+ if(p > obuf)
+ write(1, obuf, p-obuf);
}
void
@@ -92,7 +83,7 @@ isoutf_in(int fd, long *, struct convert *out)
c = isochartorune(&runes[j], buf+i);
if(runes[j] == Runeerror){
if(squawk)
- EPR "%s: bad UTF sequence near byte %ld in input\n", argv0, ninput+i);
+ warn("bad UTF sequence near byte %ld in input", ninput+i);
if(clean){
i++;
continue;
@@ -123,7 +114,8 @@ isoutf_out(Rune *base, int n, long *)
for(r = base, p = obuf; n-- > 0; r++)
p += runetoisoutf(p, r);
noutput += p-obuf;
- write(1, obuf, p-obuf);
+ if(p > obuf)
+ write(1, obuf, p-obuf);
}
@@ -291,10 +283,6 @@ fullisorune(char *str, int n)
return 0;
}
-#ifdef PLAN9
-int errno;
-#endif
-
enum
{
T1 = 0x00,
@@ -326,10 +314,6 @@ enum
Wchar3 = (1UL<<(Bit3+2*Bitx))-1,
Wchar4 = (1UL<<(Bit4+3*Bitx))-1,
Wchar5 = (1UL<<(Bit5+4*Bitx))-1,
-
-#ifndef EILSEQ
- EILSEQ = 123,
-#endif /* EILSEQ */
};
int
@@ -478,6 +462,5 @@ our_mbtowc(unsigned long *p, char *s, unsigned n)
return 1;
bad:
- errno = EILSEQ;
return -1;
}