diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index 24f204ae54a..67db5b98f03 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -257,9 +257,8 @@ ucol_open( const char *loc, UCollator *result = NULL; UResourceBundle *b = ures_open(NULL, loc, status); - /* first take on tailoring version: */ - /* get CollationElements -> Version */ - UResourceBundle *binary = ures_getByKey(b, "%%CollationBin", NULL, status); + UResourceBundle *collElem = ures_getByKey(b, "CollationElements", NULL, status); + UResourceBundle *binary = ures_getByKey(collElem, "%%CollationBin", NULL, status); if(*status == U_MISSING_RESOURCE_ERROR) { /* if we don't find tailoring, we'll fallback to UCA */ *status = U_USING_DEFAULT_ERROR; @@ -298,6 +297,7 @@ ucol_open( const char *loc, } else { /* There is another error, and we're just gonna clean up */ clean: ures_close(b); + ures_close(collElem); ures_close(binary); return NULL; } @@ -306,6 +306,7 @@ clean: } result->requestedLocale = (char *)uprv_malloc((uprv_strlen(loc)+1)*sizeof(char)); uprv_strcpy(result->requestedLocale, loc); + ures_close(collElem); return result; } diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c index abc87d4fdc5..71cc93f0092 100644 --- a/icu4c/source/test/cintltst/creststn.c +++ b/icu4c/source/test/cintltst/creststn.c @@ -631,7 +631,7 @@ static void TestBinaryCollationData(){ if(U_SUCCESS(status)){ CONFIRM_ErrorCode(status, U_ZERO_ERROR); CONFIRM_INT_EQ(ures_getType(coll), RES_TABLE); - binColl=ures_getByKey(teRes, "%%CollationBin", binColl, &status); + binColl=ures_getByKey(coll, "%%CollationBin", binColl, &status); if(U_SUCCESS(status)){ CONFIRM_ErrorCode(status, U_ZERO_ERROR); CONFIRM_INT_EQ(ures_getType(binColl), RES_BINARY); @@ -711,7 +711,8 @@ static void TestAPI() { log_err("ERROR: ures_getNextResource() failed \n"); } key=ures_getKey(teFillin); - if(strcmp(key, "%%CollationBin") != 0){ + /*if(strcmp(key, "%%CollationBin") != 0){*/ + if(strcmp(key, "CollationElements") != 0){ log_err("ERROR: ures_getNextResource() failed\n"); } @@ -910,7 +911,7 @@ static void TestErrorConditions(){ /*Test ures_getBinary(0 status != U_ILLEGAL_ARGUMENT_ERROR*/ status=U_ZERO_ERROR; coll = ures_getByKey(teRes, "CollationElements", coll, &status); - binColl=ures_getByKey(teRes, "%%CollationBin", binColl, &status); + binColl=ures_getByKey(coll, "%%CollationBin", binColl, &status); status=U_ILLEGAL_ARGUMENT_ERROR; binResult=(uint8_t*)ures_getBinary(binColl, &len, &status);