This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Patch: UTF-8 output bug fix
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: UTF-8 output bug fix
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 21 Sep 1999 17:18:48 -0600
- Reply-To: tromey at cygnus dot com
I'm committing the appended patch. It fixes a bug (two Mauve test
cases) in the UTF-8 output converter. There are still more bugs here,
but I'm not addressing them yet (I've had this patch around for a long
time and I just want to get it off my list).
1999-09-21 Tom Tromey <tromey@cygnus.com>
* gnu/gcj/convert/Output_UTF8.java (write): Don't exit loop unless
both `inlength' and `bytes_todo' are 0. Simplified 2-byte case.
Tom
Index: gnu/gcj/convert/Output_UTF8.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/gnu/gcj/convert/Output_UTF8.java,v
retrieving revision 1.2
diff -u -r1.2 Output_UTF8.java
--- Output_UTF8.java 1999/04/16 17:21:59 1.2
+++ Output_UTF8.java 1999/09/21 23:18:07
@@ -25,7 +25,7 @@
// Saves the previous char if it was a high-surrogate.
char hi_part;
- // Value of imcomplete character.
+ // Value of incomplete character.
int value;
// Number of continuation bytes still to emit.
int bytes_todo;
@@ -36,9 +36,9 @@
int avail = buf.length - count;
for (;;)
{
- if (inlength == 0 || avail == 0)
+ if (avail == 0 || (inlength == 0 && bytes_todo == 0))
break;
- // The algororith is made more complicated because we want to write
+ // The algorithm is made more complicated because we want to write
// at least one byte in the output buffer, if there is room for
// that byte, and at least one input character is available.
// This makes the code more robust, since client code will
@@ -70,17 +70,9 @@
else if (ch <= 0x07FF)
{
buf[count++] = (byte) (0xC0 | (ch >> 6));
- if (--avail > 0)
- {
- buf[count++] = (byte) ((ch & 0x3F) | 0x80);
- avail--;
- }
- else
- {
- value = ch;
- bytes_todo = 1;
- break;
- }
+ avail--;
+ value = ch;
+ bytes_todo = 1;
}
else if (ch >= 0xD800 && ch <= 0xDFFF && standardUTF8)
{