]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/uspoof_impl.cpp
ICU-57131.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / uspoof_impl.cpp
index 9c662f8048336e70581300ba3f418c4a662ae945..4e98db548a48efae90b4b64ff710ae60c541561f 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 2008-2014, International Business Machines
+*   Copyright (C) 2008-2016, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 */
@@ -28,12 +28,11 @@ U_NAMESPACE_BEGIN
 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SpoofImpl)
 
 SpoofImpl::SpoofImpl(SpoofData *data, UErrorCode &status) :
-        fMagic(0), fChecks(USPOOF_ALL_CHECKS), fSpoofData(NULL), fAllowedCharsSet(NULL) , 
+        fMagic(0), fChecks(USPOOF_ALL_CHECKS), fSpoofData(data), fAllowedCharsSet(NULL) , 
         fAllowedLocales(NULL), fCachedIdentifierInfo(NULL) {
     if (U_FAILURE(status)) {
         return;
     }
-    fSpoofData = data;
     fRestrictionLevel = USPOOF_HIGHLY_RESTRICTIVE;
 
     UnicodeSet *allowedCharsSet = new UnicodeSet(0, 0x10ffff);
@@ -357,7 +356,7 @@ const char * SpoofImpl::getAllowedLocales(UErrorCode &/*status*/) {
 void SpoofImpl::addScriptChars(const char *locale, UnicodeSet *allowedChars, UErrorCode &status) {
     UScriptCode scripts[30];
 
-    int32_t numScripts = uscript_getCode(locale, scripts, sizeof(scripts)/sizeof(UScriptCode), &status);
+    int32_t numScripts = uscript_getCode(locale, scripts, UPRV_LENGTHOF(scripts), &status);
     if (U_FAILURE(status)) {
         return;
     }
@@ -500,11 +499,12 @@ spoofDataIsAcceptable(void *context,
 
 //
 //  SpoofData::getDefault() - return a wrapper around the spoof data that is
-//                           baked into the default ICU data.
+//                            baked into the default ICU data.
+//
+//               Called once, from the initOnce() function in uspoof_impl.cpp; the resulting
+//               SpoofData is shared by all spoof checkers using the default data.
 //
 SpoofData *SpoofData::getDefault(UErrorCode &status) {
-    // TODO:  Cache it.  Lazy create, keep until cleanup.
-
     UDataMemory *udm = udata_openChoice(NULL, "cfu", "confusables",
                                         spoofDataIsAcceptable, 
                                         NULL,       // context, would receive dataVersion if supplied.
@@ -567,7 +567,6 @@ SpoofData::SpoofData(UErrorCode &status) {
         return;
     }
     fDataOwned = true;
-    fRefCount = 1;
 
     // The spoof header should already be sized to be a multiple of 16 bytes.
     // Just in case it's not, round it up.