Cleaned up all of the MSVC W3 warnings and most of the W4 warnings in the common and i18n projects.
bmpBlockBits[i]|=bits;
}
- mask=~(0x10001<<0xd); // Lead byte 0xED.
+ mask= static_cast<uint32_t>(~(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<uint32_t>(~(0x10001<<0xd)); // Lead byte 0xED.
for(i=32; i<64; ++i) { // Second half of 4k block.
bmpBlockBits[i]&=mask;
}
return *this;
}
if(sLength<0) {
- sLength=uprv_strlen(s);
+ sLength= static_cast<int32_t>(uprv_strlen(s));
}
if(sLength>0) {
if(s==(buffer.getAlias()+len)) {
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\allinone\Build.Windows.ProjectConfiguration.props" />
-
<PropertyGroup Label="Globals">
<ProjectGuid>{73C0A65B-D1F2-4DE1-B3A6-15DAD2C23F3D}</ProjectGuid>
</PropertyGroup>
<Import Project="$(SolutionDir)\Windows.CopyUnicodeHeaderFiles.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
// 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;
}
}
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;
}
}
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;
}
}
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;
}
}
// 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) {
// 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) {
}
void *temp=uhash_get(cache, name);
if(temp==NULL) {
- int32_t keyLength=uprv_strlen(name)+1;
+ int32_t keyLength= static_cast<int32_t>(uprv_strlen(name)+1);
char *nameCopy=(char *)uprv_malloc(keyLength);
if(nameCopy==NULL) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
}
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;
}
}
: path(NULL), locale(Locale::getRoot())
{
if (path) {
- int32_t len = uprv_strlen(path);
+ int32_t len = static_cast<int32_t>(uprv_strlen(path));
this->path = (const char*) uprv_malloc(len + 1);
if (this->path) {
uprv_strcpy((char *)this->path, path);
}
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;
resultRemainder.findAndReplace(formatOpenParen, formatReplaceOpenParen);
resultRemainder.findAndReplace(formatCloseParen, formatReplaceCloseParen);
- LocalPointer<StringEnumeration> e(locale.createKeywords(status));
+ LocalPointer<StringEnumeration> 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;
}
/* 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++;
int32_t
Locale::hashCode() const
{
- return ustr_hashCharsN(fullName, uprv_strlen(fullName));
+ return ustr_hashCharsN(fullName, static_cast<int32_t>(uprv_strlen(fullName)));
}
void
}
} 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);
}
}
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];
-
- 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;
+ minDecompNoCP = static_cast<UChar>(inIndexes[IX_MIN_DECOMP_NO_CP]);
+ minCompNoMaybeCP = static_cast<UChar>(inIndexes[IX_MIN_COMP_NO_MAYBE_CP]);
+ minLcccCP = static_cast<UChar>(inIndexes[IX_MIN_LCCC_CP]);
+
+ minYesNo = static_cast<uint16_t>(inIndexes[IX_MIN_YES_NO]);
+ minYesNoMappingsOnly = static_cast<uint16_t>(inIndexes[IX_MIN_YES_NO_MAPPINGS_ONLY]);
+ minNoNo = static_cast<uint16_t>(inIndexes[IX_MIN_NO_NO]);
+ minNoNoCompBoundaryBefore = static_cast<uint16_t>(inIndexes[IX_MIN_NO_NO_COMP_BOUNDARY_BEFORE]);
+ minNoNoCompNoMaybeCC = static_cast<uint16_t>(inIndexes[IX_MIN_NO_NO_COMP_NO_MAYBE_CC]);
+ minNoNoEmpty = static_cast<uint16_t>(inIndexes[IX_MIN_NO_NO_EMPTY]);
+ limitNoNo = static_cast<uint16_t>(inIndexes[IX_LIMIT_NO_NO]);
+ minMaybeYes = static_cast<uint16_t>(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;
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);
}
}
// 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<int32_t>(utext_getNativeIndex(&fText));
UErrorCode status = U_ZERO_ERROR;
fBreakCache->preceding(adjustedOffset, status);
// 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<int32_t>(utext_getNativeIndex(&fText));
bool result = false;
UErrorCode status = U_ZERO_ERROR;
#ifdef RBBI_DEBUG
if (gTrace) {
- RBBIDebugPrintf(" %4ld ", utext_getNativeIndex(&fText));
+ RBBIDebugPrintf(" %4lld ", utext_getNativeIndex(&fText));
if (0x20<=c && c<0x7f) {
RBBIDebugPrintf("\"%c\" ", c);
} else {
fStartBufIdx = modChunkSize(fStartBufIdx + 6); // TODO: experiment. Probably revert to 1.
}
fBoundaries[nextIdx] = position;
- fStatuses[nextIdx] = ruleStatusIdx;
+ fStatuses[nextIdx] = static_cast<uint16_t>(ruleStatusIdx);
fEndBufIdx = nextIdx;
if (update == UpdateCachePosition) {
// Set current position to the newly added boundary.
fEndBufIdx = modChunkSize(fEndBufIdx - 1);
}
fBoundaries[nextIdx] = position;
- fStatuses[nextIdx] = ruleStatusIdx;
+ fStatuses[nextIdx] = static_cast<uint16_t>(ruleStatusIdx);
fStartBufIdx = nextIdx;
if (update == UpdateCachePosition) {
fBufIdx = nextIdx;
// 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)) {
addRuleRootNodes(&ruleRootNodes, tree);
UVector matchStartNodes(*fStatus);
- for (int i=0; i<ruleRootNodes.size(); ++i) {
- RBBINode *node = static_cast<RBBINode *>(ruleRootNodes.elementAt(i));
+ for (int j=0; j<ruleRootNodes.size(); ++j) {
+ RBBINode *node = static_cast<RBBINode *>(ruleRootNodes.elementAt(j));
if (node->fChainIn) {
setAdd(&matchStartNodes, node->fFirstPosSet);
}
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; state<numStates; state++) {
- RBBIStateDescriptor *sd = (RBBIStateDescriptor *)fDStates->elementAt(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; state<numStates; state++) {
+ RBBIStateDescriptor *sd = (RBBIStateDescriptor *)fDStates->elementAt(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;
} else if (existingVal > duplState) {
newVal = existingVal - 1;
}
- sd->setCharAt(col, newVal);
+ sd->setCharAt(col, static_cast<char16_t>(newVal));
}
}
}
UnicodeString &startState = *static_cast<UnicodeString *>(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<char16_t>(charClass+2));
}
// Initially make every other state table row look like the start state row,
}
// 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);
return newNode;
}
-UBool
+int32_t
StringTrieBuilder::hashNode(const void *node) {
return ((const Node *)node)->hashCode();
}
pBiDi->paras[pBiDi->paraCount-1].level=1;
}
if(isDefaultLevel) {
- pBiDi->paraLevel=pBiDi->paras[0].level;
+ pBiDi->paraLevel=static_cast<UBiDiLevel>(pBiDi->paras[0].level);
}
/* The following is needed to resolve the text direction for default level
paragraphs containing no strong character */
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<DirProp>(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<DirProp>(pOpening->contextDir); /* N0c1 */
else
- newProp=direction; /* N0c2 */
+ newProp= static_cast<DirProp>(direction); /* N0c2 */
} else {
/* forget this and any brackets nested within this pair */
- pLastIsoRun->limit=openIdx;
- return ON; /* N0d */
+ pLastIsoRun->limit= static_cast<uint16_t>(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<uint16_t>(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)
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<UChar>(u_getBidiPairedBracket(c)); /* get the matching char */
else
match=0;
if(match!=c && /* has a matching char */
pLastIsoRun->contextPos=position;
}
else if(dirProp<=R || dirProp==AL) {
- newProp=DIR_FROM_STRONG(dirProp);
+ newProp= static_cast<DirProp>(DIR_FROM_STRONG(dirProp));
pLastIsoRun->lastBase=dirProp;
pLastIsoRun->lastStrong=dirProp;
pLastIsoRun->contextDir=(UBiDiDirection)newProp;
else
start=pBiDi->paras[paraIndex-1].limit;
limit=pBiDi->paras[paraIndex].limit;
- level=pBiDi->paras[paraIndex].level;
+ level= static_cast<UBiDiLevel>(pBiDi->paras[paraIndex].level);
for(i=start; i<limit; i++)
levels[i]=level;
}
else
start=pBiDi->paras[paraIndex-1].limit;
limit=pBiDi->paras[paraIndex].limit;
- level=pBiDi->paras[paraIndex].level;
+ level= static_cast<UBiDiLevel>(pBiDi->paras[paraIndex].level);
for(i=start; i<limit; i++) {
levels[i]=level;
dirProp=dirProps[i];
DirProp dirProp;
for(i=0; i<pBiDi->paraCount; i++) {
last=(pBiDi->paras[i].limit)-1;
- level=pBiDi->paras[i].level;
+ level= static_cast<UBiDiLevel>(pBiDi->paras[i].level);
if(level==0)
continue; /* LTR paragraph */
start= i==0 ? 0 : pBiDi->paras[i-1].limit;
action_reorder(UBiDiTransform *pTransform, UErrorCode *pErrorCode)
{
ubidi_writeReordered(pTransform->pBidi, pTransform->dest, pTransform->destSize,
- pTransform->reorderingOptions, pErrorCode);
+ static_cast<uint16_t>(pTransform->reorderingOptions), pErrorCode);
*pTransform->pDestLength = pTransform->srcLength;
pTransform->reorderingOptions = UBIDI_REORDER_DEFAULT;
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<UBiDiLevel>(ubidi_getBaseDirection(text, length));
+ *pInLevel = static_cast<UBiDiLevel>(level != UBIDI_NEUTRAL) ? level
+ : *pInLevel == UBIDI_DEFAULT_RTL ? static_cast<UBiDiLevel>(RTL) : static_cast<UBiDiLevel>(LTR);
break;
}
default:
/* 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<UChar>(0x10000 | (mySourceChar << 8) | trailByte);
}
} else {
args->converter->toUBytes[0] = (uint8_t)mySourceChar;
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<uint8_t>(mySourceChar);
args->converter->toULength = 1;
args->target = myTarget;
args->source = mySource;
static int32_t findNextEsc(const char *source, const char *sourceLimit) {
- int32_t length = sourceLimit - source;
+ int32_t length = static_cast<int32_t>(sourceLimit - source);
int32_t i;
for (i = 1; i < length; i++) {
if (*(source + i) == 0x1B) {
/* 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,
/* 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,
/* 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,
/* 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,
/* 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,
/* 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,
_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,
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 */
if (mySource < sourceLimit)
{
toUBytes[i] = (char) (ch2 = *mySource);
- if (!icu::UTF8::isValidTrail(ch, ch2, i, inBytes) &&
+ if (!icu::UTF8::isValidTrail(ch, static_cast<uint8_t>(ch2), i, inBytes) &&
!(isCESU8 && i == 1 && ch == 0xed && U8_IS_TRAIL(ch2)))
{
break; /* i < inBytes */
if (mySource < sourceLimit)
{
toUBytes[i] = (char) (ch2 = *mySource);
- if (!icu::UTF8::isValidTrail(ch, ch2, i, inBytes) &&
+ if (!icu::UTF8::isValidTrail(ch, static_cast<uint8_t>(ch2), i, inBytes) &&
!(isCESU8 && i == 1 && ch == 0xed && U8_IS_TRAIL(ch2)))
{
break; /* i < inBytes */
*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<uint8_t>(mySourceChar);
args->converter->toULength = 2;
args->target = myTarget;
args->source = mySource;
--mySource;
} else {
/* Include the current byte in the illegal sequence. */
- args->converter->toUBytes[1] = mySourceChar;
+ args->converter->toUBytes[1] = static_cast<uint8_t>(mySourceChar);
args->converter->toULength = 2;
}
args->target = myTarget;
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<uint8_t>(getSISOBytes(SI, cnv->options, siBytes));
+ soLength = static_cast<uint8_t>(getSISOBytes(SO, cnv->options, soBytes));
/* conversion loop */
/*
// 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<uint32_t>(~0), static_cast<uint32_t>(~0), status);
}
for (int32_t i = 0; i < result->encodingsCount; ++i) {
// 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<uint32_t>(~0), mask,
status);
}
}
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<uint32_t>(~0), static_cast<uint32_t>(~0),
status);
}
}
ent &= ent - 1; // clear the least significant bit set
}
}
- return totalOnes;
+ return static_cast<int16_t>(totalOnes);
}
}
// 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; i<n; ++i) {
- UResourceBundle* names = ures_getByIndex(curr_p, i, NULL, &ec3);
+ UResourceBundle* names = ures_getByIndex(curr_p, i, NULL, &ec5);
iso = (char*)ures_getKey(names);
// Using hash to remove duplicated ISO codes in fallback chain.
if (localeLevel == 0) {
for (int32_t j = 0; j < num; ++j) {
// TODO: remove duplicates between singular name and
// currency long name?
- s = ures_getStringByIndex(names, j, &len, &ec3);
+ s = ures_getStringByIndex(names, j, &len, &ec5);
(*currencyNames)[*total_currency_name_count].IsoCode = iso;
UChar* upperName = toUpperCase(s, len, locale);
(*currencyNames)[*total_currency_name_count].currencyName = upperName;
umtx_lock(&gCurrencyCacheMutex);
// in order to handle racing correctly,
// not putting 'search' in a separate function.
- int8_t found = -1;
+ 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) {
}
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) {
U_ASSERT(primeIndex >= 0 && primeIndex < PRIMES_LENGTH);
- hash->primeIndex = primeIndex;
+ hash->primeIndex = static_cast<int8_t>(primeIndex);
hash->length = PRIMES[primeIndex];
p = hash->elements = (UHashElement*)
U_CAPI int32_t U_EXPORT2
uhash_hashChars(const UHashTok key) {
const char *s = (const char *)key.pointer;
- return s == NULL ? 0 : static_cast<int32_t>(ustr_hashCharsN(s, uprv_strlen(s)));
+ return s == NULL ? 0 : static_cast<int32_t>(ustr_hashCharsN(s, static_cast<int32_t>(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<int32_t>(uprv_strlen(s)));
}
U_CAPI UBool U_EXPORT2
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<int32_t>(keyValueTail-nextEqualsign), *status);
}
if (!nextSeparator && keywordValueLen > 0 && !handledInputKeyAndValue) {
/* append new entry at the end, it sorts later than existing entries */
}
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;
/* 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<int32_t>(((t+1)-s));
if(slen > ULOC_FULLNAME_CAPACITY) {
*status = U_BUFFER_OVERFLOW_ERROR;
return -1; // too big
// 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<int32_t>(uprv_strlen(legacyTypeId));
char* legacyTypeIdBuf = (char*)uprv_malloc(legacyTypeIdLen + 1);
if (legacyTypeIdBuf == NULL) {
sts = U_MEMORY_ALLOCATION_ERROR;
if (isTZ) {
// replace colon with slash if necessary
if (uprv_strchr(from, ':') != NULL) {
- int32_t fromLen = uprv_strlen(from);
+ int32_t fromLen = static_cast<int32_t>(uprv_strlen(from));
char* fromBuf = (char*)uprv_malloc(fromLen + 1);
if (fromBuf == NULL) {
sts = U_MEMORY_ALLOCATION_ERROR;
p++;
}
return (subtagLen == 6);
- return TRUE;
}
U_CFUNC const char*
buffer[--i] = (v < 10 ? '0' + v : 'A' + v - 10);
}
buffer += ndigits;
- length += ndigits;
+ length += static_cast<uint16_t>(ndigits);
WRITE_CHAR(buffer, bufferLength, length, '>');
return length;
* @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;
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 */
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;
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);
}
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:
}
static UBool caseBinaryPropertyContains(const BinaryProperty &/*prop*/, UChar32 c, UProperty which) {
- return ucase_hasBinaryProperty(c, which);
+ return static_cast<UBool>(ucase_hasBinaryProperty(c, which));
}
static UBool isBidiControl(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
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);
}
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 */
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;
class ResourceDataValue : public ResourceValue {
public:
- ResourceDataValue() : pResData(NULL), res(URES_NONE) {}
+ ResourceDataValue() : pResData(NULL), res(static_cast<Resource>(URES_NONE)) {}
virtual ~ResourceDataValue();
void setData(const ResourceData *data) { pResData = data; }
/* 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<UChar>(Shape);
}
}else if ((currLink & APRESENT) > 0) {
dest[i] = (UChar)(0xFB50 + (currLink >> 8) + Shape);
LocalMemory<char> keyName;
LocalMemory<char> keyPath;
if( key.allocateInsteadAndReset() == NULL ||
- keyName.allocateInsteadAndCopy(uprv_strlen(name)+1) == NULL ||
+ keyName.allocateInsteadAndCopy(static_cast<int32_t>(uprv_strlen(name)+1)) == NULL ||
(path != NULL &&
- keyPath.allocateInsteadAndCopy(uprv_strlen(path)+1) == NULL)
+ keyPath.allocateInsteadAndCopy(static_cast<int32_t>(uprv_strlen(path)+1)) == NULL)
) {
*status = U_MEMORY_ALLOCATION_ERROR;
usprep_unload(newProfile.getAlias());
int32_t srcIndex = srcStart;
for (;;) {
// fast path for simple cases
- UChar lead;
+ UChar lead = 0;
while (srcIndex < srcLimit) {
lead = src[srcIndex];
int32_t delta;
continue;
}
}
- lead += delta;
+ lead += static_cast<UChar>(delta);
destIndex = appendUnchanged(dest, destIndex, destCapacity,
src + prev, srcIndex - 1 - prev, options, edits);
if (destIndex >= 0) {
int32_t srcIndex = 0;
for (;;) {
// fast path for simple cases
- UChar lead;
+ UChar lead = 0;
while (srcIndex < srcLength) {
lead = src[srcIndex];
int32_t delta;
continue;
}
}
- lead += delta;
+ lead += static_cast<UChar>(delta);
destIndex = appendUnchanged(dest, destIndex, destCapacity,
src + prev, srcIndex - 1 - prev, options, edits);
if (destIndex >= 0) {
}
if(matchLen1) {
- *matchLen1=m1-org1;
- *matchLen2=m2-org2;
+ *matchLen1=static_cast<int32_t>(m1-org1);
+ *matchLen2=static_cast<int32_t>(m2-org2);
}
return cmpRes;
}
// 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;
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;
// General case, handle everything.
if (seenNonAscii == FALSE) {
seenNonAscii = TRUE;
- u8b->bufNILimit = destIx;
+ u8b_swap->bufNILimit = destIx;
}
int32_t cIx = srcIx;
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.
// 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.
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;
-
- ut->chunkContents = &buf[u8b->bufStartIdx];
- ut->chunkLength = u8b->bufLimitIdx - u8b->bufStartIdx;
+ 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_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;
}
codePointLimit=codePointStart;
if(start>=codePointStart) {
codePoint=U_SENTINEL;
- return trie->errorValue;
+ return static_cast<uint16_t>(trie->errorValue);
}
uint16_t result;
UTRIE2_U16_PREV16(trie, start, codePointStart, codePoint, result);
codePointStart=codePointLimit;
if(codePointLimit==limit) {
codePoint=U_SENTINEL;
- return trie->errorValue;
+ return static_cast<uint16_t>(trie->errorValue);
}
uint16_t result;
UTRIE2_U16_NEXT16(trie, codePointLimit, limit, codePoint, result);
if(highStart<=0x10000) {
trie->index2NullOffset=0xffff;
} else {
- trie->index2NullOffset=UTRIE2_INDEX_2_OFFSET+newTrie->index2NullOffset;
+ trie->index2NullOffset=static_cast<uint16_t>(UTRIE2_INDEX_2_OFFSET+newTrie->index2NullOffset);
}
trie->dataNullOffset=(uint16_t)(dataMove+newTrie->dataNullOffset);
trie->highValueIndex=dataMove+trie->dataLength-UTRIE2_DATA_GRANULARITY;
*/
if (tmpid[0] != 0)
{
- len = uprv_strlen(tmpid);
+ len = static_cast<int32_t>(uprv_strlen(tmpid));
icuid = (char*)uprv_calloc(len + 1, sizeof(char));
if (icuid != NULL)
{
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.
}
// 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);
}
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);
}
}
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<int32_t>(uprv_strlen(left)) : leftLength),
+ StringPiece(right, (rightLength < 0) ? static_cast<int32_t>(uprv_strlen(right)) : rightLength),
errorCode);
}
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);
doubleByteCharCount++;
if (commonChars != 0) {
- if (binarySearch(commonChars, commonCharsLen, iter.charValue) >= 0){
+ if (binarySearch(commonChars, commonCharsLen, static_cast<uint16_t>(iter.charValue)) >= 0){
commonCharCount += 1;
}
}
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;
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));
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) {
UDate now = Calendar::getNow();
UnicodeString tzDispName;
- while ((tzid = tzids->snext(status))) {
+ while ((tzid = tzids->snext(status)) != 0) {
if (U_FAILURE(status)) {
break;
}
++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<UBool>(intVector[0]);
+ fCapitalization[typeMapPtr->usageTypeEnumValue][1] = static_cast<UBool>(intVector[1]);
}
}
}
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);
}
}
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);
}
}
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);
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;
}
}
if ( distance < bestDistance ) {
- bestSkeleton = skeleton;
+ bestSkeleton = newSkeleton;
bestDistance = distance;
bestMatchDistanceInfo = fieldDifference;
}
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();
}
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();
}
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));
}
}
}
<Import Project="$(SolutionDir)\Windows.CopyUnicodeHeaderFiles.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
: cache(NULL),
numberFormat(NULL),
pluralRules(NULL),
- width(w),
+ fWidth(w),
listFormatter(NULL) {
initMeasureFormat(locale, w, NULL, status);
}
: cache(NULL),
numberFormat(NULL),
pluralRules(NULL),
- width(w),
+ fWidth(w),
listFormatter(NULL) {
initMeasureFormat(locale, w, nfToAdopt, status);
}
cache(other.cache),
numberFormat(other.numberFormat),
pluralRules(other.pluralRules),
- width(other.width),
+ fWidth(other.fWidth),
listFormatter(NULL) {
cache->addRef();
numberFormat->addRef();
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);
cache(NULL),
numberFormat(NULL),
pluralRules(NULL),
- width(UMEASFMT_WIDTH_SHORT),
+ fWidth(UMEASFMT_WIDTH_SHORT),
listFormatter(NULL) {
}
// 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.
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) {
}
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) {
return;
}
}
- width = w;
+ fWidth = w;
delete listFormatter;
listFormatter = ListFormatter::createInstance(
locale,
- listStyles[getRegularWidth(width)],
+ listStyles[getRegularWidth(fWidth)],
status);
}
if (U_FAILURE(status) || locale == getLocale(status)) {
return FALSE;
}
- initMeasureFormat(locale, width, NULL, status);
+ initMeasureFormat(locale, fWidth, NULL, status);
return U_SUCCESS(status);
}
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,
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);
}
return appendTo;
break;
}
- return appendTo;
}
static void appendRange(
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(
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;
}
// 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<const ChoiceFormat*>(formatter) ||
dynamic_cast<const PluralFormat*>(formatter) ||
, 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);
}
}
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
- description = rule1->ruleText;
+ description = rule1->fRuleText;
// check the description to see whether there's text enclosed
// in brackets
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) {
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.
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;
return;
}
rulePatternFormat = formatter->createPluralFormat(pluralType,
- this->ruleText.tempSubString(endType + 1, pluralRuleEnd - endType - 1), status);
+ fRuleText.tempSubString(endType + 1, pluralRuleEnd - endType - 1), status);
}
}
// 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
// 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;
}
{
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;
}
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);
}
// 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) {
// 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) {
// [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) {
}
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) {
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);
// 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,
// 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,
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()
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)
{
int32_t radix;
int16_t exponent;
UChar decimalPoint;
- UnicodeString ruleText;
+ UnicodeString fRuleText;
NFSubstitution* sub1;
NFSubstitution* sub2;
const RuleBasedNumberFormat* formatter;
if (fMinGrouping == -2) {
fMinGrouping = getMinGroupingForLocale(locale);
} else if (fMinGrouping == -3) {
- fMinGrouping = uprv_max(2, getMinGroupingForLocale(locale));
+ fMinGrouping = static_cast<int16_t>(uprv_max(2, getMinGroupingForLocale(locale)));
} else {
// leave fMinGrouping alone
}
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 */
UErrorCode& status) const U_OVERRIDE;
private:
- Scale multiplier;
- const MicroPropsGenerator *parent;
+ Scale fMultiplier;
+ const MicroPropsGenerator *fParent;
};
: 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;
}
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.
}
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);
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);
}
}
/** 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<MutablePatternModifier*>(this);
// 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);
}
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,
prefixLen,
rightIndex + overwriteLen + prefixLen,
suffixLen,
- *symbols,
+ *fSymbols,
status);
return prefixLen + overwriteLen + suffixLen;
}
/** 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:
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;
// Pre-32bit second transitions
ures_getByKey(res, kTRANSPRE32, &r, &ec);
transitionTimesPre32 = ures_getIntVector(&r, &len, &ec);
- transitionCountPre32 = len >> 1;
+ transitionCountPre32 = static_cast<int16_t>(len >> 1);
if (ec == U_MISSING_RESOURCE_ERROR) {
// No pre-32bit transitions
transitionTimesPre32 = NULL;
// 32bit second transitions
ures_getByKey(res, kTRANS, &r, &ec);
transitionTimes32 = ures_getIntVector(&r, &len, &ec);
- transitionCount32 = len;
+ transitionCount32 = static_cast<int16_t>(len);
if (ec == U_MISSING_RESOURCE_ERROR) {
// No 32bit transitions
transitionTimes32 = NULL;
// Post-32bit second transitions
ures_getByKey(res, kTRANSPOST32, &r, &ec);
transitionTimesPost32 = ures_getIntVector(&r, &len, &ec);
- transitionCountPost32 = len >> 1;
+ transitionCountPost32 = static_cast<int16_t>(len >> 1);
if (ec == U_MISSING_RESOURCE_ERROR) {
// No pre-32bit transitions
transitionTimesPost32 = NULL;
// 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) {
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)
, decimalFormatSymbols(NULL)
, defaultInfinityRule(NULL)
, defaultNaNRule(NULL)
- , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
+ , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
, lenient(FALSE)
, lenientParseRules(NULL)
, localizations(NULL)
RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
const UnicodeString& locs,
UParseError& perror, UErrorCode& status)
- : ruleSets(NULL)
+ : fRuleSets(NULL)
, ruleSetDescriptions(NULL)
, numRuleSets(0)
, defaultRuleSet(NULL)
, decimalFormatSymbols(NULL)
, defaultInfinityRule(NULL)
, defaultNaNRule(NULL)
- , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
+ , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
, lenient(FALSE)
, lenientParseRules(NULL)
, localizations(NULL)
RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
LocalizationInfo* info,
const Locale& alocale, UParseError& perror, UErrorCode& status)
- : ruleSets(NULL)
+ : fRuleSets(NULL)
, ruleSetDescriptions(NULL)
, numRuleSets(0)
, defaultRuleSet(NULL)
, decimalFormatSymbols(NULL)
, defaultInfinityRule(NULL)
, defaultNaNRule(NULL)
- , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
+ , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
, lenient(FALSE)
, lenientParseRules(NULL)
, localizations(NULL)
RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
UParseError& perror,
UErrorCode& status)
- : ruleSets(NULL)
+ : fRuleSets(NULL)
, ruleSetDescriptions(NULL)
, numRuleSets(0)
, defaultRuleSet(NULL)
, decimalFormatSymbols(NULL)
, defaultInfinityRule(NULL)
, defaultNaNRule(NULL)
- , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
+ , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
, lenient(FALSE)
, lenientParseRules(NULL)
, localizations(NULL)
const Locale& aLocale,
UParseError& perror,
UErrorCode& status)
- : ruleSets(NULL)
+ : fRuleSets(NULL)
, ruleSetDescriptions(NULL)
, numRuleSets(0)
, defaultRuleSet(NULL)
, decimalFormatSymbols(NULL)
, defaultInfinityRule(NULL)
, defaultNaNRule(NULL)
- , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
+ , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
, lenient(FALSE)
, lenientParseRules(NULL)
, localizations(NULL)
}
RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& alocale, UErrorCode& status)
- : ruleSets(NULL)
+ : fRuleSets(NULL)
, ruleSetDescriptions(NULL)
, numRuleSets(0)
, defaultRuleSet(NULL)
, decimalFormatSymbols(NULL)
, defaultInfinityRule(NULL)
, defaultNaNRule(NULL)
- , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
+ , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
, lenient(FALSE)
, lenientParseRules(NULL)
, localizations(NULL)
RuleBasedNumberFormat::RuleBasedNumberFormat(const RuleBasedNumberFormat& rhs)
: NumberFormat(rhs)
- , ruleSets(NULL)
+ , fRuleSets(NULL)
, ruleSetDescriptions(NULL)
, numRuleSets(0)
, defaultRuleSet(NULL)
, decimalFormatSymbols(NULL)
, defaultInfinityRule(NULL)
, defaultNaNRule(NULL)
- , roundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
+ , fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
, lenient(FALSE)
, lenientParseRules(NULL)
, localizations(NULL)
? 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) {
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);
}
}
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) {
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;
}
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;
Formattable& result,
ParsePosition& parsePosition) const
{
- if (!ruleSets) {
+ if (!fRuleSets) {
parsePosition.setErrorIndex(0);
return;
}
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);
RuleBasedNumberFormat::initDefaultRuleSet()
{
defaultRuleSet = NULL;
- if (!ruleSets) {
+ if (!fRuleSets) {
return;
}
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;
defaultRuleSet = *--p;
if (!defaultRuleSet->isPublic()) {
- while (p != ruleSets) {
+ while (p != fRuleSets) {
if ((*--p)->isPublic()) {
defaultRuleSet = *p;
break;
++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
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;
}
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;
}
// 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);
}
}
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;
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<UBool>(intVector[0]);
+ capitalizationForStandAlone = static_cast<UBool>(intVector[1]);
}
}
ures_close(rb);
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) {
RuleBasedNumberFormat::getCollator() const
{
#if !UCONFIG_NO_COLLATION
- if (!ruleSets) {
+ if (!fRuleSets) {
return NULL;
}
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);
}
}
}
* @return A rounding mode
*/
DecimalFormat::ERoundingMode RuleBasedNumberFormat::getRoundingMode() const {
- return roundingMode;
+ return fRoundingMode;
}
/**
* @param roundingMode A rounding mode
*/
void RuleBasedNumberFormat::setRoundingMode(DecimalFormat::ERoundingMode roundingMode) {
- this->roundingMode = roundingMode;
+ fRoundingMode = roundingMode;
}
U_NAMESPACE_END
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;
}
}
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) {
}
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
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;
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;
}
} else {
aliasFromRegion->code = -1;
}
- aliasFromRegion->type = URGN_DEPRECATED;
+ aliasFromRegion->fType = URGN_DEPRECATED;
} else {
- aliasFromRegion->type = URGN_DEPRECATED;
+ aliasFromRegion->fType = URGN_DEPRECATED;
}
{
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;
}
}
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.
// 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;
}
}
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<UVector> newAr(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status);
- availableRegions[ar->type] = newAr.orphan();
+ availableRegions[ar->fType] = newAr.orphan();
}
LocalPointer<UnicodeString> 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);
Region::Region ()
: code(-1),
- type(URGN_UNKNOWN),
+ fType(URGN_UNKNOWN),
containingRegion(NULL),
containedRegions(NULL),
preferredValues(NULL) {
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);
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);
return NULL;
}
- return ( containingRegion->type == type )? containingRegion: containingRegion->getContainingRegion(type);
+ return ( containingRegion->fType == type)? containingRegion: containingRegion->getContainingRegion(type);
}
/**
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);
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);
*/
URegionType
Region::getType() const {
- return type;
+ return fType;
}
RegionNameEnumeration::RegionNameEnumeration(UVector *fNameList, UErrorCode& status) {
// Utility functions
static UDateRelativeDateTimeFormatterStyle styleFromString(const char *s) {
- int32_t len = uprv_strlen(s);
+ int32_t len = static_cast<int32_t>(uprv_strlen(s));
if (len >= 7 && uprv_strcmp(s + len - 7, "-narrow") == 0) {
return UDAT_STYLE_NARROW;
}
consumeAlias(key, value, errorCode);
} else {
style = styleFromString(key);
- int32_t unitSize = uprv_strlen(key) - styleSuffixLength(style);
+ int32_t unitSize = static_cast<int32_t>(uprv_strlen(key)) - styleSuffixLength(style);
genericUnit = unitOrNegativeFromString(key, unitSize);
if (style >= 0 && genericUnit != INVALID_UNIT) {
consumeTimeUnit(key, value, errorCode);
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;
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<UBool>(intVector[0]);
+ fCapitalizationOfRelativeUnitsForStandAlone = static_cast<UBool>(intVector[1]);
}
}
#endif
case START_LINE:
{
- UChar32 c;
+ UChar32 ch;
if (startPos == fAnchorStart) {
MatchAt(startPos, FALSE, status);
if (U_FAILURE(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;
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
}
} 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);
}
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
return FALSE;
}
}
- U_ASSERT(FALSE);
+ U_ASSERT(FALSE);
case START_STRING:
case START_CHAR:
case START_LINE:
{
- UChar32 c;
+ UChar32 ch;
if (startPos == fAnchorStart) {
MatchChunkAt(startPos, FALSE, status);
if (U_FAILURE(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;
}
} 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);
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();
// 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)) {
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);
if (newFP == (int64_t *)fp) {
break;
}
- int32_t i;
- for (i=0; i<fFrameSize; i++) {
- newFP[i] = ((int64_t *)fp)[i];
+ int32_t j;
+ for (j=0; j<fFrameSize; j++) {
+ newFP[j] = ((int64_t *)fp)[j];
}
fp = (REStackFrame *)newFP;
fStack->setSize(newStackSize);
// 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; i<fFrameSize; i++) {
- newFP[i] = ((int64_t *)fp)[i];
+ int32_t j;
+ for (j=0; j<fFrameSize; j++) {
+ newFP[j] = ((int64_t *)fp)[j];
}
fp = (REStackFrame *)newFP;
fStack->setSize(newStackSize);
// 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.
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;
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;
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;
if (newFP == (int64_t *)fp) {
break;
}
- int32_t i;
- for (i=0; i<fFrameSize; i++) {
- newFP[i] = ((int64_t *)fp)[i];
+ int32_t j;
+ for (j=0; j<fFrameSize; j++) {
+ newFP[j] = ((int64_t *)fp)[j];
}
fp = (REStackFrame *)newFP;
fStack->setSize(newStackSize);
// 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; i<fFrameSize; i++) {
- newFP[i] = ((int64_t *)fp)[i];
+ int32_t j;
+ for (j=0; j<fFrameSize; j++) {
+ newFP[j] = ((int64_t *)fp)[j];
}
fp = (REStackFrame *)newFP;
fStack->setSize(newStackSize);
// 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.
// 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<int32_t>(uprv_strlen(right)); }
} else {
- if(rightLength >= 0) { leftLength = uprv_strlen(left); }
+ if(rightLength >= 0) { leftLength = static_cast<int32_t>(uprv_strlen(left)); }
}
return doCompare(reinterpret_cast<const uint8_t *>(left), leftLength,
reinterpret_cast<const uint8_t *>(right), rightLength, errorCode);
} 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)) {
icu::ScriptSet *s0 = static_cast<icu::ScriptSet *>(key0.pointer);
icu::ScriptSet *s1 = static_cast<icu::ScriptSet *>(key1.pointer);
int32_t diff = s0->countMembers() - s1->countMembers();
- if (diff != 0) return diff;
+ if (diff != 0) return static_cast<UBool>(diff);
int32_t i0 = s0->nextSetBit(0);
int32_t i1 = s1->nextSetBit(0);
while ((diff = i0-i1) == 0 && i0 > 0) {
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;
}
}
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) {
// 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];
}
}
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)<fPattern.length() &&
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) {
+ 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);
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:
}
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.
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;
}
}
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();
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;
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);
{
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) {
end = tzids + len;
hasNext = FALSE;
}
- if (canonicalID.compare(start, end - start) == 0) {
+ if (canonicalID.compare(start, static_cast<int32_t>(end - start)) == 0) {
winid = UnicodeString(ures_getKey(winzone), -1 , US_INV);
found = TRUE;
break;
if (end == NULL) {
id.setTo(tzids, -1);
} else {
- id.setTo(tzids, end - tzids);
+ id.setTo(tzids, static_cast<int32_t>(end - tzids));
}
gotID = TRUE;
}
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;
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) {
// target region
const char* region = fLocale.getCountry();
- int32_t regionLen = uprv_strlen(region);
+ int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
if (regionLen == 0) {
char loc[ULOC_FULLNAME_CAPACITY];
uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status);
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
char mzIdChar[ZID_KEY_MAX + 1];
int32_t keyLen;
- int32_t prefixLen = uprv_strlen(gMZPrefix);
+ int32_t prefixLen = static_cast<int32_t>(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);
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<int32_t>(uprv_strlen(key)) + 1);
char* newKey = (char*) uprv_malloc(len);
if (newKey == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
}
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<int32_t>(uprv_strlen(key)) - MZ_PREFIX_LEN, US_INV);
}
UnicodeString tzIDFromKey(const char* key) {
// 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;
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;
: fLocale(locale) {
UBool useWorld = TRUE;
const char* region = fLocale.getCountry();
- int32_t regionLen = uprv_strlen(region);
+ int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
if (regionLen == 0) {
UErrorCode status = U_ZERO_ERROR;
char loc[ULOC_FULLNAME_CAPACITY];
// 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);
}
}
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");
}
} else {
return -1;
}
- int32_t count;
+ int32_t count = 0;
const UnicodeString *res = NULL;
switch(type) {
p1=u_strstr(separator, sub1);
if (p0!=NULL && p1!=NULL && p0<=p1) {
separator = (const UChar *)p0 + subLen;
- len = p1 - separator;
+ len = static_cast<int32_t>(p1 - separator);
/* Desired separator is no longer zero-terminated; handle that if necessary */
if (len < resultCapacity) {
u_strncpy(result, separator, len);
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
void format(double number, NFRuleSet& rs, UnicodeString& toAppendTo, UErrorCode& status) const;
private:
- NFRuleSet **ruleSets;
+ NFRuleSet **fRuleSets;
UnicodeString* ruleSetDescriptions;
int32_t numRuleSets;
NFRuleSet *defaultRuleSet;
DecimalFormatSymbols* decimalFormatSymbols;
NFRule *defaultInfinityRule;
NFRule *defaultNaNRule;
- ERoundingMode roundingMode;
+ ERoundingMode fRoundingMode;
UBool lenient;
UnicodeString* lenientParseRules;
LocalizationInfo* localizations;
char id[4];
UnicodeString idStr;
int32_t code;
- URegionType type;
+ URegionType fType;
Region *containingRegion;
UVector *containedRegions;
UVector *preferredValues;
} 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 (;;) {
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<int16_t>(temp) : 1;
}
shift[hashFromCE32(cetable[cesize])] = 1;
// for ignorables we just shift by one. see test examples.
digits[i++] = number % 10;
number /= 10;
} while (number != 0);
- length = i;
+ length = static_cast<uint8_t>(i);
} else {
// fixed digits
for (i = 0; i < length; i++) {
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 = ':';
}
}
negative = TRUE;
tmp = -offset;
}
- int32_t hour, min, sec;
+ uint8_t hour, min, sec;
tmp /= 1000;
- sec = tmp % 60;
+ sec = static_cast<uint8_t>(tmp % 60);
tmp /= 60;
- min = tmp % 60;
- hour = tmp / 60;
+ min = static_cast<uint8_t>(tmp % 60);
+ hour = static_cast<uint8_t>(tmp / 60);
UnicodeString zid;
formatCustomID(hour, min, sec, negative, zid);