diff --git a/icu4c/source/common/uresdata.c b/icu4c/source/common/uresdata.c index 6738502b9c7..d5e61ef5575 100644 --- a/icu4c/source/common/uresdata.c +++ b/icu4c/source/common/uresdata.c @@ -187,77 +187,6 @@ _res_findTable32Item(const Resource *pRoot, const Resource res, const char *key, } } - -static Resource -_res_findTableItemN(const Resource *pRoot, const Resource res, const char *key, int32_t keyLen, - const char **realKey) { - const uint16_t *p=(const uint16_t *)RES_GET_POINTER(pRoot, res); - int32_t i, start, limit; - - limit=*p++; /* number of entries */ - - if(limit == 0) { /* this table is empty */ - *realKey = NULL; - return RES_BOGUS; - } - - /* do a binary search for the key */ - start=0; - while(startpRoot, t1, pathP, keyLen, key); + t2 = _res_findTableItem(pResData->pRoot, t1, pathP, &indexR, key); if(t2 == RES_BOGUS) { /* if we fail to get the resource by key, maybe we got an index */ indexR = uprv_strtol(pathP, &closeIndex, 10); @@ -459,7 +387,7 @@ res_findResource(const ResourceData *pResData, Resource r, const char** path, co } } } else if(type == URES_TABLE32) { - t2 = _res_findTable32ItemN(pResData->pRoot, t1, pathP, keyLen, key); + t2 = _res_findTable32Item(pResData->pRoot, t1, pathP, &indexR, key); if(t2 == RES_BOGUS) { /* if we fail to get the resource by key, maybe we got an index */ indexR = uprv_strtol(pathP, &closeIndex, 10); @@ -482,7 +410,7 @@ res_findResource(const ResourceData *pResData, Resource r, const char** path, co t1 = t2; type = RES_GET_TYPE(t1); /* position pathP to next resource key/index */ - pathP += keyLen+1; + pathP = *path; } return t1; diff --git a/icu4c/source/common/uresdata.h b/icu4c/source/common/uresdata.h index bf07226ae29..92a8667d6f2 100644 --- a/icu4c/source/common/uresdata.h +++ b/icu4c/source/common/uresdata.h @@ -199,7 +199,12 @@ res_countArrayItems(const ResourceData *pResData, const Resource res); U_CFUNC Resource res_getArrayItem(const ResourceData *pResData, Resource array, const int32_t indexS); U_CFUNC Resource res_getTableItemByIndex(const ResourceData *pResData, Resource table, int32_t indexS, const char ** key); U_CFUNC Resource res_getTableItemByKey(const ResourceData *pResData, Resource table, int32_t *indexS, const char* * key); -U_CFUNC Resource res_findResource(const ResourceData *pResData, Resource r, const char** path, const char** key); + +/* + * Modifies the contents of *path (replacing separators with NULs), + * and also moves *path forward while it finds items. + */ +U_CFUNC Resource res_findResource(const ResourceData *pResData, Resource r, char** path, const char** key); /** * Swap an ICU resource bundle. See udataswp.h.