mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 23:25:24 +02:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user