ICU-6137 Fixing flushing of CharsetISO2022. Check for errorbuffer when encoding.

X-SVN-Rev: 23532
This commit is contained in:
Michael Ow 2008-03-06 05:07:12 +00:00
parent 74c56879f0
commit c620dc4e1e
3 changed files with 9 additions and 8 deletions

View File

@ -254,7 +254,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
* @stable ICU 3.6
*/
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
if (!in.hasRemaining()) {
if (!in.hasRemaining() && this.errorBufferLength == 0) { // make sure the errorBuffer is empty
// The Java framework should have already substituted what was left.
fromUChar32 = 0;
//fromUnicodeReset();

View File

@ -2203,7 +2203,7 @@ class CharsetISO2022 extends CharsetICU {
*/
if (!err.isError() &&
(myConverterData.fromU2022State.g != 0 || myConverterData.fromU2022State.cs[0] != ASCII) &&
flush && !source.hasRemaining() && target.hasRemaining() && fromUChar32 == 0) {
flush && !source.hasRemaining() && fromUChar32 == 0) {
int sourceIndex;
outLen = 0;
@ -2656,7 +2656,7 @@ class CharsetISO2022 extends CharsetICU {
* not in ASCII mode
* end of input and no truncated input
*/
if (!err.isError() && myConverterData.fromU2022State.g != 0 && flush && !source.hasRemaining() && target.hasRemaining() && fromUChar32 == 0) {
if (!err.isError() && myConverterData.fromU2022State.g != 0 && flush && !source.hasRemaining() && fromUChar32 == 0) {
int sourceIndex;
/* we are switching to ASCII */
@ -2932,7 +2932,7 @@ class CharsetISO2022 extends CharsetICU {
* not in ASCII mode
* end of input and no truncated input
*/
if (!err.isError() && isTargetByteDBCS && flush && !source.hasRemaining() && target.hasRemaining() && fromUChar32 == 0) {
if (!err.isError() && isTargetByteDBCS && flush && !source.hasRemaining() && fromUChar32 == 0) {
int sourceIndex;
/* we are switching to ASCII */

View File

@ -359,14 +359,15 @@ public class TestConversion extends ModuleTest {
cr = encoder.encode(source, target, currentSourceLimit == sourceLen);
if (cr.isUnderflow()) {
if (target.position() == cc.bytes.limit()) {
break;
}
if (currentSourceLimit == sourceLen) {
if (target.position() == cc.bytes.limit()) {
// target contains the correct number of bytes
break;
}
// Do a final flush for cleanup, then break out
// Encode loop, exits with cr==underflow in normal operation.
//target.limit(targetLen);
target.limit(cc.bytes.limit());
target.limit(targetLen);
cr = encoder.flush(target);
if (cr.isUnderflow()) {
// good