Fix UTF bug reported on 9fans.

This commit is contained in:
rsc 2005-09-13 00:23:53 +00:00
parent 58acc3d442
commit 7f0d675d58

View file

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