| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 2012-2014, International Business Machines | 3 * Copyright (C) 2012-2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 * collationdatabuilder.cpp | 6 * collationdatabuilder.cpp |
| 7 * | 7 * |
| 8 * (replaced the former ucol_elm.cpp) | 8 * (replaced the former ucol_elm.cpp) |
| 9 * | 9 * |
| 10 * created on: 2012apr01 | 10 * created on: 2012apr01 |
| 11 * created by: Markus W. Scherer | 11 * created by: Markus W. Scherer |
| 12 */ | 12 */ |
| 13 | 13 |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 &errorCode); | 1206 &errorCode); |
| 1207 } | 1207 } |
| 1208 } | 1208 } |
| 1209 | 1209 |
| 1210 void | 1210 void |
| 1211 CollationDataBuilder::build(CollationData &data, UErrorCode &errorCode) { | 1211 CollationDataBuilder::build(CollationData &data, UErrorCode &errorCode) { |
| 1212 buildMappings(data, errorCode); | 1212 buildMappings(data, errorCode); |
| 1213 if(base != NULL) { | 1213 if(base != NULL) { |
| 1214 data.numericPrimary = base->numericPrimary; | 1214 data.numericPrimary = base->numericPrimary; |
| 1215 data.compressibleBytes = base->compressibleBytes; | 1215 data.compressibleBytes = base->compressibleBytes; |
| 1216 data.scripts = base->scripts; | 1216 data.numScripts = base->numScripts; |
| 1217 data.scriptsLength = base->scriptsLength; | 1217 data.scriptsIndex = base->scriptsIndex; |
| 1218 data.scriptStarts = base->scriptStarts; |
| 1219 data.scriptStartsLength = base->scriptStartsLength; |
| 1218 } | 1220 } |
| 1219 buildFastLatinTable(data, errorCode); | 1221 buildFastLatinTable(data, errorCode); |
| 1220 } | 1222 } |
| 1221 | 1223 |
| 1222 void | 1224 void |
| 1223 CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode)
{ | 1225 CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode)
{ |
| 1224 if(U_FAILURE(errorCode)) { return; } | 1226 if(U_FAILURE(errorCode)) { return; } |
| 1225 if(trie == NULL || utrie2_isFrozen(trie)) { | 1227 if(trie == NULL || utrie2_isFrozen(trie)) { |
| 1226 errorCode = U_INVALID_STATE_ERROR; | 1228 errorCode = U_INVALID_STATE_ERROR; |
| 1227 return; | 1229 return; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 int32_t suffixStart = prefixLength + 1; // == prefix.length() | 1372 int32_t suffixStart = prefixLength + 1; // == prefix.length() |
| 1371 if(lastCond->context.length() == suffixStart) { | 1373 if(lastCond->context.length() == suffixStart) { |
| 1372 // One prefix without contraction suffix. | 1374 // One prefix without contraction suffix. |
| 1373 U_ASSERT(firstCond == lastCond); | 1375 U_ASSERT(firstCond == lastCond); |
| 1374 ce32 = lastCond->ce32; | 1376 ce32 = lastCond->ce32; |
| 1375 cond = lastCond; | 1377 cond = lastCond; |
| 1376 } else { | 1378 } else { |
| 1377 // Build the contractions trie. | 1379 // Build the contractions trie. |
| 1378 contractionBuilder.clear(); | 1380 contractionBuilder.clear(); |
| 1379 // Entry for an empty suffix, to be stored before the trie. | 1381 // Entry for an empty suffix, to be stored before the trie. |
| 1380 uint32_t emptySuffixCE32; | 1382 uint32_t emptySuffixCE32 = 0; |
| 1381 uint32_t flags = 0; | 1383 uint32_t flags = 0; |
| 1382 if(firstCond->context.length() == suffixStart) { | 1384 if(firstCond->context.length() == suffixStart) { |
| 1383 // There is a mapping for the prefix and the single character c.
(p|c) | 1385 // There is a mapping for the prefix and the single character c.
(p|c) |
| 1384 // If no other suffix matches, then we return this value. | 1386 // If no other suffix matches, then we return this value. |
| 1385 emptySuffixCE32 = firstCond->ce32; | 1387 emptySuffixCE32 = firstCond->ce32; |
| 1386 cond = getConditionalCE32(firstCond->next); | 1388 cond = getConditionalCE32(firstCond->next); |
| 1387 } else { | 1389 } else { |
| 1388 // There is no mapping for the prefix and just the single charac
ter. | 1390 // There is no mapping for the prefix and just the single charac
ter. |
| 1389 // (There is no p|c, only p|cd, p|ce etc.) | 1391 // (There is no p|c, only p|cd, p|ce etc.) |
| 1390 flags |= Collation::CONTRACT_SINGLE_CP_NO_MATCH; | 1392 flags |= Collation::CONTRACT_SINGLE_CP_NO_MATCH; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 if(collIter == NULL) { | 1524 if(collIter == NULL) { |
| 1523 collIter = new DataBuilderCollationIterator(*this); | 1525 collIter = new DataBuilderCollationIterator(*this); |
| 1524 if(collIter == NULL) { return 0; } | 1526 if(collIter == NULL) { return 0; } |
| 1525 } | 1527 } |
| 1526 return collIter->fetchCEs(s, start, ces, cesLength); | 1528 return collIter->fetchCEs(s, start, ces, cesLength); |
| 1527 } | 1529 } |
| 1528 | 1530 |
| 1529 U_NAMESPACE_END | 1531 U_NAMESPACE_END |
| 1530 | 1532 |
| 1531 #endif // !UCONFIG_NO_COLLATION | 1533 #endif // !UCONFIG_NO_COLLATION |
| OLD | NEW |