aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/io
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2003-06-07 18:35:00 +0000
committerMark Wielaard <mark@gcc.gnu.org>2003-06-07 18:35:00 +0000
commit60e9f0d726fd28b960c5674a3c7beaf7015dbd34 (patch)
tree4416490914744db9c6d980b6558414bd86715239 /libjava/java/io
parentddc612a2ba3864c86a0e9c0b30811727096c1772 (diff)
downloadgcc-60e9f0d726fd28b960c5674a3c7beaf7015dbd34.zip
gcc-60e9f0d726fd28b960c5674a3c7beaf7015dbd34.tar.gz
gcc-60e9f0d726fd28b960c5674a3c7beaf7015dbd34.tar.bz2
re PR libgcj/8738 (java.io.CharArrayWriter's write methods erroneously throw IOExceptions)
2002-06-06 James Clark <jjc@jclark.com> Fix for PR libgcj/8738: * gnu/gcj/convert/UnicodeToBytes.java (havePendingBytes): New method. * gnu/gcj/convert/Output_SJIS.java (havePendingBytes): Likewise. * gnu/gcj/convert/Output_EUCJIS.java (havePendingBytes): Likewise. * gnu/gcj/convert/Output_UTF8.java (havePendingBytes): Likewise. (write): Always decrease avail when count is increased. * java/lang/natString.cc (getBytes): Check converter havePendingBytes() and whether output buffer is full before increasing size. 2002-06-06 Mark Wielaard <mark@klomp dot org> * java/io/PrintStream.java (writeChars(char[],int, int)): Check converter.havePendingBytes(). (writeChars(String,int,int)): Likewise. * java/io/OutputStreamWriter.java (writeChars(char[], int, int)): Check converter.havePendingBytes() and flush buffer when stalled. From-SVN: r67595
Diffstat (limited to 'libjava/java/io')
-rw-r--r--libjava/java/io/OutputStreamWriter.java9
-rw-r--r--libjava/java/io/PrintStream.java6
2 files changed, 11 insertions, 4 deletions
diff --git a/libjava/java/io/OutputStreamWriter.java b/libjava/java/io/OutputStreamWriter.java
index e4ecbdb..8a47fdf 100644
--- a/libjava/java/io/OutputStreamWriter.java
+++ b/libjava/java/io/OutputStreamWriter.java
@@ -215,7 +215,7 @@ public class OutputStreamWriter extends Writer
private void writeChars(char[] buf, int offset, int count)
throws IOException
{
- while (count > 0)
+ while (count > 0 || converter.havePendingBytes())
{
// We must flush if out.count == out.buf.length.
// It is probably a good idea to flush if out.buf is almost full.
@@ -228,6 +228,13 @@ public class OutputStreamWriter extends Writer
}
converter.setOutput(out.buf, out.count);
int converted = converter.write(buf, offset, count);
+ // Flush if we cannot make progress.
+ if (converted == 0 && out.count == converter.count)
+ {
+ out.flush();
+ if (out.count != 0)
+ throw new IOException("unable to flush output byte buffer");
+ }
offset += converted;
count -= converted;
out.count = converter.count;
diff --git a/libjava/java/io/PrintStream.java b/libjava/java/io/PrintStream.java
index ddc37ae..489b3dd 100644
--- a/libjava/java/io/PrintStream.java
+++ b/libjava/java/io/PrintStream.java
@@ -1,5 +1,5 @@
/* PrintStream.java -- OutputStream for printing output
- Copyright (C) 1998,2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -262,7 +262,7 @@ public class PrintStream extends FilterOutputStream
private void writeChars(char[] buf, int offset, int count)
throws IOException
{
- while (count > 0)
+ while (count > 0 || converter.havePendingBytes())
{
converter.setOutput(work_bytes, 0);
int converted = converter.write(buf, offset, count);
@@ -275,7 +275,7 @@ public class PrintStream extends FilterOutputStream
private void writeChars(String str, int offset, int count)
throws IOException
{
- while (count > 0)
+ while (count > 0 || converter.havePendingBytes())
{
converter.setOutput(work_bytes, 0);
int converted = converter.write(str, offset, count, work);