From 7d8ae29f34e51bb9e2b8371bbe9d5ea5224fc458 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Sun, 15 Aug 2010 00:55:54 +0000 Subject: [PATCH] ICU-7888 fix package:enumDependencies X-SVN-Rev: 28473 --- icu4c/source/tools/toolutil/package.cpp | 2 +- icu4c/source/tools/toolutil/package.h | 7 ++++++- icu4c/source/tools/toolutil/pkgitems.cpp | 12 +++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/icu4c/source/tools/toolutil/package.cpp b/icu4c/source/tools/toolutil/package.cpp index 47ccbadb20..7b7f015356 100644 --- a/icu4c/source/tools/toolutil/package.cpp +++ b/icu4c/source/tools/toolutil/package.cpp @@ -1239,7 +1239,7 @@ void Package::setItemCapacity(int32_t max) exit(U_MEMORY_ALLOCATION_ERROR); } if(items && itemCount>0) { - uprv_memcpy((void*)newItems, (const void*)items, itemCount*sizeof(items[0])); + uprv_memcpy(newItems, items, itemCount*sizeof(items[0])); } itemMax = max; items = newItems; diff --git a/icu4c/source/tools/toolutil/package.h b/icu4c/source/tools/toolutil/package.h index a1cb164b30..50ee72e656 100644 --- a/icu4c/source/tools/toolutil/package.h +++ b/icu4c/source/tools/toolutil/package.h @@ -117,13 +117,18 @@ public: UBool checkDependencies(); /* - * Enumerate all the dependencies and give the results to context and check + * Enumerate all the dependencies and give the results to context and call CheckDependency callback + * @param context user context (will be passed to check function) + * @param check will be called with context and any missing items */ void enumDependencies(void *context, CheckDependency check); private: void enumDependencies(Item *pItem, void *context, CheckDependency check); + /** + * Default CheckDependency function used by checkDependencies() + */ static void checkDependency(void *context, const char *itemName, const char *targetName); /* diff --git a/icu4c/source/tools/toolutil/pkgitems.cpp b/icu4c/source/tools/toolutil/pkgitems.cpp index 03fd093025..0dfcebf48c 100644 --- a/icu4c/source/tools/toolutil/pkgitems.cpp +++ b/icu4c/source/tools/toolutil/pkgitems.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2003-2009, International Business Machines +* Copyright (C) 2003-2010, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -284,6 +284,7 @@ ures_enumDependencies(const char *itemName, const ResourceData *pResData, Resource res, const char *inKey, const char *parentKey, int32_t depth, CheckDependency check, void *context, + Package *pkg, UErrorCode *pErrorCode) { switch(res_getPublicType(res)) { case URES_STRING: @@ -329,6 +330,7 @@ ures_enumDependencies(const char *itemName, item, itemKey, inKey, depth+1, check, context, + pkg, pErrorCode); if(U_FAILURE(*pErrorCode)) { fprintf(stderr, "icupkg/ures_enumDependencies(%s table res=%08x)[%d].recurse(%s: %08x) failed\n", @@ -349,6 +351,7 @@ ures_enumDependencies(const char *itemName, item, NULL, inKey, depth+1, check, context, + pkg, pErrorCode); if(U_FAILURE(*pErrorCode)) { fprintf(stderr, "icupkg/ures_enumDependencies(%s array res=%08x)[%d].recurse(%08x) failed\n", @@ -367,6 +370,7 @@ static void ures_enumDependencies(const char *itemName, const UDataInfo *pInfo, const uint8_t *inBytes, int32_t length, CheckDependency check, void *context, + Package *pkg, UErrorCode *pErrorCode) { ResourceData resData; @@ -397,9 +401,6 @@ ures_enumDependencies(const char *itemName, const UDataInfo *pInfo, return; } check(context, itemName, poolName); - // TODO: The Package should be passed in. - // Since the context is always a Package, we could just redeclare it. - U_NAMESPACE_QUALIFIER Package *pkg=(U_NAMESPACE_QUALIFIER Package *)context; int32_t index=pkg->findItem(poolName); if(index<0) { // We cannot work with a bundle if its pool resource is missing. @@ -433,6 +434,7 @@ ures_enumDependencies(const char *itemName, const UDataInfo *pInfo, itemName, &resData, resData.rootRes, NULL, NULL, 0, check, context, + pkg, pErrorCode); } @@ -595,7 +597,7 @@ Package::enumDependencies(Item *pItem, void *context, CheckDependency check) { * We do not want to duplicate that code, especially not together with on-the-fly swapping. */ NativeItem nrb(pItem, ures_swap); - ures_enumDependencies(pItem->name, nrb.getDataInfo(), nrb.getBytes(), nrb.getLength(), check, context, &errorCode); + ures_enumDependencies(pItem->name, nrb.getDataInfo(), nrb.getBytes(), nrb.getLength(), check, context, this, &errorCode); break; } case FMT_CNV: