Home | History | Annotate | Download | only in i18n

Lines Matching refs:coll

121     (s)->coll = (collator);
476 ucol_cloneBinary(const UCollator *coll,
488 if(coll->hasRealData == TRUE) {
489 length = coll->image->size;
491 uprv_memcpy(buffer, coll->image, length);
520 uprv_memcpy(myData->version, coll->image->version, sizeof(UVersionInfo));
522 uprv_memcpy(myData->UCAVersion, coll->image->UCAVersion, sizeof(UVersionInfo));
523 uprv_memcpy(myData->UCDVersion, coll->image->UCDVersion, sizeof(UVersionInfo));
524 uprv_memcpy(myData->formatVersion, coll->image->formatVersion, sizeof(UVersionInfo));
525 myData->jamoSpecial = coll->image->jamoSpecial;
528 uprv_memcpy(buffer+paddedsize(sizeof(UCATableHeader)), coll->options, sizeof(UColOptionSet));
537 ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize, UErrorCode *status)
553 if ((stackBuffer && !pBufferSize) || !coll){
557 if (coll->rules && coll->freeRulesOnClose) {
558 rulesSize = (int32_t)(coll->rulesLength + 1)*sizeof(UChar);
601 imageSize = ucol_cloneBinary(coll, NULL, 0, &tempStatus);
603 if (coll->freeImageOnClose) {
610 ucol_cloneBinary(coll, image, imageSize, status);
614 image = (uint8_t *)coll->image;
616 localCollator = ucol_initFromBinary(image, imageSize, coll->UCA, localCollator, status);
621 if (coll->rules) {
622 if (coll->freeRulesOnClose) {
623 localCollator->rules = u_strcpy(rules, coll->rules);
627 localCollator->rules = coll->rules;
630 localCollator->rulesLength = coll->rulesLength;
635 ucol_setAttribute(localCollator, (UColAttribute)i, ucol_getAttribute(coll, (UColAttribute)i, status), status);
641 localCollator->ucaRules = coll->ucaRules; // There should only be one copy here.
648 ucol_close(UCollator *coll)
651 UTRACE_DATA1(UTRACE_INFO, "coll = %p", coll);
652 if(coll != NULL) {
655 if(coll->validLocale != NULL) {
656 uprv_free(coll->validLocale);
658 if(coll->actualLocale != NULL) {
659 uprv_free(coll->actualLocale);
661 if(coll->requestedLocale != NULL) {
662 uprv_free(coll->requestedLocale);
664 if(coll->latinOneCEs != NULL) {
665 uprv_free(coll->latinOneCEs);
667 if(coll->options != NULL && coll->freeOptionsOnClose) {
668 uprv_free(coll->options);
670 if(coll->rules != NULL && coll->freeRulesOnClose) {
671 uprv_free((UChar *)coll->rules);
673 if(coll->image != NULL && coll->freeImageOnClose) {
674 uprv_free((UCATableHeader *)coll->image);
676 if(coll->leadBytePermutationTable != NULL) {
677 uprv_free(coll->leadBytePermutationTable);
679 if(coll->reorderCodes != NULL) {
680 uprv_free(coll->reorderCodes);
686 UTRACE_DATA1(UTRACE_INFO, "coll->freeOnClose: %d", coll->freeOnClose);
687 if(coll->freeOnClose){
690 uprv_free(coll);
699 ucol_cloneRuleData(const UCollator *coll, int32_t *length, UErrorCode *status)
705 if(coll->hasRealData == TRUE) {
706 *length = coll->image->size;
713 uprv_memcpy(result, coll->image, *length);
745 uprv_memcpy(myData->version, coll->image->version, sizeof(UVersionInfo));
747 uprv_memcpy(myData->UCAVersion, coll->image->UCAVersion, sizeof(UVersionInfo));
748 uprv_memcpy(myData->UCDVersion, coll->image->UCDVersion, sizeof(UVersionInfo));
749 uprv_memcpy(myData->formatVersion, coll->image->formatVersion, sizeof(UVersionInfo));
750 myData->jamoSpecial = coll->image->jamoSpecial;
753 uprv_memcpy(result+paddedsize(sizeof(UCATableHeader)), coll->options, sizeof(UColOptionSet));
795 * @param coll collator
798 inline UBool ucol_contractionEndCP(UChar c, const UCollator *coll) {
799 if (c < coll->minContrEndCP) {
811 htbyte = coll->contrEndCP[hash>>3];
824 inline uint8_t i_getCombiningClass(UChar32 c, const UCollator *coll) {
826 if ((c >= 0x300 && ucol_unsafeCP(c, coll)) || c > 0xFFFF) {
1434 inline uint32_t ucol_IGetNextCE(const UCollator *coll, collIterate *collationSource, UErrorCode *status) {
1575 order = coll->latinOneMapping[ch];
1577 order = ucol_prv_getSpecialCE(coll, ch, order, collationSource, status);
1593 order = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
1599 order = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
1603 order = ucol_prv_getSpecialCE(coll, ch, order, collationSource, status); /* and try to get the special CE */
1606 if(order == UCOL_NOT_FOUND && coll->UCA) { /* We couldn't find a good CE in the tailoring */
1608 order = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
1611 order = ucol_prv_getSpecialCE(coll->UCA, ch, order, collationSource, status);
1625 ucol_getNextCE(const UCollator *coll, collIterate *collationSource, UErrorCode *status) {
1626 return ucol_IGetNextCE(coll, collationSource, status);
1698 uint32_t baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->mapping, baseChar);
1700 if (baseOrder == UCOL_NOT_FOUND && data->coll->UCA) {
1701 baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->UCA->mapping, baseChar);
1929 * @param coll collator data
1934 inline uint32_t ucol_IGetPrevCE(const UCollator *coll, collIterate *data,
2074 if (ucol_contractionEndCP(ch, coll) && !isAtStartPrevIterate(data)) {
2075 result = ucol_prv_getSpecialPrevCE(coll, ch, UCOL_CONTRACTION, data, status);
2078 result = coll->latinOneMapping[ch];
2091 result = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
2096 result = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
2100 result = ucol_prv_getSpecialPrevCE(coll, ch, result, data, status);
2104 ucol_contractionEndCP(ch, data->coll))
2108 if(coll->UCA) {
2109 result = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
2114 if(coll->UCA) {
2115 result = ucol_prv_getSpecialPrevCE(coll->UCA, ch, result, data, status);
2133 ucol_getPrevCE(const UCollator *coll, collIterate *data,
2135 return ucol_IGetPrevCE(coll, data, status);
2141 ucol_getFirstCE(const UCollator *coll, UChar u, UErrorCode *status) {
2143 IInit_collIterate(coll, &u, 1, &colIt, status);
2147 return ucol_IGetNextCE(coll, &colIt, status);
2401 * @param coll current collator used
2407 uint32_t getDiscontiguous(const UCollator *coll, collIterate *source,
2441 //constart = (UChar *)coll->image + getContractOffset(CE);
2445 return *(coll->contractionCEs +
2446 (tempconstart - coll->contractionIndex));
2471 result = *(coll->contractionCEs +
2472 (UCharOffset - coll->contractionIndex));
2479 tempconstart = (UChar *)coll->image + getContractOffset(result);
2480 if (*(coll->contractionCEs + (constart - coll->contractionIndex))
2503 return *(coll->contractionCEs + (constart - coll->contractionIndex));
2679 uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate *source, UErrorCode *status) {
2716 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
2718 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
2731 CE = *(coll->contractionCEs +
2732 (UCharOffset - coll->contractionIndex));
2738 CE = *(coll->contractionCEs +
2739 (ContractionStart - coll->contractionIndex));
2766 uint32_t firstCE = *(coll->contractionCEs + ((UChar *)coll->image+getContractOffset(CE) - coll->contractionIndex)); //UCOL_NOT_FOUND;
2775 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
2779 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
2803 CE = *(coll->contractionCEs +
2804 (UCharOffset - coll->contractionIndex));
2837 (sCC = i_getCombiningClass(miss, coll)) == 0 ||
2849 CE = *(coll->contractionCEs +
2850 (ContractionStart - coll->contractionIndex));
2862 if (i_getCombiningClass(tempchar, coll) == 0) {
2868 CE = *(coll->contractionCEs +
2869 (ContractionStart - coll->contractionIndex));
2871 CE = getDiscontiguous(coll, source, ContractionStart);
2898 uint32_t tempCE = *(coll->contractionCEs + (ContractionStart - coll->contractionIndex));
2941 CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
2969 if (source->coll->numericCollation == UCOL_ON){
3150 CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
3188 if (!source->coll->image->jamoSpecial) { // FAST PATH
3190 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, V);
3192 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, T);
3195 return UTRIE_GET32_FROM_LEAD(&coll->mapping, L);
3251 CE = UTRIE_GET32_FROM_OFFSET_TRAIL(&coll->mapping, CE&0xFFFFFF, trail);
3327 uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
3367 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
3370 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
3383 CE = *(coll->contractionCEs +
3384 (UCharOffset - coll->contractionIndex));
3392 uint32_t isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, schar);
3406 isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, lead);
3408 uint32_t finalCE = UTRIE_GET32_FROM_OFFSET_TRAIL(&coll->mapping, isZeroCE&0xFFFFFF, schar);
3426 CE = *(coll->contractionCEs +
3427 (ContractionStart - coll->contractionIndex));
3450 constart = (UChar *)coll->image + getContractOffset(CE);
3455 CE = *(coll->contractionCEs +
3456 (constart - coll->contractionIndex));
3464 while (ucol_unsafeCP(schar, coll)) {
3522 IInit_collIterate(coll, UCharOffset, noChars, &temp, status);
3530 CE = ucol_IGetNextCE(coll, &temp, status);
3567 CE = ucol_IGetNextCE(coll, &temp, status);
3644 CEOffset = (uint32_t *)coll->image + getExpansionOffset(CE);
3698 if (source->coll->numericCollation == UCOL_ON){
3917 CEOffset = (uint32_t *)coll->image + getExpansionOffset(CE);
3955 if (!source->coll->image->jamoSpecial) {
3956 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, L);
3957 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, V);
3961 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, T);
4251 ucol_getSortKey(const UCollator *coll,
4259 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source string = %vh ", coll, source,
4276 keySize = coll->sortKeyGen(coll, source, sourceLength, &result, resultLength, FALSE, &status);
4293 ucol_getSortKeyWithAllocation(const UCollator *coll,
4298 return coll->sortKeyGen(coll, source, sourceLength, pResult, 0, TRUE, pErrorCode);
4307 isCompressible(const UCollator * /*coll*/, uint8_t primary1) {
4313 int32_t ucol_getSortKeySize(const UCollator *coll, collIterate *s, int32_t currentSize, UColAttributeValue strength, int32_t len) {
4315 //const UCAConstants *UCAconsts = (UCAConstants *)((uint8_t *)coll->UCA->image + coll->image->UCAConsts);
4320 UBool doCase = (coll->caseLevel == UCOL_ON);
4321 UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
4323 UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && (compareQuad == 0);
4324 UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && (compareSec == 0);
4330 uint32_t variableTopValue = coll->variableTopValue;
4331 uint8_t UCOL_COMMON_BOT4 = (uint8_t)((coll->variableTopValue>>8)+1);
4346 uint8_t caseSwitch = coll->caseSwitch;
4347 uint8_t tertiaryMask = coll->tertiaryMask;
4348 uint8_t tertiaryCommon = coll->tertiaryCommon;
4356 order = ucol_IGetNextCE(coll, s, &status);
4378 if (coll->leadBytePermutationTable != NULL && notIsContinuation) {
4379 primary1 = coll->leadBytePermutationTable[primary1];
4419 } else if(isCompressible(coll, primary1)) {
4514 currentSize += (c3/(uint32_t)coll->tertiaryTopCount)+1;
4516 currentSize += (c3/(uint32_t)coll->tertiaryBottomCount)+1;
4573 currentSize += (c3/(uint32_t)coll->tertiaryBottomCount) + ((c3%(uint32_t)coll->tertiaryBottomCount != 0)?1:0);
4656 ucol_calcSortKey(const UCollator *coll,
4664 //const UCAConstants *UCAconsts = (UCAConstants *)((uint8_t *)coll->UCA->image + coll->image->UCAConsts);
4691 UColAttributeValue strength = coll->strength;
4697 UBool doCase = (coll->caseLevel == UCOL_ON);
4698 UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && (compareSec == 0);
4699 UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
4701 UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && (compareQuad == 0);
4703 uint32_t variableTopValue = coll->variableTopValue;
4706 uint8_t UCOL_COMMON_BOT4 = (uint8_t)((coll->variableTopValue>>8)+1);
4725 } else if(coll->normalizationMode != UCOL_OFF) {
4742 IInit_collIterate(coll, source, len, &s, status);
4749 return ucol_getSortKeySize(coll, &s, sortKeySize, strength, len);
4770 uint8_t caseSwitch = coll->caseSwitch;
4771 uint8_t tertiaryMask = coll->tertiaryMask;
4772 int8_t tertiaryAddition = coll->tertiaryAddition;
4773 uint8_t tertiaryTop = coll->tertiaryTop;
4774 uint8_t tertiaryBottom = coll->tertiaryBottom;
4775 uint8_t tertiaryCommon = coll->tertiaryCommon;
4790 order = ucol_IGetNextCE(coll, &s, status);
4813 if(notIsContinuation && coll->leadBytePermutationTable != NULL) {
4814 primary1 = coll->leadBytePermutationTable[primary1];
4862 } else if(isCompressible(coll, originalPrimary1)) {
4937 if(coll->caseFirst == UCOL_UPPER_FIRST) {
4979 while (count3 > coll->tertiaryTopCount) {
4980 *tertiaries++ = (uint8_t)(tertiaryTop - coll->tertiaryTopCount);
4981 count3 -= (uint32_t)coll->tertiaryTopCount;
4985 while (count3 > coll->tertiaryBottomCount) {
4986 *tertiaries++ = (uint8_t)(tertiaryBottom + coll->tertiaryBottomCount);
4987 count3 -= (uint32_t)coll->tertiaryBottomCount;
5016 IInit_collIterate(coll, (UChar *)source, len, &s, status);
5023 sortKeySize = ucol_getSortKeySize(coll, &s, sortKeySize, strength, len);
5162 if (coll->tertiaryCommon != UCOL_COMMON_BOT3) {
5163 while (count3 >= coll->tertiaryTopCount) {
5164 *tertiaries++ = (uint8_t)(tertiaryTop - coll->tertiaryTopCount);
5165 count3 -= (uint32_t)coll->tertiaryTopCount;
5169 while (count3 > coll->tertiaryBottomCount) {
5170 *tertiaries++ = (uint8_t)(tertiaryBottom + coll->tertiaryBottomCount);
5171 count3 -= (uint32_t)coll->tertiaryBottomCount;
5293 ucol_calcSortKeySimpleTertiary(const UCollator *coll,
5303 //const UCAConstants *UCAconsts = (UCAConstants *)((uint8_t *)coll->UCA->image + coll->image->UCAConsts);
5329 if(coll->normalizationMode != UCOL_OFF) {
5342 IInit_collIterate(coll, (UChar *)source, len, &s, status);
5349 return ucol_getSortKeySize(coll, &s, sortKeySize, coll->strength, len);
5366 uint8_t caseSwitch = coll->caseSwitch;
5367 uint8_t tertiaryMask = coll->tertiaryMask;
5368 int8_t tertiaryAddition = coll->tertiaryAddition;
5369 uint8_t tertiaryTop = coll->tertiaryTop;
5370 uint8_t tertiaryBottom = coll->tertiaryBottom;
5371 uint8_t tertiaryCommon = coll->tertiaryCommon;
5384 order = ucol_IGetNextCE(coll, &s, status);
5408 if (coll->leadBytePermutationTable != NULL && notIsContinuation) {
5409 primary1 = coll->leadBytePermutationTable[primary1];
5428 } else if(isCompressible(coll, originalPrimary1)) {
5488 while (count3 > coll->tertiaryTopCount) {
5489 *tertiaries++ = (uint8_t)(tertiaryTop - coll->tertiaryTopCount);
5490 count3 -= (uint32_t)coll->tertiaryTopCount;
5494 while (count3 > coll->tertiaryBottomCount) {
5495 *tertiaries++ = (uint8_t)(tertiaryBottom + coll->tertiaryBottomCount);
5496 count3 -= (uint32_t)coll->tertiaryBottomCount;
5508 IInit_collIterate(coll, (UChar *)source, len, &s, status);
5515 sortKeySize = ucol_getSortKeySize(coll, &s, sortKeySize, coll->strength, len);
5584 if (coll->tertiaryCommon != UCOL_COMMON3_NORMAL) {
5585 while (count3 >= coll->tertiaryTopCount) {
5586 *tertiaries++ = (uint8_t)(tertiaryTop - coll->tertiaryTopCount);
5587 count3 -= (uint32_t)coll->tertiaryTopCount;
5591 while (count3 > coll->tertiaryBottomCount) {
5592 *tertiaries++ = (uint8_t)(tertiaryBottom + coll->tertiaryBottomCount);
5593 count3 -= (uint32_t)coll->tertiaryBottomCount;
5769 ucol_nextSortKeyPart(const UCollator *coll,
5780 if( coll==NULL || iter==NULL ||
5789 UTRACE_DATA6(UTRACE_VERBOSE, "coll=%p, iter=%p, state=%d %d, dest=%p, count=%d",
5790 coll, iter, state[0], state[1], dest, count);
5819 int32_t strength = ucol_getAttribute(coll, UCOL_STRENGTH, status);
5823 if(ucol_getAttribute(coll, UCOL_CASE_LEVEL, status) == UCOL_ON) {
5839 (ucol_getAttribute(coll, UCOL_HIRAGANA_QUATERNARY_MODE, status) == UCOL_ON)?0xFE:0xFF;
5841 uint32_t LVT = (coll->alternateHandling == UCOL_SHIFTED)?(coll->variableTopValue<<16):0;
5843 UBool doingFrench = (ucol_getAttribute(coll, UCOL_FRENCH_COLLATION, status) == UCOL_ON);
5850 IInit_collIterate(coll, NULL, -1, &s, status);
5869 if(ucol_getAttribute(coll, UCOL_NORMALIZATION_MODE, status) == UCOL_ON && level < UCOL_PSK_IDENTICAL) {
5932 CE = ucol_IGetPrevCE(coll, &s, status);
5934 CE = ucol_IGetNextCE(coll, &s, status);
5986 CE = ucol_IGetNextCE(coll, &s, status);
6000 if(coll->leadBytePermutationTable != NULL){
6001 CE = (coll->leadBytePermutationTable[CE>>24] << 24) | (CE & 0x00FFFFFF);
6048 CE = ucol_IGetNextCE(coll, &s, status);
6094 CE = ucol_IGetPrevCE(coll, &s, status);
6137 if(ucol_getAttribute(coll, UCOL_CASE_LEVEL, status) == UCOL_ON) {
6157 CE = ucol_IGetNextCE(coll, &s, status);
6197 if(coll->caseFirst == UCOL_UPPER_FIRST) {
6255 CE = ucol_IGetNextCE(coll, &s, status);
6273 CE ^= coll->caseSwitch;
6274 CE &= coll->tertiaryMask;
6311 CE = ucol_IGetNextCE(coll, &s, status);
6606 ucol_addLatinOneEntry(UCollator *coll, UChar ch, uint32_t CE,
6613 tertiary = (uint8_t)((CE & coll->tertiaryMask));
6614 tertiary ^= coll->caseSwitch;
6627 if (coll->leadBytePermutationTable != NULL && !continuation) {
6628 primary1 = coll->leadBytePermutationTable[primary1];
6631 coll->latinOneCEs[ch] |= (primary1 << *primShift);
6636 coll->latinOneCEs[ch] = UCOL_BAIL_OUT_CE;
6637 coll->latinOneCEs[coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6638 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6641 coll->latinOneCEs[ch] |= (primary2 << *primShift);
6645 if(reverseSecondary && coll->frenchCollation == UCOL_ON) { // reverse secondary
6646 coll->latinOneCEs[coll->latinOneTableLen+ch] >>= 8; // make space for secondary
6647 coll->latinOneCEs[coll->latinOneTableLen+ch] |= (secondary << 24);
6649 coll->latinOneCEs[coll->latinOneTableLen+ch] |= (secondary << *secShift);
6654 coll->latinOneCEs[2*coll->latinOneTableLen+ch] |= (tertiary << *terShift);
6660 ucol_resizeLatinOneTable(UCollator *coll, int32_t size, UErrorCode *status) {
6664 coll->latinOneFailed = TRUE;
6667 int32_t sizeToCopy = ((size<coll->latinOneTableLen)?size:coll->latinOneTableLen)*sizeof(uint32_t);
6669 uprv_memcpy(newTable, coll->latinOneCEs, sizeToCopy);
6670 uprv_memcpy(newTable+size, coll->latinOneCEs+coll->latinOneTableLen, sizeToCopy);
6671 uprv_memcpy(newTable+2*size, coll->latinOneCEs+2*coll->latinOneTableLen, sizeToCopy);
6672 coll->latinOneTableLen = size;
6673 uprv_free(coll->latinOneCEs);
6674 coll->latinOneCEs = newTable;
6679 ucol_setUpLatinOne(UCollator *coll, UErrorCode *status) {
6681 if(coll->latinOneCEs == NULL) {
6682 coll->latinOneCEs = (uint32_t *)uprv_malloc(sizeof(uint32_t)*UCOL_LATINONETABLELEN*3);
6683 if(coll->latinOneCEs == NULL) {
6687 coll->latinOneTableLen = UCOL_LATINONETABLELEN;
6690 UCollationElements *it = ucol_openElements(coll, &ch, 1, status);
6695 uprv_memset(coll->latinOneCEs, 0, sizeof(uint32_t)*coll->latinOneTableLen*3);
6705 CE = coll->latinOneMapping[ch];
6707 CE = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
6708 if(CE == UCOL_NOT_FOUND && coll->UCA) {
6709 CE = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
6713 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6721 coll->latinOneCEs[ch] = UCOL_BAIL_OUT_CE;
6722 coll->latinOneCEs[coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6723 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6726 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6741 const UChar *UCharOffset = (UChar *)coll->image+getContractOffset(CE);
6745 coll->latinOneCEs[ch] = CE;
6746 coll->latinOneCEs[coll->latinOneTableLen+ch] = CE;
6747 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = CE;
6752 CE = *(coll->contractionCEs +
6753 (UCharOffset - coll->contractionIndex));
6757 uint32_t *CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
6763 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6764 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6765 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6768 ucol_addLatinOneEntry(coll, (UChar)contractionOffset, *CEOffset++, &primShift, &secShift, &terShift);
6773 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6774 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6775 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6778 ucol_addLatinOneEntry(coll, (UChar)contractionOffset, *CEOffset++, &primShift, &secShift, &terShift);
6783 ucol_addLatinOneEntry(coll, (UChar)contractionOffset++, CE, &primShift, &secShift, &terShift);
6785 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6786 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6787 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6792 if(contractionOffset == coll->latinOneTableLen) { // we need to reallocate
6793 if(!ucol_resizeLatinOneTable(coll, 2*coll->latinOneTableLen, status)) {
6806 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6819 if(contractionOffset < coll->latinOneTableLen) {
6820 if(!ucol_resizeLatinOneTable(coll, contractionOffset, status)) {
6829 coll->latinOneFailed = TRUE;
6834 void ucol_updateInternalState(UCollator *coll, UErrorCode *status) {
6836 if(coll->caseFirst == UCOL_UPPER_FIRST) {
6837 coll->caseSwitch = UCOL_CASE_SWITCH;
6839 coll->caseSwitch = UCOL_NO_CASE_SWITCH;
6842 if(coll->caseLevel == UCOL_ON || coll->caseFirst == UCOL_OFF) {
6843 coll->tertiaryMask = UCOL_REMOVE_CASE;
6844 coll->tertiaryCommon = UCOL_COMMON3_NORMAL;
6845 coll->tertiaryAddition = (int8_t)UCOL_FLAG_BIT_MASK_CASE_SW_OFF; /* Should be 0x80 */
6846 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_OFF;
6847 coll->tertiaryBottom = UCOL_COMMON_BOT3;
6849 coll->tertiaryMask = UCOL_KEEP_CASE;
6850 coll->tertiaryAddition = UCOL_FLAG_BIT_MASK_CASE_SW_ON;
6851 if(coll->caseFirst == UCOL_UPPER_FIRST) {
6852 coll->tertiaryCommon = UCOL_COMMON3_UPPERFIRST;
6853 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_UPPER;
6854 coll->tertiaryBottom = UCOL_COMMON_BOTTOM3_CASE_SW_UPPER;
6856 coll->tertiaryCommon = UCOL_COMMON3_NORMAL;
6857 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_LOWER;
6858 coll->tertiaryBottom = UCOL_COMMON_BOTTOM3_CASE_SW_LOWER;
6863 uint8_t tertiaryTotal = (uint8_t)(coll->tertiaryTop - UCOL_COMMON_BOT3-1);
6864 coll->tertiaryTopCount = (uint8_t)(UCOL_PROPORTION3*tertiaryTotal); /* we multilply double with int, but need only int */
6865 coll->tertiaryBottomCount = (uint8_t)(tertiaryTotal - coll->tertiaryTopCount);
6867 if(coll->caseLevel == UCOL_OFF && coll->strength == UCOL_TERTIARY
6868 && coll->frenchCollation == UCOL_OFF && coll->alternateHandling == UCOL_NON_IGNORABLE)
6870 coll->sortKeyGen = ucol_calcSortKeySimpleTertiary;
6872 coll->sortKeyGen = ucol_calcSortKey;
6874 if(coll->caseLevel == UCOL_OFF && coll->strength <= UCOL_TERTIARY && coll->numericCollation == UCOL_OFF
6875 && coll->alternateHandling == UCOL_NON_IGNORABLE && !coll->latinOneFailed)
6877 if(coll->latinOneCEs == NULL || coll->latinOneRegenTable) {
6878 if(ucol_setUpLatinOne(coll, status)) { // if we succeed in building latin1 table, we'll use it
6880 coll->latinOneUse = TRUE;
6882 coll->latinOneUse = FALSE;
6888 coll->latinOneUse = TRUE;
6891 coll->latinOneUse = FALSE;
6897 ucol_setVariableTop(UCollator *coll, const UChar *varTop, int32_t len, UErrorCode *status) {
6898 if(U_FAILURE(*status) || coll == NULL) {
6910 IInit_collIterate(coll, varTop, len, &s, status);
6915 uint32_t CE = ucol_IGetNextCE(coll, &s, status);
6925 uint32_t nextCE = ucol_IGetNextCE(coll, &s, status);
6931 if(coll->variableTopValue != (CE & UCOL_PRIMARYMASK)>>16) {
6932 coll->variableTopValueisDefault = FALSE;
6933 coll->variableTopValue = (CE & UCOL_PRIMARYMASK)>>16;
6942 U_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status) {
6943 if(U_FAILURE(*status) || coll == NULL) {
6946 return coll->variableTopValue<<16;
6950 ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status) {
6951 if(U_FAILURE(*status) || coll == NULL) {
6955 if(coll->variableTopValue != (varTop & UCOL_PRIMARYMASK)>>16) {
6956 coll->variableTopValueisDefault = FALSE;
6957 coll->variableTopValue = (varTop & UCOL_PRIMARYMASK)>>16;
6962 ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status) {
6963 if(U_FAILURE(*status) || coll == NULL) {
6966 UColAttributeValue oldFrench = coll->frenchCollation;
6967 UColAttributeValue oldCaseFirst = coll->caseFirst;
6971 coll->numericCollation = UCOL_ON;
6972 coll->numericCollationisDefault = FALSE;
6974 coll->numericCollation = UCOL_OFF;
6975 coll->numericCollationisDefault = FALSE;
6977 coll->numericCollationisDefault = TRUE;
6978 coll->numericCollation = (UColAttributeValue)coll->options->numericCollation;
6985 coll->hiraganaQ = UCOL_ON;
6986 coll->hiraganaQisDefault = FALSE;
6988 coll->hiraganaQ = UCOL_OFF;
6989 coll->hiraganaQisDefault = FALSE;
6991 coll->hiraganaQisDefault = TRUE;
6992 coll->hiraganaQ = (UColAttributeValue)coll->options->hiraganaQ;
6999 coll->frenchCollation = UCOL_ON;
7000 coll->frenchCollationisDefault = FALSE;
7002 coll->frenchCollation = UCOL_OFF;
7003 coll->frenchCollationisDefault = FALSE;
7005 coll->frenchCollationisDefault = TRUE;
7006 coll->frenchCollation = (UColAttributeValue)coll->options->frenchCollation;
7013 coll->alternateHandling = UCOL_SHIFTED;
7014 coll->alternateHandlingisDefault = FALSE;
7016 coll->alternateHandling = UCOL_NON_IGNORABLE;
7017 coll->alternateHandlingisDefault = FALSE;
7019 coll->alternateHandlingisDefault = TRUE;
7020 coll->alternateHandling = (UColAttributeValue)coll->options->alternateHandling ;
7027 coll->caseFirst = UCOL_LOWER_FIRST;
7028 coll->caseFirstisDefault = FALSE;
7030 coll->caseFirst = UCOL_UPPER_FIRST;
7031 coll->caseFirstisDefault = FALSE;
7033 coll->caseFirst = UCOL_OFF;
7034 coll->caseFirstisDefault = FALSE;
7036 coll->caseFirst = (UColAttributeValue)coll->options->caseFirst;
7037 coll->caseFirstisDefault = TRUE;
7044 coll->caseLevel = UCOL_ON;
7045 coll->caseLevelisDefault = FALSE;
7047 coll->caseLevel = UCOL_OFF;
7048 coll->caseLevelisDefault = FALSE;
7050 coll->caseLevel = (UColAttributeValue)coll->options->caseLevel;
7051 coll->caseLevelisDefault = TRUE;
7058 coll->normalizationMode = UCOL_ON;
7059 coll->normalizationModeisDefault = FALSE;
7062 coll->normalizationMode = UCOL_OFF;
7063 coll->normalizationModeisDefault = FALSE;
7065 coll->normalizationModeisDefault = TRUE;
7066 coll->normalizationMode = (UColAttributeValue)coll->options->normalizationMode;
7067 if(coll->normalizationMode == UCOL_ON) {
7076 coll->strengthisDefault = TRUE;
7077 coll->strength = (UColAttributeValue)coll->options->strength;
7079 coll->strengthisDefault = FALSE;
7080 coll->strength = value;
7090 if(oldFrench != coll->frenchCollation || oldCaseFirst != coll->caseFirst) {
7091 coll->latinOneRegenTable = TRUE;
7093 coll->latinOneRegenTable = FALSE;
7095 ucol_updateInternalState(coll, status);
7099 ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status) {
7100 if(U_FAILURE(*status) || coll == NULL) {
7105 return coll->numericCollation;
7107 return coll->hiraganaQ;
7109 return coll->frenchCollation;
7111 return coll->alternateHandling;
7113 return coll->caseFirst;
7115 return coll->caseLevel;
7117 return coll->normalizationMode;
7119 return coll->strength;
7129 ucol_setStrength( UCollator *coll,
7133 ucol_setAttribute(coll, UCOL_STRENGTH, strength, &status);
7137 ucol_getStrength(const UCollator *coll)
7140 return ucol_getAttribute(coll, UCOL_STRENGTH, &status);
7144 ucol_getReorderCodes(const UCollator *coll,
7157 if (coll->reorderCodesLength > destCapacity) {
7159 return coll->reorderCodesLength;
7161 for (int32_t i = 0; i < coll->reorderCodesLength; i++) {
7162 dest[i] = coll->reorderCodes[i];
7164 return coll->reorderCodesLength;
7168 ucol_setReorderCodes(UCollator *coll,
7181 uprv_free(coll->reorderCodes);
7182 coll->reorderCodes = NULL;
7183 coll->reorderCodesLength = 0;
7185 uprv_free(coll->leadBytePermutationTable);
7186 coll->leadBytePermutationTable = NULL;
7189 coll->reorderCodes = (int32_t*) uprv_malloc(reorderCodesLength * sizeof(int32_t));
7190 if (coll->reorderCodes == NULL) {
7195 coll->reorderCodes[i] = reorderCodes[i];
7197 coll->reorderCodesLength = reorderCodesLength;
7198 ucol_buildPermutationTable(coll, pErrorCode);
7200 uprv_free(coll->reorderCodes);
7201 coll->reorderCodes = NULL;
7202 coll->reorderCodesLength = 0;
7213 ucol_getVersion(const UCollator* coll,
7219 uint8_t bdVersion = coll->image->version[0];
7233 versionInfo[2] = coll->image->version[1];
7234 if(coll->UCA) {
7236 versionInfo[3] = (coll->UCA->image->UCAVersion[0] & 0x1f) << 3 | (coll->UCA->image->UCAVersion[1] & 0x07);
7245 ucol_isTailored(const UCollator *coll, const UChar u, UErrorCode *status) {
7246 if(U_FAILURE(*status) || coll == NULL || coll == coll->UCA) {
7253 CE = coll->latinOneMapping[u];
7254 if(coll->UCA && CE == coll->UCA->latinOneMapping[u]) {
7258 CE = UTRIE_GET32_FROM_LEAD(&coll->mapping, u);
7262 ContractionStart = (UChar *)coll->image+getContractOffset(CE);
7263 CE = *(coll->contractionCEs + (ContractionStart- coll->contractionIndex));
7405 const UCollator *coll = sColl->coll;
7436 sourceKeyLen = ucol_getSortKey(coll, source, sourceLength, sourceKeyP, sourceKeyLen);
7443 sourceKeyLen = ucol_getSortKey(coll, source, sourceLength, sourceKeyP, sourceKeyLen);
7446 targetKeyLen = ucol_getSortKey(coll, target, targetLength, targetKeyP, targetKeyLen);
7453 targetKeyLen = ucol_getSortKey(coll, target, targetLength, targetKeyP, targetKeyLen);
7482 const UCollator *coll = sColl->coll;
7486 UColAttributeValue strength = coll->strength;
7493 UBool checkCase = (coll->caseLevel == UCOL_ON);
7494 UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && checkSecTer;
7495 UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
7497 UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && checkQuad;
7502 uint8_t caseSwitch = coll->caseSwitch;
7503 uint8_t tertiaryMask = coll->tertiaryMask;
7506 uint32_t LVT = (shifted)?(coll->variableTopValue<<16):0;
7527 sOrder = ucol_IGetNextCE(coll, sColl, status);
7536 tOrder = ucol_IGetNextCE(coll, tColl, status);
7556 if (coll->leadBytePermutationTable != NULL && !isContinuation(sOrder)) {
7557 sOrder = (coll->leadBytePermutationTable[sOrder>>24] << 24) | (sOrder & 0x00FFFFFF);
7558 tOrder = (coll->leadBytePermutationTable[tOrder>>24] << 24) | (tOrder & 0x00FFFFFF);
7572 sOrder = ucol_IGetNextCE(coll, sColl, status);
7598 if(coll->leadBytePermutationTable != NULL){
7599 sOrder = (coll->leadBytePermutationTable[sOrder>>24] << 24) | (sOrder & 0x00FFFFFF);
7622 tOrder = ucol_IGetNextCE(coll, tColl, status);
7648 if(coll->leadBytePermutationTable != NULL){
7649 tOrder = (coll->leadBytePermutationTable[tOrder>>24] << 24) | (tOrder & 0x00FFFFFF);
7949 //result = ucol_checkIdent(&sColl, &tColl, coll->normalizationMode == UCOL_ON);
7967 ucol_strcollRegular(const UCollator *coll,
7973 IInit_collIterate(coll, source, sourceLength, &sColl, status);
7974 IInit_collIterate(coll, target, targetLength, &tColl, status);
7982 ucol_getLatinOneContraction(const UCollator *coll, int32_t strength,
7985 const UChar *UCharOffset = (UChar *)coll->image+getContractOffset(CE&0xFFF);
7993 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
7999 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
8011 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset+offset]);
8019 uint32_t isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, schar);
8025 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
8041 ucol_strcollUseLatin1( const UCollator *coll,
8049 int32_t strength = coll->strength;
8057 uint32_t *elements = coll->latinOneCEs;
8081 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8088 sOrder = ucol_getLatinOneContraction(coll, UCOL_PRIMARY, sOrder, source, &sIndex, sLen);
8095 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8127 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8133 tOrder = ucol_getLatinOneContraction(coll, UCOL_PRIMARY, tOrder, target, &tIndex, tLen);
8138 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8174 elements += coll->latinOneTableLen;
8177 if(coll->frenchCollation == UCOL_OFF) { // non French
8192 sOrder = ucol_getLatinOneContraction(coll, UCOL_SECONDARY, sOrder, source, &sIndex, sLen);
8207 tOrder = ucol_getLatinOneContraction(coll, UCOL_SECONDARY, tOrder, target, &tIndex, tLen);
8233 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8286 elements += coll->latinOneTableLen;
8298 sOrder = ucol_getLatinOneContraction(coll, UCOL_TERTIARY, sOrder, source, &sIndex, sLen);
8312 tOrder = ucol_getLatinOneContraction(coll, UCOL_TERTIARY, tOrder, target, &tIndex, tLen);
8339 ucol_strcollIter( const UCollator *coll,
8349 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, sIter=%p, tIter=%p", coll, sIter, tIter);
8355 if(sIter == NULL || tIter == NULL || coll == NULL) {
8365 IInit_collIterate(coll, NULL, -1, &sColl, status);
8366 IInit_collIterate(coll, NULL, -1, &tColl, status);
8383 if(ucol_getAttribute(coll, UCOL_NORMALIZATION_MODE, status) == UCOL_ON) {
8414 if (ucol_unsafeCP((UChar)sChar, coll) || ucol_unsafeCP((UChar)tChar, coll))
8424 while (sChar != U_SENTINEL && ucol_unsafeCP((UChar)sChar, coll));
8447 ucol_strcoll( const UCollator *coll,
8457 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source=%p, target=%p", coll, source, target);
8534 if ((pSrc != source+sourceLength && ucol_unsafeCP(*pSrc, coll)) ||
8535 (pTarg != target+targetLength && ucol_unsafeCP(*pTarg, coll)))
8545 while (equalLength>0 && ucol_unsafeCP(*pSrc, coll));
8560 if(!coll->latinOneUse || (sourceLength > 0 && *source&0xff00) || (targetLength > 0 && *target&0xff00)) {
8561 returnVal = ucol_strcollRegular(coll, source, sourceLength, target, targetLength, &status);
8563 returnVal = ucol_strcollUseLatin1(coll, source, sourceLength, target, targetLength, &status);
8571 ucol_greater( const UCollator *coll,
8577 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8583 ucol_greaterOrEqual( const UCollator *coll,
8589 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8595 ucol_equal( const UCollator *coll,
8601 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8606 ucol_getUCAVersion(const UCollator* coll, UVersionInfo info) {
8607 if(coll && coll->UCA) {
8608 uprv_memcpy(info, coll->UCA->image->UCAVersion, sizeof(UVersionInfo));