]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/collationdatabuilder.cpp
ICU-551.30.tar.gz
[apple/icu.git] / icuSources / i18n / collationdatabuilder.cpp
index 8d275b76aa9b9ac4a60039895fb763ff8fd3fc13..afeb6ee4584f10f30d702a30aba40f7553bf6633 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 2012-2014, International Business Machines
+* Copyright (C) 2012-2015, International Business Machines
 * Corporation and others.  All Rights Reserved.
 *******************************************************************************
 * collationdatabuilder.cpp
@@ -35,8 +35,6 @@
 #include "uvectr64.h"
 #include "uvector.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 CollationDataBuilder::CEModifier::~CEModifier() {}
@@ -51,6 +49,10 @@ CollationDataBuilder::CEModifier::~CEModifier() {}
  * Context strings must be unique and in ascending order.
  */
 struct ConditionalCE32 : public UMemory {
+    ConditionalCE32()
+            : context(),
+              ce32(0), defaultCE32(Collation::NO_CE32), builtCE32(Collation::NO_CE32),
+              next(-1) {}
     ConditionalCE32(const UnicodeString &ct, uint32_t ce)
             : context(ct),
               ce32(ce), defaultCE32(Collation::NO_CE32), builtCE32(Collation::NO_CE32),
@@ -420,6 +422,7 @@ CollationDataBuilder::getLongPrimaryIfSingleCE(UChar32 c) const {
 int64_t
 CollationDataBuilder::getSingleCE(UChar32 c, UErrorCode &errorCode) const {
     if(U_FAILURE(errorCode)) { return 0; }
+    // Keep parallel with CollationData::getSingleCE().
     UBool fromBase = FALSE;
     uint32_t ce32 = utrie2_get32(trie, c);
     if(ce32 == Collation::FALLBACK_CE32) {
@@ -794,7 +797,7 @@ CollationDataBuilder::copyFromBaseCE32(UChar32 c, uint32_t ce32, UBool withConte
         if(!withContext) {
             return copyFromBaseCE32(c, ce32, FALSE, errorCode);
         }
-        ConditionalCE32 head(UnicodeString(), 0);
+        ConditionalCE32 head;
         UnicodeString context((UChar)0);
         int32_t index;
         if(Collation::isContractionCE32(ce32)) {
@@ -830,7 +833,7 @@ CollationDataBuilder::copyFromBaseCE32(UChar32 c, uint32_t ce32, UBool withConte
             ce32 = CollationData::readCE32(p);  // Default if no suffix match.
             return copyFromBaseCE32(c, ce32, FALSE, errorCode);
         }
-        ConditionalCE32 head(UnicodeString(), 0);
+        ConditionalCE32 head;
         UnicodeString context((UChar)0);
         copyContractionsFromBaseCE32(context, c, ce32, &head, errorCode);
         ce32 = makeBuilderContextCE32(head.next);
@@ -1210,8 +1213,10 @@ CollationDataBuilder::build(CollationData &data, UErrorCode &errorCode) {
     if(base != NULL) {
         data.numericPrimary = base->numericPrimary;
         data.compressibleBytes = base->compressibleBytes;
-        data.scripts = base->scripts;
-        data.scriptsLength = base->scriptsLength;
+        data.numScripts = base->numScripts;
+        data.scriptsIndex = base->scriptsIndex;
+        data.scriptStarts = base->scriptStarts;
+        data.scriptStartsLength = base->scriptStartsLength;
     }
     buildFastLatinTable(data, errorCode);
 }
@@ -1374,7 +1379,7 @@ CollationDataBuilder::buildContext(ConditionalCE32 *head, UErrorCode &errorCode)
             // Build the contractions trie.
             contractionBuilder.clear();
             // Entry for an empty suffix, to be stored before the trie.
-            uint32_t emptySuffixCE32;
+            uint32_t emptySuffixCE32 = 0;
             uint32_t flags = 0;
             if(firstCond->context.length() == suffixStart) {
                 // There is a mapping for the prefix and the single character c. (p|c)