// Translate "before" to CUTOFF_TYPE_BEFORE, for example. static CutoffType getCutoffTypeFromString(const char *type_str) { if (uprv_strcmp(type_str, "from") == 0) { return CUTOFF_TYPE_FROM; } else if (uprv_strcmp(type_str, "before") == 0) { return CUTOFF_TYPE_BEFORE; } else if (uprv_strcmp(type_str, "after") == 0) { return CUTOFF_TYPE_AFTER; } else if (uprv_strcmp(type_str, "at") == 0) { return CUTOFF_TYPE_AT; } else { return CUTOFF_TYPE_UNKNOWN; } }
/* Writing Functions */ static void string_write_java(struct SResource *res,UErrorCode *status) { if(uprv_strcmp(srBundle->fKeys+res->fKey,"%%UCARULES")==0 ){ char fileName[1024] ={0}; const char* file = "UCARules.utf8"; FileStream* datFile = NULL; const char* type = "new ICUListResourceBundle.ResourceString("; char* dest = (char*) uprv_malloc( 8 * res->u.fString.fLength); int32_t len = 0; if(outDir){ uprv_strcat(fileName,outDir); if(outDir[uprv_strlen(outDir)-1]!=U_FILE_SEP_CHAR){ uprv_strcat(fileName,U_FILE_SEP_STRING); } } uprv_strcat(fileName,file);/* UCARULES.utf8 UTF-8 file */ write_tabs(out); T_FileStream_write(out, type, (int32_t)uprv_strlen(type)); T_FileStream_write(out, "\"", 1); T_FileStream_write(out, file, (int32_t)uprv_strlen(file)); T_FileStream_write(out, "\")\n", 3); datFile=T_FileStream_open(fileName,"w"); if(!dest){ *status=U_MEMORY_ALLOCATION_ERROR; } u_strToUTF8(dest,8*res->u.fString.fLength,&len,res->u.fString.fChars,res->u.fString.fLength,status); if(U_FAILURE(*status)){ T_FileStream_close(datFile); uprv_free(dest); return; } T_FileStream_write(datFile,dest,len); T_FileStream_close(datFile); uprv_free(dest); }else{ str_write_java(res->u.fString.fChars,res->u.fString.fLength,TRUE,status); if(uprv_strcmp(srBundle->fKeys+res->fKey,"Rule")==0){ UChar* buf = (UChar*) uprv_malloc(sizeof(UChar)*res->u.fString.fLength); uprv_memcpy(buf,res->u.fString.fChars,res->u.fString.fLength); uprv_free(buf); } } }
AlphabeticIndex::ELangType AlphabeticIndex::langTypeFromLocale(const Locale &loc) { const char *lang = loc.getLanguage(); if (uprv_strcmp(lang, "zh") != 0) { return kNormal; } const char *script = loc.getScript(); if (uprv_strcmp(script, "Hant") == 0) { return kTraditional; } const char *country = loc.getCountry(); if (uprv_strcmp(country, "TW") == 0) { return kTraditional; } return kSimplified; }
UBool DecimalFormatSymbols::operator==(const DecimalFormatSymbols& that) const { if (this == &that) { return TRUE; } for(int32_t i = 0; i < (int32_t)kFormatSymbolCount; ++i) { if(fSymbols[(ENumberFormatSymbol)i] != that.fSymbols[(ENumberFormatSymbol)i]) { return FALSE; } } return locale == that.locale && uprv_strcmp(validLocale, that.validLocale) == 0 && uprv_strcmp(actualLocale, that.actualLocale) == 0; }
// UInitOnce singleton initialization function static void U_CALLCONV initSingletons(const char *what, UErrorCode &errorCode) { #if !NORM2_HARDCODE_NFC_DATA if (uprv_strcmp(what, "nfc") == 0) { nfcSingleton = Norm2AllModes::createInstance(NULL, "nfc", errorCode); } else #endif if (uprv_strcmp(what, "nfkc") == 0) { nfkcSingleton = Norm2AllModes::createInstance(NULL, "nfkc", errorCode); } else if (uprv_strcmp(what, "nfkc_cf") == 0) { nfkc_cfSingleton = Norm2AllModes::createInstance(NULL, "nfkc_cf", errorCode); } else { U_ASSERT(FALSE); // Unknown singleton } ucln_common_registerCleanup(UCLN_COMMON_LOADED_NORMALIZER2, uprv_loaded_normalizer2_cleanup); }
/* Return just the POSIX id, whatever happens to be in it */ static const char *uprv_getPOSIXID(void) { static const char* posixID = NULL; if (posixID == 0) { /* * On Solaris two different calls to setlocale can result in * different values. Only get this value once. * * We must check this first because an application can set this. * * LC_ALL can't be used because it's platform dependent. The LANG * environment variable seems to affect LC_CTYPE variable by default. * Here is what setlocale(LC_ALL, NULL) can return. * HPUX can return 'C C C C C C C' * Solaris can return /en_US/C/C/C/C/C on the second try. * Linux can return LC_CTYPE=C;LC_NUMERIC=C;... * * The default codepage detection also needs to use LC_CTYPE. * * Do not call setlocale(LC_*, "")! Using an empty string instead * of NULL, will modify the libc behavior. */ posixID = setlocale(LC_CTYPE, NULL); if ((posixID == 0) || (uprv_strcmp("C", posixID) == 0) || (uprv_strcmp("POSIX", posixID) == 0)) { /* Maybe we got some garbage. Try something more reasonable */ posixID = getenv("LC_ALL"); if (posixID == 0) { posixID = getenv("LC_CTYPE"); if (posixID == 0) { posixID = getenv("LANG"); } } } if ((posixID==0) || (uprv_strcmp("C", posixID) == 0) || (uprv_strcmp("POSIX", posixID) == 0)) { /* Nothing worked. Give it a nice POSIX default value. */ posixID = "en_US_POSIX"; } } return posixID; }
static void idForLocale(const char* locale, char* buffer, int capacity, UErrorCode* ec) { // !!! this is internal only, assumes buffer is not null and capacity is sufficient // Extract the country name and variant name. We only // recognize two variant names, EURO and PREEURO. char variant[ULOC_FULLNAME_CAPACITY]; uloc_getCountry(locale, buffer, capacity, ec); uloc_getVariant(locale, variant, sizeof(variant), ec); if (0 == uprv_strcmp(variant, VAR_PRE_EURO) || 0 == uprv_strcmp(variant, VAR_EURO)) { uprv_strcat(buffer, VAR_DELIM); uprv_strcat(buffer, variant); } }
static int32_t ures_compareRows(const void * context, const void * left, const void * right) { const char * keyChars = (const char *)context; return (int32_t)uprv_strcmp(keyChars + ((const Row *)left)->keyIndex, keyChars + ((const Row *)right)->keyIndex); }
U_CAPI ULocaleBundle * u_locbund_init(ULocaleBundle *result, const char *loc) { int32_t len; if(result == 0) return 0; if (loc == NULL) { loc = uloc_getDefault(); } uprv_memset(result, 0, sizeof(ULocaleBundle)); len = (int32_t)strlen(loc); result->fLocale = (char*) uprv_malloc(len + 1); if(result->fLocale == 0) { return 0; } uprv_strcpy(result->fLocale, loc); result->isInvariantLocale = uprv_strcmp(result->fLocale, "en_US_POSIX") == 0; return result; }
UnicodeString& LocaleDisplayNamesImpl::keyValueDisplayName(const char* key, const char* value, UnicodeString& result, UBool skipAdjust) const { if (uprv_strcmp(key, "currency") == 0) { // ICU4C does not have ICU4J CurrencyDisplayInfo equivalent for now. UErrorCode sts = U_ZERO_ERROR; UnicodeString ustrValue(value, -1, US_INV); int32_t len; UBool isChoice = FALSE; const UChar *currencyName = ucurr_getName(ustrValue.getTerminatedBuffer(), locale.getBaseName(), UCURR_LONG_NAME, &isChoice, &len, &sts); if (U_FAILURE(sts)) { // Return the value as is on failure result = ustrValue; return result; } result.setTo(currencyName, len); return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result); } if (nameLength == UDISPCTX_LENGTH_SHORT) { langData.get("Types%short", key, value, result); if (!result.isBogus()) { return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result); } } langData.get("Types", key, value, result); return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result); }
UBool MeasureFormat::operator==(const Format &other) const { if (this == &other) { // Same object, equal return TRUE; } if (!Format::operator==(other)) { return FALSE; } const MeasureFormat &rhs = static_cast<const MeasureFormat &>(other); // Note: Since the ListFormatter depends only on Locale and width, we // don't have to check it here. // differing widths aren't equivalent if (fWidth != rhs.fWidth) { return FALSE; } // Width the same check locales. // We don't need to check locales if both objects have same cache. if (cache != rhs.cache) { UErrorCode status = U_ZERO_ERROR; const char *localeId = getLocaleID(status); const char *rhsLocaleId = rhs.getLocaleID(status); if (U_FAILURE(status)) { // On failure, assume not equal return FALSE; } if (uprv_strcmp(localeId, rhsLocaleId) != 0) { return FALSE; } } // Locales same, check NumberFormat if shared data differs. return ( numberFormat == rhs.numberFormat || **numberFormat == **rhs.numberFormat); }
U_CDECL_BEGIN static int32_t U_CALLCONV compareToCEntries(const void *context, const void *left, const void *right) { const char *chars=(const char *)context; return (int32_t)uprv_strcmp(chars+((const ToCEntry *)left)->nameOffset, chars+((const ToCEntry *)right)->nameOffset); }
static int dotestconv(const char *name, const char *standard, const char *expected) { int res = 1; UErrorCode error; const char *tag; error = U_ZERO_ERROR; tag = ucnv_getCanonicalName(name, standard, &error); if (tag && !expected) { log_err("FAIL: Unexpectedly found %s canonical name for %s, got %s\n", standard, name, tag); res = 0; } else if (!tag && expected) { log_err_status(error, "FAIL: could not find %s canonical name for %s\n", (standard ? "\"\"" : standard), name); res = 0; } else if (expected && (name == tag || uprv_strcmp(expected, tag) != 0)) { log_err("FAIL: expected %s for %s canonical name for %s, got %s\n", expected, standard, name, tag); res = 0; } else { log_verbose("PASS: (\"%s\", \"%s\") -> %s == %s \n", name, standard, tag, expected); } return res; }
void UnifiedCacheThread::exerciseByLocale(const Locale &locale) { UErrorCode status = U_ZERO_ERROR; const UCTMultiThreadItem *origItem = NULL; fCache->get( LocaleCacheKey<UCTMultiThreadItem>(locale), fCache, origItem, status); U_ASSERT(U_SUCCESS(status)); if (uprv_strcmp(locale.getLanguage(), origItem->value)) { IntlTest::gTest->errln( "%s:%d Expected %s, got %s", __FILE__, __LINE__, locale.getLanguage(), origItem->value); } // Fetch the same item again many times. We should always get the same // pointer since this client is already holding onto it for (int32_t i = 0; i < 1000; ++i) { const UCTMultiThreadItem *item = NULL; fCache->get( LocaleCacheKey<UCTMultiThreadItem>(locale), fCache, item, status); if (item != origItem) { IntlTest::gTest->errln( "%s:%d Expected to get the same pointer", __FILE__, __LINE__); } if (item != NULL) { item->removeRef(); } } origItem->removeRef(); }
void CalendarLimitTest::TestLimitsThread(int32_t threadNum) { logln("thread %d starting", threadNum); int32_t testIndex = 0; LocalPointer<Calendar> cal; while (gTestCaseIterator.next(testIndex)) { TestCase &testCase = TestCases[testIndex]; logln("begin test of %s calendar.", testCase.type); UErrorCode status = U_ZERO_ERROR; char buf[64]; uprv_strcpy(buf, "root@calendar="); strcat(buf, testCase.type); cal.adoptInstead(Calendar::createInstance(buf, status)); if (failure(status, "Calendar::createInstance", TRUE)) { continue; } if (uprv_strcmp(cal->getType(), testCase.type) != 0) { errln((UnicodeString)"FAIL: Wrong calendar type: " + cal->getType() + " Requested: " + testCase.type); continue; } doTheoreticalLimitsTest(*(cal.getAlias()), testCase.hasLeapMonth); doLimitsTest(*(cal.getAlias()), testCase.actualTestStart, testCase.actualTestEnd); logln("end test of %s calendar.", testCase.type); } }
void CalendarData::initData(const char *locale, const char *type, UErrorCode& status) { fOtherFillin = ures_open(U_CALENDAR_DATA, locale, &status); fFillin = ures_getByKey(fOtherFillin, U_CALENDAR_KEY, fFillin, &status); if((type != NULL) && (*type != '\0') && (uprv_strcmp(type, U_GREGORIAN_KEY))) { fBundle = ures_getByKeyWithFallback(fFillin, type, NULL, &status); fFallback = ures_getByKeyWithFallback(fFillin, U_GREGORIAN_KEY, NULL, &status); #if defined (U_DEBUG_CALDATA) fprintf(stderr, "%p: CalendarData(%s, %s, %s) -> main(%p, %s)=%s, fallback(%p, %s)=%s\n", this, locale, type, u_errorName(status), fBundle, type, fBundle?ures_getLocale(fBundle, &status):"", fFallback, U_GREGORIAN_KEY, fFallback?ures_getLocale(fFallback, &status):""); #endif } else { fBundle = ures_getByKeyWithFallback(fFillin, U_GREGORIAN_KEY, NULL, &status); #if defined (U_DEBUG_CALDATA) fprintf(stderr, "%p: CalendarData(%s, %s, %s) -> main(%p, %s)=%s, fallback = NULL\n", this, locale, type, u_errorName(status), fBundle, U_GREGORIAN_KEY, fBundle?ures_getLocale(fBundle, &status):"" ); #endif } }
static int32_t _res_findTableItem(const ResourceData *pResData, const uint16_t *keyOffsets, int32_t length, const char *key, const char **realKey) { const char *tableKey; int32_t mid, start, limit; int result; /* do a binary search for the key */ start=0; limit=length; while(start<limit) { mid = (start + limit) / 2; tableKey = RES_GET_KEY16(pResData, keyOffsets[mid]); if (pResData->useNativeStrcmp) { result = uprv_strcmp(key, tableKey); } else { result = uprv_compareInvCharsAsAscii(key, tableKey); } if (result < 0) { limit = mid; } else if (result > 0) { start = mid + 1; } else { /* We found it! */ *realKey=tableKey; return mid; } } return URESDATA_ITEM_NOT_FOUND; /* not found or table is empty. */ }
static int32_t extractPackageName(const UDataSwapper *ds, const char *filename, char pkg[], int32_t capacity, UErrorCode *pErrorCode) { const char *basename; int32_t len; if(U_FAILURE(*pErrorCode)) { return 0; } basename=findBasename(filename); len=(int32_t)uprv_strlen(basename)-4; /* -4: subtract the length of ".dat" */ if(len<=0 || 0!=uprv_strcmp(basename+len, ".dat")) { udata_printError(ds, "udata_swapPackage(): \"%s\" is not recognized as a package filename (must end with .dat)\n", basename); *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } if(len>=capacity) { udata_printError(ds, "udata_swapPackage(): the package name \"%s\" is too long (>=%ld)\n", (long)capacity); *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } uprv_memcpy(pkg, basename, len); pkg[len]=0; return len; }
int32_t MeasureUnit::getAvailable( const char *type, MeasureUnit *dest, int32_t destCapacity, UErrorCode &errorCode) { if (U_FAILURE(errorCode)) { return 0; } int32_t typeIdx = binarySearch(gTypes, 0, LENGTHOF(gTypes)-1, type); if (typeIdx == -1) { if (uprv_strcmp(type, gTypes[LENGTHOF(gTypes)-1]) == 0) { typeIdx = LENGTHOF(gTypes)-1; } else { return 0; } } int32_t len = gOffsets[typeIdx + 1] - gOffsets[typeIdx]; if (destCapacity < len) { errorCode = U_BUFFER_OVERFLOW_ERROR; return len; } for (int subTypeIdx = 0; subTypeIdx < len; ++subTypeIdx) { dest[subTypeIdx].setTo(typeIdx, subTypeIdx); } return len; }
// initCDFLocaleData initializes result with data from CLDR. // inLocale is the locale, the CLDR data is stored in result. // We load the UNUM_SHORT and UNUM_LONG data looking first in local numbering // system and not including root locale in fallback. Next we try in the latn // numbering system where we fallback all the way to root. If we don't find // UNUM_SHORT data in these three places, we report an error. If we find // UNUM_SHORT data before finding UNUM_LONG data we make UNUM_LONG data fall // back to UNUM_SHORT data. static void initCDFLocaleData(const Locale& inLocale, CDFLocaleData* result, UErrorCode& status) { LocalPointer<NumberingSystem> ns(NumberingSystem::createInstance(inLocale, status)); if (U_FAILURE(status)) { return; } const char* numberingSystemName = ns->getName(); UResourceBundle* rb = ures_open(NULL, inLocale.getName(), &status); rb = ures_getByKeyWithFallback(rb, gNumberElementsTag, rb, &status); if (U_FAILURE(status)) { ures_close(rb); return; } UResourceBundle* shortDataFillIn = NULL; UResourceBundle* longDataFillIn = NULL; UResourceBundle* shortData = NULL; UResourceBundle* longData = NULL; if (uprv_strcmp(numberingSystemName, gLatnTag) != 0) { LocalUResourceBundlePointer localResource( tryGetByKeyWithFallback(rb, numberingSystemName, NULL, NOT_ROOT, status)); shortData = tryGetDecimalFallback( localResource.getAlias(), gPatternsShort, &shortDataFillIn, NOT_ROOT, status); longData = tryGetDecimalFallback( localResource.getAlias(), gPatternsLong, &longDataFillIn, NOT_ROOT, status); } if (U_FAILURE(status)) { ures_close(shortDataFillIn); ures_close(longDataFillIn); ures_close(rb); return; } // If we haven't found UNUM_SHORT look in latn numbering system. We must // succeed at finding UNUM_SHORT here. if (shortData == NULL) { LocalUResourceBundlePointer latnResource(tryGetByKeyWithFallback(rb, gLatnTag, NULL, MUST, status)); shortData = tryGetDecimalFallback(latnResource.getAlias(), gPatternsShort, &shortDataFillIn, MUST, status); if (longData == NULL) { longData = tryGetDecimalFallback(latnResource.getAlias(), gPatternsLong, &longDataFillIn, ANY, status); if (longData != NULL && isRoot(longData, status) && !isRoot(shortData, status)) { longData = NULL; } } } initCDFLocaleStyleData(shortData, &result->shortData, status); ures_close(shortDataFillIn); if (U_FAILURE(status)) { ures_close(longDataFillIn); ures_close(rb); } if (longData == NULL) { result->longData.setToBogus(); } else { initCDFLocaleStyleData(longData, &result->longData, status); } ures_close(longDataFillIn); ures_close(rb); }
// Entry point. virtual ResourceTableSink *getOrCreateTableSink(const char *key, UErrorCode &errorCode) { if (U_FAILURE(errorCode)) { return NULL; } if (uprv_strcmp(key, "locales") == 0) { return &localesSink; } else if (uprv_strcmp(key, "rules") == 0) { // Allocate one more than needed to skip [0]. See comment in parseSetNum(). data->rules = new DayPeriodRules[data->maxRuleSetNum + 1]; if (data->rules == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } else { return &rulesSink; } } return NULL; }
UnicodeString& LocaleDisplayNamesImpl::languageDisplayName(const char* lang, UnicodeString& result) const { if (uprv_strcmp("root", lang) == 0 || uprv_strchr(lang, '_') != NULL) { return result = UnicodeString(lang, -1, US_INV); } return langData.get("Languages", lang, result); }
static UBool isRoot(const UResourceBundle* rb, UErrorCode& status) { const char* actualLocale = ures_getLocaleByType( rb, ULOC_ACTUAL_LOCALE, &status); if (U_FAILURE(status)) { return FALSE; } return uprv_strcmp(actualLocale, gRoot) == 0; }
static void load(const Locale& inLocale, CDFLocaleData* result, UErrorCode& status) { LocalPointer<NumberingSystem> ns(NumberingSystem::createInstance(inLocale, status)); if (U_FAILURE(status)) { return; } const char* nsName = ns->getName(); LocalUResourceBundlePointer resource(ures_open(NULL, inLocale.getName(), &status)); if (U_FAILURE(status)) { return; } CmptDecDataSink sink(*result); sink.isFallback = FALSE; // First load the number elements data if nsName is not Latin. if (uprv_strcmp(nsName, gLatnTag) != 0) { sink.isLatin = FALSE; CharString path; path.append(gNumberElementsTag, status) .append('/', status) .append(nsName, status); ures_getAllItemsWithFallback(resource.getAlias(), path.data(), sink, status); if (status == U_MISSING_RESOURCE_ERROR) { // Silently ignore and use Latin status = U_ZERO_ERROR; } else if (U_FAILURE(status)) { return; } sink.isFallback = TRUE; } // Now load Latin. sink.isLatin = TRUE; ures_getAllItemsWithFallback(resource.getAlias(), gLatnPath, sink, status); if (U_FAILURE(status)) return; // If longData is empty, default it to be equal to shortData if (result->longData.isEmpty()) { result->longData.setToBogus(); } // Check for "other" variants in each of the three data classes, and resolve missing elements. if (!result->longData.isBogus()) { checkForOtherVariants(&result->longData, status); if (U_FAILURE(status)) return; fillInMissing(&result->longData); } checkForOtherVariants(&result->shortData, status); if (U_FAILURE(status)) return; fillInMissing(&result->shortData); // TODO: Enable this statement when currency support is added // checkForOtherVariants(&result->shortCurrencyData, status); // if (U_FAILURE(status)) return; // fillInMissing(&result->shortCurrencyData); }
static const DataHeader * offsetTOCLookupFn(const UDataMemory *pData, const char *tocEntryName, UErrorCode *pErrorCode) { const OffsetTOC *toc = (OffsetTOC *)pData->toc; if(toc!=NULL) { const char *base=(const char *)pData->toc; uint32_t start, limit, number; /* perform a binary search for the data in the common data's table of contents */ start=0; limit=toc->count; /* number of names in this table of contents */ if (limit == 0) { /* Stub common data library used during build is empty. */ return NULL; } while(start<limit-1) { number=(start+limit)/2; if(uprv_strcmp(tocEntryName, &base[toc->entry[number].nameOffset])<0) { limit=number; } else { start=number; } } if(uprv_strcmp(tocEntryName, &base[toc->entry[start].nameOffset])==0) { /* found it */ #ifdef UDATA_DEBUG /* fprintf(stderr, "Found: %p\n",(base+toc[2*start+1])) */ fprintf(stderr, "Found it\n"); #endif return (const DataHeader *)&base[toc->entry[start].dataOffset]; } else { #ifdef UDATA_DEBUG fprintf(stderr, "Not found.\n"); #endif return NULL; } } else { #ifdef UDATA_DEBUG fprintf(stderr, "returning header\n"); #endif return pData->pHeader; } }
PluralMapBase::Category PluralMapBase::toCategory(const char *pluralForm) { for (int32_t i = 0; i < UPRV_LENGTHOF(gPluralForms); ++i) { if (uprv_strcmp(pluralForm, gPluralForms[i]) == 0) { return static_cast<Category>(i); } } return NONE; }
static int compareLangEntries(const void * entry1, const void * entry2) { double fraction1 = ((const UALanguageEntry *)entry1)->userFraction; double fraction2 = ((const UALanguageEntry *)entry2)->userFraction; // want descending order if (fraction1 > fraction2) return -1; if (fraction1 < fraction2) return 1; // userFractions the same, sort by languageCode return uprv_strcmp(((const UALanguageEntry *)entry1)->languageCode,((const UALanguageEntry *)entry2)->languageCode); }
static int32_t getPluralIndex(const char *pluralForm) { int32_t len = LENGTHOF(gPluralForms); for (int32_t i = 0; i < len; ++i) { if (uprv_strcmp(pluralForm, gPluralForms[i]) == 0) { return i; } } return -1; }
static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UBool reverseExt) { int32_t result = 0; char cmd[LARGE_BUFFER_MAX_SIZE]; /* If the shard object suffix and the final object suffix is different and the final object suffix and the * archive file suffix is the same, then the final library needs to be archived. */ if (uprv_strcmp(pkgDataFlags[SOBJ_EXT], pkgDataFlags[SO_EXT]) != 0 && uprv_strcmp(pkgDataFlags[A_EXT], pkgDataFlags[SO_EXT]) == 0) { sprintf(libFileNames[LIB_FILE_VERSION], "%s%s%s.%s", libFileNames[LIB_FILE], pkgDataFlags[LIB_EXT_ORDER][0] == '.' ? "." : "", reverseExt ? version : pkgDataFlags[SO_EXT], reverseExt ? pkgDataFlags[SO_EXT] : version); sprintf(cmd, "%s %s %s%s %s%s", pkgDataFlags[AR], pkgDataFlags[ARFLAGS], targetDir, libFileNames[LIB_FILE_VERSION], targetDir, libFileNames[LIB_FILE_VERSION_TMP]); result = system(cmd); if (result != 0) { return result; } /* Remove unneeded library file. */ sprintf(cmd, "%s %s%s", RM_CMD, targetDir, libFileNames[LIB_FILE_VERSION_TMP]); result = system(cmd); if (result != 0) { return result; } } else { uprv_strcpy(libFileNames[LIB_FILE_VERSION], libFileNames[LIB_FILE_VERSION_TMP]); } return result; }
NumberingSystem* U_EXPORT2 NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) { if (U_FAILURE(status)) { return NULL; } UBool nsResolved = TRUE; UBool usingFallback = FALSE; char buffer[ULOC_KEYWORDS_CAPACITY]; int32_t count = inLocale.getKeywordValue("numbers",buffer, sizeof(buffer),status); if ( count > 0 ) { // @numbers keyword was specified in the locale buffer[count] = '\0'; // Make sure it is null terminated. if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) || !uprv_strcmp(buffer,gTraditional) || !uprv_strcmp(buffer,gFinance)) { nsResolved = FALSE; } } else { uprv_strcpy(buffer,gDefault); nsResolved = FALSE; } if (!nsResolved) { // Resolve the numbering system ( default, native, traditional or finance ) into a "real" numbering system UErrorCode localStatus = U_ZERO_ERROR; UResourceBundle *resource = ures_open(NULL, inLocale.getName(), &localStatus); UResourceBundle *numberElementsRes = ures_getByKey(resource,gNumberElements,NULL,&localStatus); while (!nsResolved) { localStatus = U_ZERO_ERROR; count = 0; const UChar *nsName = ures_getStringByKeyWithFallback(numberElementsRes, buffer, &count, &localStatus); if ( count > 0 && count < ULOC_KEYWORDS_CAPACITY ) { // numbering system found u_UCharsToChars(nsName,buffer,count); buffer[count] = '\0'; // Make sure it is null terminated. nsResolved = TRUE; } if (!nsResolved) { // Fallback behavior per TR35 - traditional falls back to native, finance and native fall back to default if (!uprv_strcmp(buffer,gNative) || !uprv_strcmp(buffer,gFinance)) { uprv_strcpy(buffer,gDefault); } else if (!uprv_strcmp(buffer,gTraditional)) { uprv_strcpy(buffer,gNative); } else { // If we get here we couldn't find even the default numbering system usingFallback = TRUE; nsResolved = TRUE; } } } ures_close(numberElementsRes); ures_close(resource); } if (usingFallback) { status = U_USING_FALLBACK_WARNING; NumberingSystem *ns = new NumberingSystem(); return ns; } else { return NumberingSystem::createInstanceByName(buffer,status); } }