summaryrefslogtreecommitdiffstats
path: root/libjava/java/io/InputStreamReader.java
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-06 20:10:41 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-06 20:10:41 +0000
commit6515f9367d9de381354d856efca1e6f22af32e70 (patch)
tree06a0be07899ac10cca7cc949fdc95c1331d3b061 /libjava/java/io/InputStreamReader.java
parenta866e0f2b523463de856075b7872e8acf2556c67 (diff)
downloadppe42-gcc-6515f9367d9de381354d856efca1e6f22af32e70.tar.gz
ppe42-gcc-6515f9367d9de381354d856efca1e6f22af32e70.zip
* java/io/InputStreamReader.java (refill): Handle no-progress
case correctly. * gnu/gcj/convert/IOConverter.java: Add 'utf8' alias. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101663 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/io/InputStreamReader.java')
-rw-r--r--libjava/java/io/InputStreamReader.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/libjava/java/io/InputStreamReader.java b/libjava/java/io/InputStreamReader.java
index f8ad53cdd01..e55f1352caa 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;
+ }
}
}
}
OpenPOWER on IntegriCloud