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:
Tom Tromey 2005-07-06 20:10:41 +00:00 committed by Tom Tromey
parent 4b7d2f0796
commit 6dfb90cf55
3 changed files with 26 additions and 4 deletions

View file

@ -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;
}
}
}
}