X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b331163bffd790ced0e88b73f44f86d49ccc48a5..4f1e1a09ce4daed860e35d359ce2fceccb0764e8:/icuSources/i18n/collationdatareader.cpp diff --git a/icuSources/i18n/collationdatareader.cpp b/icuSources/i18n/collationdatareader.cpp index 21a56537..0eb18613 100644 --- a/icuSources/i18n/collationdatareader.cpp +++ b/icuSources/i18n/collationdatareader.cpp @@ -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( @@ -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,