]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/collationdatareader.cpp
ICU-62123.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / collationdatareader.cpp
index 21a565378d9d96b108af08ab40c3795d5e3beec0..0eb1861343cdfda8d7198733851b5224736d75dc 100644 (file)
@@ -1,3 +1,5 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
 * Copyright (C) 2013-2015, International Business Machines
@@ -25,6 +27,7 @@
 #include "collationrootelements.h"
 #include "collationsettings.h"
 #include "collationtailoring.h"
+#include "collunsafe.h"
 #include "normalizer2impl.h"
 #include "uassert.h"
 #include "ucmndata.h"
@@ -262,6 +265,15 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
             return;
         }
         if(baseData == NULL) {
+#if defined(COLLUNSAFE_COLL_VERSION) && defined (COLLUNSAFE_SERIALIZE)
+          tailoring.unsafeBackwardSet = new UnicodeSet(unsafe_serializedData, unsafe_serializedCount, UnicodeSet::kSerialized, errorCode);
+          if(tailoring.unsafeBackwardSet == NULL) {
+            errorCode = U_MEMORY_ALLOCATION_ERROR;
+            return;
+          } else if (U_FAILURE(errorCode)) {
+            return;
+          }
+#else
             // Create the unsafe-backward set for the root collator.
             // Include all non-zero combining marks and trail surrogates.
             // We do this at load time, rather than at build time,
@@ -279,6 +291,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
                 return;
             }
             data->nfcImpl.addLcccChars(*tailoring.unsafeBackwardSet);
+#endif // !COLLUNSAFE_SERIALIZE || !COLLUNSAFE_COLL_VERSION
         } else {
             // Clone the root collator's set contents.
             tailoring.unsafeBackwardSet = static_cast<UnicodeSet *>(
@@ -406,7 +419,8 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
             tailoring.data, ts, fastLatinPrimaries, UPRV_LENGTHOF(fastLatinPrimaries));
     if(options == ts.options && ts.variableTop != 0 &&
             reorderCodesLength == ts.reorderCodesLength &&
-            uprv_memcmp(reorderCodes, ts.reorderCodes, reorderCodesLength * 4) == 0 &&
+            (reorderCodesLength == 0 ||
+                uprv_memcmp(reorderCodes, ts.reorderCodes, reorderCodesLength * 4) == 0) &&
             fastLatinOptions == ts.fastLatinOptions &&
             (fastLatinOptions < 0 ||
                 uprv_memcmp(fastLatinPrimaries, ts.fastLatinPrimaries,