Lines Matching defs:coll
122 (s)->coll = (collator);
477 ucol_cloneBinary(const UCollator *coll,
489 if(coll->hasRealData == TRUE) {
490 length = coll->image->size;
492 uprv_memcpy(buffer, coll->image, length);
521 uprv_memcpy(myData->version, coll->image->version, sizeof(UVersionInfo));
523 uprv_memcpy(myData->UCAVersion, coll->image->UCAVersion, sizeof(UVersionInfo));
524 uprv_memcpy(myData->UCDVersion, coll->image->UCDVersion, sizeof(UVersionInfo));
525 uprv_memcpy(myData->formatVersion, coll->image->formatVersion, sizeof(UVersionInfo));
526 myData->jamoSpecial = coll->image->jamoSpecial;
529 uprv_memcpy(buffer+paddedsize(sizeof(UCATableHeader)), coll->options, sizeof(UColOptionSet));
538 ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t * pBufferSize, UErrorCode *status)
559 if ((stackBuffer && !pBufferSize) || !coll){
564 if (coll->rules && coll->freeRulesOnClose) {
565 rulesSize = (int32_t)(coll->rulesLength + 1)*sizeof(UChar);
570 if (coll->defaultReorderCodes) {
571 defaultReorderCodesSize = coll->defaultReorderCodesLength * sizeof(int32_t);
574 if (coll->reorderCodes) {
575 reorderCodesSize = coll->reorderCodesLength * sizeof(int32_t);
578 if (coll->leadBytePermutationTable) {
624 imageSize = ucol_cloneBinary(coll, NULL, 0, &tempStatus);
626 if (coll->freeImageOnClose) {
633 ucol_cloneBinary(coll, image, imageSize, status);
637 image = (uint8_t *)coll->image;
639 localCollator = ucol_initFromBinary(image, imageSize, coll->UCA, localCollator, status);
644 if (coll->rules) {
645 if (coll->freeRulesOnClose) {
646 localCollator->rules = u_strcpy(rules, coll->rules);
650 localCollator->rules = coll->rules;
653 localCollator->rulesLength = coll->rulesLength;
657 if (coll->defaultReorderCodes) {
659 (int32_t*) uprv_memcpy(defaultReorderCodes, coll->defaultReorderCodes, coll->defaultReorderCodesLength * sizeof(int32_t));
660 localCollator->defaultReorderCodesLength = coll->defaultReorderCodesLength;
663 if (coll->reorderCodes) {
665 (int32_t*)uprv_memcpy(reorderCodes, coll->reorderCodes, coll->reorderCodesLength * sizeof(int32_t));
666 localCollator->reorderCodesLength = coll->reorderCodesLength;
669 if (coll->leadBytePermutationTable) {
671 (uint8_t*) uprv_memcpy(leadBytePermutationTable, coll->leadBytePermutationTable, 256);
677 ucol_setAttribute(localCollator, (UColAttribute)i, ucol_getAttribute(coll, (UColAttribute)i, status), status);
683 localCollator->ucaRules = coll->ucaRules; // There should only be one copy here.
690 ucol_close(UCollator *coll)
693 UTRACE_DATA1(UTRACE_INFO, "coll = %p", coll);
694 if(coll != NULL) {
697 if(coll->validLocale != NULL) {
698 uprv_free(coll->validLocale);
700 if(coll->actualLocale != NULL) {
701 uprv_free(coll->actualLocale);
703 if(coll->requestedLocale != NULL) {
704 uprv_free(coll->requestedLocale);
706 if(coll->latinOneCEs != NULL) {
707 uprv_free(coll->latinOneCEs);
709 if(coll->options != NULL && coll->freeOptionsOnClose) {
710 uprv_free(coll->options);
712 if(coll->rules != NULL && coll->freeRulesOnClose) {
713 uprv_free((UChar *)coll->rules);
715 if(coll->image != NULL && coll->freeImageOnClose) {
716 uprv_free((UCATableHeader *)coll->image);
719 if(coll->leadBytePermutationTable != NULL && coll->freeLeadBytePermutationTableOnClose == TRUE) {
720 uprv_free(coll->leadBytePermutationTable);
722 if(coll->defaultReorderCodes != NULL && coll->freeDefaultReorderCodesOnClose == TRUE) {
723 uprv_free(coll->defaultReorderCodes);
725 if(coll->reorderCodes != NULL && coll->freeReorderCodesOnClose == TRUE) {
726 uprv_free(coll->reorderCodes);
732 UTRACE_DATA1(UTRACE_INFO, "coll->freeOnClose: %d", coll->freeOnClose);
733 if(coll->freeOnClose){
736 uprv_free(coll);
745 ucol_cloneRuleData(const UCollator *coll, int32_t *length, UErrorCode *status)
751 if(coll->hasRealData == TRUE) {
752 *length = coll->image->size;
759 uprv_memcpy(result, coll->image, *length);
791 uprv_memcpy(myData->version, coll->image->version, sizeof(UVersionInfo));
793 uprv_memcpy(myData->UCAVersion, coll->image->UCAVersion, sizeof(UVersionInfo));
794 uprv_memcpy(myData->UCDVersion, coll->image->UCDVersion, sizeof(UVersionInfo));
795 uprv_memcpy(myData->formatVersion, coll->image->formatVersion, sizeof(UVersionInfo));
796 myData->jamoSpecial = coll->image->jamoSpecial;
799 uprv_memcpy(result+paddedsize(sizeof(UCATableHeader)), coll->options, sizeof(UColOptionSet));
841 * @param coll collator
844 inline UBool ucol_contractionEndCP(UChar c, const UCollator *coll) {
845 if (c < coll->minContrEndCP) {
857 htbyte = coll->contrEndCP[hash>>3];
870 inline uint8_t i_getCombiningClass(UChar32 c, const UCollator *coll) {
872 if ((c >= 0x300 && ucol_unsafeCP(c, coll)) || c > 0xFFFF) {
1485 inline uint32_t ucol_IGetNextCE(const UCollator *coll, collIterate *collationSource, UErrorCode *status) {
1626 order = coll->latinOneMapping[ch];
1628 order = ucol_prv_getSpecialCE(coll, ch, order, collationSource, status);
1644 order = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
1650 order = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
1654 order = ucol_prv_getSpecialCE(coll, ch, order, collationSource, status); /* and try to get the special CE */
1657 if(order == UCOL_NOT_FOUND && coll->UCA) { /* We couldn't find a good CE in the tailoring */
1659 order = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
1662 order = ucol_prv_getSpecialCE(coll->UCA, ch, order, collationSource, status);
1676 ucol_getNextCE(const UCollator *coll, collIterate *collationSource, UErrorCode *status) {
1677 return ucol_IGetNextCE(coll, collationSource, status);
1749 uint32_t baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->mapping, baseChar);
1751 if (baseOrder == UCOL_NOT_FOUND && data->coll->UCA) {
1752 baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->UCA->mapping, baseChar);
1980 * @param coll collator data
1985 inline uint32_t ucol_IGetPrevCE(const UCollator *coll, collIterate *data,
2125 if (ucol_contractionEndCP(ch, coll) && !isAtStartPrevIterate(data)) {
2126 result = ucol_prv_getSpecialPrevCE(coll, ch, UCOL_CONTRACTION, data, status);
2129 result = coll->latinOneMapping[ch];
2142 result = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
2147 result = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
2151 result = ucol_prv_getSpecialPrevCE(coll, ch, result, data, status);
2155 ucol_contractionEndCP(ch, data->coll))
2159 if(coll->UCA) {
2160 result = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
2165 if(coll->UCA) {
2166 result = ucol_prv_getSpecialPrevCE(coll->UCA, ch, result, data, status);
2184 ucol_getPrevCE(const UCollator *coll, collIterate *data,
2186 return ucol_IGetPrevCE(coll, data, status);
2192 ucol_getFirstCE(const UCollator *coll, UChar u, UErrorCode *status) {
2194 IInit_collIterate(coll, &u, 1, &colIt, status);
2198 return ucol_IGetNextCE(coll, &colIt, status);
2452 * @param coll current collator used
2458 uint32_t getDiscontiguous(const UCollator *coll, collIterate *source,
2492 //constart = (UChar *)coll->image + getContractOffset(CE);
2496 return *(coll->contractionCEs +
2497 (tempconstart - coll->contractionIndex));
2522 result = *(coll->contractionCEs +
2523 (UCharOffset - coll->contractionIndex));
2530 tempconstart = (UChar *)coll->image + getContractOffset(result);
2531 if (*(coll->contractionCEs + (constart - coll->contractionIndex))
2554 return *(coll->contractionCEs + (constart - coll->contractionIndex));
2730 uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate *source, UErrorCode *status) {
2767 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
2769 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
2782 CE = *(coll->contractionCEs +
2783 (UCharOffset - coll->contractionIndex));
2789 CE = *(coll->contractionCEs +
2790 (ContractionStart - coll->contractionIndex));
2817 uint32_t firstCE = *(coll->contractionCEs + ((UChar *)coll->image+getContractOffset(CE) - coll->contractionIndex)); //UCOL_NOT_FOUND;
2826 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
2830 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
2854 CE = *(coll->contractionCEs +
2855 (UCharOffset - coll->contractionIndex));
2888 (sCC = i_getCombiningClass(miss, coll)) == 0 ||
2900 CE = *(coll->contractionCEs +
2901 (ContractionStart - coll->contractionIndex));
2913 if (i_getCombiningClass(tempchar, coll) == 0) {
2919 CE = *(coll->contractionCEs +
2920 (ContractionStart - coll->contractionIndex));
2922 CE = getDiscontiguous(coll, source, ContractionStart);
2949 uint32_t tempCE = *(coll->contractionCEs + (ContractionStart - coll->contractionIndex));
2992 CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
3020 if (source->coll->numericCollation == UCOL_ON){
3201 CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
3239 if (!source->coll->image->jamoSpecial) { // FAST PATH
3241 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, V);
3243 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, T);
3246 return UTRIE_GET32_FROM_LEAD(&coll->mapping, L);
3302 CE = UTRIE_GET32_FROM_OFFSET_TRAIL(&coll->mapping, CE&0xFFFFFF, trail);
3378 uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
3418 const UChar *ContractionStart = UCharOffset = (UChar *)coll->image+getContractOffset(CE);
3421 CE = *(coll->contractionCEs + (UCharOffset - coll->contractionIndex));
3434 CE = *(coll->contractionCEs +
3435 (UCharOffset - coll->contractionIndex));
3443 uint32_t isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, schar);
3457 isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, lead);
3459 uint32_t finalCE = UTRIE_GET32_FROM_OFFSET_TRAIL(&coll->mapping, isZeroCE&0xFFFFFF, schar);
3477 CE = *(coll->contractionCEs +
3478 (ContractionStart - coll->contractionIndex));
3501 constart = (UChar *)coll->image + getContractOffset(CE);
3506 CE = *(coll->contractionCEs +
3507 (constart - coll->contractionIndex));
3515 while (ucol_unsafeCP(schar, coll)) {
3573 IInit_collIterate(coll, UCharOffset, noChars, &temp, status);
3581 CE = ucol_IGetNextCE(coll, &temp, status);
3618 CE = ucol_IGetNextCE(coll, &temp, status);
3695 CEOffset = (uint32_t *)coll->image + getExpansionOffset(CE);
3749 if (source->coll->numericCollation == UCOL_ON){
3968 CEOffset = (uint32_t *)coll->image + getExpansionOffset(CE);
4006 if (!source->coll->image->jamoSpecial) {
4007 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, L);
4008 coll->mapping, V);
4012 *(source->CEpos++) = UTRIE_GET32_FROM_LEAD(&coll->mapping, T);
4472 ucol_getSortKey(const UCollator *coll,
4480 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source string = %vh ", coll, source,
4499 coll->sortKeyGen(coll, source, sourceLength, sink, &status);
4509 ucol_getSortKeyWithAllocation(const UCollator *coll,
4514 coll->sortKeyGen(coll, source, sourceLength, sink, pErrorCode);
4530 isCompressible(const UCollator * /*coll*/, uint8_t primary1) {
4588 ucol_calcSortKey(const UCollator *coll,
4612 UColAttributeValue strength = coll->strength;
4618 UBool doCase = (coll->caseLevel == UCOL_ON);
4619 UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && (compareSec == 0);
4620 UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
4622 UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && (compareQuad == 0);
4624 uint32_t variableTopValue = coll->variableTopValue;
4627 uint8_t UCOL_COMMON_BOT4 = (uint8_t)((coll->variableTopValue>>8)+1);
4643 } else if(coll->normalizationMode != UCOL_OFF) {
4660 IInit_collIterate(coll, source, len, &s, status);
4672 uint8_t caseSwitch = coll->caseSwitch;
4673 uint8_t tertiaryMask = coll->tertiaryMask;
4674 int8_t tertiaryAddition = coll->tertiaryAddition;
4675 uint8_t tertiaryTop = coll->tertiaryTop;
4676 uint8_t tertiaryBottom = coll->tertiaryBottom;
4677 uint8_t tertiaryCommon = coll->tertiaryCommon;
4687 order = ucol_IGetNextCE(coll, &s, status);
4709 if(notIsContinuation && coll->leadBytePermutationTable != NULL) {
4710 primary1 = coll->leadBytePermutationTable[primary1];
4758 } else if(isCompressible(coll, originalPrimary1)) {
4829 if(coll->caseFirst == UCOL_UPPER_FIRST) {
4870 while (count3 > coll->tertiaryTopCount) {
4871 tertiaries.Append((uint8_t)(tertiaryTop - coll->tertiaryTopCount));
4872 count3 -= (uint32_t)coll->tertiaryTopCount;
4876 while (count3 > coll->tertiaryBottomCount) {
4877 tertiaries.Append((uint8_t)(tertiaryBottom + coll->tertiaryBottomCount));
4878 count3 -= (uint32_t)coll->tertiaryBottomCount;
4944 if (coll->tertiaryCommon != UCOL_COMMON_BOT3) {
4945 while (count3 >= coll->tertiaryTopCount) {
4946 tertiaries.Append((uint8_t)(tertiaryTop - coll->tertiaryTopCount));
4947 count3 -= (uint32_t)coll->tertiaryTopCount;
4951 while (count3 > coll->tertiaryBottomCount) {
4952 tertiaries.Append((uint8_t)(tertiaryBottom + coll->tertiaryBottomCount));
4953 count3 -= (uint32_t)coll->tertiaryBottomCount;
4987 ucol_calcSortKeySimpleTertiary(const UCollator *coll,
5011 if(coll->normalizationMode != UCOL_OFF) {
5024 IInit_collIterate(coll, (UChar *)source, len, &s, status);
5036 uint8_t caseSwitch = coll->caseSwitch;
5037 uint8_t tertiaryMask = coll->tertiaryMask;
5038 int8_t tertiaryAddition = coll->tertiaryAddition;
5039 uint8_t tertiaryTop = coll->tertiaryTop;
5040 uint8_t tertiaryBottom = coll->tertiaryBottom;
5041 uint8_t tertiaryCommon = coll->tertiaryCommon;
5049 order = ucol_IGetNextCE(coll, &s, status);
5072 if (coll->leadBytePermutationTable != NULL && notIsContinuation) {
5073 primary1 = coll->leadBytePermutationTable[primary1];
5092 } else if(isCompressible(coll, originalPrimary1)) {
5151 while (count3 > coll->tertiaryTopCount) {
5152 tertiaries.Append((uint8_t)(tertiaryTop - coll->tertiaryTopCount));
5153 count3 -= (uint32_t)coll->tertiaryTopCount;
5157 while (count3 > coll->tertiaryBottomCount) {
5158 tertiaries.Append((uint8_t)(tertiaryBottom + coll->tertiaryBottomCount));
5159 count3 -= (uint32_t)coll->tertiaryBottomCount;
5183 if (coll->tertiaryCommon != UCOL_COMMON3_NORMAL) {
5184 while (count3 >= coll->tertiaryTopCount) {
5185 tertiaries.Append((uint8_t)(tertiaryTop - coll->tertiaryTopCount));
5186 count3 -= (uint32_t)coll->tertiaryTopCount;
5190 while (count3 > coll->tertiaryBottomCount) {
5191 tertiaries.Append((uint8_t)(tertiaryBottom + coll->tertiaryBottomCount));
5192 count3 -= (uint32_t)coll->tertiaryBottomCount;
5326 ucol_nextSortKeyPart(const UCollator *coll,
5337 if( coll==NULL || iter==NULL ||
5346 UTRACE_DATA6(UTRACE_VERBOSE, "coll=%p, iter=%p, state=%d %d, dest=%p, count=%d",
5347 coll, iter, state[0], state[1], dest, count);
5376 int32_t strength = ucol_getAttribute(coll, UCOL_STRENGTH, status);
5380 if(ucol_getAttribute(coll, UCOL_CASE_LEVEL, status) == UCOL_ON) {
5396 (ucol_getAttribute(coll, UCOL_HIRAGANA_QUATERNARY_MODE, status) == UCOL_ON)?0xFE:0xFF;
5398 uint32_t LVT = (coll->alternateHandling == UCOL_SHIFTED)?(coll->variableTopValue<<16):0;
5400 UBool doingFrench = (ucol_getAttribute(coll, UCOL_FRENCH_COLLATION, status) == UCOL_ON);
5407 IInit_collIterate(coll, NULL, -1, &s, status);
5426 if(ucol_getAttribute(coll, UCOL_NORMALIZATION_MODE, status) == UCOL_ON && level < UCOL_PSK_IDENTICAL) {
5489 CE = ucol_IGetPrevCE(coll, &s, status);
5491 CE = ucol_IGetNextCE(coll, &s, status);
5543 CE = ucol_IGetNextCE(coll, &s, status);
5557 if(coll->leadBytePermutationTable != NULL){
5558 CE = (coll->leadBytePermutationTable[CE>>24] << 24) | (CE & 0x00FFFFFF);
5605 CE = ucol_IGetNextCE(coll, &s, status);
5651 CE = ucol_IGetPrevCE(coll, &s, status);
5694 if(ucol_getAttribute(coll, UCOL_CASE_LEVEL, status) == UCOL_ON) {
5714 CE = ucol_IGetNextCE(coll, &s, status);
5754 if(coll->caseFirst == UCOL_UPPER_FIRST) {
5812 CE = ucol_IGetNextCE(coll, &s, status);
5830 CE ^= coll->caseSwitch;
5831 CE &= coll->tertiaryMask;
5868 CE = ucol_IGetNextCE(coll, &s, status);
6163 ucol_addLatinOneEntry(UCollator *coll, UChar ch, uint32_t CE,
6170 tertiary = (uint8_t)((CE & coll->tertiaryMask));
6171 tertiary ^= coll->caseSwitch;
6184 if (coll->leadBytePermutationTable != NULL && !continuation) {
6185 primary1 = coll->leadBytePermutationTable[primary1];
6188 coll->latinOneCEs[ch] |= (primary1 << *primShift);
6193 coll->latinOneCEs[ch] = UCOL_BAIL_OUT_CE;
6194 coll->latinOneCEs[coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6195 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6198 coll->latinOneCEs[ch] |= (primary2 << *primShift);
6202 if(reverseSecondary && coll->frenchCollation == UCOL_ON) { // reverse secondary
6203 coll->latinOneCEs[coll->latinOneTableLen+ch] >>= 8; // make space for secondary
6204 coll->latinOneCEs[coll->latinOneTableLen+ch] |= (secondary << 24);
6206 coll->latinOneCEs[coll->latinOneTableLen+ch] |= (secondary << *secShift);
6211 coll->latinOneCEs[2*coll->latinOneTableLen+ch] |= (tertiary << *terShift);
6217 ucol_resizeLatinOneTable(UCollator *coll, int32_t size, UErrorCode *status) {
6221 coll->latinOneFailed = TRUE;
6224 int32_t sizeToCopy = ((size<coll->latinOneTableLen)?size:coll->latinOneTableLen)*sizeof(uint32_t);
6226 uprv_memcpy(newTable, coll->latinOneCEs, sizeToCopy);
6227 uprv_memcpy(newTable+size, coll->latinOneCEs+coll->latinOneTableLen, sizeToCopy);
6228 uprv_memcpy(newTable+2*size, coll->latinOneCEs+2*coll->latinOneTableLen, sizeToCopy);
6229 coll->latinOneTableLen = size;
6230 uprv_free(coll->latinOneCEs);
6231 coll->latinOneCEs = newTable;
6236 ucol_setUpLatinOne(UCollator *coll, UErrorCode *status) {
6238 if(coll->latinOneCEs == NULL) {
6239 coll->latinOneCEs = (uint32_t *)uprv_malloc(sizeof(uint32_t)*UCOL_LATINONETABLELEN*3);
6240 if(coll->latinOneCEs == NULL) {
6244 coll->latinOneTableLen = UCOL_LATINONETABLELEN;
6247 UCollationElements *it = ucol_openElements(coll, &ch, 1, status);
6252 uprv_memset(coll->latinOneCEs, 0, sizeof(uint32_t)*coll->latinOneTableLen*3);
6262 CE = coll->latinOneMapping[ch];
6264 CE = UTRIE_GET32_FROM_LEAD(&coll->mapping, ch);
6265 if(CE == UCOL_NOT_FOUND && coll->UCA) {
6266 CE = UTRIE_GET32_FROM_LEAD(&coll->UCA->mapping, ch);
6270 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6278 coll->latinOneCEs[ch] = UCOL_BAIL_OUT_CE;
6279 coll->latinOneCEs[coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6280 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = UCOL_BAIL_OUT_CE;
6283 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6298 const UChar *UCharOffset = (UChar *)coll->image+getContractOffset(CE);
6302 coll->latinOneCEs[ch] = CE;
6303 coll->latinOneCEs[coll->latinOneTableLen+ch] = CE;
6304 coll->latinOneCEs[2*coll->latinOneTableLen+ch] = CE;
6309 CE = *(coll->contractionCEs +
6310 (UCharOffset - coll->contractionIndex));
6314 uint32_t *CEOffset = (uint32_t *)coll->image+getExpansionOffset(CE); /* find the offset to expansion table */
6320 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6321 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6322 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6325 ucol_addLatinOneEntry(coll, (UChar)contractionOffset, *CEOffset++, &primShift, &secShift, &terShift);
6330 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6331 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6332 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6335 ucol_addLatinOneEntry(coll, (UChar)contractionOffset, *CEOffset++, &primShift, &secShift, &terShift);
6340 ucol_addLatinOneEntry(coll, (UChar)contractionOffset++, CE, &primShift, &secShift, &terShift);
6342 coll->latinOneCEs[(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6343 coll->latinOneCEs[coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6344 coll->latinOneCEs[2*coll->latinOneTableLen+(UChar)contractionOffset] = UCOL_BAIL_OUT_CE;
6349 if(contractionOffset == coll->latinOneTableLen) { // we need to reallocate
6350 if(!ucol_resizeLatinOneTable(coll, 2*coll->latinOneTableLen, status)) {
6363 ucol_addLatinOneEntry(coll, ch, CE, &primShift, &secShift, &terShift);
6376 if(contractionOffset < coll->latinOneTableLen) {
6377 if(!ucol_resizeLatinOneTable(coll, contractionOffset, status)) {
6386 coll->latinOneFailed = TRUE;
6391 void ucol_updateInternalState(UCollator *coll, UErrorCode *status) {
6393 if(coll->caseFirst == UCOL_UPPER_FIRST) {
6394 coll->caseSwitch = UCOL_CASE_SWITCH;
6396 coll->caseSwitch = UCOL_NO_CASE_SWITCH;
6399 if(coll->caseLevel == UCOL_ON || coll->caseFirst == UCOL_OFF) {
6400 coll->tertiaryMask = UCOL_REMOVE_CASE;
6401 coll
6402 coll->tertiaryAddition = (int8_t)UCOL_FLAG_BIT_MASK_CASE_SW_OFF; /* Should be 0x80 */
6403 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_OFF;
6404 coll->tertiaryBottom = UCOL_COMMON_BOT3;
6406 coll->tertiaryMask = UCOL_KEEP_CASE;
6407 coll->tertiaryAddition = UCOL_FLAG_BIT_MASK_CASE_SW_ON;
6408 if(coll->caseFirst == UCOL_UPPER_FIRST) {
6409 coll->tertiaryCommon = UCOL_COMMON3_UPPERFIRST;
6410 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_UPPER;
6411 coll->tertiaryBottom = UCOL_COMMON_BOTTOM3_CASE_SW_UPPER;
6413 coll->tertiaryCommon = UCOL_COMMON3_NORMAL;
6414 coll->tertiaryTop = UCOL_COMMON_TOP3_CASE_SW_LOWER;
6415 coll->tertiaryBottom = UCOL_COMMON_BOTTOM3_CASE_SW_LOWER;
6420 uint8_t tertiaryTotal = (uint8_t)(coll->tertiaryTop - coll->tertiaryBottom - 1);
6421 coll->tertiaryTopCount = (uint8_t)(UCOL_PROPORTION3*tertiaryTotal); /* we multilply double with int, but need only int */
6422 coll->tertiaryBottomCount = (uint8_t)(tertiaryTotal - coll->tertiaryTopCount);
6424 if(coll->caseLevel == UCOL_OFF && coll->strength == UCOL_TERTIARY
6425 && coll->frenchCollation == UCOL_OFF && coll->alternateHandling == UCOL_NON_IGNORABLE)
6427 coll->sortKeyGen = ucol_calcSortKeySimpleTertiary;
6429 coll->sortKeyGen = ucol_calcSortKey;
6431 if(coll->caseLevel == UCOL_OFF && coll->strength <= UCOL_TERTIARY && coll->numericCollation == UCOL_OFF
6432 && coll->alternateHandling == UCOL_NON_IGNORABLE && !coll->latinOneFailed)
6434 if(coll->latinOneCEs == NULL || coll->latinOneRegenTable) {
6435 if(ucol_setUpLatinOne(coll, status)) { // if we succeed in building latin1 table, we'll use it
6437 coll->latinOneUse = TRUE;
6439 coll->latinOneUse = FALSE;
6445 coll->latinOneUse = TRUE;
6448 coll->latinOneUse = FALSE;
6454 ucol_setVariableTop(UCollator *coll, const UChar *varTop, int32_t len, UErrorCode *status) {
6455 if(U_FAILURE(*status) || coll == NULL) {
6467 IInit_collIterate(coll, varTop, len, &s, status);
6472 uint32_t CE = ucol_IGetNextCE(coll, &s, status);
6482 uint32_t nextCE = ucol_IGetNextCE(coll, &s, status);
6488 if(coll->variableTopValue != (CE & UCOL_PRIMARYMASK)>>16) {
6489 coll->variableTopValueisDefault = FALSE;
6490 coll->variableTopValue = (CE & UCOL_PRIMARYMASK)>>16;
6499 U_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status) {
6500 if(U_FAILURE(*status) || coll == NULL) {
6503 return coll->variableTopValue<<16;
6507 ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status) {
6508 if(U_FAILURE(*status) || coll == NULL) {
6512 if(coll->variableTopValue != (varTop & UCOL_PRIMARYMASK)>>16) {
6513 coll->variableTopValueisDefault = FALSE;
6514 coll->variableTopValue = (varTop & UCOL_PRIMARYMASK)>>16;
6519 ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status) {
6520 if(U_FAILURE(*status) || coll == NULL) {
6524 UColAttributeValue oldFrench = coll->frenchCollation;
6525 UColAttributeValue oldCaseFirst = coll->caseFirst;
6529 coll->numericCollation = UCOL_ON;
6530 coll->numericCollationisDefault = FALSE;
6532 coll->numericCollation = UCOL_OFF;
6533 coll->numericCollationisDefault = FALSE;
6535 coll->numericCollationisDefault = TRUE;
6536 coll->numericCollation = (UColAttributeValue)coll->options->numericCollation;
6543 coll->hiraganaQ = UCOL_ON;
6544 coll->hiraganaQisDefault = FALSE;
6546 coll->hiraganaQ = UCOL_OFF;
6547 coll->hiraganaQisDefault = FALSE;
6549 coll->hiraganaQisDefault = TRUE;
6550 coll->hiraganaQ = (UColAttributeValue)coll->options->hiraganaQ;
6557 coll->frenchCollation = UCOL_ON;
6558 coll->frenchCollationisDefault = FALSE;
6560 coll->frenchCollation = UCOL_OFF;
6561 coll->frenchCollationisDefault = FALSE;
6563 coll->frenchCollationisDefault = TRUE;
6564 coll->frenchCollation = (UColAttributeValue)coll->options->frenchCollation;
6571 coll->alternateHandling = UCOL_SHIFTED;
6572 coll->alternateHandlingisDefault = FALSE;
6574 coll->alternateHandling = UCOL_NON_IGNORABLE;
6575 coll->alternateHandlingisDefault = FALSE;
6577 coll->alternateHandlingisDefault = TRUE;
6578 coll->alternateHandling = (UColAttributeValue)coll->options->alternateHandling ;
6585 coll->caseFirst = UCOL_LOWER_FIRST;
6586 coll->caseFirstisDefault = FALSE;
6588 coll->caseFirst = UCOL_UPPER_FIRST;
6589 coll->caseFirstisDefault = FALSE;
6591 coll->caseFirst = UCOL_OFF;
6592 coll->caseFirstisDefault = FALSE;
6594 coll->caseFirst = (UColAttributeValue)coll->options->caseFirst;
6595 coll->caseFirstisDefault = TRUE;
6602 coll->caseLevel = UCOL_ON;
6603 coll->caseLevelisDefault = FALSE;
6605 coll->caseLevel = UCOL_OFF;
6606 coll->caseLevelisDefault = FALSE;
6608 coll->caseLevel = (UColAttributeValue)coll->options->caseLevel;
6609 coll->caseLevelisDefault = TRUE;
6616 coll->normalizationMode = UCOL_ON;
6617 coll->normalizationModeisDefault = FALSE;
6620 coll->normalizationMode = UCOL_OFF;
6621 coll->normalizationModeisDefault = FALSE;
6623 coll->normalizationModeisDefault = TRUE;
6624 coll->normalizationMode = (UColAttributeValue)coll->options->normalizationMode;
6625 if(coll->normalizationMode == UCOL_ON) {
6634 coll->strengthisDefault = TRUE;
6635 coll->strength = (UColAttributeValue)coll->options->strength;
6637 coll->strengthisDefault = FALSE;
6638 coll->strength = value;
6648 if(oldFrench != coll->frenchCollation || oldCaseFirst != coll->caseFirst) {
6649 coll->latinOneRegenTable = TRUE;
6651 coll->latinOneRegenTable = FALSE;
6653 ucol_updateInternalState(coll, status);
6657 ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status) {
6658 if(U_FAILURE(*status) || coll == NULL) {
6663 return coll->numericCollation;
6665 return coll->hiraganaQ;
6667 return coll->frenchCollation;
6669 return coll->alternateHandling;
6671 return coll->caseFirst;
6673 return coll->caseLevel;
6675 return coll->normalizationMode;
6677 return coll->strength;
6687 ucol_setStrength( UCollator *coll,
6691 ucol_setAttribute(coll, UCOL_STRENGTH, strength, &status);
6695 ucol_getStrength(const UCollator *coll)
6698 return ucol_getAttribute(coll, UCOL_STRENGTH, &status);
6702 ucol_getReorderCodes(const UCollator *coll,
6716 printf("coll->reorderCodesLength = %d\n", coll->reorderCodesLength);
6717 printf("coll->defaultReorderCodesLength = %d\n", coll->defaultReorderCodesLength);
6720 if (coll->reorderCodesLength > destCapacity) {
6722 return coll->reorderCodesLength;
6724 for (int32_t i = 0; i < coll->reorderCodesLength; i++) {
6725 dest[i] = coll->reorderCodes[i];
6727 return coll->reorderCodesLength;
6731 ucol_setReorderCodes(UCollator* coll,
6744 if (coll->reorderCodes != NULL && coll->freeReorderCodesOnClose == TRUE) {
6745 uprv_free(coll->reorderCodes);
6747 coll->reorderCodes = NULL;
6748 coll->reorderCodesLength = 0;
6750 if (coll->leadBytePermutationTable != NULL && coll->freeLeadBytePermutationTableOnClose == TRUE) {
6751 uprv_free(coll->leadBytePermutationTable);
6753 coll->leadBytePermutationTable = NULL;
6756 coll->reorderCodes = (int32_t*) uprv_malloc(reorderCodesLength * sizeof(int32_t));
6757 if (coll->reorderCodes == NULL) {
6761 coll->freeReorderCodesOnClose = TRUE;
6763 coll->reorderCodes[i] = reorderCodes[i];
6765 coll->reorderCodesLength = reorderCodesLength;
6766 ucol_buildPermutationTable(coll, status);
6838 ucol_getVersion(const UCollator* coll,
6844 uint8_t bdVersion = coll->image->version[0];
6858 versionInfo[2] = coll->image->version[1];
6859 if(coll->UCA) {
6861 versionInfo[3] = (coll->UCA->image->UCAVersion[0] & 0x1f) << 3 | (coll->UCA->image->UCAVersion[1] & 0x07);
6870 ucol_isTailored(const UCollator *coll, const UChar u, UErrorCode *status) {
6871 if(U_FAILURE(*status) || coll == NULL || coll == coll->UCA) {
6878 CE = coll->latinOneMapping[u];
6879 if(coll->UCA && CE == coll->UCA->latinOneMapping[u]) {
6883 CE = UTRIE_GET32_FROM_LEAD(&coll->mapping, u);
6887 ContractionStart = (UChar *)coll->image+getContractOffset(CE);
6888 CE = *(coll->contractionCEs + (ContractionStart- coll->contractionIndex));
7030 const UCollator *coll = sColl->coll;
7061 sourceKeyLen = ucol_getSortKey(coll, source, sourceLength, sourceKeyP, sourceKeyLen);
7068 sourceKeyLen = ucol_getSortKey(coll, source, sourceLength, sourceKeyP, sourceKeyLen);
7071 targetKeyLen = ucol_getSortKey(coll, target, targetLength, targetKeyP, targetKeyLen);
7078 targetKeyLen = ucol_getSortKey(coll, target, targetLength, targetKeyP, targetKeyLen);
7107 const UCollator *coll = sColl->coll;
7111 UColAttributeValue strength = coll->strength;
7118 UBool checkCase = (coll->caseLevel == UCOL_ON);
7119 UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && checkSecTer;
7120 UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
7122 UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && checkQuad;
7127 uint8_t caseSwitch = coll->caseSwitch;
7128 uint8_t tertiaryMask = coll->tertiaryMask;
7131 uint32_t LVT = (shifted)?(coll->variableTopValue<<16):0;
7152 sOrder = ucol_IGetNextCE(coll, sColl, status);
7161 tOrder = ucol_IGetNextCE(coll, tColl, status);
7181 if (coll->leadBytePermutationTable != NULL && !isContinuation(sOrder)) {
7182 sOrder = (coll->leadBytePermutationTable[sOrder>>24] << 24) | (sOrder & 0x00FFFFFF);
7183 tOrder = (coll->leadBytePermutationTable[tOrder>>24] << 24) | (tOrder & 0x00FFFFFF);
7197 sOrder = ucol_IGetNextCE(coll, sColl, status);
7223 if(coll->leadBytePermutationTable != NULL){
7224 sOrder = (coll->leadBytePermutationTable[sOrder>>24] << 24) | (sOrder & 0x00FFFFFF);
7247 tOrder = ucol_IGetNextCE(coll, tColl, status);
7273 if(coll->leadBytePermutationTable != NULL){
7274 tOrder = (coll->leadBytePermutationTable[tOrder>>24] << 24) | (tOrder & 0x00FFFFFF);
7574 //result = ucol_checkIdent(&sColl, &tColl, coll->normalizationMode == UCOL_ON);
7592 ucol_strcollRegular(const UCollator *coll,
7598 IInit_collIterate(coll, source, sourceLength, &sColl, status);
7599 IInit_collIterate(coll, target, targetLength, &tColl, status);
7607 ucol_getLatinOneContraction(const UCollator *coll, int32_t strength,
7610 const UChar *UCharOffset = (UChar *)coll->image+getContractOffset(CE&0xFFF);
7618 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
7624 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
7636 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset+offset]);
7644 uint32_t isZeroCE = UTRIE_GET32_FROM_LEAD(&coll->mapping, schar);
7650 return(coll->latinOneCEs[strength*coll->latinOneTableLen+latinOneOffset]);
7666 ucol_strcollUseLatin1( const UCollator *coll,
7674 int32_t strength = coll->strength;
7682 uint32_t *elements = coll->latinOneCEs;
7706 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
7713 sOrder = ucol_getLatinOneContraction(coll, UCOL_PRIMARY, sOrder, source, &sIndex, sLen);
7720 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
7752 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
7758 tOrder = ucol_getLatinOneContraction(coll, UCOL_PRIMARY, tOrder, target, &tIndex, tLen);
7763 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
7799 elements += coll->latinOneTableLen;
7802 if(coll->frenchCollation == UCOL_OFF) { // non French
7817 sOrder = ucol_getLatinOneContraction(coll, UCOL_SECONDARY, sOrder, source, &sIndex, sLen);
7832 tOrder = ucol_getLatinOneContraction(coll, UCOL_SECONDARY, tOrder, target, &tIndex, tLen);
7858 return ucol_strcollRegular(coll, source, sLen, target, tLen, status);
7911 elements += coll->latinOneTableLen;
7923 sOrder = ucol_getLatinOneContraction(coll, UCOL_TERTIARY, sOrder, source, &sIndex, sLen);
7937 tOrder = ucol_getLatinOneContraction(coll, UCOL_TERTIARY, tOrder, target, &tIndex, tLen);
7964 ucol_strcollIter( const UCollator *coll,
7974 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, sIter=%p, tIter=%p", coll, sIter, tIter);
7980 if(sIter == NULL || tIter == NULL || coll == NULL) {
7990 IInit_collIterate(coll, NULL, -1, &sColl, status);
7991 IInit_collIterate(coll, NULL, -1, &tColl, status);
8008 if(ucol_getAttribute(coll, UCOL_NORMALIZATION_MODE, status) == UCOL_ON) {
8039 if (ucol_unsafeCP((UChar)sChar, coll) || ucol_unsafeCP((UChar)tChar, coll))
8049 while (sChar != U_SENTINEL && ucol_unsafeCP((UChar)sChar, coll));
8072 ucol_strcoll( const UCollator *coll,
8082 UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source=%p, target=%p", coll, source, target);
8159 if ((pSrc != source+sourceLength && ucol_unsafeCP(*pSrc, coll)) ||
8160 (pTarg != target+targetLength && ucol_unsafeCP(*pTarg, coll)))
8170 while (equalLength>0 && ucol_unsafeCP(*pSrc, coll));
8185 if(!coll->latinOneUse || (sourceLength > 0 && *source&0xff00) || (targetLength > 0 && *target&0xff00)) {
8186 returnVal = ucol_strcollRegular(coll, source, sourceLength, target, targetLength, &status);
8188 returnVal = ucol_strcollUseLatin1(coll, source, sourceLength, target, targetLength, &status);
8196 ucol_greater( const UCollator *coll,
8202 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8208 ucol_greaterOrEqual( const UCollator *coll,
8214 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8220 ucol_equal( const UCollator *coll,
8226 return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
8231 ucol_getUCAVersion(const UCollator* coll, UVersionInfo info) {
8232 if(coll && coll->UCA) {
8233 uprv_memcpy(info, coll->UCA->image->UCAVersion, sizeof(UVersionInfo));