From 536f9b83c0bed9986800d806c74ae4d225628fe3 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 21 May 2006 18:57:51 +0000 Subject: import from plan9 --- src/cmd/tcs/utf.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/cmd/tcs/utf.c') diff --git a/src/cmd/tcs/utf.c b/src/cmd/tcs/utf.c index 9aad892b..f87a310b 100644 --- a/src/cmd/tcs/utf.c +++ b/src/cmd/tcs/utf.c @@ -45,15 +45,15 @@ utf_in(int fd, long *notused, struct convert *out) tot = 0; while((n = read(fd, buf+tot, N-tot)) >= 0){ tot += n; - for(i=j=0; i= T3) { if(n < 3) - goto badlen; + goto bad; c1 = us[1] ^ Tx; c2 = us[2] ^ Tx; if((c1|c2) & T2) goto bad; if(c0 >= T5) { if(n < 5) - goto badlen; + goto bad; c3 = us[3] ^ Tx; c4 = us[4] ^ Tx; if((c3|c4) & T2) @@ -413,7 +417,7 @@ our_mbtowc(unsigned long *p, char *s, unsigned n) if(c0 >= T6) { /* 6 bytes */ if(n < 6) - goto badlen; + goto bad; c5 = us[5] ^ Tx; if(c5 & T2) goto bad; @@ -437,7 +441,7 @@ our_mbtowc(unsigned long *p, char *s, unsigned n) if(c0 >= T4) { /* 4 bytes */ if(n < 4) - goto badlen; + goto bad; c3 = us[3] ^ Tx; if(c3 & T2) goto bad; @@ -460,7 +464,7 @@ our_mbtowc(unsigned long *p, char *s, unsigned n) if(c0 >= T2) { /* 2 bytes */ if(n < 2) - goto badlen; + goto bad; c1 = us[1] ^ Tx; if(c1 & T2) goto bad; @@ -480,6 +484,4 @@ our_mbtowc(unsigned long *p, char *s, unsigned n) bad: errno = EILSEQ; return -1; -badlen: - return -2; } -- cgit v1.2.3