ICU-5794 Prevent an infinite loop.
X-SVN-Rev: 23153
This commit is contained in:
parent
e221b8c263
commit
35aa7a6339
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* Copyright (C) 2007, International Business Machines Corporation and
|
* Copyright (C) 2007-2008, International Business Machines Corporation and
|
||||||
* others. All Rights Reserved.
|
* others. All Rights Reserved.
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*
|
*
|
||||||
@ -96,7 +96,7 @@ static const UChar uCharPluralRules[NUMBER_PLURAL_RULES][128] = {
|
|||||||
LOW_R, 0},
|
LOW_R, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
static Hashtable *fPluralRuleLocaleHash=NULL;
|
static Hashtable *gPluralRuleLocaleHash=NULL;
|
||||||
static const UChar PLURAL_KEYWORD_ZERO[] = {LOW_Z,LOW_E,LOW_R,LOW_O, 0};
|
static const UChar PLURAL_KEYWORD_ZERO[] = {LOW_Z,LOW_E,LOW_R,LOW_O, 0};
|
||||||
static const UChar PLURAL_KEYWORD_ONE[]={LOW_O,LOW_N,LOW_E,0};
|
static const UChar PLURAL_KEYWORD_ONE[]={LOW_O,LOW_N,LOW_E,0};
|
||||||
static const UChar PLURAL_KEYWORD_TWO[]={LOW_T,LOW_W,LOW_O,0};
|
static const UChar PLURAL_KEYWORD_TWO[]={LOW_T,LOW_W,LOW_O,0};
|
||||||
@ -185,17 +185,17 @@ PluralRules::forLocale(const Locale& locale, UErrorCode& status) {
|
|||||||
delete newRules;
|
delete newRules;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
UnicodeString localeName=UnicodeString(locale.getName());
|
UnicodeString localeName(locale.getName());
|
||||||
locRules = (RuleChain *) (fPluralRuleLocaleHash->get(localeName));
|
locRules = (RuleChain *) (newRules->fLocaleStringsHash->get(localeName));
|
||||||
if ( locRules==NULL ) {
|
if (locRules == NULL) {
|
||||||
// Check parent locales.
|
// Check parent locales.
|
||||||
char parentLocale[50];
|
char parentLocale[ULOC_FULLNAME_CAPACITY];
|
||||||
const char *curLocaleName=locale.getName();
|
const char *curLocaleName=locale.getName();
|
||||||
int32_t localeNameLen=0;
|
int32_t localeNameLen=0;
|
||||||
uprv_strcpy(parentLocale, curLocaleName);
|
uprv_strcpy(parentLocale, curLocaleName);
|
||||||
while((localeNameLen=uloc_getParent(parentLocale, parentLocale, 50, &status))>=0 ) {
|
while ((localeNameLen=uloc_getParent(parentLocale, parentLocale, ULOC_FULLNAME_CAPACITY, &status)) > 0) {
|
||||||
locRules = (RuleChain *) (fPluralRuleLocaleHash->get(localeName));
|
locRules = (RuleChain *) (newRules->fLocaleStringsHash->get(localeName));
|
||||||
if ( locRules != NULL ) {
|
if (locRules != NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,16 +452,16 @@ PluralRules::initHashtable(UErrorCode& status) {
|
|||||||
if (fLocaleStringsHash!=NULL) {
|
if (fLocaleStringsHash!=NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( fPluralRuleLocaleHash == NULL ) {
|
if ( gPluralRuleLocaleHash == NULL ) {
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
// This static PluralRule hashtable residents in memory until end of application.
|
// This static PluralRule hashtable residents in memory until end of application.
|
||||||
if ((fPluralRuleLocaleHash = new Hashtable(TRUE, status))!=NULL) {
|
if ((gPluralRuleLocaleHash = new Hashtable(TRUE, status))!=NULL) {
|
||||||
fLocaleStringsHash = fPluralRuleLocaleHash;
|
fLocaleStringsHash = gPluralRuleLocaleHash;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fLocaleStringsHash = fPluralRuleLocaleHash;
|
fLocaleStringsHash = gPluralRuleLocaleHash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user