X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..2ca993e82fb37b597a3c73ecd1586a139a6579c5:/icuSources/common/aaplbfct.cpp diff --git a/icuSources/common/aaplbfct.cpp b/icuSources/common/aaplbfct.cpp index e77a3105..fbecac0e 100644 --- a/icuSources/common/aaplbfct.cpp +++ b/icuSources/common/aaplbfct.cpp @@ -1,6 +1,6 @@ /** ******************************************************************************* - * Copyright (C) 2007, International Business Machines Corporation, Apple Inc.,* + * Copyright (C) 2007,2012 International Business Machines Corporation, Apple Inc.,* * and others. All Rights Reserved. * ******************************************************************************* */ @@ -8,11 +8,10 @@ #define __STDC_LIMIT_MACROS 1 #include "unicode/utypes.h" -#if !UCONFIG_NO_BREAK_ITERATION && defined(U_DARWIN) +#if !UCONFIG_NO_BREAK_ITERATION && U_PLATFORM_IS_DARWIN_BASED #include "brkeng.h" #include "dictbe.h" -#include "triedict.h" #include "aaplbfct.h" #include "unicode/uscript.h" #include "unicode/uniset.h" @@ -30,6 +29,9 @@ #include #include #include +// The following is now already included by platform.h (included indirectly by +// utypes.h) if U_PLATFORM_IS_DARWIN_BASED but it doesn't hurt to re-include here +#include U_NAMESPACE_BEGIN @@ -45,6 +47,10 @@ AppleLanguageBreakFactory::AppleLanguageBreakFactory(UErrorCode &status) AppleLanguageBreakFactory::~AppleLanguageBreakFactory() { } +#if !TARGET_OS_EMBEDDED +#if 0 +// need to update loadDictionaryMatcherFor implementation below + // Helper function that makes a length-delimited buffer look NUL-terminated static __attribute__((always_inline)) inline UChar nextUChar(const UChar *&p, ptrdiff_t &l) { if (l > 0) { @@ -176,11 +182,26 @@ static void addDictFile(MutableTrieDictionary *to, const char *path) { static const char sArchType[] = ".le"; // little endian #endif -const CompactTrieDictionary * -AppleLanguageBreakFactory::loadDictionaryFor(UScriptCode script, int32_t breakType) { - const CompactTrieDictionary *icuDict = ICULanguageBreakFactory::loadDictionaryFor(script, breakType); +#endif +#endif + +/* +In ICU50, +ICULanguageBreakFactory changes from + virtual const CompactTrieDictionary *loadDictionaryFor(UScriptCode script, int32_t breakType); +to + virtual DictionaryMatcher *loadDictionaryMatcherFor(UScriptCode script, int32_t breakType); +and CompactTrieDictionary no longer exists. Need to work out new implementation below. +*/ + +DictionaryMatcher * +AppleLanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script, int32_t breakType) { + DictionaryMatcher *icuDictMatcher = ICULanguageBreakFactory::loadDictionaryMatcherFor(script, breakType); +#if !TARGET_OS_EMBEDDED +#if 0 +// need to update loadDictionaryMatcherFor implementation below // We only look for a user dictionary if there is actually an ICU dictionary - if (icuDict != NULL) { + if (icuDictMatcher != NULL) { UErrorCode status = U_ZERO_ERROR; const char *scriptName = uscript_getName(script); char path[256]; // PATH_MAX is overkill in this case @@ -196,7 +217,7 @@ AppleLanguageBreakFactory::loadDictionaryFor(UScriptCode script, int32_t breakTy // Iterate the dictionary directories and accumulate in dirGlob NSSearchPathEnumerationState state = NSStartSearchPathEnumeration(NSLibraryDirectory, (NSSearchPathDomainMask) (NSUserDomainMask|NSLocalDomainMask|NSNetworkDomainMask)); - while (state = NSGetNextSearchPathEnumeration(state, path)) { + while ((state = NSGetNextSearchPathEnumeration(state, path)) != 0) { // First get the directory itself. We should never overflow, but use strlcat anyway // to avoid a crash if we do. strlcat(path, "/Dictionaries", sizeof(path)); @@ -210,7 +231,7 @@ AppleLanguageBreakFactory::loadDictionaryFor(UScriptCode script, int32_t breakTy // TODO: Delete the cache? if (dirGlob.gl_pathc == 0) { globfree(&dirGlob); - return icuDict; + return icuDictMatcher; } // See if there is a cache file already; get its mod time @@ -228,7 +249,7 @@ AppleLanguageBreakFactory::loadDictionaryFor(UScriptCode script, int32_t breakTy globFlags &= ~GLOB_APPEND; char **pathsp = dirGlob.gl_pathv; const char *dictpath; - while (dictpath = *pathsp++) { + while ((dictpath = *pathsp++) != NULL) { // Stat the directory -- ignore if stat failure if (!stat(dictpath, &dictStat)) { // Glob the dictionaries in the directory @@ -251,7 +272,7 @@ AppleLanguageBreakFactory::loadDictionaryFor(UScriptCode script, int32_t breakTy // TODO: Delete the cache? if (fileGlob.gl_pathc == 0) { globfree(&fileGlob); - return icuDict; + return icuDictMatcher; } // Now compare the last modified stamp for the cache against all the dictionaries @@ -266,7 +287,7 @@ AppleLanguageBreakFactory::loadDictionaryFor(UScriptCode script, int32_t breakTy // Do we need to build the dictionary cache? if (!cacheGood) { // Create a mutable dictionary from the ICU dictionary - MutableTrieDictionary *sum = icuDict->cloneMutable(status); + MutableTrieDictionary *sum = icuDictMatcher->cloneMutable(status); pathsp = fileGlob.gl_pathv; while (U_SUCCESS(status) && (dictpath = *pathsp++)) { // Add the contents of a file to the sum @@ -352,16 +373,18 @@ AppleLanguageBreakFactory::loadDictionaryFor(UScriptCode script, int32_t breakTy // If we were successful, free the ICU dictionary and return ours if (U_SUCCESS(status)) { - delete icuDict; + delete icuDictMatcher; return cacheDict; } else { delete cacheDict; } } - return icuDict; +#endif +#endif + return icuDictMatcher; } U_NAMESPACE_END -#endif /* #if !UCONFIG_NO_BREAK_ITERATION && defined(U_DARWIN) */ +#endif /* #if !UCONFIG_NO_BREAK_ITERATION && U_PLATFORM_IS_DARWIN_BASED */