Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: source/common/uresbund.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/common/uprops.cpp ('k') | source/common/uresdata.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ****************************************************************************** 2 ******************************************************************************
3 * Copyright (C) 1997-2013, International Business Machines Corporation and 3 * Copyright (C) 1997-2014, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ****************************************************************************** 5 ******************************************************************************
6 * 6 *
7 * File URESBUND.C 7 * File URESBUND.C
8 * 8 *
9 * Modification History: 9 * Modification History:
10 * 10 *
11 * Date Name Description 11 * Date Name Description
12 * 04/01/97 aliu Creation. 12 * 04/01/97 aliu Creation.
13 * 06/14/99 stephen Removed functions taking a filename suffix. 13 * 06/14/99 stephen Removed functions taking a filename suffix.
(...skipping 15 matching lines...) Expand all
29 #include "cmemory.h" 29 #include "cmemory.h"
30 #include "cstring.h" 30 #include "cstring.h"
31 #include "uhash.h" 31 #include "uhash.h"
32 #include "unicode/uenum.h" 32 #include "unicode/uenum.h"
33 #include "uenumimp.h" 33 #include "uenumimp.h"
34 #include "ulocimp.h" 34 #include "ulocimp.h"
35 #include "umutex.h" 35 #include "umutex.h"
36 #include "putilimp.h" 36 #include "putilimp.h"
37 #include "uassert.h" 37 #include "uassert.h"
38 38
39 using namespace icu;
39 40
40 /* 41 /*
41 Static cache for already opened resource bundles - mostly for keeping fallback i nfo 42 Static cache for already opened resource bundles - mostly for keeping fallback i nfo
42 TODO: This cache should probably be removed when the deprecated code is 43 TODO: This cache should probably be removed when the deprecated code is
43 completely removed. 44 completely removed.
44 */ 45 */
45 static UHashtable *cache = NULL; 46 static UHashtable *cache = NULL;
46 static icu::UInitOnce gCacheInitOnce; 47 static icu::UInitOnce gCacheInitOnce;
47 48
48 static UMutex resbMutex = U_MUTEX_INITIALIZER; 49 static UMutex resbMutex = U_MUTEX_INITIALIZER;
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 *status = U_ILLEGAL_ARGUMENT_ERROR; 1726 *status = U_ILLEGAL_ARGUMENT_ERROR;
1726 return fillIn; 1727 return fillIn;
1727 } 1728 }
1728 1729
1729 int32_t type = RES_GET_TYPE(resB->fRes); 1730 int32_t type = RES_GET_TYPE(resB->fRes);
1730 if(URES_IS_TABLE(type)) { 1731 if(URES_IS_TABLE(type)) {
1731 res = getTableItemByKeyPath(&(resB->fResData), resB->fRes, inKey); 1732 res = getTableItemByKeyPath(&(resB->fResData), resB->fRes, inKey);
1732 const char* key = inKey; 1733 const char* key = inKey;
1733 if(res == RES_BOGUS) { 1734 if(res == RES_BOGUS) {
1734 UResourceDataEntry *dataEntry = resB->fData; 1735 UResourceDataEntry *dataEntry = resB->fData;
1735 char path[256]; 1736 CharString path;
1736 char* myPath = path; 1737 char *myPath = NULL;
1737 const char* resPath = resB->fResPath; 1738 const char* resPath = resB->fResPath;
1738 int32_t len = resB->fResPathLen; 1739 int32_t len = resB->fResPathLen;
1739 while(res == RES_BOGUS && dataEntry->fParent != NULL) { /* Otherwise , we'll look in parents */ 1740 while(res == RES_BOGUS && dataEntry->fParent != NULL) { /* Otherwise , we'll look in parents */
1740 dataEntry = dataEntry->fParent; 1741 dataEntry = dataEntry->fParent;
1741 rootRes = dataEntry->fData.rootRes; 1742 rootRes = dataEntry->fData.rootRes;
1742 1743
1743 if(dataEntry->fBogus == U_ZERO_ERROR) { 1744 if(dataEntry->fBogus == U_ZERO_ERROR) {
1745 path.clear();
1744 if (len > 0) { 1746 if (len > 0) {
1745 uprv_memcpy(path, resPath, len); 1747 path.append(resPath, len, *status);
1746 } 1748 }
1747 uprv_strcpy(path+len, inKey); 1749 path.append(inKey, *status);
1748 myPath = path; 1750 if (U_FAILURE(*status)) {
1751 ures_close(helper);
1752 return fillIn;
1753 }
1754 myPath = path.data();
1749 key = inKey; 1755 key = inKey;
1750 do { 1756 do {
1751 res = res_findResource(&(dataEntry->fData), rootRes, &my Path, &key); 1757 res = res_findResource(&(dataEntry->fData), rootRes, &my Path, &key);
1752 if (RES_GET_TYPE(res) == URES_ALIAS && *myPath) { 1758 if (RES_GET_TYPE(res) == URES_ALIAS && *myPath) {
1753 /* We hit an alias, but we didn't finish following t he path. */ 1759 /* We hit an alias, but we didn't finish following t he path. */
1754 helper = init_resb_result(&(dataEntry->fData), res, NULL, -1, dataEntry, resB, 0, helper, status); 1760 helper = init_resb_result(&(dataEntry->fData), res, NULL, -1, dataEntry, resB, 0, helper, status);
1755 /*helper = init_resb_result(&(dataEntry->fData), res , inKey, -1, dataEntry, resB, 0, helper, status);*/ 1761 /*helper = init_resb_result(&(dataEntry->fData), res , inKey, -1, dataEntry, resB, 0, helper, status);*/
1756 if(helper) { 1762 if(helper) {
1757 dataEntry = helper->fData; 1763 dataEntry = helper->fData;
1758 rootRes = helper->fRes; 1764 rootRes = helper->fRes;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 if (!resourceBundle) { 1981 if (!resourceBundle) {
1976 *status = U_ILLEGAL_ARGUMENT_ERROR; 1982 *status = U_ILLEGAL_ARGUMENT_ERROR;
1977 return NULL; 1983 return NULL;
1978 } else { 1984 } else {
1979 switch(type) { 1985 switch(type) {
1980 case ULOC_ACTUAL_LOCALE: 1986 case ULOC_ACTUAL_LOCALE:
1981 return resourceBundle->fData->fName; 1987 return resourceBundle->fData->fName;
1982 case ULOC_VALID_LOCALE: 1988 case ULOC_VALID_LOCALE:
1983 return resourceBundle->fTopLevelData->fName; 1989 return resourceBundle->fTopLevelData->fName;
1984 case ULOC_REQUESTED_LOCALE: 1990 case ULOC_REQUESTED_LOCALE:
1985 return NULL;
1986 default: 1991 default:
1987 *status = U_ILLEGAL_ARGUMENT_ERROR; 1992 *status = U_ILLEGAL_ARGUMENT_ERROR;
1988 return NULL; 1993 return NULL;
1989 } 1994 }
1990 } 1995 }
1991 } 1996 }
1992 1997
1993 U_CFUNC const char* ures_getName(const UResourceBundle* resB) { 1998 U_CFUNC const char* ures_getName(const UResourceBundle* resB) {
1994 if(resB == NULL) { 1999 if(resB == NULL) {
1995 return NULL; 2000 return NULL;
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 ures_close(bund); 2760 ures_close(bund);
2756 bund = NULL; 2761 bund = NULL;
2757 continue; 2762 continue;
2758 } 2763 }
2759 2764
2760 while((subPtr = ures_getNextResource(&item,&subItem,&subStatus)) 2765 while((subPtr = ures_getNextResource(&item,&subItem,&subStatus))
2761 && U_SUCCESS(subStatus)) { 2766 && U_SUCCESS(subStatus)) {
2762 const char *k; 2767 const char *k;
2763 int32_t i; 2768 int32_t i;
2764 k = ures_getKey(subPtr); 2769 k = ures_getKey(subPtr);
2765 2770
2766 #if defined(URES_TREE_DEBUG) 2771 #if defined(URES_TREE_DEBUG)
2767 /* fprintf(stderr, "%s | %s | %s | %s\n", path?path:"<ICUDATA>", key word, locale, k); */ 2772 /* fprintf(stderr, "%s | %s | %s | %s\n", path?path:"<ICUDATA>", key word, locale, k); */
2768 #endif 2773 #endif
2769 for(i=0;k&&i<valuesCount;i++) { 2774 if(k == NULL || *k == 0 ||
2775 uprv_strcmp(k, DEFAULT_TAG) == 0 || uprv_strncmp(k, "private -", 8) == 0) {
2776 // empty or "default" or unlisted type
2777 continue;
2778 }
2779 for(i=0; i<valuesCount; i++) {
2770 if(!uprv_strcmp(valuesList[i],k)) { 2780 if(!uprv_strcmp(valuesList[i],k)) {
2771 k = NULL; /* found duplicate */ 2781 k = NULL; /* found duplicate */
2782 break;
2772 } 2783 }
2773 } 2784 }
2774 if(k && *k) { 2785 if(k != NULL) {
2775 int32_t kLen = (int32_t)uprv_strlen(k); 2786 int32_t kLen = (int32_t)uprv_strlen(k);
2776 if(!uprv_strcmp(k,DEFAULT_TAG)) {
2777 continue; /* don't need 'default'. */
2778 }
2779 if((valuesCount >= (VALUES_LIST_SIZE-1)) || /* no more spa ce in list .. */ 2787 if((valuesCount >= (VALUES_LIST_SIZE-1)) || /* no more spa ce in list .. */
2780 ((valuesIndex+kLen+1+1) >= VALUES_BUF_SIZE)) { /* no more sp ace in buffer (string + 2 nulls) */ 2788 ((valuesIndex+kLen+1+1) >= VALUES_BUF_SIZE)) { /* no more sp ace in buffer (string + 2 nulls) */
2781 *status = U_ILLEGAL_ARGUMENT_ERROR; /* out of space.. */ 2789 *status = U_ILLEGAL_ARGUMENT_ERROR; /* out of space.. */
2782 } else { 2790 } else {
2783 uprv_strcpy(valuesBuf+valuesIndex, k); 2791 uprv_strcpy(valuesBuf+valuesIndex, k);
2784 valuesList[valuesCount++] = valuesBuf+valuesIndex; 2792 valuesList[valuesCount++] = valuesBuf+valuesIndex;
2785 valuesIndex += kLen; 2793 valuesIndex += kLen;
2786 #if defined(URES_TREE_DEBUG) 2794 #if defined(URES_TREE_DEBUG)
2787 fprintf(stderr, "%s | %s | %s | [%s] (UNIQUE)\n", 2795 fprintf(stderr, "%s | %s | %s | [%s] (UNIQUE)\n",
2788 path?path:"<ICUDATA>", keyword, locale, k); 2796 path?path:"<ICUDATA>", keyword, locale, k);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 ures_getVersionByKey(const UResourceBundle* res, const char *key, UVersionInfo v er, UErrorCode *status) { 2879 ures_getVersionByKey(const UResourceBundle* res, const char *key, UVersionInfo v er, UErrorCode *status) {
2872 const UChar *str; 2880 const UChar *str;
2873 int32_t len; 2881 int32_t len;
2874 str = ures_getStringByKey(res, key, &len, status); 2882 str = ures_getStringByKey(res, key, &len, status);
2875 if(U_SUCCESS(*status)) { 2883 if(U_SUCCESS(*status)) {
2876 u_versionFromUString(ver, str); 2884 u_versionFromUString(ver, str);
2877 } 2885 }
2878 } 2886 }
2879 2887
2880 /* eof */ 2888 /* eof */
OLDNEW
« no previous file with comments | « source/common/uprops.cpp ('k') | source/common/uresdata.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698