aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>1999-09-21 23:20:43 +0000
committerTom Tromey <tromey@gcc.gnu.org>1999-09-21 23:20:43 +0000
commit707f5f6d4515f26085d4d5c062464a3895b05cdf (patch)
treeda4f43d642f9825ae706547c79efb5a1a6ed3396
parent5057b5e8d1088230c77b7305d16511497556e7b0 (diff)
downloadgcc-707f5f6d4515f26085d4d5c062464a3895b05cdf.zip
gcc-707f5f6d4515f26085d4d5c062464a3895b05cdf.tar.gz
gcc-707f5f6d4515f26085d4d5c062464a3895b05cdf.tar.bz2
Output_UTF8.java (write): Don't exit loop unless both `inlength' and `bytes_todo' are 0.
* gnu/gcj/convert/Output_UTF8.java (write): Don't exit loop unless both `inlength' and `bytes_todo' are 0. Simplified 2-byte case. From-SVN: r29570
-rw-r--r--libjava/ChangeLog3
-rw-r--r--libjava/gnu/gcj/convert/Output_UTF8.java20
2 files changed, 9 insertions, 14 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index f43d80e..f054dbe 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,8 @@
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.
+
* include/posix-threads.h (_Jv_MutexDestroy): Use
_Jv_PthreadGetMutex.
(_Jv_MutexLock): Likewise.
diff --git a/libjava/gnu/gcj/convert/Output_UTF8.java b/libjava/gnu/gcj/convert/Output_UTF8.java
index db2215a..d842f2b 100644
--- a/libjava/gnu/gcj/convert/Output_UTF8.java
+++ b/libjava/gnu/gcj/convert/Output_UTF8.java
@@ -25,7 +25,7 @@ public class Output_UTF8 extends UnicodeToBytes
// 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 @@ public class Output_UTF8 extends UnicodeToBytes
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 @@ public class Output_UTF8 extends UnicodeToBytes
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)
{