| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 1996-2014, International Business Machines | 3 * Copyright (C) 1996-2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 * rulebasedcollator.cpp | 6 * rulebasedcollator.cpp |
| 7 * | 7 * |
| 8 * (replaced the former tblcoll.cpp) | 8 * (replaced the former tblcoll.cpp) |
| 9 * | 9 * |
| 10 * created on: 2012feb14 with new and old collation code | 10 * created on: 2012feb14 with new and old collation code |
| 11 * created by: Markus W. Scherer | 11 * created by: Markus W. Scherer |
| 12 */ | 12 */ |
| 13 | 13 |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 return; | 666 return; |
| 667 } | 667 } |
| 668 const CollationSettings &defaultSettings = getDefaultSettings(); | 668 const CollationSettings &defaultSettings = getDefaultSettings(); |
| 669 if(length == 1 && reorderCodes[0] == UCOL_REORDER_CODE_DEFAULT) { | 669 if(length == 1 && reorderCodes[0] == UCOL_REORDER_CODE_DEFAULT) { |
| 670 if(settings != &defaultSettings) { | 670 if(settings != &defaultSettings) { |
| 671 CollationSettings *ownedSettings = SharedObject::copyOnWrite(setting
s); | 671 CollationSettings *ownedSettings = SharedObject::copyOnWrite(setting
s); |
| 672 if(ownedSettings == NULL) { | 672 if(ownedSettings == NULL) { |
| 673 errorCode = U_MEMORY_ALLOCATION_ERROR; | 673 errorCode = U_MEMORY_ALLOCATION_ERROR; |
| 674 return; | 674 return; |
| 675 } | 675 } |
| 676 ownedSettings->aliasReordering(defaultSettings.reorderCodes, | 676 ownedSettings->copyReorderingFrom(defaultSettings, errorCode); |
| 677 defaultSettings.reorderCodesLength, | |
| 678 defaultSettings.reorderTable); | |
| 679 setFastLatinOptions(*ownedSettings); | 677 setFastLatinOptions(*ownedSettings); |
| 680 } | 678 } |
| 681 return; | 679 return; |
| 682 } | 680 } |
| 683 CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings); | 681 CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings); |
| 684 if(ownedSettings == NULL) { | 682 if(ownedSettings == NULL) { |
| 685 errorCode = U_MEMORY_ALLOCATION_ERROR; | 683 errorCode = U_MEMORY_ALLOCATION_ERROR; |
| 686 return; | 684 return; |
| 687 } | 685 } |
| 688 if(length == 0) { | 686 ownedSettings->setReordering(*data, reorderCodes, length, errorCode); |
| 689 ownedSettings->resetReordering(); | |
| 690 } else { | |
| 691 uint8_t reorderTable[256]; | |
| 692 data->makeReorderTable(reorderCodes, length, reorderTable, errorCode); | |
| 693 if(U_FAILURE(errorCode)) { return; } | |
| 694 if(!ownedSettings->setReordering(reorderCodes, length, reorderTable)) { | |
| 695 errorCode = U_MEMORY_ALLOCATION_ERROR; | |
| 696 return; | |
| 697 } | |
| 698 } | |
| 699 setFastLatinOptions(*ownedSettings); | 687 setFastLatinOptions(*ownedSettings); |
| 700 } | 688 } |
| 701 | 689 |
| 702 void | 690 void |
| 703 RuleBasedCollator::setFastLatinOptions(CollationSettings &ownedSettings) const { | 691 RuleBasedCollator::setFastLatinOptions(CollationSettings &ownedSettings) const { |
| 704 ownedSettings.fastLatinOptions = CollationFastLatin::getOptions( | 692 ownedSettings.fastLatinOptions = CollationFastLatin::getOptions( |
| 705 data, ownedSettings, | 693 data, ownedSettings, |
| 706 ownedSettings.fastLatinPrimaries, UPRV_LENGTHOF(ownedSettings.fastLa
tinPrimaries)); | 694 ownedSettings.fastLatinPrimaries, UPRV_LENGTHOF(ownedSettings.fastLa
tinPrimaries)); |
| 707 } | 695 } |
| 708 | 696 |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 int32_t | 1647 int32_t |
| 1660 RuleBasedCollator::getMaxExpansion(int32_t order) const { | 1648 RuleBasedCollator::getMaxExpansion(int32_t order) const { |
| 1661 UErrorCode errorCode = U_ZERO_ERROR; | 1649 UErrorCode errorCode = U_ZERO_ERROR; |
| 1662 (void)initMaxExpansions(errorCode); | 1650 (void)initMaxExpansions(errorCode); |
| 1663 return CollationElementIterator::getMaxExpansion(tailoring->maxExpansions, o
rder); | 1651 return CollationElementIterator::getMaxExpansion(tailoring->maxExpansions, o
rder); |
| 1664 } | 1652 } |
| 1665 | 1653 |
| 1666 U_NAMESPACE_END | 1654 U_NAMESPACE_END |
| 1667 | 1655 |
| 1668 #endif // !UCONFIG_NO_COLLATION | 1656 #endif // !UCONFIG_NO_COLLATION |
| OLD | NEW |