In message "Re: [kaffe] kaffe.io.ByteToCharIconv may go in to an endless loop"
    on 02/11/21, Ito Kazumitsu <[EMAIL PROTECTED]> writes:

> > and found that in the abnormal cases "carry" is called endlessly.
> 
> Here is a patch to solve this problem.

The following patch would better simulate JDK's behavior.

--- libraries/clib/native/ByteToCharIconv.c.orig        Tue Apr 16 04:14:50 2002
+++ libraries/clib/native/ByteToCharIconv.c     Thu Nov 21 09:16:34 2002
@@ -89,6 +89,16 @@
     icv_out = buffer;
 #endif
     ret = iconv (cd, &icv_in, &icv_inlen, &icv_out, &icv_outlen);
+    if (ret < 0) {
+       /* convert the begining of an invalid  multibyte  sequence to '?' */
+       if (errno == EILSEQ) {
+               icv_in++;
+               icv_inlen--;
+               *(icv_out++) = 0;
+               *(icv_out++) = '?';
+               icv_outlen -= 2;
+       }
+    }
 #ifndef WORDS_BIGENDIAN
     swab (buffer, jc + toPos, toLen * 2 - icv_outlen);
     KFREE (buffer);

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to