diff options
author | mcheshkov <mcheshkov@yandex-team.ru> | 2022-02-10 16:46:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:15 +0300 |
commit | e9d19cec64684c9c1e6b0c98297e5b895cf904fe (patch) | |
tree | 2768b1223e96a8a0610a93d18425d9647c1123c8 /contrib/libs/icu/common/uresbund.cpp | |
parent | 60040c91ffe701a84689b2c6310ff845e65cff42 (diff) | |
download | ydb-e9d19cec64684c9c1e6b0c98297e5b895cf904fe.tar.gz |
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/common/uresbund.cpp')
-rw-r--r-- | contrib/libs/icu/common/uresbund.cpp | 420 |
1 files changed, 210 insertions, 210 deletions
diff --git a/contrib/libs/icu/common/uresbund.cpp b/contrib/libs/icu/common/uresbund.cpp index 97df4a85eb..87ef6e8853 100644 --- a/contrib/libs/icu/common/uresbund.cpp +++ b/contrib/libs/icu/common/uresbund.cpp @@ -1,4 +1,4 @@ -// © 2016 and later: Unicode, Inc. and others. +// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ****************************************************************************** @@ -21,7 +21,7 @@ ****************************************************************************** */ -#include "unicode/ures.h" +#include "unicode/ures.h" #include "unicode/ustring.h" #include "unicode/ucnv.h" #include "charstr.h" @@ -31,7 +31,7 @@ #include "ucln_cmn.h" #include "cmemory.h" #include "cstring.h" -#include "mutex.h" +#include "mutex.h" #include "uhash.h" #include "unicode/uenum.h" #include "uenumimp.h" @@ -39,7 +39,7 @@ #include "umutex.h" #include "putilimp.h" #include "uassert.h" -#include "uresdata.h" +#include "uresdata.h" using namespace icu; @@ -49,9 +49,9 @@ TODO: This cache should probably be removed when the deprecated code is completely removed. */ static UHashtable *cache = NULL; -static icu::UInitOnce gCacheInitOnce = U_INITONCE_INITIALIZER; +static icu::UInitOnce gCacheInitOnce = U_INITONCE_INITIALIZER; -static UMutex resbMutex; +static UMutex resbMutex; /* INTERNAL: hashes an entry */ static int32_t U_CALLCONV hashEntry(const UHashTok parm) { @@ -95,7 +95,7 @@ static UBool chopLocale(char *name) { * Internal function */ static void entryIncrease(UResourceDataEntry *entry) { - Mutex lock(&resbMutex); + Mutex lock(&resbMutex); entry->fCountExisting++; while(entry->fParent != NULL) { entry = entry->fParent; @@ -182,7 +182,7 @@ static int32_t ures_flushCache() /*if shared data hasn't even been lazy evaluated yet * return 0 */ - Mutex lock(&resbMutex); + Mutex lock(&resbMutex); if (cache == NULL) { return 0; } @@ -228,7 +228,7 @@ U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void) { const UHashElement *e; UResourceDataEntry *resB; - Mutex lock(&resbMutex); + Mutex lock(&resbMutex); if (cache == NULL) { fprintf(stderr,"%s:%d: RB Cache is NULL.\n", __FILE__, __LINE__); return FALSE; @@ -363,12 +363,12 @@ static UResourceDataEntry *init_entry(const char *localeID, const char *path, UE /* this is the actual loading */ res_load(&(r->fData), r->fPath, r->fName, status); - if (U_FAILURE(*status)) { - /* if we failed to load due to an out-of-memory error, exit early. */ - if (*status == U_MEMORY_ALLOCATION_ERROR) { - uprv_free(r); - return NULL; - } + if (U_FAILURE(*status)) { + /* if we failed to load due to an out-of-memory error, exit early. */ + if (*status == U_MEMORY_ALLOCATION_ERROR) { + uprv_free(r); + return NULL; + } /* we have no such entry in dll, so it will always use fallback */ *status = U_USING_FALLBACK_WARNING; r->fBogus = U_USING_FALLBACK_WARNING; @@ -393,8 +393,8 @@ static UResourceDataEntry *init_entry(const char *localeID, const char *path, UE /* We'll try to get alias string from the bundle */ aliasres = res_getResource(&(r->fData), "%%ALIAS"); if (aliasres != RES_BOGUS) { - // No tracing: called during initial data loading - const UChar *alias = res_getStringNoTrace(&(r->fData), aliasres, &aliasLen); + // No tracing: called during initial data loading + const UChar *alias = res_getStringNoTrace(&(r->fData), aliasres, &aliasLen); if(alias != NULL && aliasLen > 0) { /* if there is actual alias - unload and load new data */ u_UCharsToChars(alias, aliasName, aliasLen+1); r->fAlias = init_entry(aliasName, path, status); @@ -485,9 +485,9 @@ findFirstExisting(const char* path, char* name, /*Fallback data stuff*/ *hasChopped = chopLocale(name); - if (*hasChopped && *name == '\0') { - uprv_strcpy(name, "und"); - } + if (*hasChopped && *name == '\0') { + uprv_strcpy(name, "und"); + } } return r; } @@ -512,18 +512,18 @@ U_CFUNC void ures_initStackObject(UResourceBundle* resB) { ures_setIsStackObject(resB, TRUE); } -U_NAMESPACE_BEGIN - -StackUResourceBundle::StackUResourceBundle() { - ures_initStackObject(&bundle); -} - -StackUResourceBundle::~StackUResourceBundle() { - ures_close(&bundle); -} - -U_NAMESPACE_END - +U_NAMESPACE_BEGIN + +StackUResourceBundle::StackUResourceBundle() { + ures_initStackObject(&bundle); +} + +StackUResourceBundle::~StackUResourceBundle() { + ures_close(&bundle); +} + +U_NAMESPACE_END + static UBool // returns U_SUCCESS(*status) loadParentsExceptRoot(UResourceDataEntry *&t1, char name[], int32_t nameCapacity, @@ -535,8 +535,8 @@ loadParentsExceptRoot(UResourceDataEntry *&t1, Resource parentRes = res_getResource(&t1->fData, "%%Parent"); if (parentRes != RES_BOGUS) { // An explicit parent was found. int32_t parentLocaleLen = 0; - // No tracing: called during initial data loading - const UChar *parentLocaleName = res_getStringNoTrace(&(t1->fData), parentRes, &parentLocaleLen); + // No tracing: called during initial data loading + const UChar *parentLocaleName = res_getStringNoTrace(&(t1->fData), parentRes, &parentLocaleLen); if(parentLocaleName != NULL && 0 < parentLocaleLen && parentLocaleLen < nameCapacity) { u_UCharsToChars(parentLocaleName, name, parentLocaleLen + 1); if (uprv_strcmp(name, kRootLocaleName) == 0) { @@ -555,11 +555,11 @@ loadParentsExceptRoot(UResourceDataEntry *&t1, UErrorCode usrStatus = U_ZERO_ERROR; if (usingUSRData) { // This code inserts user override data into the inheritance chain. u2 = init_entry(name, usrDataPath, &usrStatus); - // If we failed due to out-of-memory, report that to the caller and exit early. - if (usrStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = usrStatus; - return FALSE; - } + // If we failed due to out-of-memory, report that to the caller and exit early. + if (usrStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = usrStatus; + return FALSE; + } } if (usingUSRData && U_SUCCESS(usrStatus) && u2->fBogus == U_ZERO_ERROR) { @@ -660,105 +660,105 @@ static UResourceDataEntry *entryOpen(const char* path, const char* localeID, } } - Mutex lock(&resbMutex); // Lock resbMutex until the end of this function. - - /* We're going to skip all the locales that do not have any data */ - r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); - - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finish; - } - - if(r != NULL) { /* if there is one real locale, we can look for parents. */ - t1 = r; - hasRealData = TRUE; - if ( usingUSRData ) { /* This code inserts user override data into the inheritance chain */ - UErrorCode usrStatus = U_ZERO_ERROR; - UResourceDataEntry *u1 = init_entry(t1->fName, usrDataPath, &usrStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finish; - } - if ( u1 != NULL ) { - if(u1->fBogus == U_ZERO_ERROR) { - u1->fParent = t1; - r = u1; - } else { - /* the USR override data wasn't found, set it to be deleted */ - u1->fCountExisting = 0; - } - } - } - if (hasChopped && !isRoot) { - if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { - goto finish; - } - } - } - - /* we could have reached this point without having any real data */ - /* if that is the case, we need to chain in the default locale */ - if(r==NULL && openType == URES_OPEN_LOCALE_DEFAULT_ROOT && !isDefault && !isRoot) { - /* insert default locale */ - uprv_strcpy(name, uloc_getDefault()); + Mutex lock(&resbMutex); // Lock resbMutex until the end of this function. + + /* We're going to skip all the locales that do not have any data */ + r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); + + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + + if(r != NULL) { /* if there is one real locale, we can look for parents. */ + t1 = r; + hasRealData = TRUE; + if ( usingUSRData ) { /* This code inserts user override data into the inheritance chain */ + UErrorCode usrStatus = U_ZERO_ERROR; + UResourceDataEntry *u1 = init_entry(t1->fName, usrDataPath, &usrStatus); + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + if ( u1 != NULL ) { + if(u1->fBogus == U_ZERO_ERROR) { + u1->fParent = t1; + r = u1; + } else { + /* the USR override data wasn't found, set it to be deleted */ + u1->fCountExisting = 0; + } + } + } + if (hasChopped && !isRoot) { + if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { + goto finish; + } + } + } + + /* we could have reached this point without having any real data */ + /* if that is the case, we need to chain in the default locale */ + if(r==NULL && openType == URES_OPEN_LOCALE_DEFAULT_ROOT && !isDefault && !isRoot) { + /* insert default locale */ + uprv_strcpy(name, uloc_getDefault()); r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finish; - } - intStatus = U_USING_DEFAULT_WARNING; - if(r != NULL) { /* the default locale exists */ + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + intStatus = U_USING_DEFAULT_WARNING; + if(r != NULL) { /* the default locale exists */ t1 = r; hasRealData = TRUE; - isDefault = TRUE; - // TODO: Why not if (usingUSRData) { ... } like in the non-default-locale code path? + isDefault = TRUE; + // TODO: Why not if (usingUSRData) { ... } like in the non-default-locale code path? if (hasChopped && !isRoot) { if (!loadParentsExceptRoot(t1, name, UPRV_LENGTHOF(name), usingUSRData, usrDataPath, status)) { - goto finish; + goto finish; } } } - } + } - /* we could still have r == NULL at this point - maybe even default locale is not */ - /* present */ - if(r == NULL) { - uprv_strcpy(name, kRootLocaleName); - r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); - // If we failed due to out-of-memory, report the failure and exit early. - if (intStatus == U_MEMORY_ALLOCATION_ERROR) { - *status = intStatus; - goto finish; - } - if(r != NULL) { - t1 = r; + /* we could still have r == NULL at this point - maybe even default locale is not */ + /* present */ + if(r == NULL) { + uprv_strcpy(name, kRootLocaleName); + r = findFirstExisting(path, name, &isRoot, &hasChopped, &isDefault, &intStatus); + // If we failed due to out-of-memory, report the failure and exit early. + if (intStatus == U_MEMORY_ALLOCATION_ERROR) { + *status = intStatus; + goto finish; + } + if(r != NULL) { + t1 = r; intStatus = U_USING_DEFAULT_WARNING; - hasRealData = TRUE; - } else { /* we don't even have the root locale */ - *status = U_MISSING_RESOURCE_ERROR; - goto finish; + hasRealData = TRUE; + } else { /* we don't even have the root locale */ + *status = U_MISSING_RESOURCE_ERROR; + goto finish; } - } else if(!isRoot && uprv_strcmp(t1->fName, kRootLocaleName) != 0 && - t1->fParent == NULL && !r->fData.noFallback) { - if (!insertRootBundle(t1, status)) { - goto finish; + } else if(!isRoot && uprv_strcmp(t1->fName, kRootLocaleName) != 0 && + t1->fParent == NULL && !r->fData.noFallback) { + if (!insertRootBundle(t1, status)) { + goto finish; } - if(!hasRealData) { - r->fBogus = U_USING_DEFAULT_WARNING; + if(!hasRealData) { + r->fBogus = U_USING_DEFAULT_WARNING; } - } - - // TODO: Does this ever loop? - while(r != NULL && !isRoot && t1->fParent != NULL) { - t1->fParent->fCountExisting++; - t1 = t1->fParent; - } + } -finish: + // TODO: Does this ever loop? + while(r != NULL && !isRoot && t1->fParent != NULL) { + t1->fParent->fCountExisting++; + t1 = t1->fParent; + } + +finish: if(U_SUCCESS(*status)) { if(intStatus != U_ZERO_ERROR) { *status = intStatus; @@ -782,7 +782,7 @@ entryOpenDirect(const char* path, const char* localeID, UErrorCode* status) { return NULL; } - Mutex lock(&resbMutex); + Mutex lock(&resbMutex); // findFirstExisting() without fallbacks. UResourceDataEntry *r = init_entry(localeID, path, status); if(U_SUCCESS(*status)) { @@ -862,7 +862,7 @@ static void entryCloseInt(UResourceDataEntry *resB) { */ static void entryClose(UResourceDataEntry *resB) { - Mutex lock(&resbMutex); + Mutex lock(&resbMutex); entryCloseInt(resB); } @@ -1119,11 +1119,11 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, UResourceDataEntry *dataEntry = mainRes->fData; char stackPath[URES_MAX_BUFFER_SIZE]; char *pathBuf = stackPath, *myPath = pathBuf; - if(uprv_strlen(keyPath) >= UPRV_LENGTHOF(stackPath)) { + if(uprv_strlen(keyPath) >= UPRV_LENGTHOF(stackPath)) { pathBuf = (char *)uprv_malloc((uprv_strlen(keyPath)+1)*sizeof(char)); if(pathBuf == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; - ures_close(mainRes); + ures_close(mainRes); return NULL; } } @@ -1167,7 +1167,7 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, if(mainRes != result) { ures_close(mainRes); } - ResourceTracer(resB).maybeTrace("getalias"); + ResourceTracer(resB).maybeTrace("getalias"); return result; } } else { @@ -1247,7 +1247,7 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r, /*resB->fParent = parent->fRes;*/ uprv_memmove(&resB->fResData, rdata, sizeof(ResourceData)); resB->fSize = res_countArrayItems(&(resB->fResData), resB->fRes); - ResourceTracer(resB).trace("get"); + ResourceTracer(resB).trace("get"); return resB; } @@ -1296,7 +1296,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getString(const UResourceBundle* resB, int32_ *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - s = res_getString({resB}, &(resB->fResData), resB->fRes, len); + s = res_getString({resB}, &(resB->fResData), resB->fRes, len); if (s == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -1385,7 +1385,7 @@ U_CAPI const uint8_t* U_EXPORT2 ures_getBinary(const UResourceBundle* resB, int3 *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - p = res_getBinary({resB}, &(resB->fResData), resB->fRes, len); + p = res_getBinary({resB}, &(resB->fResData), resB->fRes, len); if (p == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -1402,7 +1402,7 @@ U_CAPI const int32_t* U_EXPORT2 ures_getIntVector(const UResourceBundle* resB, i *status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } - p = res_getIntVector({resB}, &(resB->fResData), resB->fRes, len); + p = res_getIntVector({resB}, &(resB->fResData), resB->fRes, len); if (p == NULL) { *status = U_RESOURCE_TYPE_MISMATCH; } @@ -1423,7 +1423,7 @@ U_CAPI int32_t U_EXPORT2 ures_getInt(const UResourceBundle* resB, UErrorCode *st *status = U_RESOURCE_TYPE_MISMATCH; return 0xffffffff; } - return res_getInt({resB}, resB->fRes); + return res_getInt({resB}, resB->fRes); } U_CAPI uint32_t U_EXPORT2 ures_getUInt(const UResourceBundle* resB, UErrorCode *status) { @@ -1438,7 +1438,7 @@ U_CAPI uint32_t U_EXPORT2 ures_getUInt(const UResourceBundle* resB, UErrorCode * *status = U_RESOURCE_TYPE_MISMATCH; return 0xffffffff; } - return res_getUInt({resB}, resB->fRes); + return res_getUInt({resB}, resB->fRes); } U_CAPI UResType U_EXPORT2 ures_getType(const UResourceBundle *resB) { @@ -1449,15 +1449,15 @@ U_CAPI UResType U_EXPORT2 ures_getType(const UResourceBundle *resB) { } U_CAPI const char * U_EXPORT2 ures_getKey(const UResourceBundle *resB) { - // - // TODO: Trace ures_getKey? I guess not usually. - // - // We usually get the key string to decide whether we want the value, or to - // make a key-value pair. Tracing the value should suffice. - // - // However, I believe we have some data (e.g., in res_index) where the key - // strings are the data. Tracing the enclosing table should suffice. - // + // + // TODO: Trace ures_getKey? I guess not usually. + // + // We usually get the key string to decide whether we want the value, or to + // make a key-value pair. Tracing the value should suffice. + // + // However, I believe we have some data (e.g., in res_index) where the key + // strings are the data. Tracing the enclosing table should suffice. + // if(resB == NULL) { return NULL; } @@ -1480,7 +1480,7 @@ static const UChar* ures_getStringWithAlias(const UResourceBundle *resB, Resourc ures_close(tempRes); return result; } else { - return res_getString({resB, sIndex}, &(resB->fResData), r, len); + return res_getString({resB, sIndex}, &(resB->fResData), r, len); } } @@ -1516,7 +1516,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* switch(RES_GET_TYPE(resB->fRes)) { case URES_STRING: case URES_STRING_V2: - return res_getString({resB}, &(resB->fResData), resB->fRes, len); + return res_getString({resB}, &(resB->fResData), resB->fRes, len); case URES_TABLE: case URES_TABLE16: case URES_TABLE32: @@ -1661,7 +1661,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByIndex(const UResourceBundle *resB, switch(RES_GET_TYPE(resB->fRes)) { case URES_STRING: case URES_STRING_V2: - return res_getString({resB}, &(resB->fResData), resB->fRes, len); + return res_getString({resB}, &(resB->fResData), resB->fRes, len); case URES_TABLE: case URES_TABLE16: case URES_TABLE32: @@ -1953,10 +1953,10 @@ void getAllItemsWithFallback( // When the sink sees the no-fallback/no-inheritance marker, // then it would remove the parent's item. // We would deserialize parent values even though they are overridden in a child bundle. - value.setData(&bundle->fResData); + value.setData(&bundle->fResData); UResourceDataEntry *parentEntry = bundle->fData->fParent; UBool hasParent = parentEntry != NULL && U_SUCCESS(parentEntry->fBogus); - value.setResource(bundle->fRes, ResourceTracer(bundle)); + value.setResource(bundle->fRes, ResourceTracer(bundle)); sink.put(bundle->fKey, value, !hasParent, errorCode); if (hasParent) { // We might try to query the sink whether @@ -2001,53 +2001,53 @@ void getAllItemsWithFallback( } // namespace -// Requires a ResourceDataValue fill-in, so that we need not cast from a ResourceValue. -// Unfortunately, the caller must know which subclass to make and pass in. -// Alternatively, we could make it as polymorphic as in Java by -// returning a ResourceValue pointer (possibly wrapped into a LocalPointer) -// that the caller then owns. -// -// Also requires a UResourceBundle fill-in, so that the value's ResourceTracer -// can point to a non-local bundle. -// Without tracing, the child bundle could be a function-local object. -U_CAPI void U_EXPORT2 -ures_getValueWithFallback(const UResourceBundle *bundle, const char *path, - UResourceBundle *tempFillIn, - ResourceDataValue &value, UErrorCode &errorCode) { - if (U_FAILURE(errorCode)) { return; } - if (path == nullptr) { - errorCode = U_ILLEGAL_ARGUMENT_ERROR; - return; - } - const UResourceBundle *rb; - if (*path == 0) { - // empty path - rb = bundle; - } else { - rb = ures_getByKeyWithFallback(bundle, path, tempFillIn, &errorCode); - if (U_FAILURE(errorCode)) { - return; - } - } - value.setData(&rb->fResData); - value.setResource(rb->fRes, ResourceTracer(rb)); -} - +// Requires a ResourceDataValue fill-in, so that we need not cast from a ResourceValue. +// Unfortunately, the caller must know which subclass to make and pass in. +// Alternatively, we could make it as polymorphic as in Java by +// returning a ResourceValue pointer (possibly wrapped into a LocalPointer) +// that the caller then owns. +// +// Also requires a UResourceBundle fill-in, so that the value's ResourceTracer +// can point to a non-local bundle. +// Without tracing, the child bundle could be a function-local object. U_CAPI void U_EXPORT2 +ures_getValueWithFallback(const UResourceBundle *bundle, const char *path, + UResourceBundle *tempFillIn, + ResourceDataValue &value, UErrorCode &errorCode) { + if (U_FAILURE(errorCode)) { return; } + if (path == nullptr) { + errorCode = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + const UResourceBundle *rb; + if (*path == 0) { + // empty path + rb = bundle; + } else { + rb = ures_getByKeyWithFallback(bundle, path, tempFillIn, &errorCode); + if (U_FAILURE(errorCode)) { + return; + } + } + value.setData(&rb->fResData); + value.setResource(rb->fRes, ResourceTracer(rb)); +} + +U_CAPI void U_EXPORT2 ures_getAllItemsWithFallback(const UResourceBundle *bundle, const char *path, icu::ResourceSink &sink, UErrorCode &errorCode) { if (U_FAILURE(errorCode)) { return; } - if (path == nullptr) { + if (path == nullptr) { errorCode = U_ILLEGAL_ARGUMENT_ERROR; return; } - StackUResourceBundle stackBundle; + StackUResourceBundle stackBundle; const UResourceBundle *rb; if (*path == 0) { // empty path rb = bundle; } else { - rb = ures_getByKeyWithFallback(bundle, path, stackBundle.getAlias(), &errorCode); + rb = ures_getByKeyWithFallback(bundle, path, stackBundle.getAlias(), &errorCode); if (U_FAILURE(errorCode)) { return; } @@ -2137,7 +2137,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c switch (RES_GET_TYPE(res)) { case URES_STRING: case URES_STRING_V2: - return res_getString({resB, key}, rd, res, len); + return res_getString({resB, key}, rd, res, len); case URES_ALIAS: { const UChar* result = 0; @@ -2159,7 +2159,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c switch (RES_GET_TYPE(res)) { case URES_STRING: case URES_STRING_V2: - return res_getString({resB, key}, &(resB->fResData), res, len); + return res_getString({resB, key}, &(resB->fResData), res, len); case URES_ALIAS: { const UChar* result = 0; @@ -2180,7 +2180,7 @@ U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, c /* here should go a first attempt to locate the key using index table */ const ResourceData *rd = getFallbackData(resB, &key, &realData, &res, status); if(U_SUCCESS(*status)) { - // TODO: Tracing + // TODO: Tracing return res_getString(rd, res, len); } else { *status = U_MISSING_RESOURCE_ERROR; @@ -2326,8 +2326,8 @@ ures_openWithType(UResourceBundle *r, const char* path, const char* localeID, r->fSize = res_countArrayItems(&(r->fResData), r->fRes); r->fIndex = -1; - ResourceTracer(r).traceOpen(); - + ResourceTracer(r).traceOpen(); + return r; } @@ -2351,13 +2351,13 @@ ures_openDirect(const char* path, const char* localeID, UErrorCode* status) { } /** - * Internal API: This function is used to open a resource bundle + * Internal API: This function is used to open a resource bundle * proper fallback chaining is executed while initialization. * The result is stored in cache for later fallback search. - * - * Same as ures_open(), but uses the fill-in parameter and does not allocate a new bundle. + * + * Same as ures_open(), but uses the fill-in parameter and does not allocate a new bundle. */ -U_INTERNAL void U_EXPORT2 +U_INTERNAL void U_EXPORT2 ures_openFillIn(UResourceBundle *r, const char* path, const char* localeID, UErrorCode* status) { if(U_SUCCESS(*status) && r == NULL) { @@ -2368,18 +2368,18 @@ ures_openFillIn(UResourceBundle *r, const char* path, } /** - * Same as ures_openDirect(), but uses the fill-in parameter and does not allocate a new bundle. - */ -U_INTERNAL void U_EXPORT2 -ures_openDirectFillIn(UResourceBundle *r, const char* path, const char* localeID, UErrorCode* status) { - if(U_SUCCESS(*status) && r == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return; - } - ures_openWithType(r, path, localeID, URES_OPEN_DIRECT, status); -} - -/** + * Same as ures_openDirect(), but uses the fill-in parameter and does not allocate a new bundle. + */ +U_INTERNAL void U_EXPORT2 +ures_openDirectFillIn(UResourceBundle *r, const char* path, const char* localeID, UErrorCode* status) { + if(U_SUCCESS(*status) && r == NULL) { + *status = U_ILLEGAL_ARGUMENT_ERROR; + return; + } + ures_openWithType(r, path, localeID, URES_OPEN_DIRECT, status); +} + +/** * API: Counts members. For arrays and tables, returns number of resources. * For strings, returns 1. */ @@ -2517,7 +2517,7 @@ ures_loc_nextLocale(UEnumeration* en, UResourceBundle *k = NULL; const char *result = NULL; int32_t len = 0; - if(ures_hasNext(res) && (k = ures_getNextResource(res, &ctx->curr, status)) != 0) { + if(ures_hasNext(res) && (k = ures_getNextResource(res, &ctx->curr, status)) != 0) { result = ures_getKey(k); len = (int32_t)uprv_strlen(result); } @@ -2611,8 +2611,8 @@ ures_getFunctionalEquivalent(char *result, int32_t resultCapacity, char defVal[1024] = ""; /* default value for given locale */ char defLoc[1024] = ""; /* default value for given locale */ char base[1024] = ""; /* base locale */ - char found[1024] = ""; - char parent[1024] = ""; + char found[1024] = ""; + char parent[1024] = ""; char full[1024] = ""; UResourceBundle bund1, bund2; UResourceBundle *res = NULL; @@ -2939,7 +2939,7 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status) valuesBuf[0]=0; valuesBuf[1]=0; - while((locale = uenum_next(locs, &locLen, status)) != 0) { + while((locale = uenum_next(locs, &locLen, status)) != 0) { UResourceBundle *bund = NULL; UResourceBundle *subPtr = NULL; UErrorCode subStatus = U_ZERO_ERROR; /* don't fail if a bundle is unopenable */ @@ -2964,7 +2964,7 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status) continue; } - while((subPtr = ures_getNextResource(&item,&subItem,&subStatus)) != 0 + while((subPtr = ures_getNextResource(&item,&subItem,&subStatus)) != 0 && U_SUCCESS(subStatus)) { const char *k; int32_t i; |