ICU-1941 aliasing more robust when data is absent - found while testing lipo
X-SVN-Rev: 9884
This commit is contained in:
parent
b7120e2ff7
commit
1acbac0711
@ -544,65 +544,66 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r,
|
|||||||
{
|
{
|
||||||
/* got almost everything, let's try to open */
|
/* got almost everything, let's try to open */
|
||||||
/* first, open the bundle with real data */
|
/* first, open the bundle with real data */
|
||||||
UResourceBundle *mainRes = ures_openDirect(path, locale, status);
|
UResourceBundle *result = resB;
|
||||||
UResourceBundle *result = NULL;
|
|
||||||
const char* temp = NULL;
|
const char* temp = NULL;
|
||||||
|
UResourceBundle *mainRes = ures_openDirect(path, locale, status);
|
||||||
if(keyPath == NULL) {
|
if(U_SUCCESS(*status)) {
|
||||||
/* no key path. This means that we are going to
|
if(keyPath == NULL) {
|
||||||
* to use the corresponding resource from
|
/* no key path. This means that we are going to
|
||||||
* another bundle
|
* to use the corresponding resource from
|
||||||
*/
|
* another bundle
|
||||||
/* first, we are going to get a corresponding parent
|
*/
|
||||||
* resource to the one we are searching.
|
/* first, we are going to get a corresponding parent
|
||||||
*/
|
* resource to the one we are searching.
|
||||||
const char* aKey = parent->fResPath;
|
*/
|
||||||
if(aKey) {
|
const char* aKey = parent->fResPath;
|
||||||
r = res_findResource(&(mainRes->fResData), mainRes->fRes, &aKey, &temp);
|
if(aKey) {
|
||||||
} else {
|
r = res_findResource(&(mainRes->fResData), mainRes->fRes, &aKey, &temp);
|
||||||
r = mainRes->fRes;
|
} else {
|
||||||
}
|
r = mainRes->fRes;
|
||||||
if(key) {
|
|
||||||
/* we need to make keyPath from parents fResPath and
|
|
||||||
* current key, if there is a key associated
|
|
||||||
*/
|
|
||||||
aKey = key;
|
|
||||||
r = res_findResource(&(mainRes->fResData), r, &aKey, &temp);
|
|
||||||
} else if(index != -1) {
|
|
||||||
/* if there is no key, but there is an index, try to get by the index */
|
|
||||||
/* here we have either a table or an array, so get the element */
|
|
||||||
if(RES_GET_TYPE(r) == RES_TABLE) {
|
|
||||||
r = res_getTableItemByIndex(&(mainRes->fResData), r, index, &aKey);
|
|
||||||
} else { /* array */
|
|
||||||
r = res_getArrayItem(&(mainRes->fResData), r, index);
|
|
||||||
}
|
}
|
||||||
}
|
if(key) {
|
||||||
if(r != RES_BOGUS) {
|
/* we need to make keyPath from parents fResPath and
|
||||||
result = init_resb_result(&(mainRes->fResData), r, key, -1, mainRes->fData, parent, noAlias+1, resB, status);
|
* current key, if there is a key associated
|
||||||
} else {
|
*/
|
||||||
*status = U_MISSING_RESOURCE_ERROR;
|
aKey = key;
|
||||||
result = resB;
|
r = res_findResource(&(mainRes->fResData), r, &aKey, &temp);
|
||||||
}
|
} else if(index != -1) {
|
||||||
} else {
|
/* if there is no key, but there is an index, try to get by the index */
|
||||||
/* this one is a bit trickier.
|
/* here we have either a table or an array, so get the element */
|
||||||
* we start finding keys, but after we resolve one alias, the path might continue.
|
if(RES_GET_TYPE(r) == RES_TABLE) {
|
||||||
* Consider:
|
r = res_getTableItemByIndex(&(mainRes->fResData), r, index, &aKey);
|
||||||
* aliastest:alias { "testtypes/anotheralias/Sequence" }
|
} else { /* array */
|
||||||
* anotheralias:alias { "/ICUDATA/sh/CollationElements" }
|
r = res_getArrayItem(&(mainRes->fResData), r, index);
|
||||||
* aliastest resource should finally have the sequence, not collation elements.
|
}
|
||||||
*/
|
}
|
||||||
result = mainRes;
|
if(r != RES_BOGUS) {
|
||||||
while(*keyPath) {
|
result = init_resb_result(&(mainRes->fResData), r, key, -1, mainRes->fData, parent, noAlias+1, resB, status);
|
||||||
r = res_findResource(&(result->fResData), result->fRes, (const char**)&keyPath, &temp);
|
} else {
|
||||||
if(r == RES_BOGUS) {
|
|
||||||
*status = U_MISSING_RESOURCE_ERROR;
|
*status = U_MISSING_RESOURCE_ERROR;
|
||||||
result = resB;
|
result = resB;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
resB = init_resb_result(&(result->fResData), r, key, -1, result->fData, parent, noAlias+1, resB, status);
|
} else {
|
||||||
result = resB;
|
/* this one is a bit trickier.
|
||||||
|
* we start finding keys, but after we resolve one alias, the path might continue.
|
||||||
|
* Consider:
|
||||||
|
* aliastest:alias { "testtypes/anotheralias/Sequence" }
|
||||||
|
* anotheralias:alias { "/ICUDATA/sh/CollationElements" }
|
||||||
|
* aliastest resource should finally have the sequence, not collation elements.
|
||||||
|
*/
|
||||||
|
result = mainRes;
|
||||||
|
while(*keyPath && U_SUCCESS(*status)) {
|
||||||
|
r = res_findResource(&(result->fResData), result->fRes, (const char**)&keyPath, &temp);
|
||||||
|
if(r == RES_BOGUS) {
|
||||||
|
*status = U_MISSING_RESOURCE_ERROR;
|
||||||
|
result = resB;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
resB = init_resb_result(&(result->fResData), r, key, -1, result->fData, parent, noAlias+1, resB, status);
|
||||||
|
result = resB;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uprv_free(chAlias);
|
uprv_free(chAlias);
|
||||||
ures_close(mainRes);
|
ures_close(mainRes);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user