diff options
author | Tom Tromey <tromey@redhat.com> | 2005-07-06 20:10:41 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-07-06 20:10:41 +0000 |
commit | 6dfb90cf55f7a7abfcbe6a4bf80b38569cc2a8b6 (patch) | |
tree | 06a0be07899ac10cca7cc949fdc95c1331d3b061 /libjava/java | |
parent | 4b7d2f0796e4f0a49fb56c2ec6477db742b919b6 (diff) | |
download | gcc-6dfb90cf55f7a7abfcbe6a4bf80b38569cc2a8b6.zip gcc-6dfb90cf55f7a7abfcbe6a4bf80b38569cc2a8b6.tar.gz gcc-6dfb90cf55f7a7abfcbe6a4bf80b38569cc2a8b6.tar.bz2 |
InputStreamReader.java (refill): Handle no-progress case correctly.
* java/io/InputStreamReader.java (refill): Handle no-progress
case correctly.
* gnu/gcj/convert/IOConverter.java: Add 'utf8' alias.
From-SVN: r101663
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/io/InputStreamReader.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libjava/java/io/InputStreamReader.java b/libjava/java/io/InputStreamReader.java index f8ad53c..e55f135 100644 --- a/libjava/java/io/InputStreamReader.java +++ b/libjava/java/io/InputStreamReader.java @@ -289,9 +289,23 @@ public class InputStreamReader extends Reader return -1; converter.setInput(in.buf, in.pos, in.count); int count = converter.read(buf, offset, length); - in.skip(converter.inpos - in.pos); - if (count > 0) - return count; + + // We might have bytes but not have made any progress. In + // this case we try to refill. If refilling fails, we assume + // we have a malformed character at the end of the stream. + if (count == 0 && converter.inpos == in.pos) + { + in.mark(in.count); + if (! in.refill ()) + throw new CharConversionException (); + in.reset(); + } + else + { + in.skip(converter.inpos - in.pos); + if (count > 0) + return count; + } } } } |