ICU-7959 Fix endian failure in compound text.
X-SVN-Rev: 29216
This commit is contained in:
parent
bbb368c939
commit
d15a8c9c92
@ -286,14 +286,14 @@ _CompoundTextOpen(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorC
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
_CompoundTextClose(UConverter *converter) {
|
_CompoundTextClose(UConverter *converter) {
|
||||||
UConverterSharedData** gbCharset = (UConverterSharedData**)(converter->extraInfo);
|
UConverterDataCompoundText* myConverterData = (UConverterDataCompoundText*)(converter->extraInfo);
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
|
||||||
if (converter->extraInfo != NULL) {
|
if (converter->extraInfo != NULL) {
|
||||||
/*close the array of converter pointers and free the memory*/
|
/*close the array of converter pointers and free the memory*/
|
||||||
for (i = 0; i < NUM_OF_CONVERTERS; i++) {
|
for (i = 0; i < NUM_OF_CONVERTERS; i++) {
|
||||||
if(gbCharset[i] != NULL) {
|
if (myConverterData->myConverterArray[i] != NULL) {
|
||||||
ucnv_unloadSharedDataIfReady(gbCharset[i]);
|
ucnv_unloadSharedDataIfReady(myConverterData->myConverterArray[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,8 +323,8 @@ UConverter_fromUnicode_CompoundText_OFFSETS(UConverterFromUnicodeArgs* args, UEr
|
|||||||
uint8_t tmpTargetBuffer[7];
|
uint8_t tmpTargetBuffer[7];
|
||||||
int32_t tmpTargetBufferLength = 0;
|
int32_t tmpTargetBufferLength = 0;
|
||||||
COMPOUND_TEXT_CONVERTERS currentState, tmpState;
|
COMPOUND_TEXT_CONVERTERS currentState, tmpState;
|
||||||
uint8_t buffer[4];
|
uint32_t pValue;
|
||||||
int32_t bufferLength = 0;
|
int32_t pValueLength = 0;
|
||||||
int32_t i, n;
|
int32_t i, n;
|
||||||
|
|
||||||
UConverterDataCompoundText *myConverterData = (UConverterDataCompoundText *) cnv->extraInfo;
|
UConverterDataCompoundText *myConverterData = (UConverterDataCompoundText *) cnv->extraInfo;
|
||||||
@ -389,8 +389,8 @@ getTrail:
|
|||||||
if (tmpState == DO_SEARCH) {
|
if (tmpState == DO_SEARCH) {
|
||||||
/* Test all available converters */
|
/* Test all available converters */
|
||||||
for (i = 1; i < SEARCH_LENGTH; i++) {
|
for (i = 1; i < SEARCH_LENGTH; i++) {
|
||||||
bufferLength = ucnv_MBCSFromUChar32(myConverterData->myConverterArray[i], sourceChar, (uint32_t*)buffer, useFallback);
|
pValueLength = ucnv_MBCSFromUChar32(myConverterData->myConverterArray[i], sourceChar, &pValue, useFallback);
|
||||||
if (bufferLength > 0) {
|
if (pValueLength > 0) {
|
||||||
tmpState = (COMPOUND_TEXT_CONVERTERS)i;
|
tmpState = (COMPOUND_TEXT_CONVERTERS)i;
|
||||||
if (currentState != tmpState) {
|
if (currentState != tmpState) {
|
||||||
currentState = tmpState;
|
currentState = tmpState;
|
||||||
@ -398,20 +398,19 @@ getTrail:
|
|||||||
tmpTargetBuffer[tmpTargetBufferLength++] = escSeqCompoundText[currentState][i];
|
tmpTargetBuffer[tmpTargetBufferLength++] = escSeqCompoundText[currentState][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (n = 0; n < bufferLength; n++) {
|
for (n = (pValueLength - 1); n >= 0; n--) {
|
||||||
tmpTargetBuffer[tmpTargetBufferLength++] = buffer[(bufferLength -1) - n];
|
tmpTargetBuffer[tmpTargetBufferLength++] = (uint8_t)(pValue >> (n * 8));
|
||||||
}
|
}
|
||||||
/* TODO: Reset? */
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (tmpState == COMPOUND_TEXT_SINGLE_0) {
|
} else if (tmpState == COMPOUND_TEXT_SINGLE_0) {
|
||||||
tmpTargetBuffer[tmpTargetBufferLength++] = (uint8_t)sourceChar;
|
tmpTargetBuffer[tmpTargetBufferLength++] = (uint8_t)sourceChar;
|
||||||
} else {
|
} else {
|
||||||
bufferLength = ucnv_MBCSFromUChar32(myConverterData->myConverterArray[currentState], sourceChar, (uint32_t*)buffer, useFallback);
|
pValueLength = ucnv_MBCSFromUChar32(myConverterData->myConverterArray[currentState], sourceChar, &pValue, useFallback);
|
||||||
if (bufferLength > 0) {
|
if (pValueLength > 0) {
|
||||||
for (n = 0; n < bufferLength; n++) {
|
for (n = (pValueLength - 1); n >= 0; n--) {
|
||||||
tmpTargetBuffer[tmpTargetBufferLength++] = buffer[(bufferLength -1) - n];
|
tmpTargetBuffer[tmpTargetBufferLength++] = (uint8_t)(pValue >> (n * 8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user