mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-05 21:45:37 +00:00
ICU-10774 fix a knownissue: Collator::getAvailableLocales calculation.
Also, replace uhash_nextElement's parameter "-1" with UHASH_FIRST for clarity. Also, improve service registration debugging code X-SVN-Rev: 36836
This commit is contained in:
parent
6371975e05
commit
7e6c572256
35 changed files with 380 additions and 254 deletions
|
@ -294,7 +294,7 @@ void U_EXPORT2 CanonicalIterator::permute(UnicodeString &source, UBool skipZeros
|
|||
for (i = 0; i < source.length(); i += U16_LENGTH(cp)) {
|
||||
cp = source.char32At(i);
|
||||
const UHashElement *ne = NULL;
|
||||
int32_t el = -1;
|
||||
int32_t el = UHASH_FIRST;
|
||||
UnicodeString subPermuteString = source;
|
||||
|
||||
// optimization:
|
||||
|
@ -359,7 +359,7 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
|||
// TODO: optimize by not permuting any class zero.
|
||||
|
||||
const UHashElement *ne = NULL;
|
||||
int32_t el = -1;
|
||||
int32_t el = UHASH_FIRST;
|
||||
//Iterator it = basic.iterator();
|
||||
ne = basic.nextElement(el);
|
||||
//while (it.hasNext())
|
||||
|
@ -370,7 +370,7 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
|||
permutations.removeAll();
|
||||
permute(item, CANITER_SKIP_ZEROES, &permutations, status);
|
||||
const UHashElement *ne2 = NULL;
|
||||
int32_t el2 = -1;
|
||||
int32_t el2 = UHASH_FIRST;
|
||||
//Iterator it2 = permutations.iterator();
|
||||
ne2 = permutations.nextElement(el2);
|
||||
//while (it2.hasNext())
|
||||
|
@ -416,7 +416,7 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
|||
}
|
||||
//result.toArray(finalResult);
|
||||
result_len = 0;
|
||||
el = -1;
|
||||
el = UHASH_FIRST;
|
||||
ne = result.nextElement(el);
|
||||
while(ne != NULL) {
|
||||
finalResult[result_len++] = *((UnicodeString *)(ne->value.pointer));
|
||||
|
@ -463,7 +463,7 @@ Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UCh
|
|||
UnicodeString prefix(segment, i);
|
||||
prefix += cp2;
|
||||
|
||||
int32_t el = -1;
|
||||
int32_t el = UHASH_FIRST;
|
||||
const UHashElement *ne = remainder.nextElement(el);
|
||||
while (ne != NULL) {
|
||||
UnicodeString item = *((UnicodeString *)(ne->value.pointer));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1997-2011, International Business Machines
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
* Date Name Description
|
||||
|
@ -85,6 +85,10 @@ public:
|
|||
|
||||
const UHashElement* find(const UnicodeString& key) const;
|
||||
|
||||
/**
|
||||
* @param pos - must be UHASH_FIRST on first call, and untouched afterwards.
|
||||
* @see uhash_nextElement
|
||||
*/
|
||||
const UHashElement* nextElement(int32_t& pos) const;
|
||||
|
||||
UKeyComparator* setKeyComparator(UKeyComparator*keyComp);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
/*
|
||||
***************************************************************************
|
||||
* Copyright (C) 2002-2011 International Business Machines Corporation
|
||||
* Copyright (C) 2002-2014 International Business Machines Corporation
|
||||
* and others. All rights reserved.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
@ -230,7 +230,7 @@ void RBBISymbolTable::rbbiSymtablePrint() const {
|
|||
"Name Node Val String Val\n"
|
||||
"----------------------------------------------------------------------\n");
|
||||
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *e = NULL;
|
||||
for (;;) {
|
||||
e = uhash_nextElement(fHashTable, &pos);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2012, International Business Machines Corporation.
|
||||
* Copyright (C) 2001-2014, International Business Machines Corporation.
|
||||
* All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -102,7 +102,7 @@ UnicodeString&
|
|||
ICUServiceKey::debug(UnicodeString& result) const
|
||||
{
|
||||
debugClass(result);
|
||||
result.append(" id: ");
|
||||
result.append((UnicodeString)" id: ");
|
||||
result.append(_id);
|
||||
return result;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ ICUServiceKey::debug(UnicodeString& result) const
|
|||
UnicodeString&
|
||||
ICUServiceKey::debugClass(UnicodeString& result) const
|
||||
{
|
||||
return result.append("ICUServiceKey");
|
||||
return result.append((UnicodeString)"ICUServiceKey");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -170,17 +170,17 @@ UnicodeString&
|
|||
SimpleFactory::debug(UnicodeString& toAppendTo) const
|
||||
{
|
||||
debugClass(toAppendTo);
|
||||
toAppendTo.append(" id: ");
|
||||
toAppendTo.append((UnicodeString)" id: ");
|
||||
toAppendTo.append(_id);
|
||||
toAppendTo.append(", visible: ");
|
||||
toAppendTo.append(_visible ? "T" : "F");
|
||||
toAppendTo.append((UnicodeString)", visible: ");
|
||||
toAppendTo.append(_visible ? (UnicodeString)"T" : (UnicodeString)"F");
|
||||
return toAppendTo;
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
SimpleFactory::debugClass(UnicodeString& toAppendTo) const
|
||||
{
|
||||
return toAppendTo.append("SimpleFactory");
|
||||
return toAppendTo.append((UnicodeString)"SimpleFactory");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -619,7 +619,7 @@ ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorC
|
|||
if (map != NULL) {
|
||||
ICUServiceKey* fallbackKey = createKey(matchID, status);
|
||||
|
||||
for (int32_t pos = -1;;) {
|
||||
for (int32_t pos = UHASH_FIRST;;) {
|
||||
const UHashElement* e = map->nextElement(pos);
|
||||
if (e == NULL) {
|
||||
break;
|
||||
|
@ -761,7 +761,7 @@ ICUService::getDisplayNames(UVector& result,
|
|||
return result;
|
||||
}
|
||||
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* entry = NULL;
|
||||
while ((entry = m->nextElement(pos)) != NULL) {
|
||||
const UnicodeString* id = (const UnicodeString*)entry->key.pointer;
|
||||
|
@ -788,7 +788,7 @@ ICUService::getDisplayNames(UVector& result,
|
|||
* nextElement(pos) will skip the position at pos and begin the iteration
|
||||
* at the next position, which in this case will be 0.
|
||||
*/
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *entry = NULL;
|
||||
while ((entry = dnCache->cache.nextElement(pos)) != NULL) {
|
||||
const UnicodeString* id = (const UnicodeString*)entry->value.pointer;
|
||||
|
|
|
@ -158,13 +158,13 @@ UnicodeString&
|
|||
LocaleKey::debug(UnicodeString& result) const
|
||||
{
|
||||
ICUServiceKey::debug(result);
|
||||
result.append(" kind: ");
|
||||
result.append((UnicodeString)" kind: ");
|
||||
result.append(_kind);
|
||||
result.append(" primaryID: ");
|
||||
result.append((UnicodeString)" primaryID: ");
|
||||
result.append(_primaryID);
|
||||
result.append(" fallbackID: ");
|
||||
result.append((UnicodeString)" fallbackID: ");
|
||||
result.append(_fallbackID);
|
||||
result.append(" currentID: ");
|
||||
result.append((UnicodeString)" currentID: ");
|
||||
result.append(_currentID);
|
||||
return result;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ LocaleKey::debug(UnicodeString& result) const
|
|||
UnicodeString&
|
||||
LocaleKey::debugClass(UnicodeString& result) const
|
||||
{
|
||||
return result.append("LocaleKey ");
|
||||
return result.append((UnicodeString)"LocaleKey ");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2001-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -71,9 +71,8 @@ LocaleKeyFactory::updateVisibleIDs(Hashtable& result, UErrorCode& status) const
|
|||
const Hashtable* supported = getSupportedIDs(status);
|
||||
if (supported) {
|
||||
UBool visible = (_coverage & 0x1) == 0;
|
||||
|
||||
const UHashElement* elem = NULL;
|
||||
int32_t pos = 0;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
while ((elem = supported->nextElement(pos)) != NULL) {
|
||||
const UnicodeString& id = *((const UnicodeString*)elem->key.pointer);
|
||||
if (!visible) {
|
||||
|
@ -127,9 +126,9 @@ UnicodeString&
|
|||
LocaleKeyFactory::debug(UnicodeString& result) const
|
||||
{
|
||||
debugClass(result);
|
||||
result.append(", name: ");
|
||||
result.append((UnicodeString)", name: ");
|
||||
result.append(_name);
|
||||
result.append(", coverage: ");
|
||||
result.append((UnicodeString)", coverage: ");
|
||||
result.append(_coverage);
|
||||
return result;
|
||||
}
|
||||
|
@ -137,7 +136,7 @@ LocaleKeyFactory::debug(UnicodeString& result) const
|
|||
UnicodeString&
|
||||
LocaleKeyFactory::debugClass(UnicodeString& result) const
|
||||
{
|
||||
return result.append("LocaleKeyFactory");
|
||||
return result.append((UnicodeString)"LocaleKeyFactory");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2011, International Business Machines Corporation and *
|
||||
* Copyright (C) 2001-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
}
|
||||
|
||||
virtual UnicodeString& debugClass(UnicodeString& result) const {
|
||||
return result.append("Key");
|
||||
return result.append((UnicodeString)"Key");
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2001-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -73,14 +73,14 @@ UnicodeString&
|
|||
ICUResourceBundleFactory::debug(UnicodeString& result) const
|
||||
{
|
||||
LocaleKeyFactory::debug(result);
|
||||
result.append(", bundle: ");
|
||||
result.append((UnicodeString)", bundle: ");
|
||||
return result.append(_bundleName);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
ICUResourceBundleFactory::debugClass(UnicodeString& result) const
|
||||
{
|
||||
return result.append("ICUResourceBundleFactory");
|
||||
return result.append((UnicodeString)"ICUResourceBundleFactory");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -97,9 +97,9 @@ UnicodeString&
|
|||
SimpleLocaleKeyFactory::debug(UnicodeString& result) const
|
||||
{
|
||||
LocaleKeyFactory::debug(result);
|
||||
result.append(", id: ");
|
||||
result.append((UnicodeString)", id: ");
|
||||
result.append(_id);
|
||||
result.append(", kind: ");
|
||||
result.append((UnicodeString)", kind: ");
|
||||
result.append(_kind);
|
||||
return result;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ SimpleLocaleKeyFactory::debug(UnicodeString& result) const
|
|||
UnicodeString&
|
||||
SimpleLocaleKeyFactory::debugClass(UnicodeString& result) const
|
||||
{
|
||||
return result.append("SimpleLocaleKeyFactory");
|
||||
return result.append((UnicodeString)"SimpleLocaleKeyFactory");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1996-2013, International Business Machines Corporation and
|
||||
* Copyright (c) 1996-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************
|
||||
*
|
||||
|
@ -1086,7 +1086,7 @@ ucnv_flushCache ()
|
|||
i = 0;
|
||||
do {
|
||||
remaining = 0;
|
||||
pos = -1;
|
||||
pos = UHASH_FIRST;
|
||||
while ((e = uhash_nextElement (SHARED_DATA_HASHTABLE, &pos)) != NULL)
|
||||
{
|
||||
mySharedData = (UConverterSharedData *) e->value.pointer;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1997-2011, International Business Machines
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
* Date Name Description
|
||||
|
@ -575,7 +575,7 @@ uhash_close(UHashtable *hash) {
|
|||
}
|
||||
if (hash->elements != NULL) {
|
||||
if (hash->keyDeleter != NULL || hash->valueDeleter != NULL) {
|
||||
int32_t pos=-1;
|
||||
int32_t pos=UHASH_FIRST;
|
||||
UHashElement *e;
|
||||
while ((e = (UHashElement*) uhash_nextElement(hash, &pos)) != NULL) {
|
||||
HASH_DELETE_KEY_VALUE(hash, e->key.pointer, e->value.pointer);
|
||||
|
@ -756,7 +756,7 @@ uhash_iremovei(UHashtable *hash,
|
|||
|
||||
U_CAPI void U_EXPORT2
|
||||
uhash_removeAll(UHashtable *hash) {
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *e;
|
||||
U_ASSERT(hash != NULL);
|
||||
if (hash->count != 0) {
|
||||
|
@ -885,7 +885,7 @@ uhash_equals(const UHashtable* hash1, const UHashtable* hash2){
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
pos=-1;
|
||||
pos=UHASH_FIRST;
|
||||
for(i=0; i<count1; i++){
|
||||
const UHashElement* elem1 = uhash_nextElement(hash1, &pos);
|
||||
const UHashTok key1 = elem1->key;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1997-2011, International Business Machines
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
* Date Name Description
|
||||
|
@ -484,6 +484,13 @@ uhash_removeAll(UHashtable *hash);
|
|||
U_CAPI const UHashElement* U_EXPORT2
|
||||
uhash_find(const UHashtable *hash, const void* key);
|
||||
|
||||
/**
|
||||
* \def UHASH_FIRST
|
||||
* Constant for use with uhash_nextElement
|
||||
* @see uhash_nextElement
|
||||
*/
|
||||
#define UHASH_FIRST (-1)
|
||||
|
||||
/**
|
||||
* Iterate through the elements of a UHashtable. The caller must not
|
||||
* modify the returned object. However, uhash_removeElement() may be
|
||||
|
@ -492,7 +499,7 @@ uhash_find(const UHashtable *hash, const void* key);
|
|||
* called during iteration the iteration will then be out of sync and
|
||||
* should be restarted.
|
||||
* @param hash The target UHashtable.
|
||||
* @param pos This should be set to -1 initially, and left untouched
|
||||
* @param pos This should be set to UHASH_FIRST initially, and left untouched
|
||||
* thereafter.
|
||||
* @return a hash element, or NULL if no further key-value pairs
|
||||
* exist in the table.
|
||||
|
|
|
@ -147,7 +147,7 @@ void UnifiedCache::dumpContents() const {
|
|||
// On entry, gCacheMutex must be held.
|
||||
// On exit, cache contents dumped to stderr.
|
||||
void UnifiedCache::_dumpContents() const {
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *element = uhash_nextElement(fHashtable, &pos);
|
||||
char buffer[256];
|
||||
int32_t cnt = 0;
|
||||
|
@ -193,7 +193,7 @@ UnifiedCache::~UnifiedCache() {
|
|||
// Returns TRUE if any value in cache was flushed or FALSE otherwise.
|
||||
UBool UnifiedCache::_flush(UBool all) const {
|
||||
UBool result = FALSE;
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *element = uhash_nextElement(fHashtable, &pos);
|
||||
for (; element != NULL; element = uhash_nextElement(fHashtable, &pos)) {
|
||||
const SharedObject *sharedObject =
|
||||
|
|
|
@ -187,7 +187,7 @@ static int32_t ures_flushCache()
|
|||
do {
|
||||
deletedMore = FALSE;
|
||||
/*creates an enumeration to iterate through every element in the table */
|
||||
pos = -1;
|
||||
pos = UHASH_FIRST;
|
||||
while ((e = uhash_nextElement(cache, &pos)) != NULL)
|
||||
{
|
||||
resB = (UResourceDataEntry *) e->value.pointer;
|
||||
|
@ -222,7 +222,7 @@ static int32_t ures_flushCache()
|
|||
|
||||
U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void) {
|
||||
UBool cacheNotEmpty = FALSE;
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *e;
|
||||
UResourceDataEntry *resB;
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ static int32_t
|
|||
usprep_internal_flushCache(UBool noRefCount){
|
||||
UStringPrepProfile *profile = NULL;
|
||||
UStringPrepKey *key = NULL;
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
int32_t deletedNum = 0;
|
||||
const UHashElement *e;
|
||||
|
||||
|
|
|
@ -868,7 +868,7 @@ static void fillInMissing(CDFLocaleStyleData* result) {
|
|||
}
|
||||
}
|
||||
// Iterate over each variant.
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = uhash_nextElement(result->unitsByVariant, &pos);
|
||||
for (;element != NULL; element = uhash_nextElement(result->unitsByVariant, &pos)) {
|
||||
CDFUnit* units = (CDFUnit*) element->value.pointer;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2011, International Business Machines Corporation and
|
||||
* Copyright (C) 2009-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -338,7 +338,7 @@ CurrencyPluralInfo::deleteHash(Hashtable* hTable)
|
|||
if ( hTable == NULL ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
while ( (element = hTable->nextElement(pos)) != NULL ) {
|
||||
const UHashTok valueTok = element->value;
|
||||
|
@ -376,7 +376,7 @@ CurrencyPluralInfo::copyHash(const Hashtable* source,
|
|||
if ( U_FAILURE(status) ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
if ( source ) {
|
||||
while ( (element = source->nextElement(pos)) != NULL ) {
|
||||
|
|
|
@ -636,7 +636,7 @@ DecimalFormat::setupCurrencyAffixPatterns(UErrorCode& status) {
|
|||
// save the unique currency plural patterns of this locale.
|
||||
Hashtable* pluralPtn = fCurrencyPluralInfo->fPluralCountToCurrencyUnitPattern;
|
||||
const UHashElement* element = NULL;
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
Hashtable pluralPatternSet;
|
||||
while ((element = pluralPtn->nextElement(pos)) != NULL) {
|
||||
const UHashTok valueTok = element->value;
|
||||
|
@ -2391,7 +2391,7 @@ DecimalFormat::parseForCurrency(const UnicodeString& text,
|
|||
}
|
||||
// Then, parse against affix patterns.
|
||||
// Those are currency patterns and currency plural patterns.
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
while ( (element = fAffixPatternsForCurrency->nextElement(pos)) != NULL ) {
|
||||
const UHashTok valueTok = element->value;
|
||||
|
@ -5347,7 +5347,7 @@ DecimalFormat::deleteHashForAffix(Hashtable*& table)
|
|||
if ( table == NULL ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
while ( (element = table->nextElement(pos)) != NULL ) {
|
||||
const UHashTok valueTok = element->value;
|
||||
|
@ -5366,7 +5366,7 @@ DecimalFormat::deleteHashForAffixPattern()
|
|||
if ( fAffixPatternsForCurrency == NULL ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
while ( (element = fAffixPatternsForCurrency->nextElement(pos)) != NULL ) {
|
||||
const UHashTok valueTok = element->value;
|
||||
|
@ -5385,7 +5385,7 @@ DecimalFormat::copyHashForAffixPattern(const Hashtable* source,
|
|||
if ( U_FAILURE(status) ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
if ( source ) {
|
||||
while ( (element = source->nextElement(pos)) != NULL ) {
|
||||
|
@ -5645,7 +5645,7 @@ DecimalFormat::copyHashForAffix(const Hashtable* source,
|
|||
if ( U_FAILURE(status) ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
if ( source ) {
|
||||
while ( (element = source->nextElement(pos)) != NULL ) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2008-2012, International Business Machines Corporation and
|
||||
* Copyright (C) 2008-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -481,7 +481,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
|
|||
bestMatchDistanceInfo = 0;
|
||||
int8_t fieldLength = sizeof(skeletonFieldWidth)/sizeof(skeletonFieldWidth[0]);
|
||||
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* elem = NULL;
|
||||
while ( (elem = fIntervalPatterns->nextElement(pos)) != NULL ) {
|
||||
const UHashTok keyTok = elem->key;
|
||||
|
@ -586,7 +586,7 @@ DateIntervalInfo::deleteHash(Hashtable* hTable)
|
|||
if ( hTable == NULL ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
while ( (element = hTable->nextElement(pos)) != NULL ) {
|
||||
const UHashTok valueTok = element->value;
|
||||
|
@ -649,7 +649,7 @@ DateIntervalInfo::copyHash(const Hashtable* source,
|
|||
if ( U_FAILURE(status) ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
if ( source ) {
|
||||
while ( (element = source->nextElement(pos)) != NULL ) {
|
||||
|
|
|
@ -1261,7 +1261,7 @@ DateTimePatternGenerator::copyHashtable(Hashtable *other, UErrorCode &status) {
|
|||
if(U_FAILURE(status)){
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* elem = NULL;
|
||||
// walk through the hash table and create a deep clone
|
||||
while((elem = other->nextElement(pos))!= NULL){
|
||||
|
|
|
@ -167,7 +167,7 @@ IdentifierInfo &IdentifierInfo::setIdentifier(const UnicodeString &identifier, U
|
|||
// We also compute any commonalities among the alternates.
|
||||
if (uhash_count(fScriptSetSet) > 0) {
|
||||
fCommonAmongAlternates->setAll();
|
||||
for (int32_t it = -1;;) {
|
||||
for (int32_t it = UHASH_FIRST;;) {
|
||||
const UHashElement *nextHashEl = uhash_nextElement(fScriptSetSet, &it);
|
||||
if (nextHashEl == NULL) {
|
||||
break;
|
||||
|
@ -179,7 +179,7 @@ IdentifierInfo &IdentifierInfo::setIdentifier(const UnicodeString &identifier, U
|
|||
} else {
|
||||
fCommonAmongAlternates->intersect(*next);
|
||||
// [[Arab Syrc Thaa]; [Arab Syrc]] => [[Arab Syrc]]
|
||||
for (int32_t otherIt = -1;;) {
|
||||
for (int32_t otherIt = UHASH_FIRST;;) {
|
||||
const UHashElement *otherHashEl = uhash_nextElement(fScriptSetSet, &otherIt);
|
||||
if (otherHashEl == NULL) {
|
||||
break;
|
||||
|
@ -269,7 +269,7 @@ UBool IdentifierInfo::containsWithAlternates(const ScriptSet &container, const S
|
|||
if (!container.contains(containee)) {
|
||||
return FALSE;
|
||||
}
|
||||
for (int32_t iter = -1; ;) {
|
||||
for (int32_t iter = UHASH_FIRST; ;) {
|
||||
const UHashElement *hashEl = uhash_nextElement(fScriptSetSet, &iter);
|
||||
if (hashEl == NULL) {
|
||||
break;
|
||||
|
@ -287,7 +287,7 @@ UnicodeString &IdentifierInfo::displayAlternates(UnicodeString &dest, const UHas
|
|||
if (U_FAILURE(status)) {
|
||||
return dest;
|
||||
}
|
||||
for (int32_t pos = -1; ;) {
|
||||
for (int32_t pos = UHASH_FIRST; ;) {
|
||||
const UHashElement *el = uhash_nextElement(alternates, &pos);
|
||||
if (el == NULL) {
|
||||
break;
|
||||
|
|
|
@ -413,7 +413,7 @@ MessageFormat::operator==(const Format& rhs) const
|
|||
if (count != rhs_count) {
|
||||
return FALSE;
|
||||
}
|
||||
int32_t idx = 0, rhs_idx = 0, pos = -1, rhs_pos = -1;
|
||||
int32_t idx = 0, rhs_idx = 0, pos = UHASH_FIRST, rhs_pos = UHASH_FIRST;
|
||||
for (; idx < count && rhs_idx < rhs_count && U_SUCCESS(ec); ++idx, ++rhs_idx) {
|
||||
const UHashElement* cur = uhash_nextElement(customFormatArgStarts, &pos);
|
||||
const UHashElement* rhs_cur = uhash_nextElement(that.customFormatArgStarts, &rhs_pos);
|
||||
|
@ -1332,7 +1332,7 @@ void MessageFormat::copyObjects(const MessageFormat& that, UErrorCode& ec) {
|
|||
|
||||
const int32_t count = uhash_count(that.cachedFormatters);
|
||||
int32_t pos, idx;
|
||||
for (idx = 0, pos = -1; idx < count && U_SUCCESS(ec); ++idx) {
|
||||
for (idx = 0, pos = UHASH_FIRST; idx < count && U_SUCCESS(ec); ++idx) {
|
||||
const UHashElement* cur = uhash_nextElement(that.cachedFormatters, &pos);
|
||||
Format* newFormat = ((Format*)(cur->value.pointer))->clone();
|
||||
if (newFormat) {
|
||||
|
@ -1350,7 +1350,7 @@ void MessageFormat::copyObjects(const MessageFormat& that, UErrorCode& ec) {
|
|||
}
|
||||
const int32_t count = uhash_count(that.customFormatArgStarts);
|
||||
int32_t pos, idx;
|
||||
for (idx = 0, pos = -1; idx < count && U_SUCCESS(ec); ++idx) {
|
||||
for (idx = 0, pos = UHASH_FIRST; idx < count && U_SUCCESS(ec); ++idx) {
|
||||
const UHashElement* cur = uhash_nextElement(that.customFormatArgStarts, &pos);
|
||||
uhash_iputi(customFormatArgStarts, cur->key.integer, cur->value.integer, &ec);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData&
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t i = 0;
|
||||
variableNames.setValueDeleter(uprv_deleteUObject);
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *e;
|
||||
while ((e = other.variableNames.nextElement(pos)) != 0) {
|
||||
UnicodeString* value =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1999-2011, International Business Machines
|
||||
* Copyright (C) 1999-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
|
@ -1106,7 +1106,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
|
|||
}
|
||||
|
||||
data->variableNames.removeAll();
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* he = variableNames.nextElement(pos);
|
||||
while (he != NULL) {
|
||||
UnicodeString* tempus = (UnicodeString*)(((UnicodeString*)(he->value.pointer))->clone());
|
||||
|
|
|
@ -305,7 +305,7 @@ void Region::loadRegionData(UErrorCode &status) {
|
|||
}
|
||||
|
||||
// Create the availableRegions lists
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
while ( const UHashElement* element = uhash_nextElement(regionIDMap,&pos)) {
|
||||
Region *ar = (Region *)element->value.pointer;
|
||||
if ( availableRegions[ar->type] == NULL ) {
|
||||
|
|
|
@ -189,7 +189,7 @@ TimeUnitFormat::parseObject(const UnicodeString& source,
|
|||
i < TimeUnit::UTIMEUNIT_FIELD_COUNT;
|
||||
i = (TimeUnit::UTimeUnitFields)(i+1)) {
|
||||
Hashtable* countToPatterns = fTimeUnitToCountToPatterns[i];
|
||||
int32_t elemPos = -1;
|
||||
int32_t elemPos = UHASH_FIRST;
|
||||
const UHashElement* elem = NULL;
|
||||
while ((elem = countToPatterns->nextElement(elemPos)) != NULL){
|
||||
const UHashTok keyTok = elem->key;
|
||||
|
@ -686,7 +686,7 @@ TimeUnitFormat::setNumberFormat(const NumberFormat& format, UErrorCode& status){
|
|||
|
||||
void
|
||||
TimeUnitFormat::deleteHash(Hashtable* htable) {
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
if ( htable ) {
|
||||
while ( (element = htable->nextElement(pos)) != NULL ) {
|
||||
|
@ -707,7 +707,7 @@ TimeUnitFormat::copyHash(const Hashtable* source, Hashtable* target, UErrorCode&
|
|||
if ( U_FAILURE(status) ) {
|
||||
return;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
if ( source ) {
|
||||
while ( (element = source->nextElement(pos)) != NULL ) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2001-2011, International Business Machines
|
||||
* Copyright (c) 2001-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
|
@ -728,7 +728,7 @@ int32_t TransliteratorRegistry::countAvailableSources(void) const {
|
|||
|
||||
UnicodeString& TransliteratorRegistry::getAvailableSource(int32_t index,
|
||||
UnicodeString& result) const {
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *e = 0;
|
||||
while (index-- >= 0) {
|
||||
e = specDAG.nextElement(pos);
|
||||
|
@ -757,7 +757,7 @@ UnicodeString& TransliteratorRegistry::getAvailableTarget(int32_t index,
|
|||
result.truncate(0); // invalid source
|
||||
return result;
|
||||
}
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *e = 0;
|
||||
while (index-- >= 0) {
|
||||
e = targets->nextElement(pos);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011-2013, International Business Machines Corporation and
|
||||
* Copyright (C) 2011-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -1185,7 +1185,7 @@ U_CDECL_END
|
|||
* block.
|
||||
*/
|
||||
static void sweepCache() {
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* elem;
|
||||
double now = (double)uprv_getUTCtime();
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ U_CDECL_END
|
|||
* block.
|
||||
*/
|
||||
static void sweepCache() {
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* elem;
|
||||
double now = (double)uprv_getUTCtime();
|
||||
|
||||
|
|
|
@ -997,9 +997,6 @@ CollationAPITest::TestCompare(/* char* par */)
|
|||
void
|
||||
CollationAPITest::TestGetAll(/* char* par */)
|
||||
{
|
||||
if (logKnownIssue("10774","Side effects from utility/LocaleTest/TestGetLocale")) {
|
||||
return;
|
||||
}
|
||||
int32_t count1, count2;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 2002-2012, International Business Machines Corporation and
|
||||
* Copyright (c) 2002-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************
|
||||
*
|
||||
|
@ -263,7 +263,7 @@ UnicodeString CanonicalIteratorTest::collectionToString(Hashtable *col) {
|
|||
int32_t i = 0;
|
||||
|
||||
const UHashElement *ne = NULL;
|
||||
int32_t el = -1;
|
||||
int32_t el = UHASH_FIRST;
|
||||
//Iterator it = basic.iterator();
|
||||
ne = col->nextElement(el);
|
||||
//while (it.hasNext())
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <string.h>
|
||||
#include "putilimp.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "hash.h"
|
||||
|
||||
static const char* const rawData[33][8] = {
|
||||
|
||||
|
@ -1832,124 +1833,159 @@ void LocaleTest::TestGetLocale(void) {
|
|||
|
||||
// Calendar
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
req = "en_US_BROOKLYN";
|
||||
Calendar* cal = Calendar::createInstance(Locale::createFromName(req), ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
dataerrln("FAIL: Calendar::createInstance failed - %s", u_errorName(ec));
|
||||
} else {
|
||||
valid = cal->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = cal->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
{
|
||||
UErrorCode ec = U_ZERO_ERROR; // give each resource type its own error code
|
||||
req = "en_US_BROOKLYN";
|
||||
Calendar* cal = Calendar::createInstance(Locale::createFromName(req), ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Calendar::getLocale() failed");
|
||||
dataerrln("FAIL: Calendar::createInstance failed - %s", u_errorName(ec));
|
||||
} else {
|
||||
_checklocs("Calendar", req, valid, actual);
|
||||
valid = cal->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = cal->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Calendar::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("Calendar", req, valid, actual);
|
||||
}
|
||||
/* Make sure that it fails correctly */
|
||||
ec = U_FILE_ACCESS_ERROR;
|
||||
if (cal->getLocale(ULOC_VALID_LOCALE, ec).getName()[0] != 0) {
|
||||
errln("FAIL: Calendar::getLocale() failed to fail correctly. It should have returned \"\"");
|
||||
}
|
||||
ec = U_ZERO_ERROR;
|
||||
}
|
||||
/* Make sure that it fails correctly */
|
||||
ec = U_FILE_ACCESS_ERROR;
|
||||
if (cal->getLocale(ULOC_VALID_LOCALE, ec).getName()[0] != 0) {
|
||||
errln("FAIL: Calendar::getLocale() failed to fail correctly. It should have returned \"\"");
|
||||
}
|
||||
ec = U_ZERO_ERROR;
|
||||
delete cal;
|
||||
}
|
||||
delete cal;
|
||||
#endif
|
||||
|
||||
// DecimalFormat, DecimalFormatSymbols
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
req = "fr_FR_NICE";
|
||||
NumberFormat* nf = NumberFormat::createInstance(Locale::createFromName(req), ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
dataerrln("FAIL: NumberFormat::createInstance failed - %s", u_errorName(ec));
|
||||
} else {
|
||||
DecimalFormat* dec = dynamic_cast<DecimalFormat*>(nf);
|
||||
if (dec == NULL) {
|
||||
errln("FAIL: NumberFormat::createInstance does not return a DecimalFormat");
|
||||
return;
|
||||
}
|
||||
valid = dec->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = dec->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
{
|
||||
UErrorCode ec = U_ZERO_ERROR; // give each resource type its own error code
|
||||
req = "fr_FR_NICE";
|
||||
NumberFormat* nf = NumberFormat::createInstance(Locale::createFromName(req), ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: DecimalFormat::getLocale() failed");
|
||||
dataerrln("FAIL: NumberFormat::createInstance failed - %s", u_errorName(ec));
|
||||
} else {
|
||||
_checklocs("DecimalFormat", req, valid, actual);
|
||||
}
|
||||
DecimalFormat* dec = dynamic_cast<DecimalFormat*>(nf);
|
||||
if (dec == NULL) {
|
||||
errln("FAIL: NumberFormat::createInstance does not return a DecimalFormat");
|
||||
return;
|
||||
}
|
||||
valid = dec->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = dec->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: DecimalFormat::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("DecimalFormat", req, valid, actual);
|
||||
}
|
||||
|
||||
const DecimalFormatSymbols* sym = dec->getDecimalFormatSymbols();
|
||||
if (sym == NULL) {
|
||||
errln("FAIL: getDecimalFormatSymbols returned NULL");
|
||||
return;
|
||||
const DecimalFormatSymbols* sym = dec->getDecimalFormatSymbols();
|
||||
if (sym == NULL) {
|
||||
errln("FAIL: getDecimalFormatSymbols returned NULL");
|
||||
return;
|
||||
}
|
||||
valid = sym->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = sym->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: DecimalFormatSymbols::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("DecimalFormatSymbols", req, valid, actual);
|
||||
}
|
||||
}
|
||||
valid = sym->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = sym->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: DecimalFormatSymbols::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("DecimalFormatSymbols", req, valid, actual);
|
||||
}
|
||||
delete nf;
|
||||
}
|
||||
delete nf;
|
||||
#endif
|
||||
|
||||
// DateFormat, DateFormatSymbols
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
req = "de_CH_LUCERNE";
|
||||
DateFormat* df =
|
||||
DateFormat::createDateInstance(DateFormat::kDefault,
|
||||
Locale::createFromName(req));
|
||||
if (df == 0){
|
||||
dataerrln("Error calling DateFormat::createDateInstance()");
|
||||
} else {
|
||||
SimpleDateFormat* dat = dynamic_cast<SimpleDateFormat*>(df);
|
||||
if (dat == NULL) {
|
||||
errln("FAIL: DateFormat::createInstance does not return a SimpleDateFormat");
|
||||
return;
|
||||
}
|
||||
valid = dat->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = dat->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: SimpleDateFormat::getLocale() failed");
|
||||
{
|
||||
UErrorCode ec = U_ZERO_ERROR; // give each resource type its own error code
|
||||
req = "de_CH_LUCERNE";
|
||||
DateFormat* df =
|
||||
DateFormat::createDateInstance(DateFormat::kDefault,
|
||||
Locale::createFromName(req));
|
||||
if (df == 0){
|
||||
dataerrln("Error calling DateFormat::createDateInstance()");
|
||||
} else {
|
||||
_checklocs("SimpleDateFormat", req, valid, actual);
|
||||
}
|
||||
SimpleDateFormat* dat = dynamic_cast<SimpleDateFormat*>(df);
|
||||
if (dat == NULL) {
|
||||
errln("FAIL: DateFormat::createInstance does not return a SimpleDateFormat");
|
||||
return;
|
||||
}
|
||||
valid = dat->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = dat->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: SimpleDateFormat::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("SimpleDateFormat", req, valid, actual);
|
||||
}
|
||||
|
||||
const DateFormatSymbols* sym = dat->getDateFormatSymbols();
|
||||
if (sym == NULL) {
|
||||
errln("FAIL: getDateFormatSymbols returned NULL");
|
||||
return;
|
||||
const DateFormatSymbols* sym = dat->getDateFormatSymbols();
|
||||
if (sym == NULL) {
|
||||
errln("FAIL: getDateFormatSymbols returned NULL");
|
||||
return;
|
||||
}
|
||||
valid = sym->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = sym->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: DateFormatSymbols::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("DateFormatSymbols", req, valid, actual);
|
||||
}
|
||||
}
|
||||
valid = sym->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = sym->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: DateFormatSymbols::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("DateFormatSymbols", req, valid, actual);
|
||||
}
|
||||
delete df;
|
||||
}
|
||||
delete df;
|
||||
#endif
|
||||
|
||||
// BreakIterator
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
req = "es_ES_BARCELONA";
|
||||
reqLoc = Locale::createFromName(req);
|
||||
BreakIterator* brk = BreakIterator::createWordInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
dataerrln("FAIL: BreakIterator::createWordInstance failed - %s", u_errorName(ec));
|
||||
} else {
|
||||
valid = brk->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = brk->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
{
|
||||
UErrorCode ec = U_ZERO_ERROR; // give each resource type its own error code
|
||||
req = "es_ES_BARCELONA";
|
||||
reqLoc = Locale::createFromName(req);
|
||||
BreakIterator* brk = BreakIterator::createWordInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::getLocale() failed");
|
||||
dataerrln("FAIL: BreakIterator::createWordInstance failed - %s", u_errorName(ec));
|
||||
} else {
|
||||
_checklocs("BreakIterator", req, valid, actual);
|
||||
}
|
||||
valid = brk->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = brk->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("BreakIterator", req, valid, actual);
|
||||
}
|
||||
|
||||
// After registering something, the behavior should be different
|
||||
URegistryKey key = BreakIterator::registerInstance(brk, reqLoc, UBRK_WORD, ec);
|
||||
brk = 0; // registerInstance adopts
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::registerInstance() failed");
|
||||
} else {
|
||||
// After registering something, the behavior should be different
|
||||
URegistryKey key = BreakIterator::registerInstance(brk, reqLoc, UBRK_WORD, ec);
|
||||
brk = 0; // registerInstance adopts
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::registerInstance() failed");
|
||||
} else {
|
||||
brk = BreakIterator::createWordInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::createWordInstance failed");
|
||||
} else {
|
||||
valid = brk->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = brk->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::getLocale() failed");
|
||||
} else {
|
||||
// N.B.: now expect valid==actual==req
|
||||
_checklocs("BreakIterator(registered)",
|
||||
req, valid, actual, "eq", "eq");
|
||||
}
|
||||
}
|
||||
// No matter what, unregister
|
||||
BreakIterator::unregister(key, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::unregister() failed");
|
||||
}
|
||||
delete brk;
|
||||
brk = 0;
|
||||
}
|
||||
|
||||
// After unregistering, should behave normally again
|
||||
brk = BreakIterator::createWordInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::createWordInstance failed");
|
||||
|
@ -1959,101 +1995,176 @@ void LocaleTest::TestGetLocale(void) {
|
|||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::getLocale() failed");
|
||||
} else {
|
||||
// N.B.: now expect valid==actual==req
|
||||
_checklocs("BreakIterator(registered)",
|
||||
req, valid, actual, "eq", "eq");
|
||||
_checklocs("BreakIterator(unregistered)", req, valid, actual);
|
||||
}
|
||||
}
|
||||
// No matter what, unregister
|
||||
BreakIterator::unregister(key, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::unregister() failed");
|
||||
}
|
||||
delete brk;
|
||||
brk = 0;
|
||||
}
|
||||
|
||||
// After unregistering, should behave normally again
|
||||
brk = BreakIterator::createWordInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::createWordInstance failed");
|
||||
} else {
|
||||
valid = brk->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = brk->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: BreakIterator::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("BreakIterator(unregistered)", req, valid, actual);
|
||||
}
|
||||
}
|
||||
delete brk;
|
||||
}
|
||||
delete brk;
|
||||
#endif
|
||||
|
||||
// Collator
|
||||
#if !UCONFIG_NO_COLLATION
|
||||
req = "hi_IN_BHOPAL";
|
||||
reqLoc = Locale::createFromName(req);
|
||||
Collator* coll = Collator::createInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
dataerrln("FAIL: Collator::createInstance failed - %s", u_errorName(ec));
|
||||
} else {
|
||||
valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("Collator", req, valid, actual);
|
||||
}
|
||||
{
|
||||
UErrorCode ec = U_ZERO_ERROR; // give each resource type its own error code
|
||||
|
||||
// After registering something, the behavior should be different
|
||||
URegistryKey key = Collator::registerInstance(coll, reqLoc, ec);
|
||||
coll = 0; // registerInstance adopts
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::registerInstance() failed");
|
||||
} else {
|
||||
coll = Collator::createInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::createWordInstance failed");
|
||||
} else {
|
||||
valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::getLocale() failed");
|
||||
} else {
|
||||
// N.B.: now expect valid==actual==req
|
||||
_checklocs("Collator(registered)",
|
||||
req, valid, actual, "eq", "eq");
|
||||
}
|
||||
}
|
||||
// No matter what, unregister
|
||||
Collator::unregister(key, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::unregister() failed");
|
||||
}
|
||||
delete coll;
|
||||
coll = 0;
|
||||
}
|
||||
checkRegisteredCollators(NULL); // Don't expect any extras
|
||||
|
||||
// After unregistering, should behave normally again
|
||||
coll = Collator::createInstance(reqLoc, ec);
|
||||
req = "hi_IN_BHOPAL";
|
||||
reqLoc = Locale::createFromName(req);
|
||||
Collator* coll = Collator::createInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::createInstance failed");
|
||||
dataerrln("FAIL: Collator::createInstance failed - %s", u_errorName(ec));
|
||||
} else {
|
||||
valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("Collator(unregistered)", req, valid, actual);
|
||||
_checklocs("Collator", req, valid, actual);
|
||||
}
|
||||
|
||||
// After registering something, the behavior should be different
|
||||
URegistryKey key = Collator::registerInstance(coll, reqLoc, ec);
|
||||
coll = 0; // registerInstance adopts
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::registerInstance() failed");
|
||||
} else {
|
||||
coll = Collator::createInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::createWordInstance failed");
|
||||
} else {
|
||||
valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::getLocale() failed");
|
||||
} else {
|
||||
// N.B.: now expect valid==actual==req
|
||||
_checklocs("Collator(registered)",
|
||||
req, valid, actual, "eq", "eq");
|
||||
}
|
||||
}
|
||||
checkRegisteredCollators(req); // include hi_IN_BHOPAL
|
||||
|
||||
// No matter what, unregister
|
||||
Collator::unregister(key, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::unregister() failed");
|
||||
}
|
||||
delete coll;
|
||||
coll = 0;
|
||||
}
|
||||
|
||||
// After unregistering, should behave normally again
|
||||
coll = Collator::createInstance(reqLoc, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::createInstance failed");
|
||||
} else {
|
||||
valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
|
||||
actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
errln("FAIL: Collator::getLocale() failed");
|
||||
} else {
|
||||
_checklocs("Collator(unregistered)", req, valid, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete coll;
|
||||
|
||||
checkRegisteredCollators(NULL); // extra should be gone again
|
||||
}
|
||||
delete coll;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !UCONFIG_NO_COLLATION
|
||||
void LocaleTest::checkRegisteredCollators(const char *expectExtra) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t count1=0,count2=0;
|
||||
Hashtable oldHash(status);
|
||||
Hashtable newHash(status);
|
||||
TEST_ASSERT_STATUS(status);
|
||||
|
||||
UnicodeString expectStr(expectExtra?expectExtra:"n/a", "");
|
||||
|
||||
// the 'old' list (non enumeration)
|
||||
const Locale* oldList = Collator::getAvailableLocales(count1);
|
||||
if(oldList == NULL) {
|
||||
errln("Error: Collator::getAvailableLocales(count) returned NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
// the 'new' list (enumeration)
|
||||
LocalPointer<StringEnumeration> newEnum(Collator::getAvailableLocales());
|
||||
if(newEnum.isNull()) {
|
||||
errln("Error: collator::getAvailableLocales() returned NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
// OK. Let's add all of the OLD
|
||||
// then check for any in the NEW not in OLD
|
||||
// then check for any in OLD not in NEW.
|
||||
|
||||
// 1. add all of OLD
|
||||
for(int32_t i=0;i<count1;i++) {
|
||||
const UnicodeString key(oldList[i].getName(), "");
|
||||
if(!strcmp(oldList[i].getName(),"haw")) {
|
||||
infoln("Note: old had 'haw'");
|
||||
}
|
||||
int32_t oldI = oldHash.puti(key, 1, status);
|
||||
if( oldI == 1 ){
|
||||
errln("Error: duplicate key %s in Collator::getAvailableLocales(count) list.\n",
|
||||
oldList[i].getName());
|
||||
return;
|
||||
}
|
||||
if(expectExtra != NULL && !strcmp(expectExtra, oldList[i].getName())) {
|
||||
errln("Inexplicably, Collator::getAvailableCollators(count) had registered collator %s. This shouldn't happen, so I am going to consider it an error.\n", expectExtra);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. add all of NEW
|
||||
const UnicodeString *locStr;
|
||||
UBool foundExpected = FALSE;
|
||||
while((locStr = newEnum->snext(status)) && U_SUCCESS(status)) {
|
||||
count2++;
|
||||
|
||||
if(expectExtra != NULL && expectStr == *locStr) {
|
||||
foundExpected = TRUE;
|
||||
logln(UnicodeString("Found expected registered collator: ","") + expectStr);
|
||||
}
|
||||
|
||||
if( oldHash.geti(*locStr) == 0 ) {
|
||||
if(expectExtra != NULL && expectStr==*locStr) {
|
||||
logln(UnicodeString("As expected, Collator::getAvailableLocales(count) is missing registered collator ") + expectStr);
|
||||
} else {
|
||||
errln(UnicodeString("Error: Collator::getAvailableLocales(count) is missing: ","")
|
||||
+ *locStr);
|
||||
}
|
||||
}
|
||||
newHash.puti(*locStr, 1, status);
|
||||
}
|
||||
|
||||
// 3. check all of OLD again
|
||||
for(int32_t i=0;i<count1;i++) {
|
||||
const UnicodeString key(oldList[i].getName(), "");
|
||||
int32_t newI = newHash.geti(key);
|
||||
if(newI == 0) {
|
||||
errln(UnicodeString("Error: Collator::getAvailableLocales() is missing: ","")
|
||||
+ key);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t expectCount2 = count1;
|
||||
if(expectExtra != NULL) {
|
||||
expectCount2 ++; // if an extra item registered, bump the expect count
|
||||
}
|
||||
|
||||
assertEquals("Collator::getAvail() count", expectCount2, count2);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void LocaleTest::TestVariantWithOutCountry(void) {
|
||||
Locale loc("en","","POSIX");
|
||||
if (0 != strcmp(loc.getVariant(), "POSIX")) {
|
||||
|
|
|
@ -169,4 +169,12 @@ private:
|
|||
DVAR_NO,
|
||||
DNAME_NO
|
||||
};
|
||||
|
||||
#if !UCONFIG_NO_COLLATION
|
||||
/**
|
||||
* Check on registered collators.
|
||||
* @param expectExtra if non-null, the locale ID of an 'extra' locale that is registered.
|
||||
*/
|
||||
void checkRegisteredCollators(const char *expectExtra = NULL);
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -1734,7 +1734,7 @@ bundle_compactStrings(struct SRBRoot *bundle, UErrorCode *status) {
|
|||
bundle->f16BitUnits[0] = 0;
|
||||
utf16Length = 1;
|
||||
++bundle->f16BitUnitsLength;
|
||||
for (pos = -1, i = 0; i < count; ++i) {
|
||||
for (pos = UHASH_FIRST, i = 0; i < count; ++i) {
|
||||
array[i] = (struct SResource *)uhash_nextElement(stringSet, &pos)->key.pointer;
|
||||
}
|
||||
/* Sort the strings so that each one is immediately followed by all of its suffixes. */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012, International Business Machines
|
||||
* Copyright (C) 1999-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
|
@ -236,7 +236,7 @@ static UBool U_CALLCONV compareEntries(const UHashTok p1, const UHashTok p2) {
|
|||
static void
|
||||
storeMappingData(){
|
||||
|
||||
int32_t pos = -1;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* element = NULL;
|
||||
ValueStruct* value = NULL;
|
||||
int32_t codepoint = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue