Home | History | Annotate | Download | only in i18n

Lines Matching full:coll

107     (s)->coll = (collator);
384 ucol_cloneBinary(const UCollator *coll,
396 if(coll->hasRealData == TRUE) {
397 length = coll->image->size;
399 uprv_memcpy(buffer, coll->image, length);
428 uprv_memcpy(myData->version, coll->image->version, sizeof(UVersionInfo));
430 uprv_memcpy(myData->UCAVersion, coll->image->UCAVersion, sizeof(UVersionInfo));
431 uprv_memcpy(myData->UCDVersion, coll->image->UCDVersion, sizeof(UVersionInfo));
432 uprv_memcpy(myData->formatVersion, coll->image->formatVersion, sizeof(UVersionInfo));
433 myData->jamoSpecial = coll->image->jamoSpecial;
436 uprv_memcpy(buffer+paddedsize(sizeof(UCATableHeader)), coll->options, sizeof(UColOptionSet));
445 ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize, UErrorCode *status)
461 if ((stackBuffer && !pBufferSize) || !coll){
465 if (coll->rules && coll->freeRulesOnClose) {
466 rulesSize = (int32_t)(coll->rulesLength + 1)*sizeof(UChar);
509 imageSize = ucol_cloneBinary(coll, NULL, 0, &tempStatus);
511 if (coll->freeImageOnClose) {
518 ucol_cloneBinary(coll, image, imageSize, status);
522 image = (uint8_t *)coll->image;
524 localCollator = ucol_initFromBinary(image, imageSize, coll->UCA, localCollator, status);
529 if (coll->rules) {
530 if (coll->freeRulesOnClose) {
531 localCollator->rules = u_strcpy(rules, coll->rules);
535 localCollator->rules = coll->rules;
538 localCollator->rulesLength = coll->rulesLength;
543 ucol_setAttribute(localCollator, (UColAttribute)i, ucol_getAttribute(coll, (UColAttribute)i, status), status);
549 localCollator->ucaRules = coll->ucaRules; // There should only be one copy here.
556 ucol_close(UCollator *coll)
559 UTRACE_DATA1(UTRACE_INFO, "coll = %p", coll);
560 if(coll != NULL) {
563 if(coll->validLocale != NULL) {
564 uprv_free(coll->validLocale);
566 if(coll->actualLocale != NULL) {
567 uprv_free(coll->actualLocale);
569 if(coll->requestedLocale != NULL) {
570 uprv_free(coll->requestedLocale);
572 if(coll->latinOneCEs != NULL) {
573 uprv_free(coll->latinOneCEs);
575 if(coll->options != NULL && coll->freeOptionsOnClose) {
576 uprv_free(coll->options);
578 if(coll->rules != NULL && coll->freeRulesOnClose) {
579 uprv_free((UChar *)coll->rules);
581 if(coll->image != NULL && coll->freeImageOnClose) {
582 uprv_free((UCATableHeader *)coll->image);
588 UTRACE_DATA1(UTRACE_INFO, "coll->freeOnClose: %d", coll->freeOnClose);
589 if(coll->freeOnClose){
592 uprv_free(coll);
601 ucol_cloneRuleData(const UCollator *coll, int32_t *length, UErrorCode *status)
607 if(coll->hasRealData == TRUE) {
608 *length = coll->image->size;
615 uprv_memcpy(result, coll->image, *length);
647 uprv_memcpy(myData->version, coll->image->version, sizeof(UVersionInfo));
649 uprv_memcpy(myData->UCAVersion, coll->image->UCAVersion, sizeof(UVersionInfo));
650 uprv_memcpy(myData->UCDVersion, coll->image->UCDVersion, sizeof(UVersionInfo));
651 uprv_memcpy(myData->formatVersion, coll->image->formatVersion, sizeof(UVersionInfo));
652 myData->jamoSpecial = coll->image->jamoSpecial;
655 uprv_memcpy(result+paddedsize(sizeof(UCATableHeader)), coll->options, sizeof(UColOptionSet));
694 * @param coll collator
697 inline UBool ucol_contractionEndCP(UChar c, const UCollator *coll) {
698 if (c < coll->minContrEndCP) {
710 htbyte = coll->contrEndCP[hash>>3];
723 inline uint8_t i_getCombiningClass(UChar32 c, const UCollator *coll) {
725 if ((c >= 0x300 && ucol_unsafeCP(c, coll)) || c > 0xFFFF) {
1354 inline uint32_t ucol_IGetNextCE(const UCollator *coll, collIterate *collationSource, UErrorCode *status) {
1494 order = coll->latinOneMapping[ch];
1496 order = ucol_prv_getSpecialCE(coll, ch, order, collationSource, status);
1512 order = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
1518 order = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
1522 order = ucol_prv_getSpecialCE(coll, ch, order, collationSource, status); /* and try to get the special CE */
1525 if(order == UCOL_NOT_FOUND && coll->UCA) { /* We couldn't find a good CE in the tailoring */
1527 order = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
1530 order = ucol_prv_getSpecialCE(coll->UCA, ch, order, collationSource, status);
1542 ucol_getNextCE(const UCollator *coll, collIterate *collationSource, UErrorCode *status) {
1543 return ucol_IGetNextCE(coll, collationSource, status);
1645 uint32_t baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->mapping, baseChar);
1647 if (baseOrder == UCOL_NOT_FOUND && data->coll->UCA) {
1648 baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->UCA->mapping, baseChar);
1810 * @param coll collator data
1815 inline uint32_t ucol_IGetPrevCE(const UCollator *coll, collIterate *data,
1954 if (ucol_contractionEndCP(ch, coll) && !isAtStartPrevIterate(data)) {
1955 result = ucol_prv_getSpecialPrevCE(coll, ch, UCOL_CONTRACTION, data, status);
1958 result = coll->latinOneMapping[ch];
1971 result = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
1976 result = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
1980 result = ucol_prv_getSpecialPrevCE(coll, ch, result, data, status);
1984 ucol_contractionEndCP(ch, data->coll))
1988 if(coll->UCA) {
1989 result = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
1994 if(coll->UCA) {
1995 result = ucol_prv_getSpecialPrevCE(coll->UCA, ch, result, data, status);
2012 ucol_getPrevCE(const UCollator *coll, collIterate *data,
2014 return ucol_IGetPrevCE(coll, data, status);
2020 ucol_getFirstCE(const UCollator *coll, UChar u, UErrorCode *status) {
2023 IInit_collIterate(coll, &u, 1, &colIt);
2024 order = ucol_IGetNextCE(coll, &colIt, status);
2025 /*UCOL_GETNEXTCE(order, coll, colIt, status);*/
2370 * @param coll current collator used
2376 uint32_t getDiscontiguous(const UCollator *coll, collIterate *source,
2414 //constart = (UChar *)coll->image + getContractOffset(CE);
2419 return *(coll->contractionCEs +
2420 (tempconstart - coll->contractionIndex));
2448 result = *(coll->contractionCEs +
2449 (UCharOffset - coll->contractionIndex));
2457 tempconstart = (UChar *)coll->image + getContractOffset(result);
2458 if (*(coll->contractionCEs + (constart - coll->contractionIndex))
2482 return *(coll->contractionCEs + (constart - coll->contractionIndex));
2723 uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate *source, UErrorCode *status) {
2760 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
2762 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
2775 CE = *(coll->contractionCEs +
2776 (UCharOffset - coll->contractionIndex));
2782 CE = *(coll->contractionCEs +
2783 (ContractionStart - coll->contractionIndex));
2810 uint32_t firstCE = *(coll->contractionCEs + ((UChar *)coll->image+getContractOffset(CE) - coll->contractionIndex)); //UCOL_NOT_FOUND;
2819 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
2823 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
2847 CE = *(coll->contractionCEs +
2848 (UCharOffset - coll->contractionIndex));
2881 (sCC = i_getCombiningClass(miss, coll)) == 0 ||
2893 CE = *(coll->contractionCEs +
2894 (ContractionStart - coll->contractionIndex));
2906 if (i_getCombiningClass(tempchar, coll) == 0) {
2912 CE = *(coll->contractionCEs +
2913 (ContractionStart - coll->contractionIndex));
2915 CE = getDiscontiguous(coll, source, ContractionStart);
2942 uint32_t tempCE = *(coll->contractionCEs + (ContractionStart - coll->contractionIndex));
2985 CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
3013 if (source->coll->numericCollation == UCOL_ON){
3194 CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
3232 if (!source->coll->image->jamoSpecial) { // FAST PATH
3234 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, V);
3236 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, T);
3239 return UTRIE_GET32_FROM_LEAD(&coll->mapping, L);
3289 CE = UTRIE_GET32_FROM_OFFSET_TRAIL(&coll->mapping, CE&0xFFFFFF, trail);
3377 uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
3417 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
3420 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
3433 CE = *(coll->contractionCEs +
3434 (UCharOffset - coll->contractionIndex));
3442 uint32_t isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, schar);
3456 isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, lead);
3458 uint32_t finalCE = UTRIE_GET32_FROM_OFFSET_TRAIL(&coll->mapping, isZeroCE&0xFFFFFF, schar);
3476 CE = *(coll->contractionCEs +
3477 (ContractionStart - coll->contractionIndex));
3500 constart = (UChar *)coll->image + getContractOffset(CE);
3505 CE = *(coll->contractionCEs +
3506 (constart - coll->contractionIndex));
3514 while (ucol_unsafeCP(schar, coll)) {
3572 IInit_collIterate(coll, UCharOffset, noChars, &temp);
3577 CE = ucol_IGetNextCE(coll, &temp, status);
3673 CE = ucol_IGetNextCE(coll, &temp, status);
3761 CEOffset = (uint32_t *)coll->image + getExpansionOffset(CE);
3816 if (source->coll->numericCollation == UCOL_ON){
4032 CEOffset = (uint32_t *)coll->image + getExpansionOffset(CE);
4077 if (!source->coll->image->jamoSpecial) {
4078 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, L);
4079 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, V);
4083 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, T);
4363 ucol_getSortKey(const UCollator *coll,
4371 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source string = %vh ", coll, source,
4388 keySize = coll->sortKeyGen(coll, source, sourceLength, &result, resultLength, FALSE, &status);
4405 ucol_getSortKeyWithAllocation(const UCollator *coll,
4410 return coll->sortKeyGen(coll, source, sourceLength, pResult, 0, TRUE, pErrorCode);
4417 int32_t ucol_getSortKeySize(const UCollator *coll, collIterate *s, int32_t currentSize, UColAttributeValue strength, int32_t len) {
4419 //const UCAConstants *UCAconsts = (UCAConstants *)((uint8_t *)coll->UCA->image + coll->image->UCAConsts);
4424 UBool doCase = (coll->caseLevel == UCOL_ON);
4425 UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
4427 UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && (compareQuad == 0);
4428 UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && (compareSec == 0);
4434 uint32_t variableTopValue = coll->variableTopValue;
4435 uint8_t UCOL_COMMON_BOT4 = (uint8_t)((coll->variableTopValue>>8)+1);
4450 uint8_t caseSwitch = coll->caseSwitch;
4451 uint8_t tertiaryMask = coll->tertiaryMask;
4452 uint8_t tertiaryCommon = coll->tertiaryCommon;
4460 order = ucol_IGetNextCE(coll, s, &status);
4619 currentSize += (c3/(uint32_t)coll->tertiaryTopCount)+1;
4621 currentSize += (c3/(uint32_t)coll->tertiaryBottomCount)+1;
4678 currentSize += (c3/(uint32_t)coll->tertiaryBottomCount) + ((c3%(uint32_t)coll->tertiaryBottomCount != 0)?1:0);
4761 ucol_calcSortKey(const UCollator *coll,
4769 //const UCAConstants *UCAconsts = (UCAConstants *)((uint8_t *)coll->UCA->image + coll->image->UCAConsts);
4798 UColAttributeValue strength = coll->strength;
4804 UBool doCase = (coll->caseLevel == UCOL_ON);
4805 UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && (compareSec == 0);
4806 UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
4808 UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && (compareQuad == 0);
4809 /*const uint8_t *scriptOrder = coll->scriptOrder;*/
4811 uint32_t variableTopValue = coll->variableTopValue;
4814 uint8_t UCOL_COMMON_BOT4 = (uint8_t)((coll->variableTopValue>>8)+1);
4833 } else if(coll->normalizationMode != UCOL_OFF) {
4865 IInit_collIterate(coll, (UChar *)source, len, &s);
4871 int32_t keyLen = ucol_getSortKeySize(coll, &s, sortKeySize, strength, len);
4896 uint8_t caseSwitch = coll->caseSwitch;
4897 uint8_t tertiaryMask = coll->tertiaryMask;
4898 int8_t tertiaryAddition = coll->tertiaryAddition;
4899 uint8_t tertiaryTop = coll->tertiaryTop;
4900 uint8_t tertiaryBottom = coll->tertiaryBottom;
4901 uint8_t tertiaryCommon = coll->tertiaryCommon;
4916 order = ucol_IGetNextCE(coll, &s, status);
5064 if(coll->caseFirst == UCOL_UPPER_FIRST) {
5106 while (count3 > coll->tertiaryTopCount) {
5107 *tertiaries++ = (uint8_t)(tertiaryTop - coll->tertiaryTopCount);
5108 count3 -= (uint32_t)coll->tertiaryTopCount;
5112 while (count3 > coll->tertiaryBottomCount) {
5113 *tertiaries++ = (uint8_t)(tertiaryBottom + coll->tertiaryBottomCount);
5114 count3 -= (uint32_t)coll->tertiaryBottomCount;
5143 IInit_collIterate(coll, (UChar *)source, len, &s);
5147 sortKeySize = ucol_getSortKeySize(coll, &s, sortKeySize, strength, len);
5286 if (coll->tertiaryCommon != UCOL_COMMON_BOT3) {
5287 while (count3 >= coll->tertiaryTopCount) {
5288 *tertiaries++ = (uint8_t)(tertiaryTop - coll->tertiaryTopCount);
5289 count3 -= (uint32_t)coll->tertiaryTopCount;
5293 while (count3 > coll->tertiaryBottomCount) {
5294 *tertiaries++ = (uint8_t)(tertiaryBottom + coll->tertiaryBottomCount);
5295 count3 -= (uint32_t)coll->tertiaryBottomCount;
5421 ucol_calcSortKeySimpleTertiary(const UCollator *coll,
5431 //const UCAConstants *UCAconsts = (UCAConstants *)((uint8_t *)coll->UCA->image + coll->image->UCAConsts);
5459 if(coll->normalizationMode != UCOL_OFF && UNORM_YES != unorm_quickCheck(source, len, UNORM_FCD, status)) {
5490 IInit_collIterate(coll, (UChar *)source, len, &s);
5496 int32_t t = ucol_getSortKeySize(coll, &s, sortKeySize, coll->strength, len);
5517 uint8_t caseSwitch = coll->caseSwitch;
5518 uint8_t tertiaryMask = coll->tertiaryMask;
5519 int8_t tertiaryAddition = coll->tertiaryAddition;
5520 uint8_t tertiaryTop = coll->tertiaryTop;
5521 uint8_t tertiaryBottom = coll->tertiaryBottom;
5522 uint8_t tertiaryCommon = coll->tertiaryCommon;
5535 order = ucol_IGetNextCE(coll, &s, status);
5636 while (count3 > coll->tertiaryTopCount) {
5637 *tertiaries++ = (uint8_t)(tertiaryTop - coll->tertiaryTopCount);
5638 count3 -= (uint32_t)coll->tertiaryTopCount;
5642 while (count3 > coll->tertiaryBottomCount) {
5643 *tertiaries++ = (uint8_t)(tertiaryBottom + coll->tertiaryBottomCount);
5644 count3 -= (uint32_t)coll->tertiaryBottomCount;
5656 IInit_collIterate(coll, (UChar *)source, len, &s);
5660 sortKeySize = ucol_getSortKeySize(coll, &s, sortKeySize, coll->strength, len);
5729 if (coll->tertiaryCommon != UCOL_COMMON3_NORMAL) {
5730 while (count3 >= coll->tertiaryTopCount) {
5731 *tertiaries++ = (uint8_t)(tertiaryTop - coll->tertiaryTopCount);
5732 count3 -= (uint32_t)coll->tertiaryTopCount;
5736 while (count3 > coll->tertiaryBottomCount) {
5737 *tertiaries++ = (uint8_t)(tertiaryBottom + coll->tertiaryBottomCount);
5738 count3 -= (uint32_t)coll->tertiaryBottomCount;
5918 ucol_nextSortKeyPart(const UCollator *coll,
5929 if( coll==NULL || iter==NULL ||
5938 UTRACE_DATA6(UTRACE_VERBOSE, "coll=%p, iter=%p, state=%d %d, dest=%p, count=%d",
5939 coll, iter, state[0], state[1], dest, count);
5968 int32_t strength = ucol_getAttribute(coll, UCOL_STRENGTH, status);
5972 if(ucol_getAttribute(coll, UCOL_CASE_LEVEL, status) == UCOL_ON) {
5988 (ucol_getAttribute(coll, UCOL_HIRAGANA_QUATERNARY_MODE, status) == UCOL_ON)?0xFE:0xFF;
5990 uint32_t LVT = (coll->alternateHandling == UCOL_SHIFTED)?(coll->variableTopValue<<16):0;
5992 UBool doingFrench = (ucol_getAttribute(coll, UCOL_FRENCH_COLLATION, status) == UCOL_ON);
5999 IInit_collIterate(coll, NULL, -1, &s);
6014 if(ucol_getAttribute(coll, UCOL_NORMALIZATION_MODE, status) == UCOL_ON && level < UCOL_PSK_IDENTICAL) {
6077 CE = ucol_IGetPrevCE(coll, &s, status);
6079 CE = ucol_IGetNextCE(coll, &s, status);
6131 CE = ucol_IGetNextCE(coll, &s, status);
6188 CE = ucol_IGetNextCE(coll, &s, status);
6234 CE = ucol_IGetPrevCE(coll, &s, status);
6277 if(ucol_getAttribute(coll, UCOL_CASE_LEVEL, status) == UCOL_ON) {
6296 CE = ucol_IGetNextCE(coll, &s, status);
6331 if(coll->caseFirst == UCOL_UPPER_FIRST) {
6389 CE = ucol_IGetNextCE(coll, &s, status);
6407 CE ^= coll->caseSwitch;
6408 CE &= coll->tertiaryMask;
6445 CE = ucol_IGetNextCE(coll, &s, status);
6740 ucol_addLatinOneEntry(UCollator *coll, UChar ch, uint32_t CE,
6746 tertiary = (uint8_t)((CE & coll->tertiaryMask));
6747 tertiary ^= coll->caseSwitch;
6760 coll->latinOneCEs[ch] |= (primary1 << *primShift);
6765 coll->latinOneCEs[ch] = UCOL_BAIL_OUT_CE;
6766 coll->latinOneCEs[coll
6767 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6770 coll->latinOneCEs[ch] |= (primary2 << *primShift);
6774 if(reverseSecondary && coll->frenchCollation == UCOL_ON) { // reverse secondary
6775 coll->latinOneCEs[coll->latinOneTableLen+ch] >>= 8; // make space for secondary
6776 coll->latinOneCEs[coll->latinOneTableLen+ch] |= (secondary << 24);
6778 coll->latinOneCEs[coll->latinOneTableLen+ch] |= (secondary << *secShift);
6783 coll->latinOneCEs[2*coll->latinOneTableLen+ch] |= (tertiary << *terShift);
6789 ucol_resizeLatinOneTable(UCollator *coll, int32_t size, UErrorCode *status) {
6793 coll->latinOneFailed = TRUE;
6796 int32_t sizeToCopy = ((size<coll->latinOneTableLen)?size:coll->latinOneTableLen)*sizeof(uint32_t);
6798 uprv_memcpy(newTable, coll->latinOneCEs, sizeToCopy);
6799 uprv_memcpy(newTable+size, coll->latinOneCEs+coll->latinOneTableLen, sizeToCopy);
6800 uprv_memcpy(newTable+2*size, coll->latinOneCEs+2*coll->latinOneTableLen, sizeToCopy);
6801 coll->latinOneTableLen = size;
6802 uprv_free(coll->latinOneCEs);
6803 coll->latinOneCEs = newTable;
6808 ucol_setUpLatinOne(UCollator *coll, UErrorCode *status) {
6810 if(coll->latinOneCEs == NULL) {
6811 coll->latinOneCEs = (uint32_t *)uprv_malloc(sizeof(uint32_t)*UCOL_LATINONETABLELEN*3);
6812 if(coll->latinOneCEs == NULL) {
6816 coll->latinOneTableLen = UCOL_LATINONETABLELEN;
6819 UCollationElements *it = ucol_openElements(coll, &ch, 1, status);
6824 uprv_memset(coll->latinOneCEs, 0, sizeof(uint32_t)*coll->latinOneTableLen*3);
6834 CE = coll->latinOneMapping[ch];
6836 CE = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
6837 if(CE == UCOL_NOT_FOUND && coll->UCA) {
6838 CE = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
6842 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6850 coll->latinOneCEs[ch] = UCOL_BAIL_OUT_CE;
6851 coll->latinOneCEs[coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6852 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6855 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6870 const UChar *UCharOffset = (UChar *)coll->image+getContractOffset(CE);
6874 coll->latinOneCEs[ch] = CE;
6875 coll->latinOneCEs[coll->latinOneTableLen+ch] = CE;
6876 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = CE;
6881 CE = *(coll->contractionCEs +
6882 (UCharOffset - coll->contractionIndex));
6886 uint32_t *CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
6892 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6893 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6894 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6897 ucol_addLatinOneEntry(coll, (UChar)contractionOffset, *CEOffset++, &primShift, &secShift, &terShift);
6902 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6903 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6904 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6907 ucol_addLatinOneEntry(coll, (UChar)contractionOffset, *CEOffset++, &primShift, &secShift, &terShift);
6912 ucol_addLatinOneEntry(coll, (UChar)contractionOffset++, CE, &primShift, &secShift, &terShift);
6914 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6915 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6916 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6921 if(contractionOffset == coll->latinOneTableLen) { // we need to reallocate
6922 if(!ucol_resizeLatinOneTable(coll, 2*coll->latinOneTableLen, status)) {
6935 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6948 if(contractionOffset < coll->latinOneTableLen) {
6949 if(!ucol_resizeLatinOneTable(coll, contractionOffset, status)) {
6958 coll->latinOneFailed = TRUE;
6963 void ucol_updateInternalState(UCollator *coll, UErrorCode *status) {
6965 if(coll->caseFirst == UCOL_UPPER_FIRST) {
6966 coll->caseSwitch = UCOL_CASE_SWITCH;
6968 coll->caseSwitch = UCOL_NO_CASE_SWITCH;
6971 if(coll->caseLevel == UCOL_ON || coll->caseFirst == UCOL_OFF) {
6972 coll->tertiaryMask = UCOL_REMOVE_CASE;
6973 coll->tertiaryCommon = UCOL_COMMON3_NORMAL;
6974 coll->tertiaryAddition = (int8_t)UCOL_FLAG_BIT_MASK_CASE_SW_OFF; /* Should be 0x80 */
6975 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_OFF;
6976 coll->tertiaryBottom = UCOL_COMMON_BOT3;
6978 coll->tertiaryMask = UCOL_KEEP_CASE;
6979 coll->tertiaryAddition = UCOL_FLAG_BIT_MASK_CASE_SW_ON;
6980 if(coll->caseFirst == UCOL_UPPER_FIRST) {
6981 coll->tertiaryCommon = UCOL_COMMON3_UPPERFIRST;
6982 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_UPPER;
6983 coll->tertiaryBottom = UCOL_COMMON_BOTTOM3_CASE_SW_UPPER;
6985 coll->tertiaryCommon = UCOL_COMMON3_NORMAL;
6986 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_LOWER;
6987 coll->tertiaryBottom = UCOL_COMMON_BOTTOM3_CASE_SW_LOWER;
6992 uint8_t tertiaryTotal = (uint8_t)(coll->tertiaryTop - UCOL_COMMON_BOT3-1);
6993 coll->tertiaryTopCount = (uint8_t)(UCOL_PROPORTION3*tertiaryTotal); /* we multilply double with int, but need only int */
6994 coll->tertiaryBottomCount = (uint8_t)(tertiaryTotal - coll->tertiaryTopCount);
6996 if(coll->caseLevel == UCOL_OFF && coll->strength == UCOL_TERTIARY
6997 && coll->frenchCollation == UCOL_OFF && coll->alternateHandling == UCOL_NON_IGNORABLE)
6999 coll->sortKeyGen = ucol_calcSortKeySimpleTertiary;
7001 coll->sortKeyGen = ucol_calcSortKey;
7003 if(coll->caseLevel == UCOL_OFF && coll->strength <= UCOL_TERTIARY && coll->numericCollation == UCOL_OFF
7004 && coll->alternateHandling == UCOL_NON_IGNORABLE && !coll->latinOneFailed)
7006 if(coll->latinOneCEs == NULL || coll->latinOneRegenTable) {
7007 if(ucol_setUpLatinOne(coll, status)) { // if we succeed in building latin1 table, we'll use it
7009 coll->latinOneUse = TRUE;
7011 coll->latinOneUse = FALSE;
7017 coll->latinOneUse = TRUE;
7020 coll->latinOneUse = FALSE;
7026 ucol_setVariableTop(UCollator *coll, const UChar *varTop, int32_t len, UErrorCode *status) {
7027 if(U_FAILURE(*status) || coll == NULL) {
7039 IInit_collIterate(coll, varTop, len, &s);
7041 uint32_t CE = ucol_IGetNextCE(coll, &s, status);
7051 uint32_t nextCE = ucol_IGetNextCE(coll, &s, status);
7057 if(coll->variableTopValue != (CE & UCOL_PRIMARYMASK)>>16) {
7058 coll->variableTopValueisDefault = FALSE;
7059 coll->variableTopValue = (CE & UCOL_PRIMARYMASK)>>16;
7068 U_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status) {
7069 if(U_FAILURE(*status) || coll == NULL) {
7072 return coll->variableTopValue<<16;
7076 ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status) {
7077 if(U_FAILURE(*status) || coll == NULL) {
7081 if(coll->variableTopValue != (varTop & UCOL_PRIMARYMASK)>>16) {
7082 coll->variableTopValueisDefault = FALSE;
7083 coll->variableTopValue = (varTop & UCOL_PRIMARYMASK)>>16;
7088 ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status) {
7089 if(U_FAILURE(*status) || coll == NULL) {
7092 UColAttributeValue oldFrench = coll->frenchCollation;
7093 UColAttributeValue oldCaseFirst = coll->caseFirst;
7097 coll->numericCollation = UCOL_ON;
7098 coll->numericCollationisDefault = FALSE;
7100 coll->numericCollation = UCOL_OFF;
7101 coll->numericCollationisDefault = FALSE;
7103 coll->numericCollationisDefault = TRUE;
7104 coll->numericCollation = (UColAttributeValue)coll->options->numericCollation;
7111 coll->hiraganaQ = UCOL_ON;
7112 coll->hiraganaQisDefault = FALSE;
7114 coll->hiraganaQ = UCOL_OFF;
7115 coll->hiraganaQisDefault = FALSE;
7117 coll->hiraganaQisDefault = TRUE;
7118 coll->hiraganaQ = (UColAttributeValue)coll->options->hiraganaQ;
7125 coll->frenchCollation = UCOL_ON;
7126 coll->frenchCollationisDefault = FALSE;
7128 coll->frenchCollation = UCOL_OFF;
7129 coll->frenchCollationisDefault = FALSE;
7131 coll->frenchCollationisDefault = TRUE;
7132 coll->frenchCollation = (UColAttributeValue)coll->options->frenchCollation;
7139 coll->alternateHandling = UCOL_SHIFTED;
7140 coll->alternateHandlingisDefault = FALSE;
7142 coll->alternateHandling = UCOL_NON_IGNORABLE;
7143 coll->alternateHandlingisDefault = FALSE;
7145 coll->alternateHandlingisDefault = TRUE;
7146 coll->alternateHandling = (UColAttributeValue)coll->options->alternateHandling ;
7153 coll->caseFirst = UCOL_LOWER_FIRST;
7154 coll->caseFirstisDefault = FALSE;
7156 coll->caseFirst = UCOL_UPPER_FIRST;
7157 coll->caseFirstisDefault = FALSE;
7159 coll->caseFirst = UCOL_OFF;
7160 coll->caseFirstisDefault = FALSE;
7162 coll->caseFirst = (UColAttributeValue)coll->options->caseFirst;
7163 coll->caseFirstisDefault = TRUE;
7170 coll->caseLevel = UCOL_ON;
7171 coll->caseLevelisDefault = FALSE;
7173 coll->caseLevel = UCOL_OFF;
7174 coll->caseLevelisDefault = FALSE;
7176 coll->caseLevel = (UColAttributeValue)coll->options->caseLevel;
7177 coll->caseLevelisDefault = TRUE;
7184 coll->normalizationMode = UCOL_ON;
7185 coll->normalizationModeisDefault = FALSE;
7187 coll->normalizationMode = UCOL_OFF;
7188 coll->normalizationModeisDefault = FALSE;
7190 coll->normalizationModeisDefault = TRUE;
7191 coll->normalizationMode = (UColAttributeValue)coll->options->normalizationMode;
7198 coll->strengthisDefault = TRUE;
7199 coll->strength = (UColAttributeValue)coll->options->strength;
7201 coll->strengthisDefault = FALSE;
7202 coll->strength = value;
7212 if(oldFrench != coll->frenchCollation || oldCaseFirst != coll->caseFirst) {
7213 coll->latinOneRegenTable = TRUE;
7215 coll->latinOneRegenTable = FALSE;
7217 ucol_updateInternalState(coll, status);
7221 ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status) {
7222 if(U_FAILURE(*status) || coll == NULL) {
7227 return coll->numericCollation;
7229 return coll->hiraganaQ;
7231 return coll->frenchCollation;
7233 return coll->alternateHandling;
7235 return coll->caseFirst;
7237 return coll->caseLevel;
7239 return coll->normalizationMode;
7241 return coll->strength;
7251 ucol_setStrength( UCollator *coll,
7255 ucol_setAttribute(coll, UCOL_STRENGTH, strength, &status);
7259 ucol_getStrength(const UCollator *coll)
7262 return ucol_getAttribute(coll, UCOL_STRENGTH, &status);
7271 ucol_getVersion(const UCollator* coll,
7277 uint8_t bdVersion = coll->image->version[0];
7291 versionInfo[2] = coll->image->version[1];
7292 if(coll->UCA) {
7294 versionInfo[3] = (coll->UCA->image->UCAVersion[0] & 0x1f) << 3 | (coll->UCA->image->UCAVersion[1] & 0x07);
7303 ucol_isTailored(const UCollator *coll, const UChar u, UErrorCode *status) {
7304 if(U_FAILURE(*status) || coll == NULL || coll == coll->UCA) {
7311 CE = coll->latinOneMapping[u];
7312 if(coll->UCA && CE == coll->UCA->latinOneMapping[u]) {
7316 CE = UTRIE_GET32_FROM_LEAD(&coll->mapping, u);
7320 ContractionStart = (UChar *)coll->image+getContractOffset(CE);
7321 CE = *(coll->contractionCEs + (ContractionStart- coll->contractionIndex));
7541 const UCollator *coll = sColl->coll;
7574 sourceKeyLen = ucol_getSortKey(coll, source, sourceLength, sourceKeyP, sourceKeyLen);
7581 sourceKeyLen = ucol_getSortKey(coll, source, sourceLength, sourceKeyP, sourceKeyLen);
7584 targetKeyLen = ucol_getSortKey(coll, target, targetLength, targetKeyP, targetKeyLen);
7591 targetKeyLen = ucol_getSortKey(coll, target, targetLength, targetKeyP, targetKeyLen);
7617 // const UCollator *coll,
7626 const UCollator *coll = sColl->coll;
7630 UColAttributeValue strength = coll->strength;
7637 UBool checkCase = (coll->caseLevel == UCOL_ON);
7638 UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && checkSecTer;
7639 UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
7641 UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && checkQuad;
7646 uint8_t caseSwitch = coll->caseSwitch;
7647 uint8_t tertiaryMask = coll->tertiaryMask;
7650 uint32_t LVT = (shifted)?(coll->variableTopValue<<16):0;
7671 sOrder = ucol_IGetNextCE(coll, sColl, status);
7680 tOrder = ucol_IGetNextCE(coll, tColl, status);
7710 sOrder = ucol_IGetNextCE(coll, sColl, status);
7757 tOrder = ucol_IGetNextCE(coll, tColl, status);
8079 //result = ucol_checkIdent(&sColl, &tColl, coll->normalizationMode == UCOL_ON);
8101 ucol_getLatinOneContraction(const UCollator *coll, int32_t strength,
8104 const UChar *UCharOffset = (UChar *)coll->image+getContractOffset(CE&0xFFF);
8112 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
8118 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
8130 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset+offset]);
8138 uint32_t isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, schar);
8144 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
8160 ucol_strcollUseLatin1( const UCollator *coll,
8168 int32_t strength = coll->strength;
8176 uint32_t *elements = coll->latinOneCEs;
8201 //return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8208 sOrder = ucol_getLatinOneContraction(coll, UCOL_PRIMARY, sOrder, source, &sIndex, sLen);
8216 //return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8249 //return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8255 tOrder = ucol_getLatinOneContraction(coll, UCOL_PRIMARY, tOrder, target, &tIndex, tLen);
8261 //return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8297 elements += coll->latinOneTableLen;
8300 if(coll->frenchCollation == UCOL_OFF) { // non French
8315 sOrder = ucol_getLatinOneContraction(coll, UCOL_SECONDARY, sOrder, source, &sIndex, sLen);
8330 tOrder = ucol_getLatinOneContraction(coll, UCOL_SECONDARY, tOrder, target, &tIndex, tLen);
8357 //return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
8410 elements += coll->latinOneTableLen;
8422 sOrder = ucol_getLatinOneContraction(coll, UCOL_TERTIARY, sOrder, source, &sIndex, sLen);
8436 tOrder = ucol_getLatinOneContraction(coll, UCOL_TERTIARY, tOrder, target, &tIndex, tLen);
8464 IInit_collIterate(coll, source, sLen, &sColl);
8465 IInit_collIterate(coll, target, tLen, &tColl);
8471 ucol_strcollIter( const UCollator *coll,
8481 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, sIter=%p, tIter=%p", coll, sIter, tIter);
8487 if(sIter == NULL || tIter == NULL || coll == NULL) {
8504 IInit_collIterate(coll, NULL, -1, &sColl);
8507 IInit_collIterate(coll, NULL, -1, &tColl);
8511 if(ucol_getAttribute(coll, UCOL_NORMALIZATION_MODE, status) == UCOL_ON) {
8542 if (ucol_unsafeCP((UChar)sChar, coll) || ucol_unsafeCP((UChar)tChar, coll))
8552 while (sChar != U_SENTINEL && ucol_unsafeCP((UChar)sChar, coll));
8575 ucol_strcoll( const UCollator *coll,
8585 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source=%p, target=%p", coll, source, target);
8662 if (pSrc != source+sourceLength && ucol_unsafeCP(*pSrc, coll) ||
8663 pTarg != target+targetLength && ucol_unsafeCP(*pTarg, coll))
8673 while (equalLength>0 && ucol_unsafeCP(*pSrc, coll));
8688 if(!coll->latinOneUse || (sourceLength > 0 && *source&0xff00) || (targetLength > 0 && *target&0xff00)) {
8691 IInit_collIterate(coll, source, sourceLength, &sColl);
8692 IInit_collIterate(coll, target, targetLength, &tColl);
8695 returnVal = ucol_strcollUseLatin1(coll, source, sourceLength, target, targetLength, &status);
8703 ucol_greater( const UCollator *coll,
8709 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8715 ucol_greaterOrEqual( const UCollator *coll,
8721 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8727 ucol_equal( const UCollator *coll,
8733 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8738 ucol_getUCAVersion(const UCollator* coll, UVersionInfo info) {
8739 if(coll && coll->UCA) {
8740 uprv_memcpy(info, coll->UCA->image->UCAVersion, sizeof(UVersionInfo));