mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-6955 Fix CharsetSCSU error and add test case.
X-SVN-Rev: 26137
This commit is contained in:
parent
283c484852
commit
905834ecca
4 changed files with 23 additions and 16 deletions
7
icu4c/source/test/testdata/conversion.txt
vendored
7
icu4c/source/test/testdata/conversion.txt
vendored
|
@ -857,6 +857,13 @@ conversion:table(nofallback) {
|
|||
:intvector{},
|
||||
:int{1}, :int{0}, "", ".", :bin{""}
|
||||
}
|
||||
{
|
||||
"SCSU",
|
||||
:bin{ 1b9a1b541bb2411bfd1b0041 },
|
||||
"",
|
||||
:intvector{},
|
||||
:int{1}, :int{0}, "", ".", :bin{""}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class CharsetSCSU extends CharsetICU{
|
|||
/* values between reservedStart and fixedThreshold are reserved */
|
||||
private static final int reservedStart=0xA8;
|
||||
/* use table of predefined fixed offsets for values from fixedThreshold */
|
||||
private static final int fixedThreshold=0xF;
|
||||
private static final int fixedThreshold=0xF9;
|
||||
//};
|
||||
|
||||
protected byte[] fromUSubstitution = new byte[]{(byte)0x0E,(byte)0xFF, (byte)0xFD};
|
||||
|
@ -325,7 +325,6 @@ class CharsetSCSU extends CharsetICU{
|
|||
charErrorBufferLength = 1;
|
||||
label = EndLoop;
|
||||
cr = CoderResult.OVERFLOW;
|
||||
LabelLoop = false;
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
@ -488,7 +487,7 @@ class CharsetSCSU extends CharsetICU{
|
|||
return label;
|
||||
}else if(b<gapThreshold){
|
||||
data.toUDynamicOffsets[dynamicWindow] = b<<7L;
|
||||
}else if((byte)(b - gapThreshold)<(reservedStart - gapThreshold)){
|
||||
}else if(((b - gapThreshold)&UConverterConstants.UNSIGNED_BYTE_MASK)<(reservedStart - gapThreshold)){
|
||||
data.toUDynamicOffsets[dynamicWindow] = (b<<7L) + gapOffset;
|
||||
}else if(b>=fixedThreshold){
|
||||
data.toUDynamicOffsets[dynamicWindow] = fixedOffsets[b-fixedThreshold];
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:64afad09d989cb4175ee8cac27bc635053264d550b8369a6feeafca713dc2dda
|
||||
size 772407
|
||||
oid sha256:d8e824c842e59c326c65665a7e9f26ec7c7c4c8aa1cec2bde603fb8f27371184
|
||||
size 772451
|
||||
|
|
|
@ -5320,17 +5320,18 @@ public class TestCharset extends TestFmwk {
|
|||
}
|
||||
// Test overflow buffer
|
||||
{
|
||||
byte[] testOverflow = {
|
||||
0x41,(byte) 0xdf, 0x12,(byte) 0x81, 0x03, 0x5f, 0x10, (byte)0xdf, 0x1b, 0x03,
|
||||
(byte)0xdf, 0x1c,(byte) 0x88,(byte) 0x80, 0x0b, (byte)0xbf,(byte) 0xff,(byte) 0xff
|
||||
};
|
||||
decode.reset();
|
||||
try {
|
||||
smBufDecode(decode, "SCSU overflow test", ByteBuffer.wrap(testOverflow), CharBuffer.allocate(8), true, true);
|
||||
errln("Buffer overflow exception should have been thrown.");
|
||||
} catch (BufferOverflowException ex) {
|
||||
} catch (Exception ex) {
|
||||
errln("Buffer overflow exception should have been thrown.");
|
||||
ByteBuffer overflowTest = ByteBuffer.wrap(allFeaturesSCSU);
|
||||
int sizes[] = { 8, 2, 11 };
|
||||
for (int i = 0; i < sizes.length; i++) {
|
||||
try {
|
||||
decode.reset();
|
||||
overflowTest.position(0);
|
||||
smBufDecode(decode, "SCSU overflow test", overflowTest, CharBuffer.allocate(sizes[i]), true, false);
|
||||
errln("Buffer overflow exception should have been thrown.");
|
||||
} catch (BufferOverflowException ex) {
|
||||
} catch (Exception ex) {
|
||||
errln("Buffer overflow exception should have been thrown.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue