From b13c9513480d324a18dd8f31b4bf2306d3bee26f Mon Sep 17 00:00:00 2001 From: Daniel Ju <41210545+daniel-ju@users.noreply.github.com> Date: Fri, 10 Aug 2018 18:05:58 -0700 Subject: [PATCH] ICU-20043 ICU-13214 ICU-13764 MSVC W3 and W4 warning cleanup (#53) Cleaned up all of the MSVC W3 warnings and most of the W4 warnings in the common and i18n projects. --- icu4c/source/common/bmpset.cpp | 4 +- icu4c/source/common/charstr.cpp | 2 +- icu4c/source/common/common.vcxproj | 3 +- icu4c/source/common/dictbe.cpp | 16 +-- icu4c/source/common/edits.cpp | 4 +- icu4c/source/common/loadednormalizer2impl.cpp | 2 +- icu4c/source/common/locdspnm.cpp | 22 ++-- icu4c/source/common/locid.cpp | 4 +- icu4c/source/common/normalizer2impl.cpp | 28 ++--- icu4c/source/common/normalizer2impl.h | 2 +- icu4c/source/common/rbbi.cpp | 6 +- icu4c/source/common/rbbi_cache.cpp | 4 +- icu4c/source/common/rbbiscan.cpp | 2 +- icu4c/source/common/rbbitblb.cpp | 35 +++--- icu4c/source/common/serv.cpp | 4 +- icu4c/source/common/stringtriebuilder.cpp | 2 +- icu4c/source/common/ubidi.cpp | 28 ++--- icu4c/source/common/ubiditransform.cpp | 8 +- icu4c/source/common/ucnv2022.cpp | 4 +- icu4c/source/common/ucnv_ct.cpp | 2 +- icu4c/source/common/ucnv_u16.cpp | 4 +- icu4c/source/common/ucnv_u32.cpp | 12 +- icu4c/source/common/ucnv_u8.cpp | 4 +- icu4c/source/common/ucnvhz.cpp | 4 +- icu4c/source/common/ucnvmbcs.cpp | 4 +- icu4c/source/common/ucnvsel.cpp | 8 +- icu4c/source/common/ucurr.cpp | 11 +- icu4c/source/common/uhash.cpp | 6 +- icu4c/source/common/uloc.cpp | 6 +- icu4c/source/common/uloc_keytype.cpp | 5 +- icu4c/source/common/unames.cpp | 2 +- icu4c/source/common/unicode/messagepattern.h | 4 +- .../source/common/unicode/stringtriebuilder.h | 2 +- icu4c/source/common/unifiedcache.cpp | 2 +- icu4c/source/common/uniset_props.cpp | 10 +- icu4c/source/common/uprops.cpp | 2 +- icu4c/source/common/uresbund.cpp | 6 +- icu4c/source/common/uresdata.h | 2 +- icu4c/source/common/ushape.cpp | 2 +- icu4c/source/common/usprep.cpp | 4 +- icu4c/source/common/ustrcase.cpp | 12 +- icu4c/source/common/utext.cpp | 64 +++++------ icu4c/source/common/utrie2.cpp | 4 +- icu4c/source/common/utrie2_builder.cpp | 2 +- icu4c/source/common/wintz.cpp | 2 +- icu4c/source/i18n/alphaindex.cpp | 8 +- icu4c/source/i18n/anytrans.cpp | 6 +- icu4c/source/i18n/coll.cpp | 4 +- icu4c/source/i18n/collationkeys.cpp | 12 +- icu4c/source/i18n/csrmbcs.cpp | 2 +- icu4c/source/i18n/currpinf.cpp | 10 +- icu4c/source/i18n/dcfmtsym.cpp | 2 +- icu4c/source/i18n/dtfmtsym.cpp | 6 +- icu4c/source/i18n/dtitvfmt.cpp | 6 +- icu4c/source/i18n/dtitvinf.cpp | 6 +- icu4c/source/i18n/dtptngen.cpp | 14 +-- icu4c/source/i18n/i18n.vcxproj | 2 +- icu4c/source/i18n/measfmt.cpp | 33 +++--- icu4c/source/i18n/msgfmt.cpp | 2 +- icu4c/source/i18n/nfrule.cpp | 104 +++++++++--------- icu4c/source/i18n/nfrule.h | 2 +- icu4c/source/i18n/number_grouping.cpp | 2 +- icu4c/source/i18n/number_multiplier.cpp | 8 +- icu4c/source/i18n/number_multiplier.h | 4 +- icu4c/source/i18n/number_patternmodifier.cpp | 64 +++++------ icu4c/source/i18n/number_patternmodifier.h | 18 +-- icu4c/source/i18n/olsontz.cpp | 6 +- icu4c/source/i18n/plurrule.cpp | 4 +- icu4c/source/i18n/rbnf.cpp | 98 ++++++++--------- icu4c/source/i18n/rbt_pars.cpp | 12 +- icu4c/source/i18n/region.cpp | 44 ++++---- icu4c/source/i18n/reldatefmt.cpp | 4 +- icu4c/source/i18n/reldtfmt.cpp | 6 +- icu4c/source/i18n/rematch.cpp | 74 ++++++------- icu4c/source/i18n/rulebasedcollator.cpp | 10 +- icu4c/source/i18n/scriptset.cpp | 2 +- icu4c/source/i18n/smpdtfmt.cpp | 66 +++++------ icu4c/source/i18n/timezone.cpp | 10 +- icu4c/source/i18n/transreg.cpp | 6 +- icu4c/source/i18n/tzfmt.cpp | 6 +- icu4c/source/i18n/tzgnames.cpp | 2 +- icu4c/source/i18n/tznames.cpp | 2 +- icu4c/source/i18n/tznames_impl.cpp | 14 +-- icu4c/source/i18n/ucol_res.cpp | 14 +-- icu4c/source/i18n/udat.cpp | 2 +- icu4c/source/i18n/ulocdata.cpp | 2 +- icu4c/source/i18n/unicode/measfmt.h | 2 +- icu4c/source/i18n/unicode/rbnf.h | 4 +- icu4c/source/i18n/unicode/region.h | 2 +- icu4c/source/i18n/uregex.cpp | 4 +- icu4c/source/i18n/usearch.cpp | 2 +- icu4c/source/i18n/vtzone.cpp | 2 +- icu4c/source/i18n/zonemeta.cpp | 16 +-- 93 files changed, 546 insertions(+), 551 deletions(-) diff --git a/icu4c/source/common/bmpset.cpp b/icu4c/source/common/bmpset.cpp index 35bc80dce35..bc79f5e5a63 100644 --- a/icu4c/source/common/bmpset.cpp +++ b/icu4c/source/common/bmpset.cpp @@ -241,13 +241,13 @@ void BMPSet::overrideIllegal() { bmpBlockBits[i]|=bits; } - mask=~(0x10001<<0xd); // Lead byte 0xED. + mask= static_cast(~(0x10001<<0xd)); // Lead byte 0xED. bits=1<<0xd; for(i=32; i<64; ++i) { // Second half of 4k block. bmpBlockBits[i]=(bmpBlockBits[i]&mask)|bits; } } else { - mask=~(0x10001<<0xd); // Lead byte 0xED. + mask= static_cast(~(0x10001<<0xd)); // Lead byte 0xED. for(i=32; i<64; ++i) { // Second half of 4k block. bmpBlockBits[i]&=mask; } diff --git a/icu4c/source/common/charstr.cpp b/icu4c/source/common/charstr.cpp index 353f1d52542..0b785e9c010 100644 --- a/icu4c/source/common/charstr.cpp +++ b/icu4c/source/common/charstr.cpp @@ -79,7 +79,7 @@ CharString &CharString::append(const char *s, int32_t sLength, UErrorCode &error return *this; } if(sLength<0) { - sLength=uprv_strlen(s); + sLength= static_cast(uprv_strlen(s)); } if(sLength>0) { if(s==(buffer.getAlias()+len)) { diff --git a/icu4c/source/common/common.vcxproj b/icu4c/source/common/common.vcxproj index 0f501406fc0..99c4533a573 100644 --- a/icu4c/source/common/common.vcxproj +++ b/icu4c/source/common/common.vcxproj @@ -2,7 +2,6 @@ - {73C0A65B-D1F2-4DE1-B3A6-15DAD2C23F3D} @@ -450,4 +449,4 @@ - + \ No newline at end of file diff --git a/icu4c/source/common/dictbe.cpp b/icu4c/source/common/dictbe.cpp index d8ae45c6826..cdef7938698 100644 --- a/icu4c/source/common/dictbe.cpp +++ b/icu4c/source/common/dictbe.cpp @@ -325,9 +325,9 @@ foundBest: // two characters after uc were not 0x0E4C THANTHAKHAT before // checking the dictionary. That is just a performance filter, // but it's not clear it's faster than checking the trie. - int32_t candidates = words[(wordsFound + 1) % THAI_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); + int32_t num_candidates = words[(wordsFound + 1) % THAI_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); utext_setNativeIndex(text, current + cuWordLength + chars); - if (candidates > 0) { + if (num_candidates > 0) { break; } } @@ -555,9 +555,9 @@ foundBest: if (fEndWordSet.contains(pc) && fBeginWordSet.contains(uc)) { // Maybe. See if it's in the dictionary. // TODO: this looks iffy; compare with old code. - int32_t candidates = words[(wordsFound + 1) % LAO_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); + int32_t num_candidates = words[(wordsFound + 1) % LAO_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); utext_setNativeIndex(text, current + cuWordLength + chars); - if (candidates > 0) { + if (num_candidates > 0) { break; } } @@ -748,9 +748,9 @@ foundBest: if (fEndWordSet.contains(pc) && fBeginWordSet.contains(uc)) { // Maybe. See if it's in the dictionary. // TODO: this looks iffy; compare with old code. - int32_t candidates = words[(wordsFound + 1) % BURMESE_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); + int32_t num_candidates = words[(wordsFound + 1) % BURMESE_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); utext_setNativeIndex(text, current + cuWordLength + chars); - if (candidates > 0) { + if (num_candidates > 0) { break; } } @@ -953,9 +953,9 @@ foundBest: uc = utext_current32(text); if (fEndWordSet.contains(pc) && fBeginWordSet.contains(uc)) { // Maybe. See if it's in the dictionary. - int32_t candidates = words[(wordsFound + 1) % KHMER_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); + int32_t num_candidates = words[(wordsFound + 1) % KHMER_LOOKAHEAD].candidates(text, fDictionary, rangeEnd); utext_setNativeIndex(text, current+cuWordLength+chars); - if (candidates > 0) { + if (num_candidates > 0) { break; } } diff --git a/icu4c/source/common/edits.cpp b/icu4c/source/common/edits.cpp index 3b3611fcf80..00a8d601a1c 100644 --- a/icu4c/source/common/edits.cpp +++ b/icu4c/source/common/edits.cpp @@ -276,7 +276,7 @@ Edits &Edits::mergeAndAppend(const Edits &ab, const Edits &bc, UErrorCode &error // ab deletions meet bc insertions at the same intermediate-string index. // Some users expect the bc insertions to come first, so we fetch from bc first. if (bc_bLength == 0) { - if (bcHasNext && (bcHasNext = bcIter.next(errorCode))) { + if (bcHasNext && (bcHasNext = bcIter.next(errorCode)) != 0) { bc_bLength = bcIter.oldLength(); cLength = bcIter.newLength(); if (bc_bLength == 0) { @@ -293,7 +293,7 @@ Edits &Edits::mergeAndAppend(const Edits &ab, const Edits &bc, UErrorCode &error // else see if the other iterator is done, too. } if (ab_bLength == 0) { - if (abHasNext && (abHasNext = abIter.next(errorCode))) { + if (abHasNext && (abHasNext = abIter.next(errorCode)) != 0) { aLength = abIter.oldLength(); ab_bLength = abIter.newLength(); if (ab_bLength == 0) { diff --git a/icu4c/source/common/loadednormalizer2impl.cpp b/icu4c/source/common/loadednormalizer2impl.cpp index 288a7d69536..041d11853c4 100644 --- a/icu4c/source/common/loadednormalizer2impl.cpp +++ b/icu4c/source/common/loadednormalizer2impl.cpp @@ -247,7 +247,7 @@ Normalizer2::getInstance(const char *packageName, } void *temp=uhash_get(cache, name); if(temp==NULL) { - int32_t keyLength=uprv_strlen(name)+1; + int32_t keyLength= static_cast(uprv_strlen(name)+1); char *nameCopy=(char *)uprv_malloc(keyLength); if(nameCopy==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; diff --git a/icu4c/source/common/locdspnm.cpp b/icu4c/source/common/locdspnm.cpp index 6ceb6cfc8bc..2d9389e910a 100644 --- a/icu4c/source/common/locdspnm.cpp +++ b/icu4c/source/common/locdspnm.cpp @@ -45,9 +45,9 @@ static int32_t ncat(char *buffer, uint32_t buflen, ...) { } va_start(args, buflen); - while ((str = va_arg(args, char *))) { + while ((str = va_arg(args, char *)) != 0) { char c; - while (p != e && (c = *str++)) { + while (p != e && (c = *str++) != 0) { *p++ = c; } } @@ -98,7 +98,7 @@ ICUDataTable::ICUDataTable(const char* path, const Locale& locale) : path(NULL), locale(Locale::getRoot()) { if (path) { - int32_t len = uprv_strlen(path); + int32_t len = static_cast(uprv_strlen(path)); this->path = (const char*) uprv_malloc(len + 1); if (this->path) { uprv_strcpy((char *)this->path, path); @@ -560,21 +560,21 @@ LocaleDisplayNamesImpl::adjustForUsageAndContext(CapContextUsage usage, } UnicodeString& -LocaleDisplayNamesImpl::localeDisplayName(const Locale& locale, +LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc, UnicodeString& result) const { - if (locale.isBogus()) { + if (loc.isBogus()) { result.setToBogus(); return result; } UnicodeString resultName; - const char* lang = locale.getLanguage(); + const char* lang = loc.getLanguage(); if (uprv_strlen(lang) == 0) { lang = "root"; } - const char* script = locale.getScript(); - const char* country = locale.getCountry(); - const char* variant = locale.getVariant(); + const char* script = loc.getScript(); + const char* country = loc.getCountry(); + const char* variant = loc.getVariant(); UBool hasScript = uprv_strlen(script) > 0; UBool hasCountry = uprv_strlen(country) > 0; @@ -630,14 +630,14 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& locale, resultRemainder.findAndReplace(formatOpenParen, formatReplaceOpenParen); resultRemainder.findAndReplace(formatCloseParen, formatReplaceCloseParen); - LocalPointer e(locale.createKeywords(status)); + LocalPointer e(loc.createKeywords(status)); if (e.isValid() && U_SUCCESS(status)) { UnicodeString temp2; char value[ULOC_KEYWORD_AND_VALUES_CAPACITY]; // sigh, no ULOC_VALUE_CAPACITY const char* key; while ((key = e->next((int32_t *)0, status)) != NULL) { value[0] = 0; - locale.getKeywordValue(key, value, ULOC_KEYWORD_AND_VALUES_CAPACITY, status); + loc.getKeywordValue(key, value, ULOC_KEYWORD_AND_VALUES_CAPACITY, status); if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING) { return result; } diff --git a/icu4c/source/common/locid.cpp b/icu4c/source/common/locid.cpp index afc8b81ca26..d799f5dc9cc 100644 --- a/icu4c/source/common/locid.cpp +++ b/icu4c/source/common/locid.cpp @@ -552,7 +552,7 @@ Locale& Locale::init(const char* localeID, UBool canonicalize) /* after uloc_getName/canonicalize() we know that only '_' are separators */ separator = field[0] = fullName; fieldIdx = 1; - while ((separator = uprv_strchr(field[fieldIdx-1], SEP_CHAR)) && fieldIdx < UPRV_LENGTHOF(field)-1) { + while ((separator = uprv_strchr(field[fieldIdx-1], SEP_CHAR)) != 0 && fieldIdx < UPRV_LENGTHOF(field)-1) { field[fieldIdx] = separator + 1; fieldLen[fieldIdx-1] = (int32_t)(separator - field[fieldIdx-1]); fieldIdx++; @@ -659,7 +659,7 @@ Locale::initBaseName(UErrorCode &status) { int32_t Locale::hashCode() const { - return ustr_hashCharsN(fullName, uprv_strlen(fullName)); + return ustr_hashCharsN(fullName, static_cast(uprv_strlen(fullName))); } void diff --git a/icu4c/source/common/normalizer2impl.cpp b/icu4c/source/common/normalizer2impl.cpp index 15b4a528934..eba0f03544a 100644 --- a/icu4c/source/common/normalizer2impl.cpp +++ b/icu4c/source/common/normalizer2impl.cpp @@ -122,7 +122,7 @@ int32_t getJamoTMinusBase(const uint8_t *src, const uint8_t *limit) { } } else if (src[1] == 0x87) { uint8_t t = src[2]; - if ((int8_t)t <= (int8_t)0x82) { + if ((int8_t)t <= (int8_t)0x82u) { return t - (0xa7 - 0x40); } } @@ -422,20 +422,20 @@ Normalizer2Impl::~Normalizer2Impl() { void Normalizer2Impl::init(const int32_t *inIndexes, const UTrie2 *inTrie, const uint16_t *inExtraData, const uint8_t *inSmallFCD) { - minDecompNoCP=inIndexes[IX_MIN_DECOMP_NO_CP]; - minCompNoMaybeCP=inIndexes[IX_MIN_COMP_NO_MAYBE_CP]; - minLcccCP=inIndexes[IX_MIN_LCCC_CP]; + minDecompNoCP = static_cast(inIndexes[IX_MIN_DECOMP_NO_CP]); + minCompNoMaybeCP = static_cast(inIndexes[IX_MIN_COMP_NO_MAYBE_CP]); + minLcccCP = static_cast(inIndexes[IX_MIN_LCCC_CP]); - minYesNo=inIndexes[IX_MIN_YES_NO]; - minYesNoMappingsOnly=inIndexes[IX_MIN_YES_NO_MAPPINGS_ONLY]; - minNoNo=inIndexes[IX_MIN_NO_NO]; - minNoNoCompBoundaryBefore=inIndexes[IX_MIN_NO_NO_COMP_BOUNDARY_BEFORE]; - minNoNoCompNoMaybeCC=inIndexes[IX_MIN_NO_NO_COMP_NO_MAYBE_CC]; - minNoNoEmpty=inIndexes[IX_MIN_NO_NO_EMPTY]; - limitNoNo=inIndexes[IX_LIMIT_NO_NO]; - minMaybeYes=inIndexes[IX_MIN_MAYBE_YES]; - U_ASSERT((minMaybeYes&7)==0); // 8-aligned for noNoDelta bit fields - centerNoNoDelta=(minMaybeYes>>DELTA_SHIFT)-MAX_DELTA-1; + minYesNo = static_cast(inIndexes[IX_MIN_YES_NO]); + minYesNoMappingsOnly = static_cast(inIndexes[IX_MIN_YES_NO_MAPPINGS_ONLY]); + minNoNo = static_cast(inIndexes[IX_MIN_NO_NO]); + minNoNoCompBoundaryBefore = static_cast(inIndexes[IX_MIN_NO_NO_COMP_BOUNDARY_BEFORE]); + minNoNoCompNoMaybeCC = static_cast(inIndexes[IX_MIN_NO_NO_COMP_NO_MAYBE_CC]); + minNoNoEmpty = static_cast(inIndexes[IX_MIN_NO_NO_EMPTY]); + limitNoNo = static_cast(inIndexes[IX_LIMIT_NO_NO]); + minMaybeYes = static_cast(inIndexes[IX_MIN_MAYBE_YES]); + U_ASSERT((minMaybeYes & 7) == 0); // 8-aligned for noNoDelta bit fields + centerNoNoDelta = (minMaybeYes >> DELTA_SHIFT) - MAX_DELTA - 1; normTrie=inTrie; diff --git a/icu4c/source/common/normalizer2impl.h b/icu4c/source/common/normalizer2impl.h index 9dd4d1e5ab1..8f187522ae1 100644 --- a/icu4c/source/common/normalizer2impl.h +++ b/icu4c/source/common/normalizer2impl.h @@ -118,7 +118,7 @@ public: buffer[0]=(UChar)(JAMO_L_BASE+c/JAMO_V_COUNT); buffer[1]=(UChar)(JAMO_V_BASE+c%JAMO_V_COUNT); } else { - buffer[0]=orig-c2; // LV syllable + buffer[0]=(UChar)(orig-c2); // LV syllable buffer[1]=(UChar)(JAMO_T_BASE+c2); } } diff --git a/icu4c/source/common/rbbi.cpp b/icu4c/source/common/rbbi.cpp index c5ea2770ba9..f7e82cb15d8 100644 --- a/icu4c/source/common/rbbi.cpp +++ b/icu4c/source/common/rbbi.cpp @@ -628,7 +628,7 @@ int32_t RuleBasedBreakIterator::preceding(int32_t offset) { // or on a trail byte if the input is UTF-8. utext_setNativeIndex(&fText, offset); - int32_t adjustedOffset = utext_getNativeIndex(&fText); + int32_t adjustedOffset = static_cast(utext_getNativeIndex(&fText)); UErrorCode status = U_ZERO_ERROR; fBreakCache->preceding(adjustedOffset, status); @@ -655,7 +655,7 @@ UBool RuleBasedBreakIterator::isBoundary(int32_t offset) { // But we still need the side effect of leaving iteration at the following boundary. utext_setNativeIndex(&fText, offset); - int32_t adjustedOffset = utext_getNativeIndex(&fText); + int32_t adjustedOffset = static_cast(utext_getNativeIndex(&fText)); bool result = false; UErrorCode status = U_ZERO_ERROR; @@ -848,7 +848,7 @@ int32_t RuleBasedBreakIterator::handleNext() { #ifdef RBBI_DEBUG if (gTrace) { - RBBIDebugPrintf(" %4ld ", utext_getNativeIndex(&fText)); + RBBIDebugPrintf(" %4lld ", utext_getNativeIndex(&fText)); if (0x20<=c && c<0x7f) { RBBIDebugPrintf("\"%c\" ", c); } else { diff --git a/icu4c/source/common/rbbi_cache.cpp b/icu4c/source/common/rbbi_cache.cpp index 60316ce6420..519c6104989 100644 --- a/icu4c/source/common/rbbi_cache.cpp +++ b/icu4c/source/common/rbbi_cache.cpp @@ -603,7 +603,7 @@ void RuleBasedBreakIterator::BreakCache::addFollowing(int32_t position, int32_t fStartBufIdx = modChunkSize(fStartBufIdx + 6); // TODO: experiment. Probably revert to 1. } fBoundaries[nextIdx] = position; - fStatuses[nextIdx] = ruleStatusIdx; + fStatuses[nextIdx] = static_cast(ruleStatusIdx); fEndBufIdx = nextIdx; if (update == UpdateCachePosition) { // Set current position to the newly added boundary. @@ -631,7 +631,7 @@ bool RuleBasedBreakIterator::BreakCache::addPreceding(int32_t position, int32_t fEndBufIdx = modChunkSize(fEndBufIdx - 1); } fBoundaries[nextIdx] = position; - fStatuses[nextIdx] = ruleStatusIdx; + fStatuses[nextIdx] = static_cast(ruleStatusIdx); fStartBufIdx = nextIdx; if (update == UpdateCachePosition) { fBufIdx = nextIdx; diff --git a/icu4c/source/common/rbbiscan.cpp b/icu4c/source/common/rbbiscan.cpp index c82e1ea0315..f536ab5d398 100644 --- a/icu4c/source/common/rbbiscan.cpp +++ b/icu4c/source/common/rbbiscan.cpp @@ -380,7 +380,7 @@ UBool RBBIRuleScanner::doParseActions(int32_t action) // with the current rule expression (on the Node Stack) // with the resulting OR expression going to *destRules // - RBBINode *thisRule = fNodeStack[fNodeStackPtr]; + thisRule = fNodeStack[fNodeStackPtr]; RBBINode *prevRules = *destRules; RBBINode *orNode = pushNewNode(RBBINode::opOr); if (U_FAILURE(*fRB->fStatus)) { diff --git a/icu4c/source/common/rbbitblb.cpp b/icu4c/source/common/rbbitblb.cpp index 18da5231b97..a20b51777cd 100644 --- a/icu4c/source/common/rbbitblb.cpp +++ b/icu4c/source/common/rbbitblb.cpp @@ -428,8 +428,8 @@ void RBBITableBuilder::calcChainedFollowPos(RBBINode *tree) { addRuleRootNodes(&ruleRootNodes, tree); UVector matchStartNodes(*fStatus); - for (int i=0; i(ruleRootNodes.elementAt(i)); + for (int j=0; j(ruleRootNodes.elementAt(j)); if (node->fChainIn) { setAdd(&matchStartNodes, node->fFirstPosSet); } @@ -1082,21 +1082,22 @@ bool RBBITableBuilder::findDuplCharClassFrom(IntPair *categories) { int32_t numStates = fDStates->size(); int32_t numCols = fRB->fSetBuilder->getNumCharCategories(); - uint16_t table_base; - uint16_t table_dupl; for (; categories->first < numCols-1; categories->first++) { for (categories->second=categories->first+1; categories->second < numCols; categories->second++) { - for (int32_t state=0; stateelementAt(state); - table_base = (uint16_t)sd->fDtran->elementAti(categories->first); - table_dupl = (uint16_t)sd->fDtran->elementAti(categories->second); - if (table_base != table_dupl) { - break; - } - } - if (table_base == table_dupl) { - return true; - } + // Initialized to different values to prevent returning true if numStates = 0 (implies no duplicates). + uint16_t table_base = 0; + uint16_t table_dupl = 1; + for (int32_t state=0; stateelementAt(state); + table_base = (uint16_t)sd->fDtran->elementAti(categories->first); + table_dupl = (uint16_t)sd->fDtran->elementAti(categories->second); + if (table_base != table_dupl) { + break; + } + } + if (table_base == table_dupl) { + return true; + } } } return false; @@ -1236,7 +1237,7 @@ void RBBITableBuilder::removeSafeState(IntPair duplStates) { } else if (existingVal > duplState) { newVal = existingVal - 1; } - sd->setCharAt(col, newVal); + sd->setCharAt(col, static_cast(newVal)); } } } @@ -1415,7 +1416,7 @@ void RBBITableBuilder::buildSafeReverseTable(UErrorCode &status) { UnicodeString &startState = *static_cast(fSafeTable->elementAt(1)); for (int32_t charClass=0; charClass < numCharClasses; ++charClass) { // Note: +2 for the start & stop state. - startState.setCharAt(charClass, charClass+2); + startState.setCharAt(charClass, static_cast(charClass+2)); } // Initially make every other state table row look like the start state row, diff --git a/icu4c/source/common/serv.cpp b/icu4c/source/common/serv.cpp index 959ab604c68..619e8c7c8bd 100644 --- a/icu4c/source/common/serv.cpp +++ b/icu4c/source/common/serv.cpp @@ -702,9 +702,9 @@ ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const } // fallback - UErrorCode status = U_ZERO_ERROR; + status = U_ZERO_ERROR; ICUServiceKey* fallbackKey = createKey(&id, status); - while (fallbackKey->fallback()) { + while (fallbackKey != NULL && fallbackKey->fallback()) { UnicodeString us; fallbackKey->currentID(us); f = (ICUServiceFactory*)map->get(us); diff --git a/icu4c/source/common/stringtriebuilder.cpp b/icu4c/source/common/stringtriebuilder.cpp index cf5b7b73ae2..6f9cc2e5c22 100644 --- a/icu4c/source/common/stringtriebuilder.cpp +++ b/icu4c/source/common/stringtriebuilder.cpp @@ -373,7 +373,7 @@ StringTrieBuilder::registerFinalValue(int32_t value, UErrorCode &errorCode) { return newNode; } -UBool +int32_t StringTrieBuilder::hashNode(const void *node) { return ((const Node *)node)->hashCode(); } diff --git a/icu4c/source/common/ubidi.cpp b/icu4c/source/common/ubidi.cpp index 531ed64cff6..4b65d491859 100644 --- a/icu4c/source/common/ubidi.cpp +++ b/icu4c/source/common/ubidi.cpp @@ -624,7 +624,7 @@ getDirProps(UBiDi *pBiDi) { pBiDi->paras[pBiDi->paraCount-1].level=1; } if(isDefaultLevel) { - pBiDi->paraLevel=pBiDi->paras[0].level; + pBiDi->paraLevel=static_cast(pBiDi->paras[0].level); } /* The following is needed to resolve the text direction for default level paragraphs containing no strong character */ @@ -825,28 +825,28 @@ bracketProcessClosing(BracketData *bd, int32_t openIdx, int32_t position) { N0c1. */ if((direction==0 && pOpening->flags&FOUND_L) || - (direction==1 && pOpening->flags&FOUND_R)) { /* N0b */ - newProp=direction; + (direction==1 && pOpening->flags&FOUND_R)) { /* N0b */ + newProp=static_cast(direction); } - else if(pOpening->flags&(FOUND_L|FOUND_R)) { /* N0c */ + else if(pOpening->flags&(FOUND_L|FOUND_R)) { /* N0c */ /* it is stable if there is no containing pair or in conditions too complicated and not worth checking */ stable=(openIdx==pLastIsoRun->start); if(direction!=pOpening->contextDir) - newProp=pOpening->contextDir; /* N0c1 */ + newProp= static_cast(pOpening->contextDir); /* N0c1 */ else - newProp=direction; /* N0c2 */ + newProp= static_cast(direction); /* N0c2 */ } else { /* forget this and any brackets nested within this pair */ - pLastIsoRun->limit=openIdx; - return ON; /* N0d */ + pLastIsoRun->limit= static_cast(openIdx); + return ON; /* N0d */ } bd->pBiDi->dirProps[pOpening->position]=newProp; bd->pBiDi->dirProps[position]=newProp; /* Update nested N0c pairs that may be affected */ fixN0c(bd, openIdx, pOpening->position, newProp); if(stable) { - pLastIsoRun->limit=openIdx; /* forget any brackets nested within this pair */ + pLastIsoRun->limit= static_cast(openIdx); /* forget any brackets nested within this pair */ /* remove lower located synonyms if any */ while(pLastIsoRun->limit>pLastIsoRun->start && bd->openings[pLastIsoRun->limit-1].position==pOpening->position) @@ -918,7 +918,7 @@ bracketProcessChar(BracketData *bd, int32_t position) { bracket or it is a case of N0d */ /* Now see if it is an opening bracket */ if(c) - match=u_getBidiPairedBracket(c); /* get the matching char */ + match= static_cast(u_getBidiPairedBracket(c)); /* get the matching char */ else match=0; if(match!=c && /* has a matching char */ @@ -948,7 +948,7 @@ bracketProcessChar(BracketData *bd, int32_t position) { pLastIsoRun->contextPos=position; } else if(dirProp<=R || dirProp==AL) { - newProp=DIR_FROM_STRONG(dirProp); + newProp= static_cast(DIR_FROM_STRONG(dirProp)); pLastIsoRun->lastBase=dirProp; pLastIsoRun->lastStrong=dirProp; pLastIsoRun->contextDir=(UBiDiDirection)newProp; @@ -1101,7 +1101,7 @@ resolveExplicitLevels(UBiDi *pBiDi, UErrorCode *pErrorCode) { else start=pBiDi->paras[paraIndex-1].limit; limit=pBiDi->paras[paraIndex].limit; - level=pBiDi->paras[paraIndex].level; + level= static_cast(pBiDi->paras[paraIndex].level); for(i=start; iparas[paraIndex-1].limit; limit=pBiDi->paras[paraIndex].limit; - level=pBiDi->paras[paraIndex].level; + level= static_cast(pBiDi->paras[paraIndex].level); for(i=start; iparaCount; i++) { last=(pBiDi->paras[i].limit)-1; - level=pBiDi->paras[i].level; + level= static_cast(pBiDi->paras[i].level); if(level==0) continue; /* LTR paragraph */ start= i==0 ? 0 : pBiDi->paras[i-1].limit; diff --git a/icu4c/source/common/ubiditransform.cpp b/icu4c/source/common/ubiditransform.cpp index fd7b90fd37c..e6d1d9c086d 100644 --- a/icu4c/source/common/ubiditransform.cpp +++ b/icu4c/source/common/ubiditransform.cpp @@ -146,7 +146,7 @@ static UBool action_reorder(UBiDiTransform *pTransform, UErrorCode *pErrorCode) { ubidi_writeReordered(pTransform->pBidi, pTransform->dest, pTransform->destSize, - pTransform->reorderingOptions, pErrorCode); + static_cast(pTransform->reorderingOptions), pErrorCode); *pTransform->pDestLength = pTransform->srcLength; pTransform->reorderingOptions = UBIDI_REORDER_DEFAULT; @@ -393,9 +393,9 @@ resolveBaseDirection(const UChar *text, uint32_t length, switch (*pInLevel) { case UBIDI_DEFAULT_LTR: case UBIDI_DEFAULT_RTL: { - UBiDiLevel level = ubidi_getBaseDirection(text, length); - *pInLevel = level != UBIDI_NEUTRAL ? level - : *pInLevel == UBIDI_DEFAULT_RTL ? RTL : LTR; + UBiDiLevel level = static_cast(ubidi_getBaseDirection(text, length)); + *pInLevel = static_cast(level != UBIDI_NEUTRAL) ? level + : *pInLevel == UBIDI_DEFAULT_RTL ? static_cast(RTL) : static_cast(LTR); break; } default: diff --git a/icu4c/source/common/ucnv2022.cpp b/icu4c/source/common/ucnv2022.cpp index 2ef5db97754..d1a50d269f1 100644 --- a/icu4c/source/common/ucnv2022.cpp +++ b/icu4c/source/common/ucnv2022.cpp @@ -2772,7 +2772,7 @@ getTrailByte: /* report a pair of illegal bytes if the second byte is not a DBCS starter */ ++mySource; /* add another bit so that the code below writes 2 bytes in case of error */ - mySourceChar = 0x10000 | (mySourceChar << 8) | trailByte; + mySourceChar = static_cast(0x10000 | (mySourceChar << 8) | trailByte); } } else { args->converter->toUBytes[0] = (uint8_t)mySourceChar; @@ -3304,7 +3304,7 @@ UConverter_toUnicode_ISO_2022_CN_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, myData->isEmptySegment = FALSE; /* we are handling it, reset to avoid future spurious errors */ *err = U_ILLEGAL_ESCAPE_SEQUENCE; args->converter->toUCallbackReason = UCNV_IRREGULAR; - args->converter->toUBytes[0] = mySourceChar; + args->converter->toUBytes[0] = static_cast(mySourceChar); args->converter->toULength = 1; args->target = myTarget; args->source = mySource; diff --git a/icu4c/source/common/ucnv_ct.cpp b/icu4c/source/common/ucnv_ct.cpp index 51e31aa4116..b40e1b2c970 100644 --- a/icu4c/source/common/ucnv_ct.cpp +++ b/icu4c/source/common/ucnv_ct.cpp @@ -180,7 +180,7 @@ _CompoundTextgetName(const UConverter* cnv); static int32_t findNextEsc(const char *source, const char *sourceLimit) { - int32_t length = sourceLimit - source; + int32_t length = static_cast(sourceLimit - source); int32_t i; for (i = 1; i < length; i++) { if (*(source + i) == 0x1B) { diff --git a/icu4c/source/common/ucnv_u16.cpp b/icu4c/source/common/ucnv_u16.cpp index 28f2727ecdf..a5e8367400a 100644 --- a/icu4c/source/common/ucnv_u16.cpp +++ b/icu4c/source/common/ucnv_u16.cpp @@ -71,7 +71,7 @@ _UTF16BEFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs, /* write the BOM if necessary */ if(cnv->fromUnicodeStatus==UCNV_NEED_TO_WRITE_BOM) { - static const char bom[]={ (char)0xfe, (char)0xff }; + static const char bom[]={ (char)0xfeu, (char)0xffu }; ucnv_fromUWriteBytes(cnv, bom, 2, &pArgs->target, pArgs->targetLimit, @@ -672,7 +672,7 @@ _UTF16LEFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs, /* write the BOM if necessary */ if(cnv->fromUnicodeStatus==UCNV_NEED_TO_WRITE_BOM) { - static const char bom[]={ (char)0xff, (char)0xfe }; + static const char bom[]={ (char)0xffu, (char)0xfeu }; ucnv_fromUWriteBytes(cnv, bom, 2, &pArgs->target, pArgs->targetLimit, diff --git a/icu4c/source/common/ucnv_u32.cpp b/icu4c/source/common/ucnv_u32.cpp index 5777117a924..9f98914b9d7 100644 --- a/icu4c/source/common/ucnv_u32.cpp +++ b/icu4c/source/common/ucnv_u32.cpp @@ -228,7 +228,7 @@ T_UConverter_fromUnicode_UTF32_BE(UConverterFromUnicodeArgs * args, /* write the BOM if necessary */ if(args->converter->fromUnicodeStatus==UCNV_NEED_TO_WRITE_BOM) { - static const char bom[]={ 0, 0, (char)0xfe, (char)0xff }; + static const char bom[]={ 0, 0, (char)0xfeu, (char)0xffu }; ucnv_fromUWriteBytes(args->converter, bom, 4, &args->target, args->targetLimit, @@ -331,7 +331,7 @@ T_UConverter_fromUnicode_UTF32_BE_OFFSET_LOGIC(UConverterFromUnicodeArgs * args, /* write the BOM if necessary */ if(args->converter->fromUnicodeStatus==UCNV_NEED_TO_WRITE_BOM) { - static const char bom[]={ 0, 0, (char)0xfe, (char)0xff }; + static const char bom[]={ 0, 0, (char)0xfeu, (char)0xffu }; ucnv_fromUWriteBytes(args->converter, bom, 4, &args->target, args->targetLimit, @@ -706,7 +706,7 @@ T_UConverter_fromUnicode_UTF32_LE(UConverterFromUnicodeArgs * args, /* write the BOM if necessary */ if(args->converter->fromUnicodeStatus==UCNV_NEED_TO_WRITE_BOM) { - static const char bom[]={ (char)0xff, (char)0xfe, 0, 0 }; + static const char bom[]={ (char)0xffu, (char)0xfeu, 0, 0 }; ucnv_fromUWriteBytes(args->converter, bom, 4, &args->target, args->targetLimit, @@ -817,7 +817,7 @@ T_UConverter_fromUnicode_UTF32_LE_OFFSET_LOGIC(UConverterFromUnicodeArgs * args, /* write the BOM if necessary */ if(args->converter->fromUnicodeStatus==UCNV_NEED_TO_WRITE_BOM) { - static const char bom[]={ (char)0xff, (char)0xfe, 0, 0 }; + static const char bom[]={ (char)0xffu, (char)0xfeu, 0, 0 }; ucnv_fromUWriteBytes(args->converter, bom, 4, &args->target, args->targetLimit, @@ -1043,7 +1043,7 @@ _UTF32Open(UConverter *cnv, _UTF32Reset(cnv, UCNV_RESET_BOTH); } -static const char utf32BOM[8]={ 0, 0, (char)0xfe, (char)0xff, (char)0xff, (char)0xfe, 0, 0 }; +static const char utf32BOM[8]={ 0, 0, (char)0xfeu, (char)0xffu, (char)0xffu, (char)0xfeu, 0, 0 }; static void U_CALLCONV _UTF32ToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs, @@ -1071,7 +1071,7 @@ _UTF32ToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs, b=*source; if(b==0) { state=1; /* could be 00 00 FE FF */ - } else if(b==(char)0xff) { + } else if(b==(char)0xffu) { state=5; /* could be FF FE 00 00 */ } else { state=8; /* default to UTF-32BE */ diff --git a/icu4c/source/common/ucnv_u8.cpp b/icu4c/source/common/ucnv_u8.cpp index 7089d9400c6..9b518e08df6 100644 --- a/icu4c/source/common/ucnv_u8.cpp +++ b/icu4c/source/common/ucnv_u8.cpp @@ -108,7 +108,7 @@ morebytes: if (mySource < sourceLimit) { toUBytes[i] = (char) (ch2 = *mySource); - if (!icu::UTF8::isValidTrail(ch, ch2, i, inBytes) && + if (!icu::UTF8::isValidTrail(ch, static_cast(ch2), i, inBytes) && !(isCESU8 && i == 1 && ch == 0xed && U8_IS_TRAIL(ch2))) { break; /* i < inBytes */ @@ -225,7 +225,7 @@ morebytes: if (mySource < sourceLimit) { toUBytes[i] = (char) (ch2 = *mySource); - if (!icu::UTF8::isValidTrail(ch, ch2, i, inBytes) && + if (!icu::UTF8::isValidTrail(ch, static_cast(ch2), i, inBytes) && !(isCESU8 && i == 1 && ch == 0xed && U8_IS_TRAIL(ch2))) { break; /* i < inBytes */ diff --git a/icu4c/source/common/ucnvhz.cpp b/icu4c/source/common/ucnvhz.cpp index 79a83d759f1..e9f5206c163 100644 --- a/icu4c/source/common/ucnvhz.cpp +++ b/icu4c/source/common/ucnvhz.cpp @@ -199,7 +199,7 @@ UConverter_toUnicode_HZ_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, *err = U_ILLEGAL_ESCAPE_SEQUENCE; args->converter->toUCallbackReason = UCNV_IRREGULAR; args->converter->toUBytes[0] = UCNV_TILDE; - args->converter->toUBytes[1] = mySourceChar; + args->converter->toUBytes[1] = static_cast(mySourceChar); args->converter->toULength = 2; args->target = myTarget; args->source = mySource; @@ -229,7 +229,7 @@ UConverter_toUnicode_HZ_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, --mySource; } else { /* Include the current byte in the illegal sequence. */ - args->converter->toUBytes[1] = mySourceChar; + args->converter->toUBytes[1] = static_cast(mySourceChar); args->converter->toULength = 2; } args->target = myTarget; diff --git a/icu4c/source/common/ucnvmbcs.cpp b/icu4c/source/common/ucnvmbcs.cpp index 2d0c857758d..583744b73a3 100644 --- a/icu4c/source/common/ucnvmbcs.cpp +++ b/icu4c/source/common/ucnvmbcs.cpp @@ -4164,8 +4164,8 @@ ucnv_MBCSFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs, nextSourceIndex=0; /* Get the SI/SO character for the converter */ - siLength = getSISOBytes(SI, cnv->options, siBytes); - soLength = getSISOBytes(SO, cnv->options, soBytes); + siLength = static_cast(getSISOBytes(SI, cnv->options, siBytes)); + soLength = static_cast(getSISOBytes(SO, cnv->options, soBytes)); /* conversion loop */ /* diff --git a/icu4c/source/common/ucnvsel.cpp b/icu4c/source/common/ucnvsel.cpp index ba062b35cec..2b46d1c581b 100644 --- a/icu4c/source/common/ucnvsel.cpp +++ b/icu4c/source/common/ucnvsel.cpp @@ -72,7 +72,7 @@ static void generateSelectorData(UConverterSelector* result, // set errorValue to all-ones for (int32_t col = 0; col < columns; col++) { upvec_setValue(upvec, UPVEC_ERROR_VALUE_CP, UPVEC_ERROR_VALUE_CP, - col, ~0, ~0, status); + col, static_cast(~0), static_cast(~0), status); } for (int32_t i = 0; i < result->encodingsCount; ++i) { @@ -109,7 +109,7 @@ static void generateSelectorData(UConverterSelector* result, // this will be reached for the converters that fill the set with // strings. Those should be ignored by our system } else { - upvec_setValue(upvec, start_char, end_char, column, ~0, mask, + upvec_setValue(upvec, start_char, end_char, column, static_cast(~0), mask, status); } } @@ -130,7 +130,7 @@ static void generateSelectorData(UConverterSelector* result, uset_getItem(excludedCodePoints, j, &start_char, &end_char, NULL, 0, status); for (int32_t col = 0; col < columns; col++) { - upvec_setValue(upvec, start_char, end_char, col, ~0, ~0, + upvec_setValue(upvec, start_char, end_char, col, static_cast(~0), static_cast(~0), status); } } @@ -684,7 +684,7 @@ static int16_t countOnes(uint32_t* mask, int32_t len) { ent &= ent - 1; // clear the least significant bit set } } - return totalOnes; + return static_cast(totalOnes); } diff --git a/icu4c/source/common/ucurr.cpp b/icu4c/source/common/ucurr.cpp index e9a09cc1799..1062a9f3099 100644 --- a/icu4c/source/common/ucurr.cpp +++ b/icu4c/source/common/ucurr.cpp @@ -1077,11 +1077,11 @@ collectCurrencyNames(const char* locale, } // currency plurals - UErrorCode ec3 = U_ZERO_ERROR; - UResourceBundle* curr_p = ures_getByKey(rb, CURRENCYPLURALS, NULL, &ec3); + UErrorCode ec5 = U_ZERO_ERROR; + UResourceBundle* curr_p = ures_getByKey(rb, CURRENCYPLURALS, NULL, &ec5); n = ures_getSize(curr_p); for (int32_t i=0; ilocale) == 0) { @@ -1469,7 +1469,6 @@ getCacheEntry(const char* locale, UErrorCode& ec) { } umtx_lock(&gCurrencyCacheMutex); // check again. - int8_t found = -1; for (int8_t i = 0; i < CURRENCY_NAME_CACHE_NUM; ++i) { if (currCache[i]!= NULL && uprv_strcmp(locale, currCache[i]->locale) == 0) { diff --git a/icu4c/source/common/uhash.cpp b/icu4c/source/common/uhash.cpp index a80e7b8ff27..239997d05d7 100644 --- a/icu4c/source/common/uhash.cpp +++ b/icu4c/source/common/uhash.cpp @@ -218,7 +218,7 @@ _uhash_allocate(UHashtable *hash, U_ASSERT(primeIndex >= 0 && primeIndex < PRIMES_LENGTH); - hash->primeIndex = primeIndex; + hash->primeIndex = static_cast(primeIndex); hash->length = PRIMES[primeIndex]; p = hash->elements = (UHashElement*) @@ -860,13 +860,13 @@ uhash_hashUChars(const UHashTok key) { U_CAPI int32_t U_EXPORT2 uhash_hashChars(const UHashTok key) { const char *s = (const char *)key.pointer; - return s == NULL ? 0 : static_cast(ustr_hashCharsN(s, uprv_strlen(s))); + return s == NULL ? 0 : static_cast(ustr_hashCharsN(s, static_cast(uprv_strlen(s)))); } U_CAPI int32_t U_EXPORT2 uhash_hashIChars(const UHashTok key) { const char *s = (const char *)key.pointer; - return s == NULL ? 0 : ustr_hashICharsN(s, uprv_strlen(s)); + return s == NULL ? 0 : ustr_hashICharsN(s, static_cast(uprv_strlen(s))); } U_CAPI UBool U_EXPORT2 diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index 7a1dc723cff..f7073fec31f 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -1133,7 +1133,7 @@ uloc_setKeywordValue(const char* keywordName, keyValuePrefix = ';'; /* for any subsequent key-value pair */ updatedKeysAndValues.append(localeKeywordNameBuffer, keyValueLen, *status); updatedKeysAndValues.append('=', *status); - updatedKeysAndValues.append(nextEqualsign, keyValueTail-nextEqualsign, *status); + updatedKeysAndValues.append(nextEqualsign, static_cast(keyValueTail-nextEqualsign), *status); } if (!nextSeparator && keywordValueLen > 0 && !handledInputKeyAndValue) { /* append new entry at the end, it sorts later than existing entries */ @@ -1500,7 +1500,7 @@ _deleteVariant(char* variants, int32_t variantsLen, } if (uprv_strncmp(variants, toDelete, toDeleteLen) == 0 && (variantsLen == toDeleteLen || - (flag=(variants[toDeleteLen] == '_')))) + (flag=(variants[toDeleteLen] == '_')) != 0)) { int32_t d = toDeleteLen + (flag?1:0); variantsLen -= d; @@ -2412,7 +2412,7 @@ uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, UAcceptResult /* eat spaces prior to semi */ for(t=(paramEnd-1);(paramEnd>s)&&isspace(*t);t--) ; - int32_t slen = ((t+1)-s); + int32_t slen = static_cast(((t+1)-s)); if(slen > ULOC_FULLNAME_CAPACITY) { *status = U_BUFFER_OVERFLOW_ERROR; return -1; // too big diff --git a/icu4c/source/common/uloc_keytype.cpp b/icu4c/source/common/uloc_keytype.cpp index 4eea504bc26..b6f0752a707 100644 --- a/icu4c/source/common/uloc_keytype.cpp +++ b/icu4c/source/common/uloc_keytype.cpp @@ -228,7 +228,7 @@ initFromResourceBundle(UErrorCode& sts) { // a timezone key uses a colon instead of a slash in the resource. // e.g. America:Los_Angeles if (uprv_strchr(legacyTypeId, ':') != NULL) { - int32_t legacyTypeIdLen = uprv_strlen(legacyTypeId); + int32_t legacyTypeIdLen = static_cast(uprv_strlen(legacyTypeId)); char* legacyTypeIdBuf = (char*)uprv_malloc(legacyTypeIdLen + 1); if (legacyTypeIdBuf == NULL) { sts = U_MEMORY_ALLOCATION_ERROR; @@ -320,7 +320,7 @@ initFromResourceBundle(UErrorCode& sts) { if (isTZ) { // replace colon with slash if necessary if (uprv_strchr(from, ':') != NULL) { - int32_t fromLen = uprv_strlen(from); + int32_t fromLen = static_cast(uprv_strlen(from)); char* fromBuf = (char*)uprv_malloc(fromLen + 1); if (fromBuf == NULL) { sts = U_MEMORY_ALLOCATION_ERROR; @@ -472,7 +472,6 @@ isSpecialTypeRgKeyValue(const char* val) { p++; } return (subtagLen == 6); - return TRUE; } U_CFUNC const char* diff --git a/icu4c/source/common/unames.cpp b/icu4c/source/common/unames.cpp index 6ad349c2e3b..9c230dc93ee 100644 --- a/icu4c/source/common/unames.cpp +++ b/icu4c/source/common/unames.cpp @@ -466,7 +466,7 @@ static uint16_t getExtName(uint32_t code, char *buffer, uint16_t bufferLength) { buffer[--i] = (v < 10 ? '0' + v : 'A' + v - 10); } buffer += ndigits; - length += ndigits; + length += static_cast(ndigits); WRITE_CHAR(buffer, bufferLength, length, '>'); return length; diff --git a/icu4c/source/common/unicode/messagepattern.h b/icu4c/source/common/unicode/messagepattern.h index f28adafee0d..9f2a86551ca 100644 --- a/icu4c/source/common/unicode/messagepattern.h +++ b/icu4c/source/common/unicode/messagepattern.h @@ -771,8 +771,8 @@ public: * @stable ICU 4.8 */ UMessagePatternArgType getArgType() const { - UMessagePatternPartType type=getType(); - if(type==UMSGPAT_PART_TYPE_ARG_START || type==UMSGPAT_PART_TYPE_ARG_LIMIT) { + UMessagePatternPartType msgType=getType(); + if(msgType ==UMSGPAT_PART_TYPE_ARG_START || msgType ==UMSGPAT_PART_TYPE_ARG_LIMIT) { return (UMessagePatternArgType)value; } else { return UMSGPAT_ARG_TYPE_NONE; diff --git a/icu4c/source/common/unicode/stringtriebuilder.h b/icu4c/source/common/unicode/stringtriebuilder.h index 15321b45dab..fe99fdb41fd 100644 --- a/icu4c/source/common/unicode/stringtriebuilder.h +++ b/icu4c/source/common/unicode/stringtriebuilder.h @@ -66,7 +66,7 @@ class U_COMMON_API StringTrieBuilder : public UObject { public: #ifndef U_HIDE_INTERNAL_API /** @internal */ - static UBool hashNode(const void *node); + static int32_t hashNode(const void *node); /** @internal */ static UBool equalNodes(const void *left, const void *right); #endif /* U_HIDE_INTERNAL_API */ diff --git a/icu4c/source/common/unifiedcache.cpp b/icu4c/source/common/unifiedcache.cpp index f0f660ed06b..d33d8d2c01c 100644 --- a/icu4c/source/common/unifiedcache.cpp +++ b/icu4c/source/common/unifiedcache.cpp @@ -251,7 +251,7 @@ UBool UnifiedCache::_flush(UBool all) const { if (all || _isEvictable(element)) { const SharedObject *sharedObject = (const SharedObject *) element->value.pointer; - U_ASSERT(sharedObject->cachePtr = this); + U_ASSERT(sharedObject->cachePtr == this); uhash_removeElement(fHashtable, element); removeSoftRef(sharedObject); // Deletes the sharedObject when softRefCount goes to zero. result = TRUE; diff --git a/icu4c/source/common/uniset_props.cpp b/icu4c/source/common/uniset_props.cpp index 6ae6e71289b..e9d9473c2cb 100644 --- a/icu4c/source/common/uniset_props.cpp +++ b/icu4c/source/common/uniset_props.cpp @@ -1030,13 +1030,13 @@ UnicodeSet::applyPropertyAlias(const UnicodeString& prop, p == UCHAR_TRAIL_CANONICAL_COMBINING_CLASS || p == UCHAR_LEAD_CANONICAL_COMBINING_CLASS) { char* end; - double value = uprv_strtod(vname.data(), &end); + double val = uprv_strtod(vname.data(), &end); // Anything between 0 and 255 is valid even if unused. // Cast double->int only after range check. // We catch NaN here because comparing it with both 0 and 255 will be false // (as are all comparisons with NaN). - if (*end != 0 || !(0 <= value && value <= 255) || - (v = (int32_t)value) != value) { + if (*end != 0 || !(0 <= val && val <= 255) || + (v = (int32_t)val) != val) { // non-integral value or outside 0..255, or trailing junk FAIL(ec); } @@ -1052,11 +1052,11 @@ UnicodeSet::applyPropertyAlias(const UnicodeString& prop, case UCHAR_NUMERIC_VALUE: { char* end; - double value = uprv_strtod(vname.data(), &end); + double val = uprv_strtod(vname.data(), &end); if (*end != 0) { FAIL(ec); } - applyFilter(numericValueFilter, &value, UPROPS_SRC_CHAR, ec); + applyFilter(numericValueFilter, &val, UPROPS_SRC_CHAR, ec); return *this; } case UCHAR_NAME: diff --git a/icu4c/source/common/uprops.cpp b/icu4c/source/common/uprops.cpp index 21723b32aa7..3461c0b9228 100644 --- a/icu4c/source/common/uprops.cpp +++ b/icu4c/source/common/uprops.cpp @@ -56,7 +56,7 @@ static UBool defaultContains(const BinaryProperty &prop, UChar32 c, UProperty /* } static UBool caseBinaryPropertyContains(const BinaryProperty &/*prop*/, UChar32 c, UProperty which) { - return ucase_hasBinaryProperty(c, which); + return static_cast(ucase_hasBinaryProperty(c, which)); } static UBool isBidiControl(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) { diff --git a/icu4c/source/common/uresbund.cpp b/icu4c/source/common/uresbund.cpp index c51f7fdb64c..2a8ec7292b4 100644 --- a/icu4c/source/common/uresbund.cpp +++ b/icu4c/source/common/uresbund.cpp @@ -2421,7 +2421,7 @@ ures_loc_nextLocale(UEnumeration* en, UResourceBundle *k = NULL; const char *result = NULL; int32_t len = 0; - if(ures_hasNext(res) && (k = ures_getNextResource(res, &ctx->curr, status))) { + if(ures_hasNext(res) && (k = ures_getNextResource(res, &ctx->curr, status)) != 0) { result = ures_getKey(k); len = (int32_t)uprv_strlen(result); } @@ -2843,7 +2843,7 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status) valuesBuf[0]=0; valuesBuf[1]=0; - while((locale = uenum_next(locs, &locLen, status))) { + while((locale = uenum_next(locs, &locLen, status)) != 0) { UResourceBundle *bund = NULL; UResourceBundle *subPtr = NULL; UErrorCode subStatus = U_ZERO_ERROR; /* don't fail if a bundle is unopenable */ @@ -2868,7 +2868,7 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status) continue; } - while((subPtr = ures_getNextResource(&item,&subItem,&subStatus)) + while((subPtr = ures_getNextResource(&item,&subItem,&subStatus)) != 0 && U_SUCCESS(subStatus)) { const char *k; int32_t i; diff --git a/icu4c/source/common/uresdata.h b/icu4c/source/common/uresdata.h index 8d845e3dfcf..4e28ddccf63 100644 --- a/icu4c/source/common/uresdata.h +++ b/icu4c/source/common/uresdata.h @@ -475,7 +475,7 @@ U_NAMESPACE_BEGIN class ResourceDataValue : public ResourceValue { public: - ResourceDataValue() : pResData(NULL), res(URES_NONE) {} + ResourceDataValue() : pResData(NULL), res(static_cast(URES_NONE)) {} virtual ~ResourceDataValue(); void setData(const ResourceData *data) { pResData = data; } diff --git a/icu4c/source/common/ushape.cpp b/icu4c/source/common/ushape.cpp index a640ae2907c..ae13b5c1183 100644 --- a/icu4c/source/common/ushape.cpp +++ b/icu4c/source/common/ushape.cpp @@ -1323,7 +1323,7 @@ shapeUnicode(UChar *dest, int32_t sourceLength, /* to ensure the array index is within the range */ U_ASSERT(dest[i] >= 0x064Bu && dest[i]-0x064Bu < UPRV_LENGTHOF(IrrelevantPos)); - dest[i] = 0xFE70 + IrrelevantPos[(dest[i] - 0x064B)] + Shape; + dest[i] = 0xFE70 + IrrelevantPos[(dest[i] - 0x064B)] + static_cast(Shape); } }else if ((currLink & APRESENT) > 0) { dest[i] = (UChar)(0xFB50 + (currLink >> 8) + Shape); diff --git a/icu4c/source/common/usprep.cpp b/icu4c/source/common/usprep.cpp index 067ecfe7cfc..1af1d07490a 100644 --- a/icu4c/source/common/usprep.cpp +++ b/icu4c/source/common/usprep.cpp @@ -351,9 +351,9 @@ usprep_getProfile(const char* path, LocalMemory keyName; LocalMemory keyPath; if( key.allocateInsteadAndReset() == NULL || - keyName.allocateInsteadAndCopy(uprv_strlen(name)+1) == NULL || + keyName.allocateInsteadAndCopy(static_cast(uprv_strlen(name)+1)) == NULL || (path != NULL && - keyPath.allocateInsteadAndCopy(uprv_strlen(path)+1) == NULL) + keyPath.allocateInsteadAndCopy(static_cast(uprv_strlen(path)+1)) == NULL) ) { *status = U_MEMORY_ALLOCATION_ERROR; usprep_unload(newProfile.getAlias()); diff --git a/icu4c/source/common/ustrcase.cpp b/icu4c/source/common/ustrcase.cpp index 978bd3b7b86..618e847c65d 100644 --- a/icu4c/source/common/ustrcase.cpp +++ b/icu4c/source/common/ustrcase.cpp @@ -218,7 +218,7 @@ int32_t toLower(int32_t caseLocale, uint32_t options, int32_t srcIndex = srcStart; for (;;) { // fast path for simple cases - UChar lead; + UChar lead = 0; while (srcIndex < srcLimit) { lead = src[srcIndex]; int32_t delta; @@ -238,7 +238,7 @@ int32_t toLower(int32_t caseLocale, uint32_t options, continue; } } - lead += delta; + lead += static_cast(delta); destIndex = appendUnchanged(dest, destIndex, destCapacity, src + prev, srcIndex - 1 - prev, options, edits); if (destIndex >= 0) { @@ -313,7 +313,7 @@ int32_t toUpper(int32_t caseLocale, uint32_t options, int32_t srcIndex = 0; for (;;) { // fast path for simple cases - UChar lead; + UChar lead = 0; while (srcIndex < srcLength) { lead = src[srcIndex]; int32_t delta; @@ -333,7 +333,7 @@ int32_t toUpper(int32_t caseLocale, uint32_t options, continue; } } - lead += delta; + lead += static_cast(delta); destIndex = appendUnchanged(dest, destIndex, destCapacity, src + prev, srcIndex - 1 - prev, options, edits); if (destIndex >= 0) { @@ -1747,8 +1747,8 @@ static int32_t _cmpFold( } if(matchLen1) { - *matchLen1=m1-org1; - *matchLen2=m2-org2; + *matchLen1=static_cast(m1-org1); + *matchLen2=static_cast(m2-org2); } return cmpRes; } diff --git a/icu4c/source/common/utext.cpp b/icu4c/source/common/utext.cpp index a2c9008abf6..6f579bd4f27 100644 --- a/icu4c/source/common/utext.cpp +++ b/icu4c/source/common/utext.cpp @@ -1196,9 +1196,9 @@ fillForward: // Swap the UText buffers. // We want to fill what was previously the alternate buffer, // and make what was the current buffer be the new alternate. - UTF8Buf *u8b = (UTF8Buf *)ut->q; + UTF8Buf *u8b_swap = (UTF8Buf *)ut->q; ut->q = ut->p; - ut->p = u8b; + ut->p = u8b_swap; int32_t strLen = ut->b; UBool nulTerminated = FALSE; @@ -1207,9 +1207,9 @@ fillForward: nulTerminated = TRUE; } - UChar *buf = u8b->buf; - uint8_t *mapToNative = u8b->mapToNative; - uint8_t *mapToUChars = u8b->mapToUChars; + UChar *buf = u8b_swap->buf; + uint8_t *mapToNative = u8b_swap->mapToNative; + uint8_t *mapToUChars = u8b_swap->mapToUChars; int32_t destIx = 0; int32_t srcIx = ix; UBool seenNonAscii = FALSE; @@ -1230,7 +1230,7 @@ fillForward: // General case, handle everything. if (seenNonAscii == FALSE) { seenNonAscii = TRUE; - u8b->bufNILimit = destIx; + u8b_swap->bufNILimit = destIx; } int32_t cIx = srcIx; @@ -1263,22 +1263,22 @@ fillForward: mapToUChars[srcIx - ix] = (uint8_t)destIx; // fill in Buffer descriptor - u8b->bufNativeStart = ix; - u8b->bufNativeLimit = srcIx; - u8b->bufStartIdx = 0; - u8b->bufLimitIdx = destIx; + u8b_swap->bufNativeStart = ix; + u8b_swap->bufNativeLimit = srcIx; + u8b_swap->bufStartIdx = 0; + u8b_swap->bufLimitIdx = destIx; if (seenNonAscii == FALSE) { - u8b->bufNILimit = destIx; + u8b_swap->bufNILimit = destIx; } - u8b->toUCharsMapStart = u8b->bufNativeStart; + u8b_swap->toUCharsMapStart = u8b_swap->bufNativeStart; // Set UText chunk to refer to this buffer. ut->chunkContents = buf; ut->chunkOffset = 0; - ut->chunkLength = u8b->bufLimitIdx; - ut->chunkNativeStart = u8b->bufNativeStart; - ut->chunkNativeLimit = u8b->bufNativeLimit; - ut->nativeIndexingLimit = u8b->bufNILimit; + ut->chunkLength = u8b_swap->bufLimitIdx; + ut->chunkNativeStart = u8b_swap->bufNativeStart; + ut->chunkNativeLimit = u8b_swap->bufNativeLimit; + ut->nativeIndexingLimit = u8b_swap->bufNILimit; // For zero terminated strings, keep track of the maximum point // scanned so far. @@ -1311,13 +1311,13 @@ fillReverse: // Swap the UText buffers. // We want to fill what was previously the alternate buffer, // and make what was the current buffer be the new alternate. - UTF8Buf *u8b = (UTF8Buf *)ut->q; + UTF8Buf *u8b_swap = (UTF8Buf *)ut->q; ut->q = ut->p; - ut->p = u8b; + ut->p = u8b_swap; - UChar *buf = u8b->buf; - uint8_t *mapToNative = u8b->mapToNative; - uint8_t *mapToUChars = u8b->mapToUChars; + UChar *buf = u8b_swap->buf; + uint8_t *mapToNative = u8b_swap->mapToNative; + uint8_t *mapToUChars = u8b_swap->mapToUChars; int32_t toUCharsMapStart = ix - sizeof(UTF8Buf::mapToUChars) + 1; // Note that toUCharsMapStart can be negative. Happens when the remaining // text from current position to the beginning is less than the buffer size. @@ -1387,19 +1387,19 @@ fillReverse: bufNILimit = destIx; } } - u8b->bufNativeStart = srcIx; - u8b->bufNativeLimit = ix; - u8b->bufStartIdx = destIx; - u8b->bufLimitIdx = UTF8_TEXT_CHUNK_SIZE+2; - u8b->bufNILimit = bufNILimit - u8b->bufStartIdx; - u8b->toUCharsMapStart = toUCharsMapStart; + u8b_swap->bufNativeStart = srcIx; + u8b_swap->bufNativeLimit = ix; + u8b_swap->bufStartIdx = destIx; + u8b_swap->bufLimitIdx = UTF8_TEXT_CHUNK_SIZE+2; + u8b_swap->bufNILimit = bufNILimit - u8b_swap->bufStartIdx; + u8b_swap->toUCharsMapStart = toUCharsMapStart; - ut->chunkContents = &buf[u8b->bufStartIdx]; - ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx; + ut->chunkContents = &buf[u8b_swap->bufStartIdx]; + ut->chunkLength = u8b_swap->bufLimitIdx - u8b_swap->bufStartIdx; ut->chunkOffset = ut->chunkLength; - ut->chunkNativeStart = u8b->bufNativeStart; - ut->chunkNativeLimit = u8b->bufNativeLimit; - ut->nativeIndexingLimit = u8b->bufNILimit; + ut->chunkNativeStart = u8b_swap->bufNativeStart; + ut->chunkNativeLimit = u8b_swap->bufNativeLimit; + ut->nativeIndexingLimit = u8b_swap->bufNILimit; return TRUE; } diff --git a/icu4c/source/common/utrie2.cpp b/icu4c/source/common/utrie2.cpp index 8f9183bafad..fb6c67f0397 100644 --- a/icu4c/source/common/utrie2.cpp +++ b/icu4c/source/common/utrie2.cpp @@ -746,7 +746,7 @@ uint16_t BackwardUTrie2StringIterator::previous16() { codePointLimit=codePointStart; if(start>=codePointStart) { codePoint=U_SENTINEL; - return trie->errorValue; + return static_cast(trie->errorValue); } uint16_t result; UTRIE2_U16_PREV16(trie, start, codePointStart, codePoint, result); @@ -757,7 +757,7 @@ uint16_t ForwardUTrie2StringIterator::next16() { codePointStart=codePointLimit; if(codePointLimit==limit) { codePoint=U_SENTINEL; - return trie->errorValue; + return static_cast(trie->errorValue); } uint16_t result; UTRIE2_U16_NEXT16(trie, codePointLimit, limit, codePoint, result); diff --git a/icu4c/source/common/utrie2_builder.cpp b/icu4c/source/common/utrie2_builder.cpp index d8a3a067573..6a92b442c31 100644 --- a/icu4c/source/common/utrie2_builder.cpp +++ b/icu4c/source/common/utrie2_builder.cpp @@ -1334,7 +1334,7 @@ utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode) { if(highStart<=0x10000) { trie->index2NullOffset=0xffff; } else { - trie->index2NullOffset=UTRIE2_INDEX_2_OFFSET+newTrie->index2NullOffset; + trie->index2NullOffset=static_cast(UTRIE2_INDEX_2_OFFSET+newTrie->index2NullOffset); } trie->dataNullOffset=(uint16_t)(dataMove+newTrie->dataNullOffset); trie->highValueIndex=dataMove+trie->dataLength-UTRIE2_DATA_GRANULARITY; diff --git a/icu4c/source/common/wintz.cpp b/icu4c/source/common/wintz.cpp index 3aaa36a0632..1ea8c9eed6c 100644 --- a/icu4c/source/common/wintz.cpp +++ b/icu4c/source/common/wintz.cpp @@ -380,7 +380,7 @@ uprv_detectWindowsTimeZone() */ if (tmpid[0] != 0) { - len = uprv_strlen(tmpid); + len = static_cast(uprv_strlen(tmpid)); icuid = (char*)uprv_calloc(len + 1, sizeof(char)); if (icuid != NULL) { diff --git a/icu4c/source/i18n/alphaindex.cpp b/icu4c/source/i18n/alphaindex.cpp index d36a2cc6de3..3950d1a13f1 100644 --- a/icu4c/source/i18n/alphaindex.cpp +++ b/icu4c/source/i18n/alphaindex.cpp @@ -511,8 +511,8 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const { ces, errorCode) && current.charAt(current.length() - 1) != 0xFFFF /* !current.endsWith("\uffff") */) { // "AE-ligature" or "Sch" etc. - for (int32_t i = bucketList->size() - 2;; --i) { - Bucket *singleBucket = getBucket(*bucketList, i); + for (int32_t j = bucketList->size() - 2;; --j) { + Bucket *singleBucket = getBucket(*bucketList, j); if (singleBucket->labelType_ != U_ALPHAINDEX_NORMAL) { // There is no single-character bucket since the last // underflow or inflow label. @@ -608,8 +608,8 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const { } // Do not call publicBucketList->setDeleter(): // This vector shares its objects with the bucketList. - for (int32_t i = 0; i < bucketList->size(); ++i) { - bucket = getBucket(*bucketList, i); + for (int32_t j = 0; j < bucketList->size(); ++j) { + bucket = getBucket(*bucketList, j); if (bucket->displayBucket_ == NULL) { publicBucketList->addElement(bucket, errorCode); } diff --git a/icu4c/source/i18n/anytrans.cpp b/icu4c/source/i18n/anytrans.cpp index d06469e2ae2..6e382b824b9 100644 --- a/icu4c/source/i18n/anytrans.cpp +++ b/icu4c/source/i18n/anytrans.cpp @@ -391,12 +391,12 @@ void AnyTransliterator::registerIDs() { UnicodeString id; TransliteratorIDParser::STVtoID(UnicodeString(TRUE, ANY, 3), target, variant, id); ec = U_ZERO_ERROR; - AnyTransliterator* t = new AnyTransliterator(id, target, variant, + AnyTransliterator* tl = new AnyTransliterator(id, target, variant, targetScript, ec); if (U_FAILURE(ec)) { - delete t; + delete tl; } else { - Transliterator::_registerInstance(t); + Transliterator::_registerInstance(tl); Transliterator::_registerSpecialInverse(target, UnicodeString(TRUE, NULL_ID, 4), FALSE); } } diff --git a/icu4c/source/i18n/coll.cpp b/icu4c/source/i18n/coll.cpp index 25c8745cbf2..8775d29cfe1 100644 --- a/icu4c/source/i18n/coll.cpp +++ b/icu4c/source/i18n/coll.cpp @@ -986,8 +986,8 @@ Collator::internalCompareUTF8(const char *left, int32_t leftLength, return UCOL_EQUAL; } return compareUTF8( - StringPiece(left, (leftLength < 0) ? uprv_strlen(left) : leftLength), - StringPiece(right, (rightLength < 0) ? uprv_strlen(right) : rightLength), + StringPiece(left, (leftLength < 0) ? static_cast(uprv_strlen(left)) : leftLength), + StringPiece(right, (rightLength < 0) ? static_cast(uprv_strlen(right)) : rightLength), errorCode); } diff --git a/icu4c/source/i18n/collationkeys.cpp b/icu4c/source/i18n/collationkeys.cpp index 4b9e6b59075..b5c322fb446 100644 --- a/icu4c/source/i18n/collationkeys.cpp +++ b/icu4c/source/i18n/collationkeys.cpp @@ -403,13 +403,13 @@ CollationKeys::writeSortKeyUpToQuaternary(CollationIterator &iter, uint8_t *secs = secondaries.data(); int32_t last = secondaries.length() - 1; if(secSegmentStart < last) { - uint8_t *p = secs + secSegmentStart; - uint8_t *q = secs + last; + uint8_t *q = secs + secSegmentStart; + uint8_t *r = secs + last; do { - uint8_t b = *p; - *p++ = *q; - *q-- = b; - } while(p < q); + uint8_t b = *q; + *q++ = *r; + *r-- = b; + } while(q < r); } secondaries.appendByte(p == Collation::NO_CE_PRIMARY ? Collation::LEVEL_SEPARATOR_BYTE : Collation::MERGE_SEPARATOR_BYTE); diff --git a/icu4c/source/i18n/csrmbcs.cpp b/icu4c/source/i18n/csrmbcs.cpp index d98f18a19cb..5579ba8ec3f 100644 --- a/icu4c/source/i18n/csrmbcs.cpp +++ b/icu4c/source/i18n/csrmbcs.cpp @@ -166,7 +166,7 @@ int32_t CharsetRecog_mbcs::match_mbcs(InputText *det, const uint16_t commonChars doubleByteCharCount++; if (commonChars != 0) { - if (binarySearch(commonChars, commonCharsLen, iter.charValue) >= 0){ + if (binarySearch(commonChars, commonCharsLen, static_cast(iter.charValue)) >= 0){ commonCharCount += 1; } } diff --git a/icu4c/source/i18n/currpinf.cpp b/icu4c/source/i18n/currpinf.cpp index b794b760041..af9c837af89 100644 --- a/icu4c/source/i18n/currpinf.cpp +++ b/icu4c/source/i18n/currpinf.cpp @@ -333,15 +333,15 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st if (U_SUCCESS(ec)) { const char* pluralCount; while (((pluralCount = keywords->next(nullptr, ec)) != nullptr) && U_SUCCESS(ec)) { - int32_t ptnLen; + int32_t ptnLength; UErrorCode err = U_ZERO_ERROR; - const UChar* patternChars = ures_getStringByKeyWithFallback(currencyRes.getAlias(), pluralCount, &ptnLen, &err); + const UChar* patternChars = ures_getStringByKeyWithFallback(currencyRes.getAlias(), pluralCount, &ptnLength, &err); if (err == U_MEMORY_ALLOCATION_ERROR || patternChars == nullptr) { ec = err; break; } - if (U_SUCCESS(err) && ptnLen > 0) { - UnicodeString* pattern = new UnicodeString(patternChars, ptnLen); + if (U_SUCCESS(err) && ptnLength > 0) { + UnicodeString* pattern = new UnicodeString(patternChars, ptnLength); if (pattern == nullptr) { ec = U_MEMORY_ALLOCATION_ERROR; break; @@ -356,7 +356,7 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st pattern->findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3)); if (hasSeparator) { - UnicodeString negPattern(patternChars, ptnLen); + UnicodeString negPattern(patternChars, ptnLength); negPattern.findAndReplace(UnicodeString(TRUE, gPart0, 3), UnicodeString(negNumberStylePattern, negNumberStylePatternLen)); negPattern.findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3)); diff --git a/icu4c/source/i18n/dcfmtsym.cpp b/icu4c/source/i18n/dcfmtsym.cpp index e6785ab7a1f..d8b1ecdbea1 100644 --- a/icu4c/source/i18n/dcfmtsym.cpp +++ b/icu4c/source/i18n/dcfmtsym.cpp @@ -436,7 +436,7 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status, sink.resolveMissingMonetarySeparators(fSymbols); // Resolve codePointZero - UChar32 tempCodePointZero; + UChar32 tempCodePointZero = -1; for (int32_t i=0; i<=9; i++) { const UnicodeString& stringDigit = getConstDigitSymbol(i); if (stringDigit.countChar32() != 1) { diff --git a/icu4c/source/i18n/dtfmtsym.cpp b/icu4c/source/i18n/dtfmtsym.cpp index 455a8e1ee41..ab61cf42362 100644 --- a/icu4c/source/i18n/dtfmtsym.cpp +++ b/icu4c/source/i18n/dtfmtsym.cpp @@ -1311,7 +1311,7 @@ DateFormatSymbols::initZoneStringsArray(void) { UDate now = Calendar::getNow(); UnicodeString tzDispName; - while ((tzid = tzids->snext(status))) { + while ((tzid = tzids->snext(status)) != 0) { if (U_FAILURE(status)) { break; } @@ -2224,8 +2224,8 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError ++typeMapPtr; } if (typeMapPtr->usageTypeName != NULL && compResult == 0) { - fCapitalization[typeMapPtr->usageTypeEnumValue][0] = intVector[0]; - fCapitalization[typeMapPtr->usageTypeEnumValue][1] = intVector[1]; + fCapitalization[typeMapPtr->usageTypeEnumValue][0] = static_cast(intVector[0]); + fCapitalization[typeMapPtr->usageTypeEnumValue][1] = static_cast(intVector[1]); } } } diff --git a/icu4c/source/i18n/dtitvfmt.cpp b/icu4c/source/i18n/dtitvfmt.cpp index 743b534fc8f..d952cbf509d 100644 --- a/icu4c/source/i18n/dtitvfmt.cpp +++ b/icu4c/source/i18n/dtitvfmt.cpp @@ -877,8 +877,7 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton, if ( MCount < 3 ) { normalizedDateSkeleton.append(CAP_M); } else { - int32_t i; - for ( i = 0; i < MCount && i < MAX_M_COUNT; ++i ) { + for ( int32_t j = 0; j < MCount && j < MAX_M_COUNT; ++j) { normalizedDateSkeleton.append(CAP_M); } } @@ -887,8 +886,7 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton, if ( ECount <= 3 ) { normalizedDateSkeleton.append(CAP_E); } else { - int32_t i; - for ( i = 0; i < ECount && i < MAX_E_COUNT; ++i ) { + for ( int32_t j = 0; j < ECount && j < MAX_E_COUNT; ++j ) { normalizedDateSkeleton.append(CAP_E); } } diff --git a/icu4c/source/i18n/dtitvinf.cpp b/icu4c/source/i18n/dtitvinf.cpp index c863a683a5c..a289fc79c8d 100644 --- a/icu4c/source/i18n/dtitvinf.cpp +++ b/icu4c/source/i18n/dtitvinf.cpp @@ -594,7 +594,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton, const UHashElement* elem = NULL; while ( (elem = fIntervalPatterns->nextElement(pos)) != NULL ) { const UHashTok keyTok = elem->key; - UnicodeString* skeleton = (UnicodeString*)keyTok.pointer; + UnicodeString* newSkeleton = (UnicodeString*)keyTok.pointer; #ifdef DTITVINF_DEBUG skeleton->extract(0, skeleton->length(), result, "UTF-8"); sprintf(mesg, "available skeletons: skeleton: %s; \n", result); @@ -606,7 +606,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton, for ( i = 0; i < fieldLength; ++i ) { skeletonFieldWidth[i] = 0; } - parseSkeleton(*skeleton, skeletonFieldWidth); + parseSkeleton(*newSkeleton, skeletonFieldWidth); // calculate distance int32_t distance = 0; int8_t fieldDifference = 1; @@ -632,7 +632,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton, } } if ( distance < bestDistance ) { - bestSkeleton = skeleton; + bestSkeleton = newSkeleton; bestDistance = distance; bestMatchDistanceInfo = fieldDifference; } diff --git a/icu4c/source/i18n/dtptngen.cpp b/icu4c/source/i18n/dtptngen.cpp index 16e64d72377..d7b60d34c45 100644 --- a/icu4c/source/i18n/dtptngen.cpp +++ b/icu4c/source/i18n/dtptngen.cpp @@ -629,10 +629,10 @@ void DateTimePatternGenerator::getAllowedHourFormats(const Locale &locale, UErro UnicodeString DateTimePatternGenerator::getSkeleton(const UnicodeString& pattern, UErrorCode& /*status*/) { - FormatParser fp; + FormatParser fp2; DateTimeMatcher matcher; PtnSkeleton localSkeleton; - matcher.set(pattern, &fp, localSkeleton); + matcher.set(pattern, &fp2, localSkeleton); return localSkeleton.getSkeleton(); } @@ -648,10 +648,10 @@ DateTimePatternGenerator::staticGetSkeleton( UnicodeString DateTimePatternGenerator::getBaseSkeleton(const UnicodeString& pattern, UErrorCode& /*status*/) { - FormatParser fp; + FormatParser fp2; DateTimeMatcher matcher; PtnSkeleton localSkeleton; - matcher.set(pattern, &fp, localSkeleton); + matcher.set(pattern, &fp2, localSkeleton); return localSkeleton.getBaseSkeleton(); } @@ -888,9 +888,9 @@ struct DateTimePatternGenerator::AppendItemNamesSink : public ResourceSink { valueStr.getTerminatedBuffer(); } for (int32_t j = 1; j < UDATPG_WIDTH_COUNT; j++) { - UnicodeString& valueStr = dtpg.getMutableFieldDisplayName((UDateTimePatternField)i, (UDateTimePGDisplayWidth)j); - if (valueStr.isEmpty()) { - valueStr = dtpg.getFieldDisplayName((UDateTimePatternField)i, (UDateTimePGDisplayWidth)(j-1)); + UnicodeString& valueStr2 = dtpg.getMutableFieldDisplayName((UDateTimePatternField)i, (UDateTimePGDisplayWidth)j); + if (valueStr2.isEmpty()) { + valueStr2 = dtpg.getFieldDisplayName((UDateTimePatternField)i, (UDateTimePGDisplayWidth)(j-1)); } } } diff --git a/icu4c/source/i18n/i18n.vcxproj b/icu4c/source/i18n/i18n.vcxproj index 0af58a63041..3297ab20f37 100644 --- a/icu4c/source/i18n/i18n.vcxproj +++ b/icu4c/source/i18n/i18n.vcxproj @@ -557,4 +557,4 @@ - + \ No newline at end of file diff --git a/icu4c/source/i18n/measfmt.cpp b/icu4c/source/i18n/measfmt.cpp index 5970262de1a..b03d6e2f1f5 100644 --- a/icu4c/source/i18n/measfmt.cpp +++ b/icu4c/source/i18n/measfmt.cpp @@ -618,7 +618,7 @@ MeasureFormat::MeasureFormat( : cache(NULL), numberFormat(NULL), pluralRules(NULL), - width(w), + fWidth(w), listFormatter(NULL) { initMeasureFormat(locale, w, NULL, status); } @@ -631,7 +631,7 @@ MeasureFormat::MeasureFormat( : cache(NULL), numberFormat(NULL), pluralRules(NULL), - width(w), + fWidth(w), listFormatter(NULL) { initMeasureFormat(locale, w, nfToAdopt, status); } @@ -641,7 +641,7 @@ MeasureFormat::MeasureFormat(const MeasureFormat &other) : cache(other.cache), numberFormat(other.numberFormat), pluralRules(other.pluralRules), - width(other.width), + fWidth(other.fWidth), listFormatter(NULL) { cache->addRef(); numberFormat->addRef(); @@ -659,7 +659,7 @@ MeasureFormat &MeasureFormat::operator=(const MeasureFormat &other) { SharedObject::copyPtr(other.cache, cache); SharedObject::copyPtr(other.numberFormat, numberFormat); SharedObject::copyPtr(other.pluralRules, pluralRules); - width = other.width; + fWidth = other.fWidth; delete listFormatter; if (other.listFormatter != NULL) { listFormatter = new ListFormatter(*other.listFormatter); @@ -673,7 +673,7 @@ MeasureFormat::MeasureFormat() : cache(NULL), numberFormat(NULL), pluralRules(NULL), - width(UMEASFMT_WIDTH_SHORT), + fWidth(UMEASFMT_WIDTH_SHORT), listFormatter(NULL) { } @@ -703,7 +703,7 @@ UBool MeasureFormat::operator==(const Format &other) const { // don't have to check it here. // differing widths aren't equivalent - if (width != rhs.width) { + if (fWidth != rhs.fWidth) { return FALSE; } // Width the same check locales. @@ -805,7 +805,7 @@ UnicodeString &MeasureFormat::formatMeasures( if (measureCount == 1) { return formatMeasure(measures[0], **numberFormat, appendTo, pos, status); } - if (width == UMEASFMT_WIDTH_NUMERIC) { + if (fWidth == UMEASFMT_WIDTH_NUMERIC) { Formattable hms[3]; int32_t bitMap = toHMS(measures, measureCount, hms, status); if (bitMap > 0) { @@ -839,7 +839,7 @@ UnicodeString &MeasureFormat::formatMeasures( } UnicodeString MeasureFormat::getUnitDisplayName(const MeasureUnit& unit, UErrorCode& /*status*/) const { - UMeasureFormatWidth width = getRegularWidth(this->width); + UMeasureFormatWidth width = getRegularWidth(fWidth); const UChar* const* styleToDnam = cache->dnams[unit.getIndex()]; const UChar* dnam = styleToDnam[width]; if (dnam == NULL) { @@ -895,11 +895,11 @@ void MeasureFormat::initMeasureFormat( return; } } - width = w; + fWidth = w; delete listFormatter; listFormatter = ListFormatter::createInstance( locale, - listStyles[getRegularWidth(width)], + listStyles[getRegularWidth(fWidth)], status); } @@ -922,7 +922,7 @@ UBool MeasureFormat::setMeasureFormatLocale(const Locale &locale, UErrorCode &st if (U_FAILURE(status) || locale == getLocale(status)) { return FALSE; } - initMeasureFormat(locale, width, NULL, status); + initMeasureFormat(locale, fWidth, NULL, status); return U_SUCCESS(status); } @@ -956,7 +956,7 @@ UnicodeString &MeasureFormat::formatMeasure( if (isCurrency(amtUnit)) { UChar isoCode[4]; u_charsToUChars(amtUnit.getSubtype(), isoCode, 4); - return cache->getCurrencyFormat(width)->format( + return cache->getCurrencyFormat(fWidth)->format( new CurrencyAmount(amtNumber, isoCode, status), appendTo, pos, @@ -965,7 +965,7 @@ UnicodeString &MeasureFormat::formatMeasure( UnicodeString formattedNumber; StandardPlural::Form pluralForm = QuantityFormatter::selectPlural( amtNumber, nf, **pluralRules, formattedNumber, pos, status); - const SimpleFormatter *formatter = getPluralFormatter(amtUnit, width, pluralForm, status); + const SimpleFormatter *formatter = getPluralFormatter(amtUnit, fWidth, pluralForm, status); return QuantityFormatter::format(*formatter, formattedNumber, appendTo, pos, status); } @@ -1016,7 +1016,6 @@ UnicodeString &MeasureFormat::formatNumeric( return appendTo; break; } - return appendTo; } static void appendRange( @@ -1173,7 +1172,7 @@ int32_t MeasureFormat::withPerUnitAndAppend( if (U_FAILURE(status)) { return offset; } - const SimpleFormatter *perUnitFormatter = getFormatterOrNull(perUnit, width, PER_UNIT_INDEX); + const SimpleFormatter *perUnitFormatter = getFormatterOrNull(perUnit, fWidth, PER_UNIT_INDEX); if (perUnitFormatter != NULL) { const UnicodeString *params[] = {&formatted}; perUnitFormatter->formatAndAppend( @@ -1185,9 +1184,9 @@ int32_t MeasureFormat::withPerUnitAndAppend( status); return offset; } - const SimpleFormatter *perFormatter = getPerFormatter(width, status); + const SimpleFormatter *perFormatter = getPerFormatter(fWidth, status); const SimpleFormatter *pattern = - getPluralFormatter(perUnit, width, StandardPlural::ONE, status); + getPluralFormatter(perUnit, fWidth, StandardPlural::ONE, status); if (U_FAILURE(status)) { return offset; } diff --git a/icu4c/source/i18n/msgfmt.cpp b/icu4c/source/i18n/msgfmt.cpp index 8b3807e6714..8ff86a2cacf 100644 --- a/icu4c/source/i18n/msgfmt.cpp +++ b/icu4c/source/i18n/msgfmt.cpp @@ -1078,7 +1078,7 @@ void MessageFormat::format(int32_t msgStart, const void *plNumber, // that formats the number without subtracting the offset. appendTo.formatAndAppend(pluralNumber.formatter, *arg, success); } - } else if ((formatter = getCachedFormatter(i -2))) { + } else if ((formatter = getCachedFormatter(i -2)) != 0) { // Handles all ArgType.SIMPLE, and formatters from setFormat() and its siblings. if (dynamic_cast(formatter) || dynamic_cast(formatter) || diff --git a/icu4c/source/i18n/nfrule.cpp b/icu4c/source/i18n/nfrule.cpp index c75ecf06705..3ad0291649e 100644 --- a/icu4c/source/i18n/nfrule.cpp +++ b/icu4c/source/i18n/nfrule.cpp @@ -39,14 +39,14 @@ NFRule::NFRule(const RuleBasedNumberFormat* _rbnf, const UnicodeString &_ruleTex , radix(10) , exponent(0) , decimalPoint(0) - , ruleText(_ruleText) + , fRuleText(_ruleText) , sub1(NULL) , sub2(NULL) , formatter(_rbnf) , rulePatternFormat(NULL) { - if (!ruleText.isEmpty()) { - parseRuleDescriptor(ruleText, status); + if (!fRuleText.isEmpty()) { + parseRuleDescriptor(fRuleText, status); } } @@ -122,7 +122,7 @@ NFRule::makeRules(UnicodeString& description, status = U_MEMORY_ALLOCATION_ERROR; return; } - description = rule1->ruleText; + description = rule1->fRuleText; // check the description to see whether there's text enclosed // in brackets @@ -314,7 +314,7 @@ NFRule::parseRuleDescriptor(UnicodeString& description, UErrorCode& status) if (c == gSlash) { val = 0; ++p; - int64_t ll_10 = 10; + ll_10 = 10; while (p < descriptorLength) { c = descriptor.charAt(p); if (c >= gZero && c <= gNine) { @@ -418,7 +418,7 @@ NFRule::extractSubstitutions(const NFRuleSet* ruleSet, if (U_FAILURE(status)) { return; } - this->ruleText = ruleText; + fRuleText = ruleText; sub1 = extractSubstitution(ruleSet, predecessor, status); if (sub1 == NULL) { // Small optimization. There is no need to create a redundant NullSubstitution. @@ -427,15 +427,15 @@ NFRule::extractSubstitutions(const NFRuleSet* ruleSet, else { sub2 = extractSubstitution(ruleSet, predecessor, status); } - int32_t pluralRuleStart = this->ruleText.indexOf(gDollarOpenParenthesis, -1, 0); - int32_t pluralRuleEnd = (pluralRuleStart >= 0 ? this->ruleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart) : -1); + int32_t pluralRuleStart = fRuleText.indexOf(gDollarOpenParenthesis, -1, 0); + int32_t pluralRuleEnd = (pluralRuleStart >= 0 ? fRuleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart) : -1); if (pluralRuleEnd >= 0) { - int32_t endType = this->ruleText.indexOf(gComma, pluralRuleStart); + int32_t endType = fRuleText.indexOf(gComma, pluralRuleStart); if (endType < 0) { status = U_PARSE_ERROR; return; } - UnicodeString type(this->ruleText.tempSubString(pluralRuleStart + 2, endType - pluralRuleStart - 2)); + UnicodeString type(fRuleText.tempSubString(pluralRuleStart + 2, endType - pluralRuleStart - 2)); UPluralType pluralType; if (type.startsWith(UNICODE_STRING_SIMPLE("cardinal"))) { pluralType = UPLURAL_TYPE_CARDINAL; @@ -448,7 +448,7 @@ NFRule::extractSubstitutions(const NFRuleSet* ruleSet, return; } rulePatternFormat = formatter->createPluralFormat(pluralType, - this->ruleText.tempSubString(endType + 1, pluralRuleEnd - endType - 1), status); + fRuleText.tempSubString(endType + 1, pluralRuleEnd - endType - 1), status); } } @@ -484,16 +484,16 @@ NFRule::extractSubstitution(const NFRuleSet* ruleSet, // special-case the ">>>" token, since searching for the > at the // end will actually find the > in the middle - if (ruleText.indexOf(gGreaterGreaterGreater, 3, 0) == subStart) { + if (fRuleText.indexOf(gGreaterGreaterGreater, 3, 0) == subStart) { subEnd = subStart + 2; // otherwise the substitution token ends with the same character // it began with } else { - UChar c = ruleText.charAt(subStart); - subEnd = ruleText.indexOf(c, subStart + 1); + UChar c = fRuleText.charAt(subStart); + subEnd = fRuleText.indexOf(c, subStart + 1); // special case for '<%foo<<' - if (c == gLessThan && subEnd != -1 && subEnd < ruleText.length() - 1 && ruleText.charAt(subEnd+1) == c) { + if (c == gLessThan && subEnd != -1 && subEnd < fRuleText.length() - 1 && fRuleText.charAt(subEnd+1) == c) { // ordinals use "=#,##0==%abbrev=" as their rule. Notice that the '==' in the middle // occurs because of the juxtaposition of two different rules. The check for '<' is a hack // to get around this. Having the duplicate at the front would cause problems with @@ -513,12 +513,12 @@ NFRule::extractSubstitution(const NFRuleSet* ruleSet, // some text bounded by substitution token characters). Use // makeSubstitution() to create the right kind of substitution UnicodeString subToken; - subToken.setTo(ruleText, subStart, subEnd + 1 - subStart); + subToken.setTo(fRuleText, subStart, subEnd + 1 - subStart); result = NFSubstitution::makeSubstitution(subStart, this, predecessor, ruleSet, this->formatter, subToken, status); // remove the substitution from the rule text - ruleText.removeBetween(subStart, subEnd+1); + fRuleText.removeBetween(subStart, subEnd+1); return result; } @@ -601,7 +601,7 @@ NFRule::indexOfAnyRulePrefix() const { int result = -1; for (int i = 0; RULE_PREFIXES[i]; i++) { - int32_t pos = ruleText.indexOf(*RULE_PREFIXES[i]); + int32_t pos = fRuleText.indexOf(*RULE_PREFIXES[i]); if (pos != -1 && (result == -1 || pos < result)) { result = pos; } @@ -637,7 +637,7 @@ NFRule::operator==(const NFRule& rhs) const return baseValue == rhs.baseValue && radix == rhs.radix && exponent == rhs.exponent - && ruleText == rhs.ruleText + && fRuleText == rhs.fRuleText && util_equalSubstitutions(sub1, rhs.sub1) && util_equalSubstitutions(sub2, rhs.sub2); } @@ -690,14 +690,14 @@ NFRule::_appendRuleText(UnicodeString& result) const // if the rule text begins with a space, write an apostrophe // (whitespace after the rule descriptor is ignored; the // apostrophe is used to make the whitespace significant) - if (ruleText.charAt(0) == gSpace && (sub1 == NULL || sub1->getPos() != 0)) { + if (fRuleText.charAt(0) == gSpace && (sub1 == NULL || sub1->getPos() != 0)) { result.append(gTick); } // now, write the rule's rule text, inserting appropriate // substitution tokens in the appropriate places UnicodeString ruleTextCopy; - ruleTextCopy.setTo(ruleText); + ruleTextCopy.setTo(fRuleText); UnicodeString temp; if (sub2 != NULL) { @@ -743,24 +743,24 @@ NFRule::doFormat(int64_t number, UnicodeString& toInsertInto, int32_t pos, int32 // into the right places in toInsertInto (notice we do the // substitutions in reverse order so that the offsets don't get // messed up) - int32_t pluralRuleStart = ruleText.length(); + int32_t pluralRuleStart = fRuleText.length(); int32_t lengthOffset = 0; if (!rulePatternFormat) { - toInsertInto.insert(pos, ruleText); + toInsertInto.insert(pos, fRuleText); } else { - pluralRuleStart = ruleText.indexOf(gDollarOpenParenthesis, -1, 0); - int pluralRuleEnd = ruleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart); + pluralRuleStart = fRuleText.indexOf(gDollarOpenParenthesis, -1, 0); + int pluralRuleEnd = fRuleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart); int initialLength = toInsertInto.length(); - if (pluralRuleEnd < ruleText.length() - 1) { - toInsertInto.insert(pos, ruleText.tempSubString(pluralRuleEnd + 2)); + if (pluralRuleEnd < fRuleText.length() - 1) { + toInsertInto.insert(pos, fRuleText.tempSubString(pluralRuleEnd + 2)); } toInsertInto.insert(pos, rulePatternFormat->format((int32_t)(number/util64_pow(radix, exponent)), status)); if (pluralRuleStart > 0) { - toInsertInto.insert(pos, ruleText.tempSubString(0, pluralRuleStart)); + toInsertInto.insert(pos, fRuleText.tempSubString(0, pluralRuleStart)); } - lengthOffset = ruleText.length() - (toInsertInto.length() - initialLength); + lengthOffset = fRuleText.length() - (toInsertInto.length() - initialLength); } if (sub2 != NULL) { @@ -789,17 +789,17 @@ NFRule::doFormat(double number, UnicodeString& toInsertInto, int32_t pos, int32_ // [again, we have two copies of this routine that do the same thing // so that we don't sacrifice precision in a long by casting it // to a double] - int32_t pluralRuleStart = ruleText.length(); + int32_t pluralRuleStart = fRuleText.length(); int32_t lengthOffset = 0; if (!rulePatternFormat) { - toInsertInto.insert(pos, ruleText); + toInsertInto.insert(pos, fRuleText); } else { - pluralRuleStart = ruleText.indexOf(gDollarOpenParenthesis, -1, 0); - int pluralRuleEnd = ruleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart); + pluralRuleStart = fRuleText.indexOf(gDollarOpenParenthesis, -1, 0); + int pluralRuleEnd = fRuleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart); int initialLength = toInsertInto.length(); - if (pluralRuleEnd < ruleText.length() - 1) { - toInsertInto.insert(pos, ruleText.tempSubString(pluralRuleEnd + 2)); + if (pluralRuleEnd < fRuleText.length() - 1) { + toInsertInto.insert(pos, fRuleText.tempSubString(pluralRuleEnd + 2)); } double pluralVal = number; if (0 <= pluralVal && pluralVal < 1) { @@ -812,9 +812,9 @@ NFRule::doFormat(double number, UnicodeString& toInsertInto, int32_t pos, int32_ } toInsertInto.insert(pos, rulePatternFormat->format((int32_t)(pluralVal), status)); if (pluralRuleStart > 0) { - toInsertInto.insert(pos, ruleText.tempSubString(0, pluralRuleStart)); + toInsertInto.insert(pos, fRuleText.tempSubString(0, pluralRuleStart)); } - lengthOffset = ruleText.length() - (toInsertInto.length() - initialLength); + lengthOffset = fRuleText.length() - (toInsertInto.length() - initialLength); } if (sub2 != NULL) { @@ -908,15 +908,15 @@ NFRule::doParse(const UnicodeString& text, ParsePosition pp; UnicodeString workText(text); - int32_t sub1Pos = sub1 != NULL ? sub1->getPos() : ruleText.length(); - int32_t sub2Pos = sub2 != NULL ? sub2->getPos() : ruleText.length(); + int32_t sub1Pos = sub1 != NULL ? sub1->getPos() : fRuleText.length(); + int32_t sub2Pos = sub2 != NULL ? sub2->getPos() : fRuleText.length(); // check to see whether the text before the first substitution // matches the text at the beginning of the string being // parsed. If it does, strip that off the front of workText; // otherwise, dump out with a mismatch UnicodeString prefix; - prefix.setTo(ruleText, 0, sub1Pos); + prefix.setTo(fRuleText, 0, sub1Pos); #ifdef RBNF_DEBUG fprintf(stderr, "doParse %p ", this); @@ -1000,7 +1000,7 @@ NFRule::doParse(const UnicodeString& text, // the substitution, giving us a new partial parse result pp.setIndex(0); - temp.setTo(ruleText, sub1Pos, sub2Pos - sub1Pos); + temp.setTo(fRuleText, sub1Pos, sub2Pos - sub1Pos); double partialResult = matchToDelimiter(workText, start, tempBaseValue, temp, pp, sub1, nonNumericalExecutedRuleMask, @@ -1021,7 +1021,7 @@ NFRule::doParse(const UnicodeString& text, // partial result with whatever it gets back from its // substitution if there's a successful match, giving us // a real result - temp.setTo(ruleText, sub2Pos, ruleText.length() - sub2Pos); + temp.setTo(fRuleText, sub2Pos, fRuleText.length() - sub2Pos); partialResult = matchToDelimiter(workText2, 0, partialResult, temp, pp2, sub2, nonNumericalExecutedRuleMask, @@ -1039,18 +1039,18 @@ NFRule::doParse(const UnicodeString& text, else { // commented out because ParsePosition doesn't have error index in 1.1.x // restored for ICU4C port - int32_t temp = pp2.getErrorIndex() + sub1Pos + pp.getIndex(); - if (temp> parsePosition.getErrorIndex()) { - parsePosition.setErrorIndex(temp); + int32_t i_temp = pp2.getErrorIndex() + sub1Pos + pp.getIndex(); + if (i_temp> parsePosition.getErrorIndex()) { + parsePosition.setErrorIndex(i_temp); } } } else { // commented out because ParsePosition doesn't have error index in 1.1.x // restored for ICU4C port - int32_t temp = sub1Pos + pp.getErrorIndex(); - if (temp > parsePosition.getErrorIndex()) { - parsePosition.setErrorIndex(temp); + int32_t i_temp = sub1Pos + pp.getErrorIndex(); + if (i_temp > parsePosition.getErrorIndex()) { + parsePosition.setErrorIndex(i_temp); } } // keep trying to match things until the outer matchToDelimiter() @@ -1483,11 +1483,11 @@ NFRule::findText(const UnicodeString& str, rulePatternFormat->parseType(str, this, result, position); int start = position.getBeginIndex(); if (start >= 0) { - int32_t pluralRuleStart = ruleText.indexOf(gDollarOpenParenthesis, -1, 0); - int32_t pluralRuleSuffix = ruleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart) + 2; + int32_t pluralRuleStart = fRuleText.indexOf(gDollarOpenParenthesis, -1, 0); + int32_t pluralRuleSuffix = fRuleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart) + 2; int32_t matchLen = position.getEndIndex() - start; - UnicodeString prefix(ruleText.tempSubString(0, pluralRuleStart)); - UnicodeString suffix(ruleText.tempSubString(pluralRuleSuffix)); + UnicodeString prefix(fRuleText.tempSubString(0, pluralRuleStart)); + UnicodeString suffix(fRuleText.tempSubString(pluralRuleSuffix)); if (str.compare(start - prefix.length(), prefix.length(), prefix, 0, prefix.length()) == 0 && str.compare(start + matchLen, suffix.length(), suffix, 0, suffix.length()) == 0) { diff --git a/icu4c/source/i18n/nfrule.h b/icu4c/source/i18n/nfrule.h index 698b75bb637..ed33eaa5af7 100644 --- a/icu4c/source/i18n/nfrule.h +++ b/icu4c/source/i18n/nfrule.h @@ -109,7 +109,7 @@ private: int32_t radix; int16_t exponent; UChar decimalPoint; - UnicodeString ruleText; + UnicodeString fRuleText; NFSubstitution* sub1; NFSubstitution* sub2; const RuleBasedNumberFormat* formatter; diff --git a/icu4c/source/i18n/number_grouping.cpp b/icu4c/source/i18n/number_grouping.cpp index 4a1cceb4994..da32cca99a3 100644 --- a/icu4c/source/i18n/number_grouping.cpp +++ b/icu4c/source/i18n/number_grouping.cpp @@ -80,7 +80,7 @@ void Grouper::setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Lo if (fMinGrouping == -2) { fMinGrouping = getMinGroupingForLocale(locale); } else if (fMinGrouping == -3) { - fMinGrouping = uprv_max(2, getMinGroupingForLocale(locale)); + fMinGrouping = static_cast(uprv_max(2, getMinGroupingForLocale(locale))); } else { // leave fMinGrouping alone } diff --git a/icu4c/source/i18n/number_multiplier.cpp b/icu4c/source/i18n/number_multiplier.cpp index a27142c9bd6..ecb50dd9b82 100644 --- a/icu4c/source/i18n/number_multiplier.cpp +++ b/icu4c/source/i18n/number_multiplier.cpp @@ -143,14 +143,14 @@ void Scale::applyReciprocalTo(impl::DecimalQuantity& quantity) const { void MultiplierFormatHandler::setAndChain(const Scale& multiplier, const MicroPropsGenerator* parent) { - this->multiplier = multiplier; - this->parent = parent; + fMultiplier = multiplier; + fParent = parent; } void MultiplierFormatHandler::processQuantity(DecimalQuantity& quantity, MicroProps& micros, UErrorCode& status) const { - parent->processQuantity(quantity, micros, status); - multiplier.applyTo(quantity); + fParent->processQuantity(quantity, micros, status); + fMultiplier.applyTo(quantity); } #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/icu4c/source/i18n/number_multiplier.h b/icu4c/source/i18n/number_multiplier.h index 82c30c78426..d8235dc601b 100644 --- a/icu4c/source/i18n/number_multiplier.h +++ b/icu4c/source/i18n/number_multiplier.h @@ -28,8 +28,8 @@ class U_I18N_API MultiplierFormatHandler : public MicroPropsGenerator, public UM UErrorCode& status) const U_OVERRIDE; private: - Scale multiplier; - const MicroPropsGenerator *parent; + Scale fMultiplier; + const MicroPropsGenerator *fParent; }; diff --git a/icu4c/source/i18n/number_patternmodifier.cpp b/icu4c/source/i18n/number_patternmodifier.cpp index 6417e14378b..09f4f392182 100644 --- a/icu4c/source/i18n/number_patternmodifier.cpp +++ b/icu4c/source/i18n/number_patternmodifier.cpp @@ -24,11 +24,11 @@ MutablePatternModifier::MutablePatternModifier(bool isStrong) : fStrong(isStrong) {} void MutablePatternModifier::setPatternInfo(const AffixPatternProvider* patternInfo) { - this->patternInfo = patternInfo; + fPatternInfo = patternInfo; } void MutablePatternModifier::setPatternAttributes(UNumberSignDisplay signDisplay, bool perMille) { - this->signDisplay = signDisplay; + fSignDisplay = signDisplay; this->perMilleReplacesPercent = perMille; } @@ -36,20 +36,20 @@ void MutablePatternModifier::setSymbols(const DecimalFormatSymbols* symbols, const CurrencySymbols* currencySymbols, const UNumberUnitWidth unitWidth, const PluralRules* rules) { U_ASSERT((rules != nullptr) == needsPlurals()); - this->symbols = symbols; - this->currencySymbols = currencySymbols; - this->unitWidth = unitWidth; - this->rules = rules; + fSymbols = symbols; + fCurrencySymbols = currencySymbols; + fUnitWidth = unitWidth; + fRules = rules; } void MutablePatternModifier::setNumberProperties(int8_t signum, StandardPlural::Form plural) { - this->signum = signum; - this->plural = plural; + fSignum = signum; + fPlural = plural; } bool MutablePatternModifier::needsPlurals() const { UErrorCode statusLocal = U_ZERO_ERROR; - return patternInfo->containsSymbolType(AffixPatternType::TYPE_CURRENCY_TRIPLE, statusLocal); + return fPatternInfo->containsSymbolType(AffixPatternType::TYPE_CURRENCY_TRIPLE, statusLocal); // Silently ignore any error codes. } @@ -89,7 +89,7 @@ MutablePatternModifier::createImmutableAndChain(const MicroPropsGenerator* paren delete pm; return nullptr; } - return new ImmutablePatternModifier(pm, rules, parent); // adopts pm + return new ImmutablePatternModifier(pm, fRules, parent); // adopts pm } else { // Faster path when plural keyword is not needed. setNumberProperties(1, StandardPlural::Form::COUNT); @@ -112,11 +112,11 @@ ConstantMultiFieldModifier* MutablePatternModifier::createConstantModifier(UErro NumberStringBuilder b; insertPrefix(a, 0, status); insertSuffix(b, 0, status); - if (patternInfo->hasCurrencySign()) { + if (fPatternInfo->hasCurrencySign()) { return new CurrencySpacingEnabledModifier( - a, b, !patternInfo->hasBody(), fStrong, *symbols, status); + a, b, !fPatternInfo->hasBody(), fStrong, *fSymbols, status); } else { - return new ConstantMultiFieldModifier(a, b, !patternInfo->hasBody(), fStrong); + return new ConstantMultiFieldModifier(a, b, !fPatternInfo->hasBody(), fStrong); } } @@ -153,13 +153,13 @@ const Modifier* ImmutablePatternModifier::getModifier(int8_t signum, StandardPlu /** Used by the unsafe code path. */ MicroPropsGenerator& MutablePatternModifier::addToChain(const MicroPropsGenerator* parent) { - this->parent = parent; + fParent = parent; return *this; } void MutablePatternModifier::processQuantity(DecimalQuantity& fq, MicroProps& micros, UErrorCode& status) const { - parent->processQuantity(fq, micros, status); + fParent->processQuantity(fq, micros, status); // The unsafe code path performs self-mutation, so we need a const_cast. // This method needs to be const because it overrides a const method in the parent class. auto nonConstThis = const_cast(this); @@ -167,7 +167,7 @@ void MutablePatternModifier::processQuantity(DecimalQuantity& fq, MicroProps& mi // TODO: Fix this. Avoid the copy. DecimalQuantity copy(fq); micros.rounder.apply(copy, status); - nonConstThis->setNumberProperties(fq.signum(), utils::getStandardPlural(rules, copy)); + nonConstThis->setNumberProperties(fq.signum(), utils::getStandardPlural(fRules, copy)); } else { nonConstThis->setNumberProperties(fq.signum(), StandardPlural::Form::COUNT); } @@ -183,7 +183,7 @@ int32_t MutablePatternModifier::apply(NumberStringBuilder& output, int32_t leftI int32_t suffixLen = nonConstThis->insertSuffix(output, rightIndex + prefixLen, status); // If the pattern had no decimal stem body (like #,##0.00), overwrite the value. int32_t overwriteLen = 0; - if (!patternInfo->hasBody()) { + if (!fPatternInfo->hasBody()) { overwriteLen = output.splice( leftIndex + prefixLen, rightIndex + prefixLen, @@ -199,7 +199,7 @@ int32_t MutablePatternModifier::apply(NumberStringBuilder& output, int32_t leftI prefixLen, rightIndex + overwriteLen + prefixLen, suffixLen, - *symbols, + *fSymbols, status); return prefixLen + overwriteLen + suffixLen; } @@ -247,40 +247,40 @@ int32_t MutablePatternModifier::insertSuffix(NumberStringBuilder& sb, int positi /** This method contains the heart of the logic for rendering LDML affix strings. */ void MutablePatternModifier::prepareAffix(bool isPrefix) { PatternStringUtils::patternInfoToStringBuilder( - *patternInfo, isPrefix, signum, signDisplay, plural, perMilleReplacesPercent, currentAffix); + *fPatternInfo, isPrefix, fSignum, fSignDisplay, fPlural, perMilleReplacesPercent, currentAffix); } UnicodeString MutablePatternModifier::getSymbol(AffixPatternType type) const { UErrorCode localStatus = U_ZERO_ERROR; switch (type) { case AffixPatternType::TYPE_MINUS_SIGN: - return symbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kMinusSignSymbol); + return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kMinusSignSymbol); case AffixPatternType::TYPE_PLUS_SIGN: - return symbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPlusSignSymbol); + return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPlusSignSymbol); case AffixPatternType::TYPE_PERCENT: - return symbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPercentSymbol); + return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPercentSymbol); case AffixPatternType::TYPE_PERMILLE: - return symbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPerMillSymbol); + return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPerMillSymbol); case AffixPatternType::TYPE_CURRENCY_SINGLE: { // UnitWidth ISO and HIDDEN overrides the singular currency symbol. - if (unitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_ISO_CODE) { - return currencySymbols->getIntlCurrencySymbol(localStatus); - } else if (unitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_HIDDEN) { + if (fUnitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_ISO_CODE) { + return fCurrencySymbols->getIntlCurrencySymbol(localStatus); + } else if (fUnitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_HIDDEN) { return UnicodeString(); - } else if (unitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_NARROW) { - return currencySymbols->getNarrowCurrencySymbol(localStatus); + } else if (fUnitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_NARROW) { + return fCurrencySymbols->getNarrowCurrencySymbol(localStatus); } else { - return currencySymbols->getCurrencySymbol(localStatus); + return fCurrencySymbols->getCurrencySymbol(localStatus); } } case AffixPatternType::TYPE_CURRENCY_DOUBLE: - return currencySymbols->getIntlCurrencySymbol(localStatus); + return fCurrencySymbols->getIntlCurrencySymbol(localStatus); case AffixPatternType::TYPE_CURRENCY_TRIPLE: // NOTE: This is the code path only for patterns containing "¤¤¤". // Plural currencies set via the API are formatted in LongNameHandler. // This code path is used by DecimalFormat via CurrencyPluralInfo. - U_ASSERT(plural != StandardPlural::Form::COUNT); - return currencySymbols->getPluralName(plural, localStatus); + U_ASSERT(fPlural != StandardPlural::Form::COUNT); + return fCurrencySymbols->getPluralName(fPlural, localStatus); case AffixPatternType::TYPE_CURRENCY_QUAD: return UnicodeString(u"\uFFFD"); case AffixPatternType::TYPE_CURRENCY_QUINT: diff --git a/icu4c/source/i18n/number_patternmodifier.h b/icu4c/source/i18n/number_patternmodifier.h index f1359bd5747..2854ca056a1 100644 --- a/icu4c/source/i18n/number_patternmodifier.h +++ b/icu4c/source/i18n/number_patternmodifier.h @@ -196,22 +196,22 @@ class U_I18N_API MutablePatternModifier const bool fStrong; // Pattern details (initialized in setPatternInfo and setPatternAttributes) - const AffixPatternProvider *patternInfo; - UNumberSignDisplay signDisplay; + const AffixPatternProvider *fPatternInfo; + UNumberSignDisplay fSignDisplay; bool perMilleReplacesPercent; // Symbol details (initialized in setSymbols) - const DecimalFormatSymbols *symbols; - UNumberUnitWidth unitWidth; - const CurrencySymbols *currencySymbols; - const PluralRules *rules; + const DecimalFormatSymbols *fSymbols; + UNumberUnitWidth fUnitWidth; + const CurrencySymbols *fCurrencySymbols; + const PluralRules *fRules; // Number details (initialized in setNumberProperties) - int8_t signum; - StandardPlural::Form plural; + int8_t fSignum; + StandardPlural::Form fPlural; // QuantityChain details (initialized in addToChain) - const MicroPropsGenerator *parent; + const MicroPropsGenerator *fParent; // Transient fields for rendering UnicodeString currentAffix; diff --git a/icu4c/source/i18n/olsontz.cpp b/icu4c/source/i18n/olsontz.cpp index 00a59d16d73..8c68d8b52cf 100644 --- a/icu4c/source/i18n/olsontz.cpp +++ b/icu4c/source/i18n/olsontz.cpp @@ -140,7 +140,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top, // Pre-32bit second transitions ures_getByKey(res, kTRANSPRE32, &r, &ec); transitionTimesPre32 = ures_getIntVector(&r, &len, &ec); - transitionCountPre32 = len >> 1; + transitionCountPre32 = static_cast(len >> 1); if (ec == U_MISSING_RESOURCE_ERROR) { // No pre-32bit transitions transitionTimesPre32 = NULL; @@ -153,7 +153,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top, // 32bit second transitions ures_getByKey(res, kTRANS, &r, &ec); transitionTimes32 = ures_getIntVector(&r, &len, &ec); - transitionCount32 = len; + transitionCount32 = static_cast(len); if (ec == U_MISSING_RESOURCE_ERROR) { // No 32bit transitions transitionTimes32 = NULL; @@ -166,7 +166,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top, // Post-32bit second transitions ures_getByKey(res, kTRANSPOST32, &r, &ec); transitionTimesPost32 = ures_getIntVector(&r, &len, &ec); - transitionCountPost32 = len >> 1; + transitionCountPost32 = static_cast(len >> 1); if (ec == U_MISSING_RESOURCE_ERROR) { // No pre-32bit transitions transitionTimesPost32 = NULL; diff --git a/icu4c/source/i18n/plurrule.cpp b/icu4c/source/i18n/plurrule.cpp index 4a4c21e7ac2..ba5450c6379 100644 --- a/icu4c/source/i18n/plurrule.cpp +++ b/icu4c/source/i18n/plurrule.cpp @@ -699,8 +699,8 @@ PluralRules::getRuleFromResource(const Locale& locale, UPluralType type, UErrorC // Check parent locales. UErrorCode status = U_ZERO_ERROR; char parentLocaleName[ULOC_FULLNAME_CAPACITY]; - const char *curLocaleName=locale.getName(); - uprv_strcpy(parentLocaleName, curLocaleName); + const char *curLocaleName2=locale.getName(); + uprv_strcpy(parentLocaleName, curLocaleName2); while (uloc_getParent(parentLocaleName, parentLocaleName, ULOC_FULLNAME_CAPACITY, &status) > 0) { diff --git a/icu4c/source/i18n/rbnf.cpp b/icu4c/source/i18n/rbnf.cpp index b9b0a5bc47c..27afc1faaa1 100644 --- a/icu4c/source/i18n/rbnf.cpp +++ b/icu4c/source/i18n/rbnf.cpp @@ -680,7 +680,7 @@ StringLocalizationInfo::getDisplayName(int32_t localeIndex, int32_t ruleIndex) c RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, const UnicodeString& locs, const Locale& alocale, UParseError& perror, UErrorCode& status) - : ruleSets(NULL) + : fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) , defaultRuleSet(NULL) @@ -689,7 +689,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, , decimalFormatSymbols(NULL) , defaultInfinityRule(NULL) , defaultNaNRule(NULL) - , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) + , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) , lenient(FALSE) , lenientParseRules(NULL) , localizations(NULL) @@ -705,7 +705,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, const UnicodeString& locs, UParseError& perror, UErrorCode& status) - : ruleSets(NULL) + : fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) , defaultRuleSet(NULL) @@ -714,7 +714,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, , decimalFormatSymbols(NULL) , defaultInfinityRule(NULL) , defaultNaNRule(NULL) - , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) + , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) , lenient(FALSE) , lenientParseRules(NULL) , localizations(NULL) @@ -730,7 +730,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, LocalizationInfo* info, const Locale& alocale, UParseError& perror, UErrorCode& status) - : ruleSets(NULL) + : fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) , defaultRuleSet(NULL) @@ -739,7 +739,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, , decimalFormatSymbols(NULL) , defaultInfinityRule(NULL) , defaultNaNRule(NULL) - , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) + , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) , lenient(FALSE) , lenientParseRules(NULL) , localizations(NULL) @@ -754,7 +754,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, UParseError& perror, UErrorCode& status) - : ruleSets(NULL) + : fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) , defaultRuleSet(NULL) @@ -763,7 +763,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, , decimalFormatSymbols(NULL) , defaultInfinityRule(NULL) , defaultNaNRule(NULL) - , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) + , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) , lenient(FALSE) , lenientParseRules(NULL) , localizations(NULL) @@ -779,7 +779,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, const Locale& aLocale, UParseError& perror, UErrorCode& status) - : ruleSets(NULL) + : fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) , defaultRuleSet(NULL) @@ -788,7 +788,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, , decimalFormatSymbols(NULL) , defaultInfinityRule(NULL) , defaultNaNRule(NULL) - , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) + , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) , lenient(FALSE) , lenientParseRules(NULL) , localizations(NULL) @@ -801,7 +801,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description, } RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& alocale, UErrorCode& status) - : ruleSets(NULL) + : fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) , defaultRuleSet(NULL) @@ -810,7 +810,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& , decimalFormatSymbols(NULL) , defaultInfinityRule(NULL) , defaultNaNRule(NULL) - , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) + , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) , lenient(FALSE) , lenientParseRules(NULL) , localizations(NULL) @@ -868,7 +868,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& RuleBasedNumberFormat::RuleBasedNumberFormat(const RuleBasedNumberFormat& rhs) : NumberFormat(rhs) - , ruleSets(NULL) + , fRuleSets(NULL) , ruleSetDescriptions(NULL) , numRuleSets(0) , defaultRuleSet(NULL) @@ -877,7 +877,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const RuleBasedNumberFormat& rhs) , decimalFormatSymbols(NULL) , defaultInfinityRule(NULL) , defaultNaNRule(NULL) - , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) + , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary) , lenient(FALSE) , lenientParseRules(NULL) , localizations(NULL) @@ -950,8 +950,8 @@ RuleBasedNumberFormat::operator==(const Format& other) const ? FALSE : *localizations == rhs.localizations))) { - NFRuleSet** p = ruleSets; - NFRuleSet** q = rhs.ruleSets; + NFRuleSet** p = fRuleSets; + NFRuleSet** q = rhs.fRuleSets; if (p == NULL) { return q == NULL; } else if (q == NULL) { @@ -972,8 +972,8 @@ UnicodeString RuleBasedNumberFormat::getRules() const { UnicodeString result; - if (ruleSets != NULL) { - for (NFRuleSet** p = ruleSets; *p; ++p) { + if (fRuleSets != NULL) { + for (NFRuleSet** p = fRuleSets; *p; ++p) { (*p)->appendRules(result); } } @@ -987,9 +987,9 @@ RuleBasedNumberFormat::getRuleSetName(int32_t index) const UnicodeString string(TRUE, localizations->getRuleSetName(index), (int32_t)-1); return string; } - else if (ruleSets) { + else if (fRuleSets) { UnicodeString result; - for (NFRuleSet** p = ruleSets; *p; ++p) { + for (NFRuleSet** p = fRuleSets; *p; ++p) { NFRuleSet* rs = *p; if (rs->isPublic()) { if (--index == -1) { @@ -1010,8 +1010,8 @@ RuleBasedNumberFormat::getNumberOfRuleSetNames() const if (localizations) { result = localizations->getNumberOfRuleSets(); } - else if (ruleSets) { - for (NFRuleSet** p = ruleSets; *p; ++p) { + else if (fRuleSets) { + for (NFRuleSet** p = fRuleSets; *p; ++p) { if ((**p).isPublic()) { ++result; } @@ -1098,8 +1098,8 @@ RuleBasedNumberFormat::getRuleSetDisplayName(const UnicodeString& ruleSetName, c NFRuleSet* RuleBasedNumberFormat::findRuleSet(const UnicodeString& name, UErrorCode& status) const { - if (U_SUCCESS(status) && ruleSets) { - for (NFRuleSet** p = ruleSets; *p; ++p) { + if (U_SUCCESS(status) && fRuleSets) { + for (NFRuleSet** p = fRuleSets; *p; ++p) { NFRuleSet* rs = *p; if (rs->isNamed(name)) { return rs; @@ -1378,7 +1378,7 @@ RuleBasedNumberFormat::parse(const UnicodeString& text, Formattable& result, ParsePosition& parsePosition) const { - if (!ruleSets) { + if (!fRuleSets) { parsePosition.setErrorIndex(0); return; } @@ -1389,7 +1389,7 @@ RuleBasedNumberFormat::parse(const UnicodeString& text, ParsePosition high_pp(0); Formattable high_result; - for (NFRuleSet** p = ruleSets; *p; ++p) { + for (NFRuleSet** p = fRuleSets; *p; ++p) { NFRuleSet *rp = *p; if (rp->isPublic() && rp->isParseable()) { ParsePosition working_pp(0); @@ -1477,7 +1477,7 @@ void RuleBasedNumberFormat::initDefaultRuleSet() { defaultRuleSet = NULL; - if (!ruleSets) { + if (!fRuleSets) { return; } @@ -1485,7 +1485,7 @@ RuleBasedNumberFormat::initDefaultRuleSet() const UnicodeString ordinal(UNICODE_STRING_SIMPLE("%digits-ordinal")); const UnicodeString duration(UNICODE_STRING_SIMPLE("%duration")); - NFRuleSet**p = &ruleSets[0]; + NFRuleSet**p = &fRuleSets[0]; while (*p) { if ((*p)->isNamed(spellout) || (*p)->isNamed(ordinal) || (*p)->isNamed(duration)) { defaultRuleSet = *p; @@ -1497,7 +1497,7 @@ RuleBasedNumberFormat::initDefaultRuleSet() defaultRuleSet = *--p; if (!defaultRuleSet->isPublic()) { - while (p != ruleSets) { + while (p != fRuleSets) { if ((*--p)->isPublic()) { defaultRuleSet = *p; break; @@ -1588,15 +1588,15 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali ++numRuleSets; // our rule list is an array of the appropriate size - ruleSets = (NFRuleSet **)uprv_malloc((numRuleSets + 1) * sizeof(NFRuleSet *)); + fRuleSets = (NFRuleSet **)uprv_malloc((numRuleSets + 1) * sizeof(NFRuleSet *)); /* test for NULL */ - if (ruleSets == 0) { + if (fRuleSets == 0) { status = U_MEMORY_ALLOCATION_ERROR; return; } for (int i = 0; i <= numRuleSets; ++i) { - ruleSets[i] = NULL; + fRuleSets[i] = NULL; } // divide up the descriptions into individual rule-set descriptions @@ -1622,8 +1622,8 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali int32_t start = 0; for (int32_t p = description.indexOf(gSemiPercent, 2, 0); p != -1; p = description.indexOf(gSemiPercent, 2, start)) { ruleSetDescriptions[curRuleSet].setTo(description, start, p + 1 - start); - ruleSets[curRuleSet] = new NFRuleSet(this, ruleSetDescriptions, curRuleSet, status); - if (ruleSets[curRuleSet] == nullptr) { + fRuleSets[curRuleSet] = new NFRuleSet(this, ruleSetDescriptions, curRuleSet, status); + if (fRuleSets[curRuleSet] == nullptr) { status = U_MEMORY_ALLOCATION_ERROR; return; } @@ -1631,8 +1631,8 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali start = p + 1; } ruleSetDescriptions[curRuleSet].setTo(description, start, description.length() - start); - ruleSets[curRuleSet] = new NFRuleSet(this, ruleSetDescriptions, curRuleSet, status); - if (ruleSets[curRuleSet] == nullptr) { + fRuleSets[curRuleSet] = new NFRuleSet(this, ruleSetDescriptions, curRuleSet, status); + if (fRuleSets[curRuleSet] == nullptr) { status = U_MEMORY_ALLOCATION_ERROR; return; } @@ -1654,7 +1654,7 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali // away the temporary descriptions as we go) { for (int i = 0; i < numRuleSets; i++) { - ruleSets[i]->parseRules(ruleSetDescriptions[i], status); + fRuleSets[i]->parseRules(ruleSetDescriptions[i], status); } } @@ -1700,7 +1700,7 @@ RuleBasedNumberFormat::setContext(UDisplayContext value, UErrorCode& status) if ( capitalizationBrkIter == NULL && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE || (value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU && capitalizationForUIListMenu) || (value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE && capitalizationForStandAlone)) ) { - UErrorCode status = U_ZERO_ERROR; + status = U_ZERO_ERROR; capitalizationBrkIter = BreakIterator::createSentenceInstance(locale, status); if (U_FAILURE(status)) { delete capitalizationBrkIter; @@ -1724,8 +1724,8 @@ RuleBasedNumberFormat::initCapitalizationContextInfo(const Locale& thelocale) int32_t len = 0; const int32_t * intVector = ures_getIntVector(rb, &len, &status); if (U_SUCCESS(status) && intVector != NULL && len >= 2) { - capitalizationForUIListMenu = intVector[0]; - capitalizationForStandAlone = intVector[1]; + capitalizationForUIListMenu = static_cast(intVector[0]); + capitalizationForStandAlone = static_cast(intVector[1]); } } ures_close(rb); @@ -1776,12 +1776,12 @@ RuleBasedNumberFormat::stripWhitespace(UnicodeString& description) void RuleBasedNumberFormat::dispose() { - if (ruleSets) { - for (NFRuleSet** p = ruleSets; *p; ++p) { + if (fRuleSets) { + for (NFRuleSet** p = fRuleSets; *p; ++p) { delete *p; } - uprv_free(ruleSets); - ruleSets = NULL; + uprv_free(fRuleSets); + fRuleSets = NULL; } if (ruleSetDescriptions) { @@ -1831,7 +1831,7 @@ const RuleBasedCollator* RuleBasedNumberFormat::getCollator() const { #if !UCONFIG_NO_COLLATION - if (!ruleSets) { + if (!fRuleSets) { return NULL; } @@ -1974,9 +1974,9 @@ RuleBasedNumberFormat::adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsTo defaultNaNRule = NULL; initializeDefaultNaNRule(status); // Reset with the new DecimalFormatSymbols - if (ruleSets) { + if (fRuleSets) { for (int32_t i = 0; i < numRuleSets; i++) { - ruleSets[i]->setDecimalFormatSymbols(*symbolsToAdopt, status); + fRuleSets[i]->setDecimalFormatSymbols(*symbolsToAdopt, status); } } } @@ -2006,7 +2006,7 @@ RuleBasedNumberFormat::createPluralFormat(UPluralType pluralType, * @return A rounding mode */ DecimalFormat::ERoundingMode RuleBasedNumberFormat::getRoundingMode() const { - return roundingMode; + return fRoundingMode; } /** @@ -2015,7 +2015,7 @@ DecimalFormat::ERoundingMode RuleBasedNumberFormat::getRoundingMode() const { * @param roundingMode A rounding mode */ void RuleBasedNumberFormat::setRoundingMode(DecimalFormat::ERoundingMode roundingMode) { - this->roundingMode = roundingMode; + fRoundingMode = roundingMode; } U_NAMESPACE_END diff --git a/icu4c/source/i18n/rbt_pars.cpp b/icu4c/source/i18n/rbt_pars.cpp index 6ed89b1fc58..9932dbdc95e 100644 --- a/icu4c/source/i18n/rbt_pars.cpp +++ b/icu4c/source/i18n/rbt_pars.cpp @@ -194,9 +194,9 @@ const UnicodeFunctor* ParseData::lookupMatcher(UChar32 ch) const { const UnicodeFunctor* set = NULL; int32_t i = ch - data->variablesBase; if (i >= 0 && i < variablesVector->size()) { - int32_t i = ch - data->variablesBase; - set = (i < variablesVector->size()) ? - (UnicodeFunctor*) variablesVector->elementAt(i) : 0; + int32_t j = ch - data->variablesBase; + set = (j < variablesVector->size()) ? + (UnicodeFunctor*) variablesVector->elementAt(j) : 0; } return set; } @@ -1108,8 +1108,8 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, } data->variableNames.removeAll(); - int32_t pos = UHASH_FIRST; - const UHashElement* he = variableNames.nextElement(pos); + int32_t p = UHASH_FIRST; + const UHashElement* he = variableNames.nextElement(p); while (he != NULL) { UnicodeString* tempus = (UnicodeString*)(((UnicodeString*)(he->value.pointer))->clone()); if (tempus == NULL) { @@ -1118,7 +1118,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule, } data->variableNames.put(*((UnicodeString*)(he->key.pointer)), tempus, status); - he = variableNames.nextElement(pos); + he = variableNames.nextElement(p); } } variablesVector.removeAllElements(); // keeps them from getting deleted when we succeed diff --git a/icu4c/source/i18n/region.cpp b/icu4c/source/i18n/region.cpp index 66de31de8b3..d1ae02accb3 100644 --- a/icu4c/source/i18n/region.cpp +++ b/icu4c/source/i18n/region.cpp @@ -182,7 +182,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { r->idStr = *regionName; r->idStr.extract(0,r->idStr.length(),r->id,sizeof(r->id),US_INV); - r->type = URGN_TERRITORY; // Only temporary - figure out the real type later once the aliases are known. + r->fType = URGN_TERRITORY; // Only temporary - figure out the real type later once the aliases are known. Formattable result; UErrorCode ps = U_ZERO_ERROR; @@ -190,7 +190,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { if ( U_SUCCESS(ps) ) { r->code = result.getLong(); // Convert string to number uhash_iput(newNumericCodeMap.getAlias(),r->code,(void *)(r.getAlias()),&status); - r->type = URGN_SUBCONTINENT; + r->fType = URGN_SUBCONTINENT; } else { r->code = -1; } @@ -231,9 +231,9 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { } else { aliasFromRegion->code = -1; } - aliasFromRegion->type = URGN_DEPRECATED; + aliasFromRegion->fType = URGN_DEPRECATED; } else { - aliasFromRegion->type = URGN_DEPRECATED; + aliasFromRegion->fType = URGN_DEPRECATED; } { @@ -290,26 +290,26 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { UnicodeString WORLD_ID_STRING(WORLD_ID); r = (Region *) uhash_get(newRegionIDMap.getAlias(),(void *)&WORLD_ID_STRING); if ( r ) { - r->type = URGN_WORLD; + r->fType = URGN_WORLD; } UnicodeString UNKNOWN_REGION_ID_STRING(UNKNOWN_REGION_ID); r = (Region *) uhash_get(newRegionIDMap.getAlias(),(void *)&UNKNOWN_REGION_ID_STRING); if ( r ) { - r->type = URGN_UNKNOWN; + r->fType = URGN_UNKNOWN; } for ( int32_t i = 0 ; i < continents->size() ; i++ ) { r = (Region *) uhash_get(newRegionIDMap.getAlias(),(void *)continents->elementAt(i)); if ( r ) { - r->type = URGN_CONTINENT; + r->fType = URGN_CONTINENT; } } for ( int32_t i = 0 ; i < groupings->size() ; i++ ) { r = (Region *) uhash_get(newRegionIDMap.getAlias(),(void *)groupings->elementAt(i)); if ( r ) { - r->type = URGN_GROUPING; + r->fType = URGN_GROUPING; } } @@ -319,7 +319,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { UnicodeString OUTLYING_OCEANIA_REGION_ID_STRING(OUTLYING_OCEANIA_REGION_ID); r = (Region *) uhash_get(newRegionIDMap.getAlias(),(void *)&OUTLYING_OCEANIA_REGION_ID_STRING); if ( r ) { - r->type = URGN_SUBCONTINENT; + r->fType = URGN_SUBCONTINENT; } // Load territory containment info from the supplemental data. @@ -356,7 +356,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { // Set the parent region to be the containing region of the child. // Regions of type GROUPING can't be set as the parent, since another region // such as a SUBCONTINENT, CONTINENT, or WORLD must always be the parent. - if ( parentRegion->type != URGN_GROUPING) { + if ( parentRegion->fType != URGN_GROUPING) { childRegion->containingRegion = parentRegion; } } @@ -367,15 +367,15 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) { int32_t pos = UHASH_FIRST; while ( const UHashElement* element = uhash_nextElement(newRegionIDMap.getAlias(),&pos)) { Region *ar = (Region *)element->value.pointer; - if ( availableRegions[ar->type] == NULL ) { + if ( availableRegions[ar->fType] == NULL ) { LocalPointer newAr(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status); - availableRegions[ar->type] = newAr.orphan(); + availableRegions[ar->fType] = newAr.orphan(); } LocalPointer arString(new UnicodeString(ar->idStr), status); if( U_FAILURE(status) ) { return; // error out } - availableRegions[ar->type]->addElement((void *)arString.orphan(),status); + availableRegions[ar->fType]->addElement((void *)arString.orphan(),status); } ucln_i18n_registerCleanup(UCLN_I18N_REGION, region_cleanup); @@ -416,7 +416,7 @@ void Region::cleanupRegionData() { Region::Region () : code(-1), - type(URGN_UNKNOWN), + fType(URGN_UNKNOWN), containingRegion(NULL), containedRegions(NULL), preferredValues(NULL) { @@ -481,7 +481,7 @@ Region::getInstance(const char *region_code, UErrorCode &status) { return NULL; } - if ( r->type == URGN_DEPRECATED && r->preferredValues->size() == 1) { + if ( r->fType == URGN_DEPRECATED && r->preferredValues->size() == 1) { StringEnumeration *pv = r->getPreferredValues(status); pv->reset(status); const UnicodeString *ustr = pv->snext(status); @@ -529,7 +529,7 @@ Region::getInstance (int32_t code, UErrorCode &status) { return NULL; } - if ( r->type == URGN_DEPRECATED && r->preferredValues->size() == 1) { + if ( r->fType == URGN_DEPRECATED && r->preferredValues->size() == 1) { StringEnumeration *pv = r->getPreferredValues(status); pv->reset(status); const UnicodeString *ustr = pv->snext(status); @@ -580,7 +580,7 @@ Region::getContainingRegion(URegionType type) const { return NULL; } - return ( containingRegion->type == type )? containingRegion: containingRegion->getContainingRegion(type); + return ( containingRegion->fType == type)? containingRegion: containingRegion->getContainingRegion(type); } /** @@ -618,9 +618,9 @@ Region::getContainedRegions( URegionType type, UErrorCode &status ) const { StringEnumeration *cr = getContainedRegions(status); for ( int32_t i = 0 ; i < cr->count(status) ; i++ ) { - const char *id = cr->next(NULL,status); - const Region *r = Region::getInstance(id,status); - if ( r->getType() == type ) { + const char *regionId = cr->next(NULL,status); + const Region *r = Region::getInstance(regionId,status); + if ( r->getType() == type) { result->addElement((void *)&r->idStr,status); } else { StringEnumeration *children = r->getContainedRegions(type, status); @@ -672,7 +672,7 @@ Region::contains(const Region &other) const { StringEnumeration* Region::getPreferredValues(UErrorCode &status) const { umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status); // returns immediately if U_FAILURE(status) - if (U_FAILURE(status) || type != URGN_DEPRECATED) { + if (U_FAILURE(status) || fType != URGN_DEPRECATED) { return NULL; } return new RegionNameEnumeration(preferredValues,status); @@ -697,7 +697,7 @@ Region::getNumericCode() const { */ URegionType Region::getType() const { - return type; + return fType; } RegionNameEnumeration::RegionNameEnumeration(UVector *fNameList, UErrorCode& status) { diff --git a/icu4c/source/i18n/reldatefmt.cpp b/icu4c/source/i18n/reldatefmt.cpp index aad026cb62d..0a28a743e28 100644 --- a/icu4c/source/i18n/reldatefmt.cpp +++ b/icu4c/source/i18n/reldatefmt.cpp @@ -312,7 +312,7 @@ struct RelDateTimeFmtDataSink : public ResourceSink { // Utility functions static UDateRelativeDateTimeFormatterStyle styleFromString(const char *s) { - int32_t len = uprv_strlen(s); + int32_t len = static_cast(uprv_strlen(s)); if (len >= 7 && uprv_strcmp(s + len - 7, "-narrow") == 0) { return UDAT_STYLE_NARROW; } @@ -546,7 +546,7 @@ struct RelDateTimeFmtDataSink : public ResourceSink { consumeAlias(key, value, errorCode); } else { style = styleFromString(key); - int32_t unitSize = uprv_strlen(key) - styleSuffixLength(style); + int32_t unitSize = static_cast(uprv_strlen(key)) - styleSuffixLength(style); genericUnit = unitOrNegativeFromString(key, unitSize); if (style >= 0 && genericUnit != INVALID_UNIT) { consumeTimeUnit(key, value, errorCode); diff --git a/icu4c/source/i18n/reldtfmt.cpp b/icu4c/source/i18n/reldtfmt.cpp index 839198b3859..5e7ddddf74a 100644 --- a/icu4c/source/i18n/reldtfmt.cpp +++ b/icu4c/source/i18n/reldtfmt.cpp @@ -430,7 +430,7 @@ RelativeDateFormat::setContext(UDisplayContext value, UErrorCode& status) if ( fCapitalizationBrkIter == NULL && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE || (value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU && fCapitalizationOfRelativeUnitsForUIListMenu) || (value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE && fCapitalizationOfRelativeUnitsForStandAlone)) ) { - UErrorCode status = U_ZERO_ERROR; + status = U_ZERO_ERROR; fCapitalizationBrkIter = BreakIterator::createSentenceInstance(fLocale, status); if (U_FAILURE(status)) { delete fCapitalizationBrkIter; @@ -456,8 +456,8 @@ RelativeDateFormat::initCapitalizationContextInfo(const Locale& thelocale) const int32_t * intVector = ures_getIntVector(rb.getAlias(), &len, &status); if (U_SUCCESS(status) && intVector != NULL && len >= 2) { - fCapitalizationOfRelativeUnitsForUIListMenu = intVector[0]; - fCapitalizationOfRelativeUnitsForStandAlone = intVector[1]; + fCapitalizationOfRelativeUnitsForUIListMenu = static_cast(intVector[0]); + fCapitalizationOfRelativeUnitsForStandAlone = static_cast(intVector[1]); } } #endif diff --git a/icu4c/source/i18n/rematch.cpp b/icu4c/source/i18n/rematch.cpp index efa3909e5e9..cfdc1fe4d99 100644 --- a/icu4c/source/i18n/rematch.cpp +++ b/icu4c/source/i18n/rematch.cpp @@ -801,7 +801,7 @@ UBool RegexMatcher::find(UErrorCode &status) { case START_LINE: { - UChar32 c; + UChar32 ch; if (startPos == fAnchorStart) { MatchAt(startPos, FALSE, status); if (U_FAILURE(status)) { @@ -811,17 +811,17 @@ UBool RegexMatcher::find(UErrorCode &status) { return TRUE; } UTEXT_SETNATIVEINDEX(fInputText, startPos); - c = UTEXT_NEXT32(fInputText); + ch = UTEXT_NEXT32(fInputText); startPos = UTEXT_GETNATIVEINDEX(fInputText); } else { UTEXT_SETNATIVEINDEX(fInputText, startPos); - c = UTEXT_PREVIOUS32(fInputText); + ch = UTEXT_PREVIOUS32(fInputText); UTEXT_SETNATIVEINDEX(fInputText, startPos); } if (fPattern->fFlags & UREGEX_UNIX_LINES) { for (;;) { - if (c == 0x0a) { + if (ch == 0x0a) { MatchAt(startPos, FALSE, status); if (U_FAILURE(status)) { return FALSE; @@ -836,7 +836,7 @@ UBool RegexMatcher::find(UErrorCode &status) { fHitEnd = TRUE; return FALSE; } - c = UTEXT_NEXT32(fInputText); + ch = UTEXT_NEXT32(fInputText); startPos = UTEXT_GETNATIVEINDEX(fInputText); // Note that it's perfectly OK for a pattern to have a zero-length // match at the end of a string, so we must make sure that the loop @@ -846,8 +846,8 @@ UBool RegexMatcher::find(UErrorCode &status) { } } else { for (;;) { - if (isLineTerminator(c)) { - if (c == 0x0d && startPos < fActiveLimit && UTEXT_CURRENT32(fInputText) == 0x0a) { + if (isLineTerminator(ch)) { + if (ch == 0x0d && startPos < fActiveLimit && UTEXT_CURRENT32(fInputText) == 0x0a) { (void)UTEXT_NEXT32(fInputText); startPos = UTEXT_GETNATIVEINDEX(fInputText); } @@ -865,7 +865,7 @@ UBool RegexMatcher::find(UErrorCode &status) { fHitEnd = TRUE; return FALSE; } - c = UTEXT_NEXT32(fInputText); + ch = UTEXT_NEXT32(fInputText); startPos = UTEXT_GETNATIVEINDEX(fInputText); // Note that it's perfectly OK for a pattern to have a zero-length // match at the end of a string, so we must make sure that the loop @@ -1034,7 +1034,7 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) { return FALSE; } } - U_ASSERT(FALSE); + U_ASSERT(FALSE); case START_STRING: case START_CHAR: @@ -1067,7 +1067,7 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) { case START_LINE: { - UChar32 c; + UChar32 ch; if (startPos == fAnchorStart) { MatchChunkAt(startPos, FALSE, status); if (U_FAILURE(status)) { @@ -1081,8 +1081,8 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) { if (fPattern->fFlags & UREGEX_UNIX_LINES) { for (;;) { - c = inputBuf[startPos-1]; - if (c == 0x0a) { + ch = inputBuf[startPos-1]; + if (ch == 0x0a) { MatchChunkAt(startPos, FALSE, status); if (U_FAILURE(status)) { return FALSE; @@ -1105,9 +1105,9 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) { } } else { for (;;) { - c = inputBuf[startPos-1]; - if (isLineTerminator(c)) { - if (c == 0x0d && startPos < fActiveLimit && inputBuf[startPos] == 0x0a) { + ch = inputBuf[startPos-1]; + if (isLineTerminator(ch)) { + if (ch == 0x0d && startPos < fActiveLimit && inputBuf[startPos] == 0x0a) { startPos++; } MatchChunkAt(startPos, FALSE, status); @@ -2774,7 +2774,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { int64_t *pat = fPattern->fCompiledPat->getBuffer(); const UChar *litText = fPattern->fLiteralText.getBuffer(); - UVector *sets = fPattern->fSets; + UVector *fSets = fPattern->fSets; fFrameSize = fPattern->fFrameSize; REStackFrame *fp = resetStack(); @@ -3376,7 +3376,7 @@ GC_Done: // There is input left. Pick up one char and test it for set membership. UChar32 c = UTEXT_NEXT32(fInputText); - U_ASSERT(opValue > 0 && opValue < sets->size()); + U_ASSERT(opValue > 0 && opValue < fSets->size()); if (c<256) { Regex8BitSet *s8 = &fPattern->fSets8[opValue]; if (s8->contains(c)) { @@ -3384,7 +3384,7 @@ GC_Done: break; } } else { - UnicodeSet *s = (UnicodeSet *)sets->elementAt(opValue); + UnicodeSet *s = (UnicodeSet *)fSets->elementAt(opValue); if (s->contains(c)) { // The character is in the set. A Match. fp->fInputIdx = UTEXT_GETNATIVEINDEX(fInputText); @@ -3671,9 +3671,9 @@ GC_Done: if (newFP == (int64_t *)fp) { break; } - int32_t i; - for (i=0; isetSize(newStackSize); @@ -3830,9 +3830,9 @@ GC_Done: // This makes the capture groups from within the look-ahead // expression available. int64_t *newFP = fStack->getBuffer() + newStackSize - fFrameSize; - int32_t i; - for (i=0; isetSize(newStackSize); @@ -4123,9 +4123,9 @@ GC_Done: // This op scans through all matching input. // The following LOOP_C op emulates stack unwinding if the following pattern fails. { - U_ASSERT(opValue > 0 && opValue < sets->size()); + U_ASSERT(opValue > 0 && opValue < fSets->size()); Regex8BitSet *s8 = &fPattern->fSets8[opValue]; - UnicodeSet *s = (UnicodeSet *)sets->elementAt(opValue); + UnicodeSet *s = (UnicodeSet *)fSets->elementAt(opValue); // Loop through input, until either the input is exhausted or // we reach a character that is not a member of the set. @@ -4350,7 +4350,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu int64_t *pat = fPattern->fCompiledPat->getBuffer(); const UChar *litText = fPattern->fLiteralText.getBuffer(); - UVector *sets = fPattern->fSets; + UVector *fSets = fPattern->fSets; const UChar *inputBuf = fInputText->chunkContents; @@ -4928,7 +4928,7 @@ GC_Done: break; } - U_ASSERT(opValue > 0 && opValue < sets->size()); + U_ASSERT(opValue > 0 && opValue < fSets->size()); // There is input left. Pick up one char and test it for set membership. UChar32 c; @@ -4940,7 +4940,7 @@ GC_Done: break; } } else { - UnicodeSet *s = (UnicodeSet *)sets->elementAt(opValue); + UnicodeSet *s = (UnicodeSet *)fSets->elementAt(opValue); if (s->contains(c)) { // The character is in the set. A Match. break; @@ -5214,9 +5214,9 @@ GC_Done: if (newFP == (int64_t *)fp) { break; } - int32_t i; - for (i=0; isetSize(newStackSize); @@ -5361,9 +5361,9 @@ GC_Done: // This makes the capture groups from within the look-ahead // expression available. int64_t *newFP = fStack->getBuffer() + newStackSize - fFrameSize; - int32_t i; - for (i=0; isetSize(newStackSize); @@ -5623,9 +5623,9 @@ GC_Done: // This op scans through all matching input. // The following LOOP_C op emulates stack unwinding if the following pattern fails. { - U_ASSERT(opValue > 0 && opValue < sets->size()); + U_ASSERT(opValue > 0 && opValue < fSets->size()); Regex8BitSet *s8 = &fPattern->fSets8[opValue]; - UnicodeSet *s = (UnicodeSet *)sets->elementAt(opValue); + UnicodeSet *s = (UnicodeSet *)fSets->elementAt(opValue); // Loop through input, until either the input is exhausted or // we reach a character that is not a member of the set. diff --git a/icu4c/source/i18n/rulebasedcollator.cpp b/icu4c/source/i18n/rulebasedcollator.cpp index ab65f10a3bd..b057b6bbd5a 100644 --- a/icu4c/source/i18n/rulebasedcollator.cpp +++ b/icu4c/source/i18n/rulebasedcollator.cpp @@ -764,9 +764,9 @@ RuleBasedCollator::internalCompareUTF8(const char *left, int32_t leftLength, // Make sure both or neither strings have a known length. // We do not optimize for mixed length/termination. if(leftLength >= 0) { - if(rightLength < 0) { rightLength = uprv_strlen(right); } + if(rightLength < 0) { rightLength = static_cast(uprv_strlen(right)); } } else { - if(rightLength >= 0) { leftLength = uprv_strlen(left); } + if(rightLength >= 0) { leftLength = static_cast(uprv_strlen(left)); } } return doCompare(reinterpret_cast(left), leftLength, reinterpret_cast(right), rightLength, errorCode); @@ -862,9 +862,9 @@ public: } else { str.setTo(text, (int32_t)(spanLimit - text)); { - ReorderingBuffer buffer(nfcImpl, str); - if(buffer.init(str.length(), errorCode)) { - nfcImpl.makeFCD(spanLimit, textLimit, &buffer, errorCode); + ReorderingBuffer r_buffer(nfcImpl, str); + if(r_buffer.init(str.length(), errorCode)) { + nfcImpl.makeFCD(spanLimit, textLimit, &r_buffer, errorCode); } } if(U_SUCCESS(errorCode)) { diff --git a/icu4c/source/i18n/scriptset.cpp b/icu4c/source/i18n/scriptset.cpp index 073e839f890..54ead803c2a 100644 --- a/icu4c/source/i18n/scriptset.cpp +++ b/icu4c/source/i18n/scriptset.cpp @@ -298,7 +298,7 @@ uhash_compareScriptSet(UElement key0, UElement key1) { icu::ScriptSet *s0 = static_cast(key0.pointer); icu::ScriptSet *s1 = static_cast(key1.pointer); int32_t diff = s0->countMembers() - s1->countMembers(); - if (diff != 0) return diff; + if (diff != 0) return static_cast(diff); int32_t i0 = s0->nextSetBit(0); int32_t i1 = s1->nextSetBit(0); while ((diff = i0-i1) == 0 && i0 > 0) { diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index b1b90882fce..2bc8e49625f 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -244,9 +244,9 @@ SimpleDateFormat::NSOverride::~NSOverride() { void SimpleDateFormat::NSOverride::free() { NSOverride *cur = this; while (cur) { - NSOverride *next = cur->next; + NSOverride *next_temp = cur->next; delete cur; - cur = next; + cur = next_temp; } } @@ -1304,15 +1304,15 @@ SimpleDateFormat::processOverrideString(const Locale &locale, const UnicodeStrin int32_t nsNameHash = nsName.hashCode(); // See if the numbering system is in the override list, if not, then add it. - NSOverride *cur = overrideList; + NSOverride *curr = overrideList; const SharedNumberFormat *snf = NULL; UBool found = FALSE; - while ( cur && !found ) { - if ( cur->hash == nsNameHash ) { - snf = cur->snf; + while ( curr && !found ) { + if ( curr->hash == nsNameHash ) { + snf = curr->snf; found = TRUE; } - cur = cur->next; + curr = curr->next; } if (!found) { @@ -1824,14 +1824,14 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo, // Stealing am/pm value to use as our array index. // It works out: am/midnight are both 0, pm/noon are both 1, // 12 am is 12 midnight, and 12 pm is 12 noon. - int32_t value = cal.get(UCAL_AM_PM, status); + int32_t val = cal.get(UCAL_AM_PM, status); if (count <= 3) { - toAppend = &fSymbols->fAbbreviatedDayPeriods[value]; + toAppend = &fSymbols->fAbbreviatedDayPeriods[val]; } else if (count == 4 || count > 5) { - toAppend = &fSymbols->fWideDayPeriods[value]; + toAppend = &fSymbols->fWideDayPeriods[val]; } else { // count == 5 - toAppend = &fSymbols->fNarrowDayPeriods[value]; + toAppend = &fSymbols->fNarrowDayPeriods[val]; } } @@ -2281,10 +2281,10 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition& if (i+1 < fPattern.length()) { // move to next pattern character - UChar ch = fPattern.charAt(i+1); + UChar c = fPattern.charAt(i+1); // check for whitespace - if (PatternProps::isWhiteSpace(ch)) { + if (PatternProps::isWhiteSpace(c)) { i++; // Advance over run in pattern while ((i+1)isLeapYear(hc->get(UCAL_YEAR,status)) && value >= 6) { + UErrorCode monthStatus = U_ZERO_ERROR; + if (!hc->isLeapYear(hc->get(UCAL_YEAR, monthStatus)) && value >= 6) { cal.set(UCAL_MONTH, value); } else { cal.set(UCAL_MONTH, value - 1); @@ -3571,21 +3571,21 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC static const UChar alt_sep = DateFormatSymbols::ALTERNATE_TIME_SEPARATOR; // Try matching a time separator. - int32_t count = 1; + int32_t count_sep = 1; UnicodeString data[3]; fSymbols->getTimeSeparatorString(data[0]); // Add the default, if different from the locale. if (data[0].compare(&def_sep, 1) != 0) { - data[count++].setTo(def_sep); + data[count_sep++].setTo(def_sep); } // If lenient, add also the alternate, if different from the locale. if (isLenient() && data[0].compare(&alt_sep, 1) != 0) { - data[count++].setTo(alt_sep); + data[count_sep++].setTo(alt_sep); } - return matchString(text, start, UCAL_FIELD_COUNT /* => nothing to set */, data, count, NULL, cal); + return matchString(text, start, UCAL_FIELD_COUNT /* => nothing to set */, data, count_sep, NULL, cal); } case UDAT_AM_PM_MIDNIGHT_NOON_FIELD: @@ -3674,7 +3674,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC } parseInt(*src, number, pos, allowNegative,currentNumberFormat); if (pos.getIndex() != parseStart) { - int32_t value = number.getLong(); + int32_t val = number.getLong(); // Don't need suffix processing here (as in number processing at the beginning of the function); // the new fields being handled as numeric values (month, weekdays, quarters) should not have suffixes. @@ -3682,7 +3682,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC if (!getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status)) { // Check the range of the value int32_t bias = gFieldRangeBias[patternCharIndex]; - if (bias >= 0 && (value > cal.getMaximum(field) + bias || value < cal.getMinimum(field) + bias)) { + if (bias >= 0 && (val > cal.getMaximum(field) + bias || val < cal.getMinimum(field) + bias)) { return -start; } } @@ -3696,35 +3696,35 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC if (!strcmp(cal.getType(),"hebrew")) { HebrewCalendar *hc = (HebrewCalendar*)&cal; if (cal.isSet(UCAL_YEAR)) { - UErrorCode status = U_ZERO_ERROR; - if (!hc->isLeapYear(hc->get(UCAL_YEAR,status)) && value >= 6) { - cal.set(UCAL_MONTH, value); + UErrorCode monthStatus = U_ZERO_ERROR; + if (!hc->isLeapYear(hc->get(UCAL_YEAR, monthStatus)) && val >= 6) { + cal.set(UCAL_MONTH, val); } else { - cal.set(UCAL_MONTH, value - 1); + cal.set(UCAL_MONTH, val - 1); } } else { - saveHebrewMonth = value; + saveHebrewMonth = val; } } else { - cal.set(UCAL_MONTH, value - 1); + cal.set(UCAL_MONTH, val - 1); } break; case UDAT_STANDALONE_MONTH_FIELD: - cal.set(UCAL_MONTH, value - 1); + cal.set(UCAL_MONTH, val - 1); break; case UDAT_DOW_LOCAL_FIELD: case UDAT_STANDALONE_DAY_FIELD: - cal.set(UCAL_DOW_LOCAL, value); + cal.set(UCAL_DOW_LOCAL, val); break; case UDAT_QUARTER_FIELD: case UDAT_STANDALONE_QUARTER_FIELD: - cal.set(UCAL_MONTH, (value - 1) * 3); + cal.set(UCAL_MONTH, (val - 1) * 3); break; case UDAT_RELATED_YEAR_FIELD: - cal.setRelatedYear(value); + cal.setRelatedYear(val); break; default: - cal.set(field, value); + cal.set(field, val); break; } return pos.getIndex(); @@ -3971,7 +3971,7 @@ SimpleDateFormat::setContext(UDisplayContext value, UErrorCode& status) if (U_SUCCESS(status)) { if ( fCapitalizationBrkIter == NULL && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE || value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU || value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE) ) { - UErrorCode status = U_ZERO_ERROR; + status = U_ZERO_ERROR; fCapitalizationBrkIter = BreakIterator::createSentenceInstance(fLocale, status); if (U_FAILURE(status)) { delete fCapitalizationBrkIter; diff --git a/icu4c/source/i18n/timezone.cpp b/icu4c/source/i18n/timezone.cpp index 12c3039d7cb..234f52cc3dd 100644 --- a/icu4c/source/i18n/timezone.cpp +++ b/icu4c/source/i18n/timezone.cpp @@ -1031,8 +1031,8 @@ TimeZone::getEquivalentID(const UnicodeString& id, int32_t index) { UResourceBundle *ares = ures_getByKey(top, kNAMES, NULL, &ec); // dereference Zones section if (U_SUCCESS(ec)) { int32_t idLen = 0; - const UChar* id = ures_getStringByIndex(ares, zone, &idLen, &ec); - result.fastCopyFrom(UnicodeString(TRUE, id, idLen)); + const UChar* id2 = ures_getStringByIndex(ares, zone, &idLen, &ec); + result.fastCopyFrom(UnicodeString(TRUE, id2, idLen)); U_DEBUG_TZ_MSG(("gei(%d) -> %d, len%d, %s\n", index, zone, result.length(), u_errorName(ec))); } ures_close(ares); @@ -1199,7 +1199,7 @@ TimeZone::getDisplayName(UBool daylight, EDisplayType style, const Locale& local { UErrorCode status = U_ZERO_ERROR; UDate date = Calendar::getNow(); - UTimeZoneFormatTimeType timeType; + UTimeZoneFormatTimeType timeType = UTZFMT_TIME_TYPE_UNKNOWN; int32_t offset; if (style == GENERIC_LOCATION || style == LONG_GENERIC || style == SHORT_GENERIC) { @@ -1612,7 +1612,7 @@ TimeZone::getWindowsID(const UnicodeString& id, UnicodeString& winid, UErrorCode end = tzids + len; hasNext = FALSE; } - if (canonicalID.compare(start, end - start) == 0) { + if (canonicalID.compare(start, static_cast(end - start)) == 0) { winid = UnicodeString(ures_getKey(winzone), -1 , US_INV); found = TRUE; break; @@ -1673,7 +1673,7 @@ TimeZone::getIDForWindowsID(const UnicodeString& winid, const char* region, Unic if (end == NULL) { id.setTo(tzids, -1); } else { - id.setTo(tzids, end - tzids); + id.setTo(tzids, static_cast(end - tzids)); } gotID = TRUE; } diff --git a/icu4c/source/i18n/transreg.cpp b/icu4c/source/i18n/transreg.cpp index 36dcebe987d..1a96ad367f2 100644 --- a/icu4c/source/i18n/transreg.cpp +++ b/icu4c/source/i18n/transreg.cpp @@ -1330,12 +1330,12 @@ Transliterator* TransliteratorRegistry::instantiateEntry(const UnicodeString& ID int32_t passNumber = 1; for (int32_t i = 0; U_SUCCESS(status) && i < entry->u.dataVector->size(); i++) { // TODO: Should passNumber be turned into a decimal-string representation (1 -> "1")? - Transliterator* t = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + UnicodeString(passNumber++), + Transliterator* tl = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + UnicodeString(passNumber++), (TransliterationRuleData*)(entry->u.dataVector->elementAt(i)), FALSE); - if (t == 0) + if (tl == 0) status = U_MEMORY_ALLOCATION_ERROR; else - rbts->addElement(t, status); + rbts->addElement(tl, status); } if (U_FAILURE(status)) { delete rbts; diff --git a/icu4c/source/i18n/tzfmt.cpp b/icu4c/source/i18n/tzfmt.cpp index 3de84f42940..769977a3e31 100644 --- a/icu4c/source/i18n/tzfmt.cpp +++ b/icu4c/source/i18n/tzfmt.cpp @@ -2648,12 +2648,12 @@ TimeZoneFormat::checkAbuttingHoursAndMinutes() { UVector *items = fGMTOffsetPatternItems[type]; for (int32_t i = 0; i < items->size(); i++) { const GMTOffsetField* item = (GMTOffsetField*)items->elementAt(i); - GMTOffsetField::FieldType type = item->getType(); - if (type != GMTOffsetField::TEXT) { + GMTOffsetField::FieldType fieldType = item->getType(); + if (fieldType != GMTOffsetField::TEXT) { if (afterH) { fAbuttingOffsetHoursAndMinutes = TRUE; break; - } else if (type == GMTOffsetField::HOUR) { + } else if (fieldType == GMTOffsetField::HOUR) { afterH = TRUE; } } else if (afterH) { diff --git a/icu4c/source/i18n/tzgnames.cpp b/icu4c/source/i18n/tzgnames.cpp index c2e685272e9..5f5b7db3022 100644 --- a/icu4c/source/i18n/tzgnames.cpp +++ b/icu4c/source/i18n/tzgnames.cpp @@ -407,7 +407,7 @@ TZGNCore::initialize(const Locale& locale, UErrorCode& status) { // target region const char* region = fLocale.getCountry(); - int32_t regionLen = uprv_strlen(region); + int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { char loc[ULOC_FULLNAME_CAPACITY]; uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); diff --git a/icu4c/source/i18n/tznames.cpp b/icu4c/source/i18n/tznames.cpp index 689fdeb0915..5a79c22aacf 100644 --- a/icu4c/source/i18n/tznames.cpp +++ b/icu4c/source/i18n/tznames.cpp @@ -87,7 +87,7 @@ static void sweepCache() { const UHashElement* elem; double now = (double)uprv_getUTCtime(); - while ((elem = uhash_nextElement(gTimeZoneNamesCache, &pos))) { + while ((elem = uhash_nextElement(gTimeZoneNamesCache, &pos)) != 0) { TimeZoneNamesCacheEntry *entry = (TimeZoneNamesCacheEntry *)elem->value.pointer; if (entry->refCount <= 0 && (now - entry->lastAccess) > CACHE_EXPIRATION) { // delete this entry diff --git a/icu4c/source/i18n/tznames_impl.cpp b/icu4c/source/i18n/tznames_impl.cpp index 7045f099516..7bfbc04e180 100644 --- a/icu4c/source/i18n/tznames_impl.cpp +++ b/icu4c/source/i18n/tznames_impl.cpp @@ -1285,7 +1285,7 @@ static void mergeTimeZoneKey(const UnicodeString& mzID, char* result) { char mzIdChar[ZID_KEY_MAX + 1]; int32_t keyLen; - int32_t prefixLen = uprv_strlen(gMZPrefix); + int32_t prefixLen = static_cast(uprv_strlen(gMZPrefix)); keyLen = mzID.extract(0, mzID.length(), mzIdChar, ZID_KEY_MAX + 1, US_INV); uprv_memcpy((void *)result, (void *)gMZPrefix, prefixLen); uprv_memcpy((void *)(result + prefixLen), (void *)mzIdChar, keyLen); @@ -1453,7 +1453,7 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink { virtual ~ZoneStringsLoader(); void* createKey(const char* key, UErrorCode& status) { - int32_t len = sizeof(char) * (uprv_strlen(key) + 1); + int32_t len = sizeof(char) * (static_cast(uprv_strlen(key)) + 1); char* newKey = (char*) uprv_malloc(len); if (newKey == NULL) { status = U_MEMORY_ALLOCATION_ERROR; @@ -1469,7 +1469,7 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink { } UnicodeString mzIDFromKey(const char* key) { - return UnicodeString(key + MZ_PREFIX_LEN, uprv_strlen(key) - MZ_PREFIX_LEN, US_INV); + return UnicodeString(key + MZ_PREFIX_LEN, static_cast(uprv_strlen(key)) - MZ_PREFIX_LEN, US_INV); } UnicodeString tzIDFromKey(const char* key) { @@ -1944,8 +1944,8 @@ TZDBNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *nod // metazone mapping for "CST" is America_Central, // but if region is one of CN/MO/TW, "CST" is parsed // as metazone China (China Standard Time). - for (int32_t i = 0; i < ninfo->nRegions; i++) { - const char *region = ninfo->parseRegions[i]; + for (int32_t j = 0; j < ninfo->nRegions; j++) { + const char *region = ninfo->parseRegions[j]; if (uprv_strcmp(fRegion, region) == 0) { match = ninfo; matchRegion = TRUE; @@ -2059,7 +2059,7 @@ static void U_CALLCONV prepareFind(UErrorCode &status) { const UnicodeString *mzID; StringEnumeration *mzIDs = TimeZoneNamesImpl::_getAvailableMetaZoneIDs(status); if (U_SUCCESS(status)) { - while ((mzID = mzIDs->snext(status)) && U_SUCCESS(status)) { + while ((mzID = mzIDs->snext(status)) != 0 && U_SUCCESS(status)) { const TZDBNames *names = TZDBTimeZoneNames::getMetaZoneNames(*mzID, status); if (U_FAILURE(status)) { break; @@ -2128,7 +2128,7 @@ TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale) : fLocale(locale) { UBool useWorld = TRUE; const char* region = fLocale.getCountry(); - int32_t regionLen = uprv_strlen(region); + int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { UErrorCode status = U_ZERO_ERROR; char loc[ULOC_FULLNAME_CAPACITY]; diff --git a/icu4c/source/i18n/ucol_res.cpp b/icu4c/source/i18n/ucol_res.cpp index 76975ecc01d..56ed5b3c19c 100644 --- a/icu4c/source/i18n/ucol_res.cpp +++ b/icu4c/source/i18n/ucol_res.cpp @@ -400,11 +400,11 @@ CollationLoader::loadFromData(UErrorCode &errorCode) { // Try to fetch the optional rules string. { UErrorCode internalErrorCode = U_ZERO_ERROR; - int32_t length; - const UChar *s = ures_getStringByKey(data, "Sequence", &length, + int32_t len; + const UChar *s = ures_getStringByKey(data, "Sequence", &len, &internalErrorCode); if(U_SUCCESS(internalErrorCode)) { - t->rules.setTo(TRUE, s, length); + t->rules.setTo(TRUE, s, len); } } @@ -426,10 +426,10 @@ CollationLoader::loadFromData(UErrorCode &errorCode) { LocalUResourceBundlePointer def( ures_getByKeyWithFallback(actualBundle.getAlias(), "collations/default", NULL, &internalErrorCode)); - int32_t length; - const UChar *s = ures_getString(def.getAlias(), &length, &internalErrorCode); - if(U_SUCCESS(internalErrorCode) && length < UPRV_LENGTHOF(defaultType)) { - u_UCharsToChars(s, defaultType, length + 1); + int32_t len; + const UChar *s = ures_getString(def.getAlias(), &len, &internalErrorCode); + if(U_SUCCESS(internalErrorCode) && len < UPRV_LENGTHOF(defaultType)) { + u_UCharsToChars(s, defaultType, len + 1); } else { uprv_strcpy(defaultType, "standard"); } diff --git a/icu4c/source/i18n/udat.cpp b/icu4c/source/i18n/udat.cpp index 5e06dd6d069..b47e3219885 100644 --- a/icu4c/source/i18n/udat.cpp +++ b/icu4c/source/i18n/udat.cpp @@ -603,7 +603,7 @@ udat_getSymbols(const UDateFormat *fmt, } else { return -1; } - int32_t count; + int32_t count = 0; const UnicodeString *res = NULL; switch(type) { diff --git a/icu4c/source/i18n/ulocdata.cpp b/icu4c/source/i18n/ulocdata.cpp index d406b8e8c37..7f4e7b9b116 100644 --- a/icu4c/source/i18n/ulocdata.cpp +++ b/icu4c/source/i18n/ulocdata.cpp @@ -372,7 +372,7 @@ ulocdata_getLocaleSeparator(ULocaleData *uld, p1=u_strstr(separator, sub1); if (p0!=NULL && p1!=NULL && p0<=p1) { separator = (const UChar *)p0 + subLen; - len = p1 - separator; + len = static_cast(p1 - separator); /* Desired separator is no longer zero-terminated; handle that if necessary */ if (len < resultCapacity) { u_strncpy(result, separator, len); diff --git a/icu4c/source/i18n/unicode/measfmt.h b/icu4c/source/i18n/unicode/measfmt.h index 5e702692824..3167a76c33a 100644 --- a/icu4c/source/i18n/unicode/measfmt.h +++ b/icu4c/source/i18n/unicode/measfmt.h @@ -348,7 +348,7 @@ class U_I18N_API MeasureFormat : public Format { const MeasureFormatCacheData *cache; const SharedNumberFormat *numberFormat; const SharedPluralRules *pluralRules; - UMeasureFormatWidth width; + UMeasureFormatWidth fWidth; // Declared outside of MeasureFormatSharedData because ListFormatter // objects are relatively cheap to copy; therefore, they don't need to be diff --git a/icu4c/source/i18n/unicode/rbnf.h b/icu4c/source/i18n/unicode/rbnf.h index 8bdbe96bee4..df234cea040 100644 --- a/icu4c/source/i18n/unicode/rbnf.h +++ b/icu4c/source/i18n/unicode/rbnf.h @@ -1094,7 +1094,7 @@ private: void format(double number, NFRuleSet& rs, UnicodeString& toAppendTo, UErrorCode& status) const; private: - NFRuleSet **ruleSets; + NFRuleSet **fRuleSets; UnicodeString* ruleSetDescriptions; int32_t numRuleSets; NFRuleSet *defaultRuleSet; @@ -1103,7 +1103,7 @@ private: DecimalFormatSymbols* decimalFormatSymbols; NFRule *defaultInfinityRule; NFRule *defaultNaNRule; - ERoundingMode roundingMode; + ERoundingMode fRoundingMode; UBool lenient; UnicodeString* lenientParseRules; LocalizationInfo* localizations; diff --git a/icu4c/source/i18n/unicode/region.h b/icu4c/source/i18n/unicode/region.h index 80b2929e9f0..4014025f6f2 100644 --- a/icu4c/source/i18n/unicode/region.h +++ b/icu4c/source/i18n/unicode/region.h @@ -192,7 +192,7 @@ private: char id[4]; UnicodeString idStr; int32_t code; - URegionType type; + URegionType fType; Region *containingRegion; UVector *containedRegions; UVector *preferredValues; diff --git a/icu4c/source/i18n/uregex.cpp b/icu4c/source/i18n/uregex.cpp index 12f36894d71..9a189a32871 100644 --- a/icu4c/source/i18n/uregex.cpp +++ b/icu4c/source/i18n/uregex.cpp @@ -1654,8 +1654,8 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp, } else if (UTEXT_USES_U16(m->fInputText)) { srcIdx = (int32_t)nativeIdx; } else { - UErrorCode status = U_ZERO_ERROR; - srcIdx = utext_extract(m->fInputText, 0, nativeIdx, NULL, 0, &status); + UErrorCode newStatus = U_ZERO_ERROR; + srcIdx = utext_extract(m->fInputText, 0, nativeIdx, NULL, 0, &newStatus); } for (;;) { diff --git a/icu4c/source/i18n/usearch.cpp b/icu4c/source/i18n/usearch.cpp index 645db01ecb1..4f758bac515 100644 --- a/icu4c/source/i18n/usearch.cpp +++ b/icu4c/source/i18n/usearch.cpp @@ -498,7 +498,7 @@ inline void setShiftTable(int16_t shift[], int16_t backshift[], for (count = 0; count < cesize; count ++) { // number of ces from right of array to the count int temp = defaultforward - count - 1; - shift[hashFromCE32(cetable[count])] = temp > 1 ? temp : 1; + shift[hashFromCE32(cetable[count])] = temp > 1 ? static_cast(temp) : 1; } shift[hashFromCE32(cetable[cesize])] = 1; // for ignorables we just shift by one. see test examples. diff --git a/icu4c/source/i18n/vtzone.cpp b/icu4c/source/i18n/vtzone.cpp index 6ddcf4117d1..cb84c6260f6 100644 --- a/icu4c/source/i18n/vtzone.cpp +++ b/icu4c/source/i18n/vtzone.cpp @@ -135,7 +135,7 @@ static UnicodeString& appendAsciiDigits(int32_t number, uint8_t length, UnicodeS digits[i++] = number % 10; number /= 10; } while (number != 0); - length = i; + length = static_cast(i); } else { // fixed digits for (i = 0; i < length; i++) { diff --git a/icu4c/source/i18n/zonemeta.cpp b/icu4c/source/i18n/zonemeta.cpp index 02562048a52..b7139a807b3 100644 --- a/icu4c/source/i18n/zonemeta.cpp +++ b/icu4c/source/i18n/zonemeta.cpp @@ -319,10 +319,10 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) { id[len] = (char) 0; // Make sure it is null terminated. // replace '/' with ':' - char *p = id; - while (*p++) { - if (*p == '/') { - *p = ':'; + char *q = id; + while (*q++) { + if (*q == '/') { + *q = ':'; } } @@ -850,13 +850,13 @@ ZoneMeta::createCustomTimeZone(int32_t offset) { negative = TRUE; tmp = -offset; } - int32_t hour, min, sec; + uint8_t hour, min, sec; tmp /= 1000; - sec = tmp % 60; + sec = static_cast(tmp % 60); tmp /= 60; - min = tmp % 60; - hour = tmp / 60; + min = static_cast(tmp % 60); + hour = static_cast(tmp / 60); UnicodeString zid; formatCustomID(hour, min, sec, negative, zid);