Commit Diff


commit - 58acc3d4427314035b00cb29e240570e87634f64
commit + 7f0d675d583a2f219e7a54e9e72671ef6b323c55
blob - d3fa93981d6bf17712ecfa606861dee5f00d81b0
blob + bc7deb6e0f2a4cbf49f9677b57a0177f866149ab
--- src/cmd/tcs/utf.c
+++ src/cmd/tcs/utf.c
@@ -39,15 +39,16 @@ utf_in(int fd, long *notused, struct convert *out)
 		tot += n;
 		for(i=j=0; i<tot; ){
 			c = our_mbtowc(&l, buf+i, tot-i);
-			if(c == -1)
+			if(c == -2)
 				break;
-			if(c == -2){
+			if(c == -1){
 				if(squawk)
 					EPR "%s: bad UTF sequence near byte %ld in input\n", argv0, ninput+i);
 				if(clean)
 					continue;
 				nerrors++;
 				l = Runeerror;
+				c = 1;
 			}
 			runes[j++] = l;
 			i += c;