mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 14:31:31 +00:00
ICU-3984 fix a bug in the resource loading of collation reordering and rename script reordering to reordering codes
X-SVN-Rev: 28993
This commit is contained in:
parent
0a98dc21cb
commit
94239208a0
14 changed files with 158 additions and 149 deletions
|
@ -812,12 +812,12 @@
|
|||
<span class=""><span>4.6</span></span></td>
|
||||
</tr>
|
||||
<tr class="row1">
|
||||
<td class="file">coll.h</td><td class="proto">uint32_t Collator::getScriptOrder(int32_t*, const uint32_t, UErrorCode&) const</td><td class="">None<br>
|
||||
<td class="file">coll.h</td><td class="proto">uint32_t Collator::getReorderCodes(int32_t*, const uint32_t, UErrorCode&) const</td><td class="">None<br>
|
||||
</td><td>Internal<br>
|
||||
<span class=""><span>.</span></span></td>
|
||||
</tr>
|
||||
<tr class="row0">
|
||||
<td class="file">coll.h</td><td class="proto">void Collator::setScriptOrder(const int32_t*, const uint32_t, UErrorCode&)</td><td class="">None<br>
|
||||
<td class="file">coll.h</td><td class="proto">void Collator::setReorderCodes(const int32_t*, const uint32_t, UErrorCode&)</td><td class="">None<br>
|
||||
</td><td>Internal<br>
|
||||
<span class=""><span>.</span></span></td>
|
||||
</tr>
|
||||
|
@ -1136,12 +1136,12 @@
|
|||
<span class=""><span>4.6</span></span></td>
|
||||
</tr>
|
||||
<tr class="row0">
|
||||
<td class="file">tblcoll.h</td><td class="proto">uint32_t RuleBasedCollator::getScriptOrder(int32_t*, const uint32_t, UErrorCode&) const</td><td class="">None<br>
|
||||
<td class="file">tblcoll.h</td><td class="proto">uint32_t RuleBasedCollator::getReorderCodes(int32_t*, const uint32_t, UErrorCode&) const</td><td class="">None<br>
|
||||
</td><td>Internal<br>
|
||||
<span class=""><span>.</span></span></td>
|
||||
</tr>
|
||||
<tr class="row1">
|
||||
<td class="file">tblcoll.h</td><td class="proto">void RuleBasedCollator::setScriptOrder(const int32_t*, const uint32_t, UErrorCode&)</td><td class="">None<br>
|
||||
<td class="file">tblcoll.h</td><td class="proto">void RuleBasedCollator::setReorderCodes(const int32_t*, const uint32_t, UErrorCode&)</td><td class="">None<br>
|
||||
</td><td>Internal<br>
|
||||
<span class=""><span>.</span></span></td>
|
||||
</tr>
|
||||
|
@ -1288,12 +1288,12 @@
|
|||
<span class=""><span>.</span></span></td>
|
||||
</tr>
|
||||
<tr class="row0">
|
||||
<td class="file">ucol.h</td><td class="proto">uint32_t ucol_getScriptOrder(const UCollator*, int32_t*, uint32_t, UErrorCode*)</td><td class="">None<br>
|
||||
<td class="file">ucol.h</td><td class="proto">uint32_t ucol_getReorderCodes(const UCollator*, int32_t*, uint32_t, UErrorCode*)</td><td class="">None<br>
|
||||
</td><td>Internal<br>
|
||||
<span class=""><span>.</span></span></td>
|
||||
</tr>
|
||||
<tr class="row1">
|
||||
<td class="file">ucol.h</td><td class="proto">void ucol_setScriptOrder(UCollator*, const int32_t*, uint32_t, UErrorCode*)</td><td class="">None<br>
|
||||
<td class="file">ucol.h</td><td class="proto">void ucol_setReorderCodes(UCollator*, const int32_t*, uint32_t, UErrorCode*)</td><td class="">None<br>
|
||||
</td><td>Internal<br>
|
||||
<span class=""><span>.</span></span></td>
|
||||
</tr>
|
||||
|
|
|
@ -724,6 +724,7 @@
|
|||
#define ucol_getNextCE U_ICU_ENTRY_POINT_RENAME(ucol_getNextCE)
|
||||
#define ucol_getOffset U_ICU_ENTRY_POINT_RENAME(ucol_getOffset)
|
||||
#define ucol_getPrevCE U_ICU_ENTRY_POINT_RENAME(ucol_getPrevCE)
|
||||
#define ucol_getReorderCodes U_ICU_ENTRY_POINT_RENAME(ucol_getReorderCodes)
|
||||
#define ucol_getRules U_ICU_ENTRY_POINT_RENAME(ucol_getRules)
|
||||
#define ucol_getRulesEx U_ICU_ENTRY_POINT_RENAME(ucol_getRulesEx)
|
||||
#define ucol_getShortDefinitionString U_ICU_ENTRY_POINT_RENAME(ucol_getShortDefinitionString)
|
||||
|
@ -773,6 +774,7 @@
|
|||
#define ucol_setAttribute U_ICU_ENTRY_POINT_RENAME(ucol_setAttribute)
|
||||
#define ucol_setOffset U_ICU_ENTRY_POINT_RENAME(ucol_setOffset)
|
||||
#define ucol_setOptionsFromHeader U_ICU_ENTRY_POINT_RENAME(ucol_setOptionsFromHeader)
|
||||
#define ucol_setReorderCodes U_ICU_ENTRY_POINT_RENAME(ucol_setReorderCodes)
|
||||
#define ucol_setReqValidLocales U_ICU_ENTRY_POINT_RENAME(ucol_setReqValidLocales)
|
||||
#define ucol_setStrength U_ICU_ENTRY_POINT_RENAME(ucol_setStrength)
|
||||
#define ucol_setText U_ICU_ENTRY_POINT_RENAME(ucol_setText)
|
||||
|
|
|
@ -833,7 +833,7 @@ Collator::getFunctionalEquivalent(const char* keyword, const Locale& locale,
|
|||
return Locale::createFromName(loc);
|
||||
}
|
||||
|
||||
uint32_t Collator::getScriptOrder(int32_t *dest,
|
||||
uint32_t Collator::getReorderCodes(int32_t *dest,
|
||||
const uint32_t destCapacity,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
|
@ -841,8 +841,8 @@ uint32_t Collator::getScriptOrder(int32_t *dest,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Collator::setScriptOrder(const int32_t *scriptOrder,
|
||||
const uint32_t scriptOrderLength,
|
||||
void Collator::setReorderCodes(const int32_t *reorderCodes,
|
||||
const uint32_t reorderCodesLength,
|
||||
UErrorCode& status)
|
||||
{
|
||||
status = U_UNSUPPORTED_ERROR;
|
||||
|
|
|
@ -587,18 +587,18 @@ void RuleBasedCollator::setStrength(ECollationStrength newStrength)
|
|||
ucol_setAttribute(ucollator, UCOL_STRENGTH, strength, &intStatus);
|
||||
}
|
||||
|
||||
uint32_t RuleBasedCollator::getScriptOrder(int32_t *dest,
|
||||
uint32_t RuleBasedCollator::getReorderCodes(int32_t *dest,
|
||||
const uint32_t destCapacity,
|
||||
UErrorCode& status) const
|
||||
{
|
||||
return ucol_getScriptOrder(ucollator, dest, destCapacity, &status);
|
||||
return ucol_getReorderCodes(ucollator, dest, destCapacity, &status);
|
||||
}
|
||||
|
||||
void RuleBasedCollator::setScriptOrder(const int32_t *scriptOrder,
|
||||
const uint32_t scriptOrderLength,
|
||||
void RuleBasedCollator::setReorderCodes(const int32_t *reorderCodes,
|
||||
const uint32_t reorderCodesLength,
|
||||
UErrorCode& status)
|
||||
{
|
||||
ucol_setScriptOrder(ucollator, scriptOrder, scriptOrderLength, &status);
|
||||
ucol_setReorderCodes(ucollator, reorderCodes, reorderCodesLength, &status);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -673,11 +673,11 @@ ucol_close(UCollator *coll)
|
|||
if(coll->image != NULL && coll->freeImageOnClose) {
|
||||
uprv_free((UCATableHeader *)coll->image);
|
||||
}
|
||||
if(coll->scriptReorderTable != NULL) {
|
||||
uprv_free(coll->scriptReorderTable);
|
||||
if(coll->leadBytePermutationTable != NULL) {
|
||||
uprv_free(coll->leadBytePermutationTable);
|
||||
}
|
||||
if(coll->scriptOrder != NULL){
|
||||
uprv_free(coll->scriptOrder);
|
||||
if(coll->reorderCodes != NULL) {
|
||||
uprv_free(coll->reorderCodes);
|
||||
}
|
||||
|
||||
/* Here, it would be advisable to close: */
|
||||
|
@ -771,8 +771,13 @@ void ucol_setOptionsFromHeader(UCollator* result, UColOptionSet * opts, UErrorCo
|
|||
result->alternateHandling = (UColAttributeValue)opts->alternateHandling;
|
||||
result->hiraganaQ = (UColAttributeValue)opts->hiraganaQ;
|
||||
result->numericCollation = (UColAttributeValue)opts->numericCollation;
|
||||
result->scriptOrder = opts->scriptOrder;
|
||||
result->scriptOrderLength = opts->scriptOrderLength;
|
||||
result->reorderCodesLength = opts->reorderCodesLength;
|
||||
if (result->reorderCodesLength > 0) {
|
||||
result->reorderCodes = (int32_t*) uprv_malloc(result->reorderCodesLength * sizeof(int32_t));
|
||||
uprv_memcpy(result->reorderCodes, opts->reorderCodes, result->reorderCodesLength * sizeof(int32_t));
|
||||
} else {
|
||||
result->reorderCodes = NULL;
|
||||
}
|
||||
|
||||
result->caseFirstisDefault = TRUE;
|
||||
result->caseLevelisDefault = TRUE;
|
||||
|
@ -869,7 +874,9 @@ UCollator* ucol_initCollator(const UCATableHeader *image, UCollator *fillIn, con
|
|||
result->rules = NULL;
|
||||
result->rulesLength = 0;
|
||||
result->freeRulesOnClose = FALSE;
|
||||
result->scriptReorderTable = NULL;
|
||||
result->reorderCodes = NULL;
|
||||
result->reorderCodesLength = 0;
|
||||
result->leadBytePermutationTable = NULL;
|
||||
|
||||
/* get the version info from UCATableHeader and populate the Collator struct*/
|
||||
result->dataVersion[0] = result->image->version[0]; /* UCA Builder version*/
|
||||
|
@ -4356,8 +4363,8 @@ int32_t ucol_getSortKeySize(const UCollator *coll, collIterate *s, int32_t curre
|
|||
primary2 = (uint8_t)((order >>= 8) & UCOL_BYTE_SIZE_MASK);
|
||||
primary1 = (uint8_t)(order >> 8);
|
||||
|
||||
if (coll->scriptReorderTable != NULL && notIsContinuation) {
|
||||
primary1 = coll->scriptReorderTable[primary1];
|
||||
if (coll->leadBytePermutationTable != NULL && notIsContinuation) {
|
||||
primary1 = coll->leadBytePermutationTable[primary1];
|
||||
}
|
||||
|
||||
if((shifted && ((notIsContinuation && order <= variableTopValue && primary1 > 0)
|
||||
|
@ -4789,8 +4796,8 @@ ucol_calcSortKey(const UCollator *coll,
|
|||
primary2 = (uint8_t)((order >>= 8) & UCOL_BYTE_SIZE_MASK);
|
||||
primary1 = (uint8_t)(order >> 8);
|
||||
|
||||
if(notIsContinuation && coll->scriptReorderTable != NULL) {
|
||||
primary1 = coll->scriptReorderTable[primary1];
|
||||
if(notIsContinuation && coll->leadBytePermutationTable != NULL) {
|
||||
primary1 = coll->leadBytePermutationTable[primary1];
|
||||
}
|
||||
|
||||
if((shifted && ((notIsContinuation && order <= variableTopValue && primary1 > 0)
|
||||
|
@ -5383,8 +5390,8 @@ ucol_calcSortKeySimpleTertiary(const UCollator *coll,
|
|||
primary2 = (uint8_t)((order >>= 8) & UCOL_BYTE_SIZE_MASK);
|
||||
primary1 = (uint8_t)(order >> 8);
|
||||
|
||||
if (coll->scriptReorderTable != NULL && notIsContinuation) {
|
||||
primary1 = coll->scriptReorderTable[primary1];
|
||||
if (coll->leadBytePermutationTable != NULL && notIsContinuation) {
|
||||
primary1 = coll->leadBytePermutationTable[primary1];
|
||||
}
|
||||
|
||||
/* Note: This code assumes that the table is well built i.e. not having 0 bytes where they are not supposed to be. */
|
||||
|
@ -5975,8 +5982,8 @@ ucol_nextSortKeyPart(const UCollator *coll,
|
|||
break;
|
||||
}
|
||||
if(!isContinuation(CE)){
|
||||
if(coll->scriptReorderTable != NULL){
|
||||
CE = (coll->scriptReorderTable[CE>>24] << 24) | (CE & 0x00FFFFFF);
|
||||
if(coll->leadBytePermutationTable != NULL){
|
||||
CE = (coll->leadBytePermutationTable[CE>>24] << 24) | (CE & 0x00FFFFFF);
|
||||
}
|
||||
}
|
||||
if(!isShiftedCE(CE, LVT, &wasShifted)) {
|
||||
|
@ -6602,8 +6609,8 @@ ucol_addLatinOneEntry(UCollator *coll, UChar ch, uint32_t CE,
|
|||
primary1 = (uint8_t)(CE >> 8);
|
||||
|
||||
if(primary1 != 0) {
|
||||
if (coll->scriptReorderTable != NULL && !continuation) {
|
||||
primary1 = coll->scriptReorderTable[primary1];
|
||||
if (coll->leadBytePermutationTable != NULL && !continuation) {
|
||||
primary1 = coll->leadBytePermutationTable[primary1];
|
||||
}
|
||||
|
||||
coll->latinOneCEs[ch] |= (primary1 << *primShift);
|
||||
|
@ -7119,38 +7126,38 @@ ucol_getStrength(const UCollator *coll)
|
|||
}
|
||||
|
||||
U_INTERNAL uint32_t U_EXPORT2
|
||||
ucol_getScriptOrder(const UCollator *coll,
|
||||
ucol_getReorderCodes(const UCollator *coll,
|
||||
int32_t *dest,
|
||||
uint32_t destCapacity,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (coll->scriptOrder == NULL) {
|
||||
if (coll->reorderCodes == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (coll->scriptOrderLength > destCapacity) {
|
||||
if (coll->reorderCodesLength > destCapacity) {
|
||||
*pErrorCode = U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
for (uint32_t i = 0; (i < coll->scriptOrderLength) && (i < destCapacity); i++) {
|
||||
dest[i] = coll->scriptOrder[i];
|
||||
for (uint32_t i = 0; (i < coll->reorderCodesLength) && (i < destCapacity); i++) {
|
||||
dest[i] = coll->reorderCodes[i];
|
||||
}
|
||||
return coll->scriptOrderLength;
|
||||
return coll->reorderCodesLength;
|
||||
}
|
||||
|
||||
U_INTERNAL void U_EXPORT2
|
||||
ucol_setScriptOrder(UCollator *coll,
|
||||
const int32_t *scriptOrder,
|
||||
uint32_t scriptOrderLength,
|
||||
ucol_setReorderCodes(UCollator *coll,
|
||||
const int32_t *reorderCodes,
|
||||
uint32_t reorderCodesLength,
|
||||
UErrorCode *pErrorCode ){
|
||||
if (coll->scriptOrder != NULL) {
|
||||
uprv_free(coll->scriptOrder);
|
||||
if (coll->reorderCodes != NULL) {
|
||||
uprv_free(coll->reorderCodes);
|
||||
}
|
||||
coll->scriptOrder = (int32_t*) uprv_malloc(scriptOrderLength*sizeof(int32_t));
|
||||
for (uint32_t i = 0; i < scriptOrderLength; i++) {
|
||||
coll->scriptOrder[i] = scriptOrder[i];
|
||||
coll->reorderCodes = (int32_t*) uprv_malloc(reorderCodesLength * sizeof(int32_t));
|
||||
for (uint32_t i = 0; i < reorderCodesLength; i++) {
|
||||
coll->reorderCodes[i] = reorderCodes[i];
|
||||
}
|
||||
coll->scriptOrderLength = scriptOrderLength;
|
||||
coll->reorderCodesLength = reorderCodesLength;
|
||||
ucol_buildScriptReorderTable(coll, pErrorCode);
|
||||
}
|
||||
|
||||
|
@ -7504,9 +7511,9 @@ ucol_strcollRegular(collIterate *sColl, collIterate *tColl, UErrorCode *status)
|
|||
} else {
|
||||
// only need to check one for continuation
|
||||
// if one is then the other must be or the preceding CE would be a prefix of the other
|
||||
if (coll->scriptReorderTable != NULL && !isContinuation(sOrder)) {
|
||||
sOrder = (coll->scriptReorderTable[sOrder>>24] << 24) | (sOrder & 0x00FFFFFF);
|
||||
tOrder = (coll->scriptReorderTable[tOrder>>24] << 24) | (tOrder & 0x00FFFFFF);
|
||||
if (coll->leadBytePermutationTable != NULL && !isContinuation(sOrder)) {
|
||||
sOrder = (coll->leadBytePermutationTable[sOrder>>24] << 24) | (sOrder & 0x00FFFFFF);
|
||||
tOrder = (coll->leadBytePermutationTable[tOrder>>24] << 24) | (tOrder & 0x00FFFFFF);
|
||||
}
|
||||
// if two primaries are different, we are done
|
||||
result = (sOrder < tOrder) ? UCOL_LESS: UCOL_GREATER;
|
||||
|
@ -7546,8 +7553,8 @@ ucol_strcollRegular(collIterate *sColl, collIterate *tColl, UErrorCode *status)
|
|||
}
|
||||
}
|
||||
} else { /* regular */
|
||||
if(coll->scriptReorderTable != NULL){
|
||||
sOrder = (coll->scriptReorderTable[sOrder>>24] << 24) | (sOrder & 0x00FFFFFF);
|
||||
if(coll->leadBytePermutationTable != NULL){
|
||||
sOrder = (coll->leadBytePermutationTable[sOrder>>24] << 24) | (sOrder & 0x00FFFFFF);
|
||||
}
|
||||
if((sOrder & UCOL_PRIMARYMASK) > LVT) {
|
||||
UCOL_CEBUF_PUT(&sCEs, sOrder, sColl, status);
|
||||
|
@ -7596,8 +7603,8 @@ ucol_strcollRegular(collIterate *sColl, collIterate *tColl, UErrorCode *status)
|
|||
}
|
||||
}
|
||||
} else { /* regular */
|
||||
if(coll->scriptReorderTable != NULL){
|
||||
tOrder = (coll->scriptReorderTable[tOrder>>24] << 24) | (tOrder & 0x00FFFFFF);
|
||||
if(coll->leadBytePermutationTable != NULL){
|
||||
tOrder = (coll->leadBytePermutationTable[tOrder>>24] << 24) | (tOrder & 0x00FFFFFF);
|
||||
}
|
||||
if((tOrder & UCOL_PRIMARYMASK) > LVT) {
|
||||
UCOL_CEBUF_PUT(&tCEs, tOrder, tColl, status);
|
||||
|
|
|
@ -772,8 +772,8 @@ typedef struct {
|
|||
/*UColAttributeValue*/ int32_t strength; /* attribute for strength */
|
||||
/*UColAttributeValue*/ int32_t hiraganaQ; /* attribute for special Hiragana */
|
||||
/*UColAttributeValue*/ int32_t numericCollation; /* attribute for numeric collation */
|
||||
/* reorder code */ int32_t* scriptOrder;
|
||||
uint32_t scriptOrderLength;
|
||||
/* reorder code */ int32_t* reorderCodes;
|
||||
uint32_t reorderCodesLength;
|
||||
uint32_t reserved[15]; /* for future use */
|
||||
} UColOptionSet;
|
||||
|
||||
|
@ -1021,9 +1021,9 @@ struct UCollator {
|
|||
uint8_t tertiaryBottomCount;
|
||||
|
||||
UVersionInfo dataVersion; /* Data info of UCA table */
|
||||
int32_t* scriptOrder;
|
||||
uint32_t scriptOrderLength;
|
||||
uint8_t* scriptReorderTable;
|
||||
int32_t* reorderCodes;
|
||||
uint32_t reorderCodesLength;
|
||||
uint8_t* leadBytePermutationTable;
|
||||
};
|
||||
|
||||
U_CDECL_END
|
||||
|
|
|
@ -214,8 +214,8 @@ int ucol_getReorderCodesForLeadByte(UCollator *coll, int leadByte, int16_t* retu
|
|||
void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
||||
uint16_t leadBytesSize = 256;
|
||||
uint16_t leadBytes[256];
|
||||
uint32_t internalScriptOrderLength = coll->scriptOrderLength + (UCOL_REORDERCODE_LIMIT - UCOL_REORDERCODE_FIRST);
|
||||
int32_t* internalScriptOrder;
|
||||
uint32_t internalReorderCodesLength = coll->reorderCodesLength + (UCOL_REORDERCODE_LIMIT - UCOL_REORDERCODE_FIRST);
|
||||
int32_t* internalReorderCodes;
|
||||
|
||||
// The lowest byte that hasn't been assigned a mapping
|
||||
int toBottom = 0x03;
|
||||
|
@ -231,29 +231,29 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
bool permutationSlotFilled[256];
|
||||
|
||||
// nothing to do
|
||||
if(U_FAILURE(*status) || coll == NULL || coll->scriptOrderLength == 0) {
|
||||
if (coll->scriptReorderTable != NULL) {
|
||||
uprv_free(coll->scriptReorderTable);
|
||||
coll->scriptReorderTable = NULL;
|
||||
if(U_FAILURE(*status) || coll == NULL || coll->reorderCodesLength == 0) {
|
||||
if (coll->leadBytePermutationTable != NULL) {
|
||||
uprv_free(coll->leadBytePermutationTable);
|
||||
coll->leadBytePermutationTable = NULL;
|
||||
}
|
||||
coll->scriptOrderLength = 0;
|
||||
coll->reorderCodesLength = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (coll->scriptReorderTable == NULL) {
|
||||
coll->scriptReorderTable = (uint8_t*)uprv_malloc(256*sizeof(uint8_t));
|
||||
if (coll->leadBytePermutationTable == NULL) {
|
||||
coll->leadBytePermutationTable = (uint8_t*)uprv_malloc(256*sizeof(uint8_t));
|
||||
}
|
||||
|
||||
// prefill the reordering codes with the leading entries
|
||||
internalScriptOrder = (int32_t*)uprv_malloc(internalScriptOrderLength * sizeof(int32_t));
|
||||
internalReorderCodes = (int32_t*)uprv_malloc(internalReorderCodesLength * sizeof(int32_t));
|
||||
for (uint32_t codeIndex = 0; codeIndex < (UCOL_REORDERCODE_LIMIT - UCOL_REORDERCODE_FIRST); codeIndex++) {
|
||||
internalScriptOrder[codeIndex] = UCOL_REORDERCODE_FIRST + codeIndex;
|
||||
internalReorderCodes[codeIndex] = UCOL_REORDERCODE_FIRST + codeIndex;
|
||||
}
|
||||
for (uint32_t codeIndex = 0; codeIndex < coll->scriptOrderLength; codeIndex++) {
|
||||
uint32_t scriptOrderCode = coll->scriptOrder[codeIndex];
|
||||
internalScriptOrder[codeIndex + (UCOL_REORDERCODE_LIMIT - UCOL_REORDERCODE_FIRST)] = scriptOrderCode;
|
||||
if (scriptOrderCode >= UCOL_REORDERCODE_FIRST && scriptOrderCode < UCOL_REORDERCODE_LIMIT) {
|
||||
internalScriptOrder[scriptOrderCode - UCOL_REORDERCODE_FIRST] = UCOL_REORDERCODE_IGNORE;
|
||||
for (uint32_t codeIndex = 0; codeIndex < coll->reorderCodesLength; codeIndex++) {
|
||||
uint32_t reorderCodesCode = coll->reorderCodes[codeIndex];
|
||||
internalReorderCodes[codeIndex + (UCOL_REORDERCODE_LIMIT - UCOL_REORDERCODE_FIRST)] = reorderCodesCode;
|
||||
if (reorderCodesCode >= UCOL_REORDERCODE_FIRST && reorderCodesCode < UCOL_REORDERCODE_LIMIT) {
|
||||
internalReorderCodes[reorderCodesCode - UCOL_REORDERCODE_FIRST] = UCOL_REORDERCODE_IGNORE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,11 +261,11 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
if (i < toBottom || i > toTop) {
|
||||
permutationSlotFilled[i] = true;
|
||||
newLeadByteUsed[i] = true;
|
||||
coll->scriptReorderTable[i] = i;
|
||||
coll->leadBytePermutationTable[i] = i;
|
||||
} else {
|
||||
permutationSlotFilled[i] = false;
|
||||
newLeadByteUsed[i] = false;
|
||||
coll->scriptReorderTable[i] = 0;
|
||||
coll->leadBytePermutationTable[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,8 +275,8 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
* possible location. At each step, we also need to make sure that any scripts
|
||||
* that need to not be moved are copied to their same location in the final table.
|
||||
*/
|
||||
for (int scriptOrderIndex = 0; scriptOrderIndex < internalScriptOrderLength; scriptOrderIndex++) {
|
||||
int32_t next = internalScriptOrder[scriptOrderIndex];
|
||||
for (int reorderCodesIndex = 0; reorderCodesIndex < internalReorderCodesLength; reorderCodesIndex++) {
|
||||
int32_t next = internalReorderCodes[reorderCodesIndex];
|
||||
if (next == UCOL_REORDERCODE_IGNORE) {
|
||||
continue;
|
||||
}
|
||||
|
@ -284,13 +284,13 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
if (fromTheBottom == false) {
|
||||
// double turnaround
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
if (coll->scriptReorderTable != NULL) {
|
||||
uprv_free(coll->scriptReorderTable);
|
||||
coll->scriptReorderTable = NULL;
|
||||
if (coll->leadBytePermutationTable != NULL) {
|
||||
uprv_free(coll->leadBytePermutationTable);
|
||||
coll->leadBytePermutationTable = NULL;
|
||||
}
|
||||
coll->scriptOrderLength = 0;
|
||||
if (internalScriptOrder != NULL) {
|
||||
uprv_free(internalScriptOrder);
|
||||
coll->reorderCodesLength = 0;
|
||||
if (internalReorderCodes != NULL) {
|
||||
uprv_free(internalReorderCodes);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -305,18 +305,18 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
if (permutationSlotFilled[leadBytes[leadByteIndex]]) {
|
||||
// lead byte already used
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
if (coll->scriptReorderTable != NULL) {
|
||||
uprv_free(coll->scriptReorderTable);
|
||||
coll->scriptReorderTable = NULL;
|
||||
if (coll->leadBytePermutationTable != NULL) {
|
||||
uprv_free(coll->leadBytePermutationTable);
|
||||
coll->leadBytePermutationTable = NULL;
|
||||
}
|
||||
coll->scriptOrderLength = 0;
|
||||
if (internalScriptOrder != NULL) {
|
||||
uprv_free(internalScriptOrder);
|
||||
coll->reorderCodesLength = 0;
|
||||
if (internalReorderCodes != NULL) {
|
||||
uprv_free(internalReorderCodes);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
coll->scriptReorderTable[leadBytes[leadByteIndex]] = toBottom;
|
||||
coll->leadBytePermutationTable[leadBytes[leadByteIndex]] = toBottom;
|
||||
newLeadByteUsed[toBottom] = true;
|
||||
permutationSlotFilled[leadBytes[leadByteIndex]] = true;
|
||||
toBottom++;
|
||||
|
@ -327,18 +327,18 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
if (permutationSlotFilled[leadBytes[leadByteIndex]]) {
|
||||
// lead byte already used
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
if (coll->scriptReorderTable != NULL) {
|
||||
uprv_free(coll->scriptReorderTable);
|
||||
coll->scriptReorderTable = NULL;
|
||||
if (coll->leadBytePermutationTable != NULL) {
|
||||
uprv_free(coll->leadBytePermutationTable);
|
||||
coll->leadBytePermutationTable = NULL;
|
||||
}
|
||||
coll->scriptOrderLength = 0;
|
||||
if (internalScriptOrder != NULL) {
|
||||
uprv_free(internalScriptOrder);
|
||||
coll->reorderCodesLength = 0;
|
||||
if (internalReorderCodes != NULL) {
|
||||
uprv_free(internalReorderCodes);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
coll->scriptReorderTable[leadBytes[leadByteIndex]] = toTop;
|
||||
coll->leadBytePermutationTable[leadBytes[leadByteIndex]] = toTop;
|
||||
newLeadByteUsed[toTop] = true;
|
||||
permutationSlotFilled[leadBytes[leadByteIndex]] = true;
|
||||
toTop--;
|
||||
|
@ -349,7 +349,7 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
#ifdef REORDER_DEBUG
|
||||
fprintf(stdout, "\n@@@@ Partial Script Reordering Table\n");
|
||||
for (int i = 0; i < 256; i++) {
|
||||
fprintf(stdout, "\t%02x = %02x\n", i, coll->scriptReorderTable[i]);
|
||||
fprintf(stdout, "\t%02x = %02x\n", i, coll->leadBytePermutationTable[i]);
|
||||
}
|
||||
fprintf(stdout, "\n@@@@ Lead Byte Used Table\n");
|
||||
for (int i = 0; i < 256; i++) {
|
||||
|
@ -368,7 +368,7 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
while (reorderCode < 256 && newLeadByteUsed[reorderCode]) {
|
||||
reorderCode++;
|
||||
}
|
||||
coll->scriptReorderTable[i] = reorderCode;
|
||||
coll->leadBytePermutationTable[i] = reorderCode;
|
||||
permutationSlotFilled[i] = true;
|
||||
newLeadByteUsed[reorderCode] = true;
|
||||
}
|
||||
|
@ -377,12 +377,12 @@ void ucol_buildScriptReorderTable(UCollator *coll, UErrorCode *status) {
|
|||
#ifdef REORDER_DEBUG
|
||||
fprintf(stdout, "\n@@@@ Script Reordering Table\n");
|
||||
for (int i = 0; i < 256; i++) {
|
||||
fprintf(stdout, "\t%02x = %02x\n", i, coll->scriptReorderTable[i]);
|
||||
fprintf(stdout, "\t%02x = %02x\n", i, coll->leadBytePermutationTable[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (internalScriptOrder != NULL) {
|
||||
uprv_free(internalScriptOrder);
|
||||
if (internalReorderCodes != NULL) {
|
||||
uprv_free(internalReorderCodes);
|
||||
}
|
||||
|
||||
// force a regen of the latin one table since it is affected by the script reordering
|
||||
|
@ -498,7 +498,7 @@ ucol_open_internal(const char *loc,
|
|||
if (U_SUCCESS(intStatus)) {
|
||||
int32_t reorderCodesLen = 0;
|
||||
const int32_t* reorderCodes = ures_getIntVector(reorderRes, &reorderCodesLen, status);
|
||||
ucol_setScriptOrder(result, reorderCodes, reorderCodesLen, status);
|
||||
ucol_setReorderCodes(result, reorderCodes, reorderCodesLen, status);
|
||||
if (U_FAILURE(*status)) {
|
||||
goto clean;
|
||||
}
|
||||
|
@ -816,11 +816,11 @@ ucol_equals(const UCollator *source, const UCollator *target) {
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
if(source->scriptOrderLength != target->scriptOrderLength){
|
||||
if(source->reorderCodesLength != target->reorderCodesLength){
|
||||
return FALSE;
|
||||
}
|
||||
for(int i = 0; i < source->scriptOrderLength; i++){
|
||||
if(source->scriptOrder[i] != target->scriptOrder[i]){
|
||||
for (int i = 0; i < source->reorderCodesLength; i++) {
|
||||
if(source->reorderCodes[i] != target->reorderCodes[i]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,7 +419,7 @@ static const ucolTokOption rulesOptions[UTOK_OPTION_COUNT] = {
|
|||
/*18*/ {option_10, 11, NULL, 0, UCOL_ATTRIBUTE_COUNT}, /*"charsetname" */
|
||||
/*19*/ {option_11, 7, NULL, 0, UCOL_ATTRIBUTE_COUNT}, /*"charset" */
|
||||
/*20*/ {option_20, 6, NULL, 0, UCOL_ATTRIBUTE_COUNT}, /*"import" */
|
||||
/*21*/ {option_21, 7, NULL, 0, UCOL_ATTRIBUTE_COUNT} /*"scriptReorder" */
|
||||
/*21*/ {option_21, 7, NULL, 0, UCOL_ATTRIBUTE_COUNT} /*"reorder" */
|
||||
};
|
||||
|
||||
static
|
||||
|
@ -659,8 +659,8 @@ void ucol_tok_parseScriptReorder(UColTokenParser *src, UErrorCode *status) {
|
|||
*status = U_INVALID_FORMAT_ERROR;
|
||||
}
|
||||
|
||||
src->opts->scriptOrderLength = codeCount;
|
||||
src->opts->scriptOrder = (int32_t*)uprv_malloc(codeCount * sizeof(int32_t));
|
||||
src->opts->reorderCodesLength = codeCount;
|
||||
src->opts->reorderCodes = (int32_t*)uprv_malloc(codeCount * sizeof(int32_t));
|
||||
current = src->current;
|
||||
|
||||
// eat leading whitespace
|
||||
|
@ -678,11 +678,11 @@ void ucol_tok_parseScriptReorder(UColTokenParser *src, UErrorCode *status) {
|
|||
} else {
|
||||
u_UCharsToChars(current, conversion, tokenLength);
|
||||
conversion[tokenLength] = '\0';
|
||||
src->opts->scriptOrder[codeIndex] = ucol_findReorderingEntry(conversion);
|
||||
if (src->opts->scriptOrder[codeIndex] == USCRIPT_INVALID_CODE) {
|
||||
src->opts->scriptOrder[codeIndex] = u_getPropertyValueEnum(UCHAR_SCRIPT, conversion);
|
||||
src->opts->reorderCodes[codeIndex] = ucol_findReorderingEntry(conversion);
|
||||
if (src->opts->reorderCodes[codeIndex] == USCRIPT_INVALID_CODE) {
|
||||
src->opts->reorderCodes[codeIndex] = u_getPropertyValueEnum(UCHAR_SCRIPT, conversion);
|
||||
}
|
||||
if (src->opts->scriptOrder[codeIndex] == USCRIPT_INVALID_CODE) {
|
||||
if (src->opts->reorderCodes[codeIndex] == USCRIPT_INVALID_CODE) {
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -603,22 +603,22 @@ public:
|
|||
* @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of the result string (pre-flighting).
|
||||
* @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a failure before the function call.
|
||||
* @return The length of the array of the script ordering.
|
||||
* @see ucol_setScriptOrder
|
||||
* @see ucol_getReorderCodes
|
||||
* @internal
|
||||
*/
|
||||
virtual uint32_t getScriptOrder(int32_t *dest,
|
||||
virtual uint32_t getReorderCodes(int32_t *dest,
|
||||
const uint32_t destCapacity,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Set the ordering of scripts for this collator.
|
||||
* @param scriptOrder An array of script codes in the new order.
|
||||
* @param scriptOrderLength The length of scriptOrder.
|
||||
* @see ucol_getStrength
|
||||
* @param reorderCodes An array of reorder codes in the new order.
|
||||
* @param reorderCodesLength The length of reorderCodes.
|
||||
* @see ucol_setReorderCodes
|
||||
* @internal
|
||||
*/
|
||||
virtual void setScriptOrder(const int32_t* scriptOrder,
|
||||
const uint32_t scriptOrderLength,
|
||||
virtual void setReorderCodes(const int32_t* reorderCodes,
|
||||
const uint32_t reorderCodesLength,
|
||||
UErrorCode& status) ;
|
||||
|
||||
/**
|
||||
|
|
|
@ -672,22 +672,22 @@ public:
|
|||
* @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of the result string (pre-flighting).
|
||||
* @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a failure before the function call.
|
||||
* @return The length of the array of the script ordering.
|
||||
* @see ucol_setScriptOrder
|
||||
* @see ucol_getReorderCodes
|
||||
* @internal
|
||||
*/
|
||||
virtual uint32_t getScriptOrder(int32_t* dest,
|
||||
virtual uint32_t getReorderCodes(int32_t* dest,
|
||||
const uint32_t destCapacity,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Set the ordering of scripts for this collator.
|
||||
* @param scriptOrder An array of script codes in the new order.
|
||||
* @param scriptOrderLength The length of scriptOrder.
|
||||
* @see ucol_getStrength
|
||||
* @param reorderCodes An array of script codes in the new order.
|
||||
* @param reorderCodesLength The length of reorderCodes.
|
||||
* @see ucol_setReorderCodes
|
||||
* @internal
|
||||
*/
|
||||
virtual void setScriptOrder(const int32_t* scriptOrder,
|
||||
const uint32_t scriptOrderLength,
|
||||
virtual void setReorderCodes(const int32_t* reorderCodes,
|
||||
const uint32_t reorderCodesLength,
|
||||
UErrorCode& status);
|
||||
|
||||
|
||||
|
|
|
@ -544,11 +544,11 @@ ucol_setStrength(UCollator *coll,
|
|||
* @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of the result string (pre-flighting).
|
||||
* @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a failure before the function call.
|
||||
* @return The length of the array of the script ordering.
|
||||
* @see ucol_setScriptOrder
|
||||
* @see ucol_setReorderCodes
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL uint32_t U_EXPORT2
|
||||
ucol_getScriptOrder(const UCollator* coll,
|
||||
ucol_getReorderCodes(const UCollator* coll,
|
||||
int32_t* dest,
|
||||
uint32_t destCapacity,
|
||||
UErrorCode *pErrorCode);
|
||||
|
@ -556,16 +556,16 @@ ucol_getScriptOrder(const UCollator* coll,
|
|||
/**
|
||||
* Set the ordering of scripts for this collator.
|
||||
* @param coll The UCollator to set.
|
||||
* @param scriptOrder An array of script codes in the new order.
|
||||
* @param scriptOrderLength The length of scriptOrder.
|
||||
* @param reorderCodes An array of script codes in the new order.
|
||||
* @param reorderCodesLength The length of reorderCodes.
|
||||
* @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a failure before the function call.
|
||||
* @see ucol_getStrength
|
||||
* @see ucol_getReorderCodes
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
ucol_setScriptOrder(UCollator* coll,
|
||||
const int32_t* scriptOrder,
|
||||
uint32_t scriptOrderLength,
|
||||
ucol_setReorderCodes(UCollator* coll,
|
||||
const int32_t* reorderCodes,
|
||||
uint32_t reorderCodesLength,
|
||||
UErrorCode *pErrorCode);
|
||||
|
||||
/**
|
||||
|
|
|
@ -5828,7 +5828,7 @@ static void TestBeforeRuleWithScriptReordering(void)
|
|||
char srules[500] = "&[before 1]\\u03b1 < \\u0e01";
|
||||
UChar rules[500];
|
||||
uint32_t rulesLength = 0;
|
||||
UScriptCode scriptOrder[1] = {USCRIPT_GREEK};
|
||||
int32_t reorderCodes[1] = {USCRIPT_GREEK};
|
||||
UCollationResult collResult;
|
||||
|
||||
uint8_t baseKey[256];
|
||||
|
@ -5872,7 +5872,7 @@ static void TestBeforeRuleWithScriptReordering(void)
|
|||
}
|
||||
|
||||
/* reorder the scripts */
|
||||
ucol_setScriptOrder(myCollation, scriptOrder, 1, &status);
|
||||
ucol_setReorderCodes(myCollation, reorderCodes, 1, &status);
|
||||
if(U_FAILURE(status)) {
|
||||
log_err_status(status, "ERROR: while setting script order: %s\n", myErrorName(status));
|
||||
return;
|
||||
|
@ -5915,7 +5915,7 @@ static void doTestOneReorderingAPITestCase(const OneTestCase testCases[], uint32
|
|||
}
|
||||
/*ucol_setAttribute(myCollation, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
|
||||
ucol_setStrength(myCollation, UCOL_TERTIARY);*/
|
||||
ucol_setScriptOrder(myCollation, reorderTokens, reorderTokensLen, &status);
|
||||
ucol_setReorderCodes(myCollation, reorderTokens, reorderTokensLen, &status);
|
||||
if(U_FAILURE(status)) {
|
||||
log_err_status(status, "ERROR: while setting script order: %s\n", myErrorName(status));
|
||||
return;
|
||||
|
|
18
icu4c/source/test/testdata/te.txt
vendored
18
icu4c/source/test/testdata/te.txt
vendored
|
@ -88,24 +88,24 @@ te
|
|||
{
|
||||
tag0 { TE0 }
|
||||
}
|
||||
|
||||
|
||||
collations {
|
||||
standard {
|
||||
Version { "1.0" }
|
||||
Override { "FALSE" }
|
||||
Sequence {"& A < a\u0308 , A\u0308 & C < c\u0327 , C\u0327 & G < g"
|
||||
"\u0306 , G\u0306 & H < \u0131 , I , i , \u0130 < \u0132 , \u0133 & O < o\u0308 "
|
||||
", O\u0308 & S < s\u0327 , S\u0327 & U < u\u0308 , U\u0308 " }
|
||||
Version { "1.0" }
|
||||
Override { "FALSE" }
|
||||
Sequence {"[reorder Grek] & A < a\u0308 , A\u0308 & C < c\u0327 , C\u0327 & G < g"
|
||||
"\u0306 , G\u0306 & H < \u0131 , I , i , \u0130 < \u0132 , \u0133 & O < o\u0308 "
|
||||
", O\u0308 & S < s\u0327 , S\u0327 & U < u\u0308 , U\u0308" }
|
||||
}
|
||||
}
|
||||
aliasClient:alias {"/LOCALE/aliasDestination"}
|
||||
aliasDestination {"tedest"}
|
||||
rootAliasDestination {"correct"}
|
||||
a {
|
||||
a1{"a21"}
|
||||
a2{"a22"}
|
||||
a1{"a21"}
|
||||
a2{"a22"}
|
||||
a3{"a23"}
|
||||
a4{"a24"}
|
||||
a4{"a24"}
|
||||
}
|
||||
zoneStrings{
|
||||
{
|
||||
|
|
|
@ -933,7 +933,7 @@ addCollation(ParseState* state, struct SResource *result, uint32_t startline, U
|
|||
table_add(result, collationBin, line, status);
|
||||
uprv_free(data);
|
||||
|
||||
reorderCodeCount = ucol_getScriptOrder(
|
||||
reorderCodeCount = ucol_getReorderCodes(
|
||||
coll, reorderCodes, USCRIPT_CODE_LIMIT + (UCOL_REORDERCODE_LIMIT - UCOL_REORDERCODE_FIRST), &intStatus);
|
||||
if (U_SUCCESS(intStatus) && reorderCodeCount > 0) {
|
||||
struct SResource *reorderCodeRes = intvector_open(state->bundle, "%%ReorderCodes", NULL, status);
|
||||
|
|
Loading…
Add table
Reference in a new issue