ICU-6955 Fix BOCU-1 logical errors and add test case.

X-SVN-Rev: 26128
This commit is contained in:
Michael Ow 2009-06-17 22:11:57 +00:00
parent 6113fea805
commit 685da47d1a
3 changed files with 17 additions and 10 deletions

View file

@ -811,7 +811,8 @@ conversion:table(nofallback) {
:intvector{ 4, 6 },
:int{1}, :int{0}, "", ".", :bin{""}
}
// Code Coverage for BOCU-1
// Improve Code Coverage for BOCU-1
{
"BOCU-1",
:bin{ 91fbc555fd6349 },
@ -826,6 +827,13 @@ conversion:table(nofallback) {
:intvector{},
:int{1}, :int{0}, "", ".", :bin{""}
}
{
"BOCU-1",
:bin{ 5b4bccf9 },
"\u000b",
:intvector{},
:int{1}, :int{0}, "", "0", :bin{""}
}
}
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2008, International Business Machines Corporation and *
* Copyright (C) 2008-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -815,8 +815,7 @@ class CharsetBOCU1 extends CharsetICU {
/* conversion "loop" similar to _SCSUToUnicodeWithOffsets() */
if(count>0 && byteIndex>0 && target.position()<target.limit()) {
//labelType = getTrail;
labelType = getTrail(source, target, offsets);
labelType = getTrail;
}
while(LabelLoop){
@ -849,7 +848,7 @@ class CharsetBOCU1 extends CharsetICU {
count = diff;
}
while(count>0) {
if(BOCU1_START_NEG_2 <=(c=source.get(source.position())) && c< BOCU1_START_POS_2) {
if(BOCU1_START_NEG_2 <=(c=source.get(source.position())&UConverterConstants.UNSIGNED_BYTE_MASK) && c< BOCU1_START_POS_2) {
c = prev + (c-BOCU1_MIDDLE);
if(c<0x3000) {
target.put((char)c);
@ -965,10 +964,10 @@ class CharsetBOCU1 extends CharsetICU {
++nextSourceIndex;
c = decodeBocu1TrailByte(1, source.get());
if(c<0 || ((c = prev + diff + c)&UConverterConstants.UNSIGNED_INT_MASK)>0x10ffff) {
bytes[0]= source.get(-2);
bytes[1]= source.get(-1);
bytes[0]= source.get(source.position()-2);
bytes[1]= source.get(source.position()-1);
byteIndex = 2;
cr = CoderResult.malformedForLength(1);
cr = CoderResult.malformedForLength(2);
break;
}
} else if(c == BOCU1_RESET) {

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:96abd036f2721efd98951b4065d3ac8041867dd1e127fc20f4547d1c5fcfe0db
size 772172
oid sha256:e45a334fc1a57269c5a6365b5a074a3d3f41d7824cd9fa2900acda7377a1f182
size 772209