summaryrefslogtreecommitdiffstats
path: root/thirdparty/icu4c/common/ucnvmbcs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/icu4c/common/ucnvmbcs.cpp')
-rw-r--r--thirdparty/icu4c/common/ucnvmbcs.cpp390
1 files changed, 195 insertions, 195 deletions
diff --git a/thirdparty/icu4c/common/ucnvmbcs.cpp b/thirdparty/icu4c/common/ucnvmbcs.cpp
index d760603980..f5507043bf 100644
--- a/thirdparty/icu4c/common/ucnvmbcs.cpp
+++ b/thirdparty/icu4c/common/ucnvmbcs.cpp
@@ -665,7 +665,7 @@ enumToU(UConverterMBCSTable *mbcsTable, int8_t stateProps[],
if(!enumToU(
mbcsTable, stateProps, nextState,
offset+MBCS_ENTRY_TRANSITION_OFFSET(entry),
- value|(uint32_t)b,
+ value | static_cast<uint32_t>(b),
callback, context,
pErrorCode)) {
return false;
@@ -683,7 +683,7 @@ enumToU(UConverterMBCSTable *mbcsTable, int8_t stateProps[],
action=MBCS_ENTRY_FINAL_ACTION(entry);
if(action==MBCS_STATE_VALID_DIRECT_16) {
/* output BMP code point */
- c=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ c = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
} else if(action==MBCS_STATE_VALID_16) {
int32_t finalOffset=offset+MBCS_ENTRY_FINAL_VALUE_16(entry);
c=unicodeCodeUnits[finalOffset];
@@ -708,7 +708,7 @@ enumToU(UConverterMBCSTable *mbcsTable, int8_t stateProps[],
}
} else if(action==MBCS_STATE_VALID_DIRECT_20) {
/* output supplementary code point */
- c=(UChar32)(MBCS_ENTRY_FINAL_VALUE(entry)+0x10000);
+ c = static_cast<UChar32>(MBCS_ENTRY_FINAL_VALUE(entry) + 0x10000);
} else {
c=U_SENTINEL;
}
@@ -718,7 +718,7 @@ enumToU(UConverterMBCSTable *mbcsTable, int8_t stateProps[],
}
if(((++b)&0x1f)==0) {
if(anyCodePoints>=0) {
- if(!callback(context, value|(uint32_t)(b-0x20), codePoints)) {
+ if (!callback(context, value | static_cast<uint32_t>(b - 0x20), codePoints)) {
return false;
}
anyCodePoints=-1;
@@ -760,7 +760,7 @@ getStateProp(const int32_t (*stateTable)[256], int8_t stateProps[], int state) {
return stateProps[state];
}
}
- stateProps[state]|=(int8_t)((min>>5)<<3);
+ stateProps[state] |= static_cast<int8_t>((min >> 5) << 3);
/* find last non-ignorable state */
for(max=0xff; min<max; --max) {
@@ -777,7 +777,7 @@ getStateProp(const int32_t (*stateTable)[256], int8_t stateProps[], int state) {
break;
}
}
- stateProps[state]|=(int8_t)(max>>5);
+ stateProps[state] |= static_cast<int8_t>(max >> 5);
/* recurse further and collect direct-state information */
while(min<=max) {
@@ -924,7 +924,7 @@ ucnv_MBCSGetFilteredUnicodeSetForUnicode(const UConverterSharedData *sharedData,
bytes=mbcsTable->fromUnicodeBytes;
- useFallback=(UBool)(which==UCNV_ROUNDTRIP_AND_FALLBACK_SET);
+ useFallback = which == UCNV_ROUNDTRIP_AND_FALLBACK_SET;
switch(mbcsTable->outputType) {
case MBCS_OUTPUT_3:
@@ -1117,7 +1117,7 @@ _extFromU(UConverter *cnv, const UConverterSharedData *sharedData,
ucnv_extInitialMatchFromU(
cnv, cx,
cp, source, sourceLimit,
- (char **)target, (char *)targetLimit,
+ reinterpret_cast<char**>(target), reinterpret_cast<const char*>(targetLimit),
offsets, sourceIndex,
flush,
pErrorCode)
@@ -1132,7 +1132,7 @@ _extFromU(UConverter *cnv, const UConverterSharedData *sharedData,
range=gb18030Ranges[0];
for(i=0; i<UPRV_LENGTHOF(gb18030Ranges); range+=4, ++i) {
- if(range[0]<=(uint32_t)cp && (uint32_t)cp<=range[1]) {
+ if (range[0] <= static_cast<uint32_t>(cp) && static_cast<uint32_t>(cp) <= range[1]) {
/* found the Unicode code point, output the four-byte sequence for it */
uint32_t linear;
char bytes[4];
@@ -1141,17 +1141,17 @@ _extFromU(UConverter *cnv, const UConverterSharedData *sharedData,
linear=range[2]-LINEAR_18030_BASE;
/* add the offset from the beginning of the range */
- linear+=((uint32_t)cp-range[0]);
+ linear += (static_cast<uint32_t>(cp) - range[0]);
/* turn this into a four-byte sequence */
- bytes[3]=(char)(0x30+linear%10); linear/=10;
- bytes[2]=(char)(0x81+linear%126); linear/=126;
- bytes[1]=(char)(0x30+linear%10); linear/=10;
- bytes[0]=(char)(0x81+linear);
+ bytes[3] = static_cast<char>(0x30 + linear % 10); linear /= 10;
+ bytes[2] = static_cast<char>(0x81 + linear % 126); linear /= 126;
+ bytes[1] = static_cast<char>(0x30 + linear % 10); linear /= 10;
+ bytes[0] = static_cast<char>(0x81 + linear);
/* output this sequence */
ucnv_fromUWriteBytes(cnv,
- bytes, 4, (char **)target, (char *)targetLimit,
+ bytes, 4, reinterpret_cast<char**>(target), reinterpret_cast<const char*>(targetLimit),
offsets, sourceIndex, pErrorCode);
return 0;
}
@@ -1181,7 +1181,7 @@ _extToU(UConverter *cnv, const UConverterSharedData *sharedData,
if( (cx=sharedData->mbcs.extIndexes)!=nullptr &&
ucnv_extInitialMatchToU(
cnv, cx,
- length, (const char **)source, (const char *)sourceLimit,
+ length, reinterpret_cast<const char**>(source), reinterpret_cast<const char*>(sourceLimit),
target, targetLimit,
offsets, sourceIndex,
flush,
@@ -1273,7 +1273,7 @@ _EBCDICSwapLFNL(UConverterSharedData *sharedData, UErrorCode *pErrorCode) {
table=mbcsTable->fromUnicodeTable;
bytes=mbcsTable->fromUnicodeBytes;
- results=(const uint16_t *)bytes;
+ results = reinterpret_cast<const uint16_t*>(bytes);
/*
* Check that this is an EBCDIC table with SBCS portion -
@@ -1348,21 +1348,21 @@ _EBCDICSwapLFNL(UConverterSharedData *sharedData, UErrorCode *pErrorCode) {
mbcsTable->countStates*1024+
sizeofFromUBytes+
UCNV_MAX_CONVERTER_NAME_LENGTH+20;
- p=(uint8_t *)uprv_malloc(size);
+ p = static_cast<uint8_t*>(uprv_malloc(size));
if(p==nullptr) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
return false;
}
/* copy and modify the to-Unicode state table */
- newStateTable=(int32_t (*)[256])p;
+ newStateTable = reinterpret_cast<int32_t(*)[256]>(p);
uprv_memcpy(newStateTable, mbcsTable->stateTable, mbcsTable->countStates*1024);
newStateTable[0][EBCDIC_LF]=MBCS_ENTRY_FINAL(0, MBCS_STATE_VALID_DIRECT_16, U_NL);
newStateTable[0][EBCDIC_NL]=MBCS_ENTRY_FINAL(0, MBCS_STATE_VALID_DIRECT_16, U_LF);
/* copy and modify the from-Unicode result table */
- newResults=(uint16_t *)newStateTable[mbcsTable->countStates];
+ newResults = reinterpret_cast<uint16_t*>(newStateTable[mbcsTable->countStates]);
uprv_memcpy(newResults, bytes, sizeofFromUBytes);
/* conveniently, the table access macros work on the left side of expressions */
@@ -1378,7 +1378,7 @@ _EBCDICSwapLFNL(UConverterSharedData *sharedData, UErrorCode *pErrorCode) {
}
/* set the canonical converter name */
- name=(char *)newResults+sizeofFromUBytes;
+ name = reinterpret_cast<char*>(newResults) + sizeofFromUBytes;
uprv_strcpy(name, sharedData->staticData->name);
uprv_strcat(name, UCNV_SWAP_LFNL_OPTION_STRING);
@@ -1386,7 +1386,7 @@ _EBCDICSwapLFNL(UConverterSharedData *sharedData, UErrorCode *pErrorCode) {
icu::umtx_lock(nullptr);
if(mbcsTable->swapLFNLStateTable==nullptr) {
mbcsTable->swapLFNLStateTable=newStateTable;
- mbcsTable->swapLFNLFromUnicodeBytes=(uint8_t *)newResults;
+ mbcsTable->swapLFNLFromUnicodeBytes = reinterpret_cast<uint8_t*>(newResults);
mbcsTable->swapLFNLName=name;
newStateTable=nullptr;
@@ -1413,7 +1413,7 @@ writeStage3Roundtrip(const void *context, uint32_t value, UChar32 codePoints[32]
int32_t i, st3;
table=mbcsTable->fromUnicodeTable;
- bytes=(uint8_t *)mbcsTable->fromUnicodeBytes;
+ bytes = const_cast<uint8_t*>(mbcsTable->fromUnicodeBytes);
/* for EUC outputTypes, modify the value like genmbcs.c's transformEUC() */
switch(mbcsTable->outputType) {
@@ -1454,23 +1454,23 @@ writeStage3Roundtrip(const void *context, uint32_t value, UChar32 codePoints[32]
/* locate the stage 2 & 3 data */
stage2=((uint32_t *)table)+table[c>>10]+((c>>4)&0x3f);
p=bytes;
- st3=(int32_t)(uint16_t)*stage2*16+(c&0xf);
+ st3 = static_cast<int32_t>(static_cast<uint16_t>(*stage2)) * 16 + (c & 0xf);
/* write the codepage bytes into stage 3 */
switch(mbcsTable->outputType) {
case MBCS_OUTPUT_3:
case MBCS_OUTPUT_4_EUC:
p+=st3*3;
- p[0]=(uint8_t)(value>>16);
- p[1]=(uint8_t)(value>>8);
- p[2]=(uint8_t)value;
+ p[0] = static_cast<uint8_t>(value >> 16);
+ p[1] = static_cast<uint8_t>(value >> 8);
+ p[2] = static_cast<uint8_t>(value);
break;
case MBCS_OUTPUT_4:
- ((uint32_t *)p)[st3]=value;
+ reinterpret_cast<uint32_t*>(p)[st3] = value;
break;
default:
/* 2 bytes per character */
- ((uint16_t *)p)[st3]=(uint16_t)value;
+ reinterpret_cast<uint16_t*>(p)[st3] = static_cast<uint16_t>(value);
break;
}
@@ -1488,7 +1488,7 @@ reconstituteData(UConverterMBCSTable *mbcsTable,
uint16_t *stage1;
uint32_t *stage2;
uint32_t dataLength=stage1Length*2+fullStage2Length*4+mbcsTable->fromUBytesLength;
- mbcsTable->reconstitutedData=(uint8_t *)uprv_malloc(dataLength);
+ mbcsTable->reconstitutedData = static_cast<uint8_t*>(uprv_malloc(dataLength));
if(mbcsTable->reconstitutedData==nullptr) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
return;
@@ -1496,29 +1496,29 @@ reconstituteData(UConverterMBCSTable *mbcsTable,
uprv_memset(mbcsTable->reconstitutedData, 0, dataLength);
/* copy existing data and reroute the pointers */
- stage1=(uint16_t *)mbcsTable->reconstitutedData;
+ stage1 = reinterpret_cast<uint16_t*>(mbcsTable->reconstitutedData);
uprv_memcpy(stage1, mbcsTable->fromUnicodeTable, stage1Length*2);
- stage2=(uint32_t *)(stage1+stage1Length);
+ stage2 = reinterpret_cast<uint32_t*>(stage1 + stage1Length);
uprv_memcpy(stage2+(fullStage2Length-stage2Length),
mbcsTable->fromUnicodeTable+stage1Length,
stage2Length*4);
mbcsTable->fromUnicodeTable=stage1;
- mbcsTable->fromUnicodeBytes=(uint8_t *)(stage2+fullStage2Length);
+ mbcsTable->fromUnicodeBytes = reinterpret_cast<uint8_t*>(stage2 + fullStage2Length);
/* indexes into stage 2 count from the bottom of the fromUnicodeTable */
- stage2=(uint32_t *)stage1;
+ stage2 = reinterpret_cast<uint32_t*>(stage1);
/* reconstitute the initial part of stage 2 from the mbcsIndex */
{
- int32_t stageUTF8Length=((int32_t)mbcsTable->maxFastUChar+1)>>6;
+ int32_t stageUTF8Length = (static_cast<int32_t>(mbcsTable->maxFastUChar) + 1) >> 6;
int32_t stageUTF8Index=0;
int32_t st1, st2, st3, i;
for(st1=0; stageUTF8Index<stageUTF8Length; ++st1) {
st2=stage1[st1];
- if(st2!=(int32_t)stage1Length/2) {
+ if (st2 != static_cast<int32_t>(stage1Length) / 2) {
/* each stage 2 block has 64 entries corresponding to 16 entries in the mbcsIndex */
for(i=0; i<16; ++i) {
st3=mbcsTable->mbcsIndex[stageUTF8Index++];
@@ -1568,13 +1568,13 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
} else if(header->version[0]==5 && header->version[1]>=3 &&
(header->options&MBCS_OPT_UNKNOWN_INCOMPATIBLE_MASK)==0) {
headerLength=header->options&MBCS_OPT_LENGTH_MASK;
- noFromU=(UBool)((header->options&MBCS_OPT_NO_FROM_U)!=0);
+ noFromU = static_cast<UBool>((header->options & MBCS_OPT_NO_FROM_U) != 0);
} else {
*pErrorCode=U_INVALID_TABLE_FORMAT;
return;
}
- mbcsTable->outputType=(uint8_t)header->flags;
+ mbcsTable->outputType = static_cast<uint8_t>(header->flags);
if(noFromU && mbcsTable->outputType==MBCS_OUTPUT_1) {
*pErrorCode=U_INVALID_TABLE_FORMAT;
return;
@@ -1583,7 +1583,7 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
/* extension data, header version 4.2 and higher */
offset=header->flags>>8;
if(offset!=0) {
- mbcsTable->extIndexes=(const int32_t *)(raw+offset);
+ mbcsTable->extIndexes = reinterpret_cast<const int32_t*>(raw + offset);
}
if(mbcsTable->outputType==MBCS_OUTPUT_EXT_ONLY) {
@@ -1606,7 +1606,7 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
}
/* load the base table */
- baseName=(const char *)header+headerLength*4;
+ baseName = reinterpret_cast<const char*>(header) + headerLength * 4;
if(0==uprv_strcmp(baseName, sharedData->staticData->name)) {
/* forbid loading this same extension-only file */
*pErrorCode=U_INVALID_TABLE_FORMAT;
@@ -1685,7 +1685,7 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
MBCS_ENTRY_FINAL_ACTION(entry)==MBCS_STATE_CHANGE_ONLY &&
MBCS_ENTRY_FINAL_STATE(entry)!=0
) {
- mbcsTable->dbcsOnlyState=(uint8_t)MBCS_ENTRY_FINAL_STATE(entry);
+ mbcsTable->dbcsOnlyState = static_cast<uint8_t>(MBCS_ENTRY_FINAL_STATE(entry));
mbcsTable->outputType=MBCS_OUTPUT_DBCS_ONLY;
}
@@ -1702,7 +1702,7 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
/* allocate a new state table and copy the base state table contents */
count=mbcsTable->countStates;
- newStateTable=(int32_t (*)[256])uprv_malloc((count+1)*1024);
+ newStateTable = static_cast<int32_t(*)[256]>(uprv_malloc((count + 1) * 1024));
if(newStateTable==nullptr) {
ucnv_unload(baseSharedData);
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
@@ -1725,7 +1725,7 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
state[i]=MBCS_ENTRY_FINAL(0, MBCS_STATE_ILLEGAL, 0);
}
mbcsTable->stateTable=(const int32_t (*)[256])newStateTable;
- mbcsTable->countStates=(uint8_t)(count+1);
+ mbcsTable->countStates = static_cast<uint8_t>(count + 1);
mbcsTable->stateTableOwned=true;
mbcsTable->outputType=MBCS_OUTPUT_DBCS_ONLY;
@@ -1766,14 +1766,14 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
return;
}
- mbcsTable->countStates=(uint8_t)header->countStates;
+ mbcsTable->countStates = static_cast<uint8_t>(header->countStates);
mbcsTable->countToUFallbacks=header->countToUFallbacks;
- mbcsTable->stateTable=(const int32_t (*)[256])(raw+headerLength*4);
- mbcsTable->toUFallbacks=(const _MBCSToUFallback *)(mbcsTable->stateTable+header->countStates);
- mbcsTable->unicodeCodeUnits=(const uint16_t *)(raw+header->offsetToUCodeUnits);
+ mbcsTable->stateTable = reinterpret_cast<const int32_t(*)[256]>(raw + headerLength * 4);
+ mbcsTable->toUFallbacks = reinterpret_cast<const _MBCSToUFallback*>(mbcsTable->stateTable + header->countStates);
+ mbcsTable->unicodeCodeUnits = reinterpret_cast<const uint16_t*>(raw + header->offsetToUCodeUnits);
- mbcsTable->fromUnicodeTable=(const uint16_t *)(raw+header->offsetFromUTable);
- mbcsTable->fromUnicodeBytes=(const uint8_t *)(raw+header->offsetFromUBytes);
+ mbcsTable->fromUnicodeTable = reinterpret_cast<const uint16_t*>(raw + header->offsetFromUTable);
+ mbcsTable->fromUnicodeBytes = raw + header->offsetFromUBytes;
mbcsTable->fromUBytesLength=header->fromUBytesLength;
/*
@@ -1784,7 +1784,7 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
udata_getInfo((UDataMemory *)sharedData->dataMemory, &info);
if(info.formatVersion[0]>6 || (info.formatVersion[0]==6 && info.formatVersion[1]>=1)) {
/* mask off possible future extensions to be safe */
- mbcsTable->unicodeMask=(uint8_t)(sharedData->staticData->unicodeMask&3);
+ mbcsTable->unicodeMask = static_cast<uint8_t>(sharedData->staticData->unicodeMask & 3);
} else {
/* for older versions, assume worst case: contains anything possible (prevent over-optimizations) */
mbcsTable->unicodeMask=UCNV_HAS_SUPPLEMENTARY|UCNV_HAS_SURROGATES;
@@ -1825,10 +1825,10 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
* The .cnv file is prebuilt with an additional stage table with indexes
* to each block.
*/
- mbcsTable->mbcsIndex=(const uint16_t *)
- (mbcsTable->fromUnicodeBytes+
+ mbcsTable->mbcsIndex = reinterpret_cast<const uint16_t*>(
+ mbcsTable->fromUnicodeBytes +
(noFromU ? 0 : mbcsTable->fromUBytesLength));
- mbcsTable->maxFastUChar=(((char16_t)header->version[2])<<8)|0xff;
+ mbcsTable->maxFastUChar = (static_cast<char16_t>(header->version[2]) << 8) | 0xff;
}
}
@@ -1839,7 +1839,7 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
for(i=0; i<0x80; ++i) {
if(mbcsTable->stateTable[0][i]!=MBCS_ENTRY_FINAL(0, MBCS_STATE_VALID_DIRECT_16, i)) {
- asciiRoundtrips&=~((uint32_t)1<<(i>>2));
+ asciiRoundtrips &= ~(static_cast<uint32_t>(1) << (i >> 2));
}
}
mbcsTable->asciiRoundtrips=asciiRoundtrips;
@@ -1958,7 +1958,7 @@ ucnv_MBCSOpen(UConverter *cnv,
extIndexes=mbcsTable->extIndexes;
if(extIndexes!=nullptr) {
- maxBytesPerUChar=(int8_t)UCNV_GET_MAX_BYTES_PER_UCHAR(extIndexes);
+ maxBytesPerUChar = static_cast<int8_t>(UCNV_GET_MAX_BYTES_PER_UCHAR(extIndexes));
if(outputType==MBCS_OUTPUT_2_SISO) {
++maxBytesPerUChar; /* SO + multiple DBCS */
}
@@ -2048,8 +2048,8 @@ ucnv_MBCSSingleToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
/* set up the local pointers */
cnv=pArgs->converter;
- source=(const uint8_t *)pArgs->source;
- sourceLimit=(const uint8_t *)pArgs->sourceLimit;
+ source = reinterpret_cast<const uint8_t*>(pArgs->source);
+ sourceLimit = reinterpret_cast<const uint8_t*>(pArgs->sourceLimit);
target=pArgs->target;
targetLimit=pArgs->targetLimit;
offsets=pArgs->offsets;
@@ -2085,7 +2085,7 @@ ucnv_MBCSSingleToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
/* test the most common case first */
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
@@ -2099,17 +2099,17 @@ ucnv_MBCSSingleToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
* An if-else-if chain provides more reliable performance for
* the most common cases compared to a switch.
*/
- action=(uint8_t)(MBCS_ENTRY_FINAL_ACTION(entry));
+ action = static_cast<uint8_t>(MBCS_ENTRY_FINAL_ACTION(entry));
if(action==MBCS_STATE_VALID_DIRECT_20 ||
(action==MBCS_STATE_FALLBACK_DIRECT_20 && UCNV_TO_U_USE_FALLBACK(cnv))
) {
entry=MBCS_ENTRY_FINAL_VALUE(entry);
/* output surrogate pair */
- *target++=(char16_t)(0xd800|(char16_t)(entry>>10));
+ *target++ = static_cast<char16_t>(0xd800 | static_cast<char16_t>(entry >> 10));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
- c=(char16_t)(0xdc00|(char16_t)(entry&0x3ff));
+ c = static_cast<char16_t>(0xdc00 | static_cast<char16_t>(entry & 0x3ff));
if(target<targetLimit) {
*target++=c;
if(offsets!=nullptr) {
@@ -2128,7 +2128,7 @@ ucnv_MBCSSingleToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
} else if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
@@ -2152,7 +2152,7 @@ ucnv_MBCSSingleToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
break;
} else /* unassigned sequences indicated with byteIndex>0 */ {
/* try an extension mapping */
- pArgs->source=(const char *)source;
+ pArgs->source = reinterpret_cast<const char*>(source);
cnv->toUBytes[0]=*(source-1);
cnv->toULength=_extToU(cnv, cnv->sharedData,
1, &source, sourceLimit,
@@ -2160,7 +2160,7 @@ ucnv_MBCSSingleToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
&offsets, sourceIndex,
pArgs->flush,
pErrorCode);
- sourceIndex+=1+(int32_t)(source-(const uint8_t *)pArgs->source);
+ sourceIndex += 1 + static_cast<int32_t>(source - reinterpret_cast<const uint8_t*>(pArgs->source));
if(U_FAILURE(*pErrorCode)) {
/* not mappable or buffer overflow */
@@ -2170,7 +2170,7 @@ ucnv_MBCSSingleToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
}
/* write back the updated pointers */
- pArgs->source=(const char *)source;
+ pArgs->source = reinterpret_cast<const char*>(source);
pArgs->target=target;
pArgs->offsets=offsets;
}
@@ -2199,10 +2199,10 @@ ucnv_MBCSSingleToBMPWithOffsets(UConverterToUnicodeArgs *pArgs,
/* set up the local pointers */
cnv=pArgs->converter;
- source=(const uint8_t *)pArgs->source;
- sourceLimit=(const uint8_t *)pArgs->sourceLimit;
+ source = reinterpret_cast<const uint8_t*>(pArgs->source);
+ sourceLimit = reinterpret_cast<const uint8_t*>(pArgs->sourceLimit);
target=pArgs->target;
- targetCapacity=(int32_t)(pArgs->targetLimit-pArgs->target);
+ targetCapacity = static_cast<int32_t>(pArgs->targetLimit - pArgs->target);
offsets=pArgs->offsets;
if((cnv->options&UCNV_OPTION_SWAP_LFNL)!=0) {
@@ -2219,7 +2219,7 @@ ucnv_MBCSSingleToBMPWithOffsets(UConverterToUnicodeArgs *pArgs,
* since the conversion here is 1:1 char16_t:uint8_t, we need only one counter
* for the minimum of the sourceLength and targetCapacity
*/
- length=(int32_t)(sourceLimit-source);
+ length = static_cast<int32_t>(sourceLimit - source);
if(length<targetCapacity) {
targetCapacity=length;
}
@@ -2234,37 +2234,37 @@ unrolled:
loops=count=targetCapacity>>4;
do {
oredEntries=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
oredEntries|=entry=stateTable[0][*source++];
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
/* were all 16 entries really valid? */
if(!MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(oredEntries)) {
@@ -2310,7 +2310,7 @@ unrolled:
/* test the most common case first */
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
--targetCapacity;
continue;
}
@@ -2319,11 +2319,11 @@ unrolled:
* An if-else-if chain provides more reliable performance for
* the most common cases compared to a switch.
*/
- action=(uint8_t)(MBCS_ENTRY_FINAL_ACTION(entry));
+ action = static_cast<uint8_t>(MBCS_ENTRY_FINAL_ACTION(entry));
if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++ = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
--targetCapacity;
continue;
}
@@ -2339,7 +2339,7 @@ unrolled:
/* set offsets since the start or the last extension */
if(offsets!=nullptr) {
- int32_t count=(int32_t)(source-lastSource);
+ int32_t count = static_cast<int32_t>(source - lastSource);
/* predecrement: do not set the offset for the callback-causing character */
while(--count>0) {
@@ -2361,7 +2361,7 @@ unrolled:
&offsets, sourceIndex,
pArgs->flush,
pErrorCode);
- sourceIndex+=1+(int32_t)(source-lastSource);
+ sourceIndex += 1 + static_cast<int32_t>(source - lastSource);
if(U_FAILURE(*pErrorCode)) {
/* not mappable or buffer overflow */
@@ -2369,8 +2369,8 @@ unrolled:
}
/* recalculate the targetCapacity after an extension mapping */
- targetCapacity=(int32_t)(pArgs->targetLimit-target);
- length=(int32_t)(sourceLimit-source);
+ targetCapacity = static_cast<int32_t>(pArgs->targetLimit - target);
+ length = static_cast<int32_t>(sourceLimit - source);
if(length<targetCapacity) {
targetCapacity=length;
}
@@ -2397,7 +2397,7 @@ unrolled:
}
/* write back the updated pointers */
- pArgs->source=(const char *)source;
+ pArgs->source = reinterpret_cast<const char*>(source);
pArgs->target=target;
pArgs->offsets=offsets;
}
@@ -2432,7 +2432,7 @@ hasValidTrailBytes(const int32_t (*stateTable)[256], uint8_t state) {
for(b=0; b<=0xff; ++b) {
entry=row[b];
if( MBCS_ENTRY_IS_TRANSITION(entry) &&
- hasValidTrailBytes(stateTable, (uint8_t)MBCS_ENTRY_TRANSITION_STATE(entry))
+ hasValidTrailBytes(stateTable, static_cast<uint8_t>(MBCS_ENTRY_TRANSITION_STATE(entry)))
) {
return true;
}
@@ -2450,9 +2450,9 @@ isSingleOrLead(const int32_t (*stateTable)[256], uint8_t state, UBool isDBCSOnly
const int32_t *row=stateTable[state];
int32_t entry=row[b];
if(MBCS_ENTRY_IS_TRANSITION(entry)) { /* lead byte */
- return hasValidTrailBytes(stateTable, (uint8_t)MBCS_ENTRY_TRANSITION_STATE(entry));
+ return hasValidTrailBytes(stateTable, static_cast<uint8_t>(MBCS_ENTRY_TRANSITION_STATE(entry)));
} else {
- uint8_t action=(uint8_t)(MBCS_ENTRY_FINAL_ACTION(entry));
+ uint8_t action = static_cast<uint8_t>(MBCS_ENTRY_FINAL_ACTION(entry));
if(action==MBCS_STATE_CHANGE_ONLY && isDBCSOnly) {
return false; /* SI/SO are illegal for DBCS-only conversion */
} else {
@@ -2823,7 +2823,7 @@ ucnv_MBCSToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
* - If any of the non-initial bytes could be the start of a character,
* we stop the illegal sequence before the first one of those.
*/
- UBool isDBCSOnly=(UBool)(cnv->sharedData->mbcs.dbcsOnlyState!=0);
+ UBool isDBCSOnly = cnv->sharedData->mbcs.dbcsOnlyState != 0;
int8_t i;
for(i=1;
i<byteIndex && !isSingleOrLead(stateTable, state, isDBCSOnly, bytes[i]);
@@ -2890,8 +2890,8 @@ ucnv_MBCSSingleGetNextUChar(UConverterToUnicodeArgs *pArgs,
/* set up the local pointers */
cnv=pArgs->converter;
- source=(const uint8_t *)pArgs->source;
- sourceLimit=(const uint8_t *)pArgs->sourceLimit;
+ source = reinterpret_cast<const uint8_t*>(pArgs->source);
+ sourceLimit = reinterpret_cast<const uint8_t*>(pArgs->sourceLimit);
if((cnv->options&UCNV_OPTION_SWAP_LFNL)!=0) {
stateTable=(const int32_t (*)[256])cnv->sharedData->mbcs.swapLFNLStateTable;
} else {
@@ -2904,27 +2904,27 @@ ucnv_MBCSSingleGetNextUChar(UConverterToUnicodeArgs *pArgs,
/* MBCS_ENTRY_IS_FINAL(entry) */
/* write back the updated pointer early so that we can return directly */
- pArgs->source=(const char *)source;
+ pArgs->source = reinterpret_cast<const char*>(source);
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
- return (char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ return static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
}
/*
* An if-else-if chain provides more reliable performance for
* the most common cases compared to a switch.
*/
- action=(uint8_t)(MBCS_ENTRY_FINAL_ACTION(entry));
+ action = static_cast<uint8_t>(MBCS_ENTRY_FINAL_ACTION(entry));
if( action==MBCS_STATE_VALID_DIRECT_20 ||
(action==MBCS_STATE_FALLBACK_DIRECT_20 && UCNV_TO_U_USE_FALLBACK(cnv))
) {
/* output supplementary code point */
- return (UChar32)(MBCS_ENTRY_FINAL_VALUE(entry)+0x10000);
+ return static_cast<UChar32>(MBCS_ENTRY_FINAL_VALUE(entry) + 0x10000);
} else if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- return (char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ return static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
}
} else if(action==MBCS_STATE_UNASSIGNED) {
/* just fall through */
@@ -2941,7 +2941,7 @@ ucnv_MBCSSingleGetNextUChar(UConverterToUnicodeArgs *pArgs,
break;
} else /* unassigned sequence */ {
/* defer to the generic implementation */
- pArgs->source=(const char *)source-1;
+ pArgs->source = reinterpret_cast<const char*>(source) - 1;
return UCNV_GET_NEXT_UCHAR_USE_TO_U;
}
}
@@ -2999,8 +2999,8 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
}
/* set up the local pointers */
- source=lastSource=(const uint8_t *)pArgs->source;
- sourceLimit=(const uint8_t *)pArgs->sourceLimit;
+ source = lastSource = reinterpret_cast<const uint8_t*>(pArgs->source);
+ sourceLimit = reinterpret_cast<const uint8_t*>(pArgs->sourceLimit);
if((cnv->options&UCNV_OPTION_SWAP_LFNL)!=0) {
stateTable=(const int32_t (*)[256])cnv->sharedData->mbcs.swapLFNLStateTable;
@@ -3017,7 +3017,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
* then load the DBCS state from the MBCS data
* (dbcsOnlyState==0 if it is not a DBCS-only converter)
*/
- if((state=(uint8_t)(cnv->mode))==0) {
+ if ((state = static_cast<uint8_t>(cnv->mode)) == 0) {
state=cnv->sharedData->mbcs.dbcsOnlyState;
}
@@ -3026,7 +3026,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
while(source<sourceLimit) {
entry=stateTable[state][*source++];
if(MBCS_ENTRY_IS_TRANSITION(entry)) {
- state=(uint8_t)MBCS_ENTRY_TRANSITION_STATE(entry);
+ state = static_cast<uint8_t>(MBCS_ENTRY_TRANSITION_STATE(entry));
offset+=MBCS_ENTRY_TRANSITION_OFFSET(entry);
/* optimization for 1/2-byte input and BMP output */
@@ -3036,7 +3036,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
(c=unicodeCodeUnits[offset+MBCS_ENTRY_FINAL_VALUE_16(entry)])<0xfffe
) {
++source;
- state=(uint8_t)MBCS_ENTRY_FINAL_STATE(entry); /* typically 0 */
+ state = static_cast<uint8_t>(MBCS_ENTRY_FINAL_STATE(entry)); /* typically 0 */
/* output BMP code point */
break;
}
@@ -3045,16 +3045,16 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
cnv->mode=state;
/* set the next state early so that we can reuse the entry variable */
- state=(uint8_t)MBCS_ENTRY_FINAL_STATE(entry); /* typically 0 */
+ state = static_cast<uint8_t>(MBCS_ENTRY_FINAL_STATE(entry)); /* typically 0 */
/*
* An if-else-if chain provides more reliable performance for
* the most common cases compared to a switch.
*/
- action=(uint8_t)(MBCS_ENTRY_FINAL_ACTION(entry));
+ action = static_cast<uint8_t>(MBCS_ENTRY_FINAL_ACTION(entry));
if(action==MBCS_STATE_VALID_DIRECT_16) {
/* output BMP code point */
- c=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ c = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
break;
} else if(action==MBCS_STATE_VALID_16) {
offset+=MBCS_ENTRY_FINAL_VALUE_16(entry);
@@ -3092,7 +3092,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
(action==MBCS_STATE_FALLBACK_DIRECT_20 && UCNV_TO_U_USE_FALLBACK(cnv))
) {
/* output supplementary code point */
- c=(UChar32)(MBCS_ENTRY_FINAL_VALUE(entry)+0x10000);
+ c = static_cast<UChar32>(MBCS_ENTRY_FINAL_VALUE(entry) + 0x10000);
break;
} else if(action==MBCS_STATE_CHANGE_ONLY) {
/*
@@ -3104,7 +3104,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
*/
if(cnv->sharedData->mbcs.dbcsOnlyState!=0) {
/* SI/SO are illegal for DBCS-only conversion */
- state=(uint8_t)(cnv->mode); /* restore the previous state */
+ state = static_cast<uint8_t>(cnv->mode); /* restore the previous state */
/* callback(illegal) */
*pErrorCode=U_ILLEGAL_CHAR_FOUND;
@@ -3112,7 +3112,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
} else if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- c=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ c = static_cast<char16_t>(MBCS_ENTRY_FINAL_VALUE_16(entry));
break;
}
} else if(action==MBCS_STATE_UNASSIGNED) {
@@ -3137,7 +3137,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
/* defer to the generic implementation */
cnv->toUnicodeStatus=0;
cnv->mode=state;
- pArgs->source=(const char *)lastSource;
+ pArgs->source = reinterpret_cast<const char*>(lastSource);
return UCNV_GET_NEXT_UCHAR_USE_TO_U;
}
}
@@ -3147,7 +3147,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
if(U_SUCCESS(*pErrorCode) && source==sourceLimit && lastSource<source) {
/* incomplete character byte sequence */
uint8_t *bytes=cnv->toUBytes;
- cnv->toULength=(int8_t)(source-lastSource);
+ cnv->toULength = static_cast<int8_t>(source - lastSource);
do {
*bytes++=*lastSource++;
} while(lastSource<source);
@@ -3160,7 +3160,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
* - If any of the non-initial bytes could be the start of a character,
* we stop the illegal sequence before the first one of those.
*/
- UBool isDBCSOnly=(UBool)(cnv->sharedData->mbcs.dbcsOnlyState!=0);
+ UBool isDBCSOnly = static_cast<UBool>(cnv->sharedData->mbcs.dbcsOnlyState != 0);
uint8_t *bytes=cnv->toUBytes;
*bytes++=*lastSource++; /* first byte */
if(lastSource==source) {
@@ -3188,7 +3188,7 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
cnv->mode=state;
/* write back the updated pointer */
- pArgs->source=(const char *)source;
+ pArgs->source = reinterpret_cast<const char*>(source);
return c;
}
@@ -3431,8 +3431,8 @@ ucnv_MBCSDoubleFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
/* set up the local pointers */
source=pArgs->source;
sourceLimit=pArgs->sourceLimit;
- target=(uint8_t *)pArgs->target;
- targetCapacity=(int32_t)(pArgs->targetLimit-pArgs->target);
+ target = reinterpret_cast<uint8_t*>(pArgs->target);
+ targetCapacity = static_cast<int32_t>(pArgs->targetLimit - pArgs->target);
offsets=pArgs->offsets;
table=cnv->sharedData->mbcs.fromUnicodeTable;
@@ -3474,7 +3474,7 @@ ucnv_MBCSDoubleFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
c=*source++;
++nextSourceIndex;
if(c<=0x7f && IS_ASCII_ROUNDTRIP(c, asciiRoundtrips)) {
- *target++=(uint8_t)c;
+ *target++ = static_cast<uint8_t>(c);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
sourceIndex=nextSourceIndex;
@@ -3562,7 +3562,7 @@ unassigned:
&offsets, sourceIndex,
pArgs->flush,
pErrorCode);
- nextSourceIndex+=(int32_t)(source-pArgs->source);
+ nextSourceIndex += static_cast<int32_t>(source - pArgs->source);
if(U_FAILURE(*pErrorCode)) {
/* not mappable or buffer overflow */
@@ -3571,7 +3571,7 @@ unassigned:
/* a mapping was written to the target, continue */
/* recalculate the targetCapacity after an extension mapping */
- targetCapacity=(int32_t)(pArgs->targetLimit-(char *)target);
+ targetCapacity = static_cast<int32_t>(pArgs->targetLimit - reinterpret_cast<char*>(target));
/* normal end of conversion: prepare for a new character */
sourceIndex=nextSourceIndex;
@@ -3584,15 +3584,15 @@ unassigned:
/* from the first if in the loop we know that targetCapacity>0 */
if(value<=0xff) {
/* this is easy because we know that there is enough space */
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
--targetCapacity;
} else /* length==2 */ {
- *target++=(uint8_t)(value>>8);
+ *target++ = static_cast<uint8_t>(value >> 8);
if(2<=targetCapacity) {
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
*offsets++=sourceIndex;
@@ -3602,7 +3602,7 @@ unassigned:
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
- cnv->charErrorBuffer[0]=(char)value;
+ cnv->charErrorBuffer[0] = static_cast<char>(value);
cnv->charErrorBufferLength=1;
/* target overflow */
@@ -3629,7 +3629,7 @@ unassigned:
/* write back the updated pointers */
pArgs->source=source;
- pArgs->target=(char *)target;
+ pArgs->target = reinterpret_cast<char*>(target);
pArgs->offsets=offsets;
}
@@ -3657,13 +3657,13 @@ ucnv_MBCSSingleFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
cnv=pArgs->converter;
source=pArgs->source;
sourceLimit=pArgs->sourceLimit;
- target=(uint8_t *)pArgs->target;
- targetCapacity=(int32_t)(pArgs->targetLimit-pArgs->target);
+ target = reinterpret_cast<uint8_t*>(pArgs->target);
+ targetCapacity = static_cast<int32_t>(pArgs->targetLimit - pArgs->target);
offsets=pArgs->offsets;
table=cnv->sharedData->mbcs.fromUnicodeTable;
if((cnv->options&UCNV_OPTION_SWAP_LFNL)!=0) {
- results=(uint16_t *)cnv->sharedData->mbcs.swapLFNLFromUnicodeBytes;
+ results = reinterpret_cast<uint16_t*>(cnv->sharedData->mbcs.swapLFNLFromUnicodeBytes);
} else {
results=(uint16_t *)cnv->sharedData->mbcs.fromUnicodeBytes;
}
@@ -3675,7 +3675,7 @@ ucnv_MBCSSingleFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
/* use only roundtrips and fallbacks from private-use characters */
minValue=0xc00;
}
- hasSupplementary=(UBool)(cnv->sharedData->mbcs.unicodeMask&UCNV_HAS_SUPPLEMENTARY);
+ hasSupplementary = static_cast<UBool>(cnv->sharedData->mbcs.unicodeMask & UCNV_HAS_SUPPLEMENTARY);
/* get the converter state from UConverter */
c=cnv->fromUChar32;
@@ -3749,7 +3749,7 @@ getTrail:
/* assigned, write the output character bytes from value and length */
/* length==1 */
/* this is easy because we know that there is enough space */
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
@@ -3768,7 +3768,7 @@ unassigned:
&offsets, sourceIndex,
pArgs->flush,
pErrorCode);
- nextSourceIndex+=(int32_t)(source-pArgs->source);
+ nextSourceIndex += static_cast<int32_t>(source - pArgs->source);
if(U_FAILURE(*pErrorCode)) {
/* not mappable or buffer overflow */
@@ -3777,7 +3777,7 @@ unassigned:
/* a mapping was written to the target, continue */
/* recalculate the targetCapacity after an extension mapping */
- targetCapacity=(int32_t)(pArgs->targetLimit-(char *)target);
+ targetCapacity = static_cast<int32_t>(pArgs->targetLimit - reinterpret_cast<char*>(target));
/* normal end of conversion: prepare for a new character */
sourceIndex=nextSourceIndex;
@@ -3795,7 +3795,7 @@ unassigned:
/* write back the updated pointers */
pArgs->source=source;
- pArgs->target=(char *)target;
+ pArgs->target = reinterpret_cast<char*>(target);
pArgs->offsets=offsets;
}
@@ -3833,13 +3833,13 @@ ucnv_MBCSSingleFromBMPWithOffsets(UConverterFromUnicodeArgs *pArgs,
cnv=pArgs->converter;
source=pArgs->source;
sourceLimit=pArgs->sourceLimit;
- target=(uint8_t *)pArgs->target;
- targetCapacity=(int32_t)(pArgs->targetLimit-pArgs->target);
+ target = reinterpret_cast<uint8_t*>(pArgs->target);
+ targetCapacity = static_cast<int32_t>(pArgs->targetLimit - pArgs->target);
offsets=pArgs->offsets;
table=cnv->sharedData->mbcs.fromUnicodeTable;
if((cnv->options&UCNV_OPTION_SWAP_LFNL)!=0) {
- results=(uint16_t *)cnv->sharedData->mbcs.swapLFNLFromUnicodeBytes;
+ results = reinterpret_cast<uint16_t*>(cnv->sharedData->mbcs.swapLFNLFromUnicodeBytes);
} else {
results=(uint16_t *)cnv->sharedData->mbcs.fromUnicodeBytes;
}
@@ -3864,7 +3864,7 @@ ucnv_MBCSSingleFromBMPWithOffsets(UConverterFromUnicodeArgs *pArgs,
* since the conversion here is 1:1 char16_t:uint8_t, we need only one counter
* for the minimum of the sourceLength and targetCapacity
*/
- length=(int32_t)(sourceLimit-source);
+ length = static_cast<int32_t>(sourceLimit - source);
if(length<targetCapacity) {
targetCapacity=length;
}
@@ -3937,7 +3937,7 @@ unrolled:
*/
/* convert the Unicode code point in c into codepage bytes */
if(c<=0x7f && IS_ASCII_ROUNDTRIP(c, asciiRoundtrips)) {
- *target++=(uint8_t)c;
+ *target++ = static_cast<uint8_t>(c);
--targetCapacity;
c=0;
continue;
@@ -3948,7 +3948,7 @@ unrolled:
/* assigned, write the output character bytes from value and length */
/* length==1 */
/* this is easy because we know that there is enough space */
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
--targetCapacity;
/* normal end of conversion: prepare for a new character */
@@ -3993,7 +3993,7 @@ getTrail:
/* set offsets since the start or the last extension */
if(offsets!=nullptr) {
- int32_t count=(int32_t)(source-lastSource);
+ int32_t count = static_cast<int32_t>(source - lastSource);
/* do not set the offset for this character */
count-=length;
@@ -4009,11 +4009,11 @@ getTrail:
lastSource=source;
c=_extFromU(cnv, cnv->sharedData,
c, &source, sourceLimit,
- &target, (const uint8_t *)(pArgs->targetLimit),
+ &target, reinterpret_cast<const uint8_t*>(pArgs->targetLimit),
&offsets, sourceIndex,
pArgs->flush,
pErrorCode);
- sourceIndex+=length+(int32_t)(source-lastSource);
+ sourceIndex += length + static_cast<int32_t>(source - lastSource);
lastSource=source;
if(U_FAILURE(*pErrorCode)) {
@@ -4023,8 +4023,8 @@ getTrail:
/* a mapping was written to the target, continue */
/* recalculate the targetCapacity after an extension mapping */
- targetCapacity=(int32_t)(pArgs->targetLimit-(char *)target);
- length=(int32_t)(sourceLimit-source);
+ targetCapacity = static_cast<int32_t>(pArgs->targetLimit - reinterpret_cast<char*>(target));
+ length = static_cast<int32_t>(sourceLimit - source);
if(length<targetCapacity) {
targetCapacity=length;
}
@@ -4063,7 +4063,7 @@ getTrail:
/* write back the updated pointers */
pArgs->source=source;
- pArgs->target=(char *)target;
+ pArgs->target = reinterpret_cast<char*>(target);
pArgs->offsets=offsets;
}
@@ -4777,14 +4777,14 @@ unassigned:
) {
/* EBCDIC_STATEFUL ending with DBCS: emit an SI to return the output stream to SBCS */
if(targetCapacity>0) {
- *target++=(uint8_t)siBytes[0];
+ *target++ = siBytes[0];
if (siLength == 2) {
if (targetCapacity<2) {
- cnv->charErrorBuffer[0]=(uint8_t)siBytes[1];
+ cnv->charErrorBuffer[0] = siBytes[1];
cnv->charErrorBufferLength=1;
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
} else {
- *target++=(uint8_t)siBytes[1];
+ *target++ = siBytes[1];
}
}
if(offsets!=nullptr) {
@@ -4793,9 +4793,9 @@ unassigned:
}
} else {
/* target is full */
- cnv->charErrorBuffer[0]=(uint8_t)siBytes[0];
+ cnv->charErrorBuffer[0] = siBytes[0];
if (siLength == 2) {
- cnv->charErrorBuffer[1]=(uint8_t)siBytes[1];
+ cnv->charErrorBuffer[1] = siBytes[1];
}
cnv->charErrorBufferLength=siLength;
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
@@ -5042,13 +5042,13 @@ ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
cnv=pFromUArgs->converter;
source=(uint8_t *)pToUArgs->source;
sourceLimit=(uint8_t *)pToUArgs->sourceLimit;
- target=(uint8_t *)pFromUArgs->target;
- targetCapacity=(int32_t)(pFromUArgs->targetLimit-pFromUArgs->target);
+ target = reinterpret_cast<uint8_t*>(pFromUArgs->target);
+ targetCapacity = static_cast<int32_t>(pFromUArgs->targetLimit - pFromUArgs->target);
table=cnv->sharedData->mbcs.fromUnicodeTable;
sbcsIndex=cnv->sharedData->mbcs.sbcsIndex;
if((cnv->options&UCNV_OPTION_SWAP_LFNL)!=0) {
- results=(uint16_t *)cnv->sharedData->mbcs.swapLFNLFromUnicodeBytes;
+ results = reinterpret_cast<uint16_t*>(cnv->sharedData->mbcs.swapLFNLFromUnicodeBytes);
} else {
results=(uint16_t *)cnv->sharedData->mbcs.fromUnicodeBytes;
}
@@ -5061,13 +5061,13 @@ ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
/* use only roundtrips and fallbacks from private-use characters */
minValue=0xc00;
}
- hasSupplementary=(UBool)(cnv->sharedData->mbcs.unicodeMask&UCNV_HAS_SUPPLEMENTARY);
+ hasSupplementary = static_cast<UBool>(cnv->sharedData->mbcs.unicodeMask & UCNV_HAS_SUPPLEMENTARY);
/* get the converter state from the UTF-8 UConverter */
if(utf8->toULength > 0) {
toULength=oldToULength=utf8->toULength;
- toULimit=(int8_t)utf8->mode;
- c=(UChar32)utf8->toUnicodeStatus;
+ toULimit = static_cast<int8_t>(utf8->mode);
+ c = static_cast<UChar32>(utf8->toUnicodeStatus);
} else {
toULength=oldToULength=toULimit=0;
c = 0;
@@ -5080,7 +5080,7 @@ ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
{
// Do not go back into the bytes that will be read for finishing a partial
// sequence from the previous buffer.
- int32_t length=(int32_t)(sourceLimit-source) - (toULimit-oldToULength);
+ int32_t length = static_cast<int32_t>(sourceLimit - source) - (toULimit - oldToULength);
if(length>0) {
uint8_t b1=*(sourceLimit-1);
if(U8_IS_SINGLE(b1)) {
@@ -5130,7 +5130,7 @@ ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
if(U8_IS_SINGLE(b)) {
/* convert ASCII */
if(IS_ASCII_ROUNDTRIP(b, asciiRoundtrips)) {
- *target++=(uint8_t)b;
+ *target++ = b;
--targetCapacity;
continue;
} else {
@@ -5141,13 +5141,13 @@ ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
if(b<0xe0) {
if( /* handle U+0080..U+07FF inline */
b>=0xc2 &&
- (t1=(uint8_t)(*source-0x80)) <= 0x3f
+ (t1 = static_cast<uint8_t>(*source - 0x80)) <= 0x3f
) {
c=b&0x1f;
++source;
value=SBCS_RESULT_FROM_UTF8(sbcsIndex, results, c, t1);
if(value>=minValue) {
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
--targetCapacity;
continue;
} else {
@@ -5158,14 +5158,14 @@ ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
}
} else if(b==0xe0) {
if( /* handle U+0800..U+0FFF inline */
- (t1=(uint8_t)(source[0]-0x80)) <= 0x3f && t1 >= 0x20 &&
- (t2=(uint8_t)(source[1]-0x80)) <= 0x3f
+ (t1 = static_cast<uint8_t>(source[0] - 0x80)) <= 0x3f && t1 >= 0x20 &&
+ (t2 = static_cast<uint8_t>(source[1] - 0x80)) <= 0x3f
) {
c=t1;
source+=2;
value=SBCS_RESULT_FROM_UTF8(sbcsIndex, results, c, t2);
if(value>=minValue) {
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
--targetCapacity;
continue;
} else {
@@ -5212,7 +5212,7 @@ moreBytes:
utf8->toULength=toULength;
utf8->mode=toULimit;
pToUArgs->source=(char *)source;
- pFromUArgs->target=(char *)target;
+ pFromUArgs->target = reinterpret_cast<char*>(target);
return;
}
}
@@ -5238,7 +5238,7 @@ moreBytes:
}
utf8->toULength=toULength;
pToUArgs->source=(char *)source;
- pFromUArgs->target=(char *)target;
+ pFromUArgs->target = reinterpret_cast<char*>(target);
*pErrorCode=U_ILLEGAL_CHAR_FOUND;
return;
}
@@ -5247,7 +5247,7 @@ moreBytes:
if(value>=minValue) {
/* output the mapping for c */
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
--targetCapacity;
} else {
/* value<minValue means c is unassigned (unmappable) */
@@ -5283,7 +5283,7 @@ moreBytes:
/* a mapping was written to the target, continue */
/* recalculate the targetCapacity after an extension mapping */
- targetCapacity=(int32_t)(pFromUArgs->targetLimit-(char *)target);
+ targetCapacity = static_cast<int32_t>(pFromUArgs->targetLimit - reinterpret_cast<char*>(target));
}
}
} else {
@@ -5315,7 +5315,7 @@ moreBytes:
/* write back the updated pointers */
pToUArgs->source=(char *)source;
- pFromUArgs->target=(char *)target;
+ pFromUArgs->target = reinterpret_cast<char*>(target);
}
static void U_CALLCONV
@@ -5345,25 +5345,25 @@ ucnv_DBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
cnv=pFromUArgs->converter;
source=(uint8_t *)pToUArgs->source;
sourceLimit=(uint8_t *)pToUArgs->sourceLimit;
- target=(uint8_t *)pFromUArgs->target;
- targetCapacity=(int32_t)(pFromUArgs->targetLimit-pFromUArgs->target);
+ target = reinterpret_cast<uint8_t*>(pFromUArgs->target);
+ targetCapacity = static_cast<int32_t>(pFromUArgs->targetLimit - pFromUArgs->target);
table=cnv->sharedData->mbcs.fromUnicodeTable;
mbcsIndex=cnv->sharedData->mbcs.mbcsIndex;
if((cnv->options&UCNV_OPTION_SWAP_LFNL)!=0) {
- results=(uint16_t *)cnv->sharedData->mbcs.swapLFNLFromUnicodeBytes;
+ results = reinterpret_cast<uint16_t*>(cnv->sharedData->mbcs.swapLFNLFromUnicodeBytes);
} else {
results=(uint16_t *)cnv->sharedData->mbcs.fromUnicodeBytes;
}
asciiRoundtrips=cnv->sharedData->mbcs.asciiRoundtrips;
- hasSupplementary=(UBool)(cnv->sharedData->mbcs.unicodeMask&UCNV_HAS_SUPPLEMENTARY);
+ hasSupplementary = static_cast<UBool>(cnv->sharedData->mbcs.unicodeMask & UCNV_HAS_SUPPLEMENTARY);
/* get the converter state from the UTF-8 UConverter */
if(utf8->toULength > 0) {
toULength=oldToULength=utf8->toULength;
- toULimit=(int8_t)utf8->mode;
- c=(UChar32)utf8->toUnicodeStatus;
+ toULimit = static_cast<int8_t>(utf8->mode);
+ c = static_cast<UChar32>(utf8->toUnicodeStatus);
} else {
toULength=oldToULength=toULimit=0;
c = 0;
@@ -5376,7 +5376,7 @@ ucnv_DBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
{
// Do not go back into the bytes that will be read for finishing a partial
// sequence from the previous buffer.
- int32_t length=(int32_t)(sourceLimit-source) - (toULimit-oldToULength);
+ int32_t length = static_cast<int32_t>(sourceLimit - source) - (toULimit - oldToULength);
if(length>0) {
uint8_t b1=*(sourceLimit-1);
if(U8_IS_SINGLE(b1)) {
@@ -5423,7 +5423,7 @@ ucnv_DBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
if( /* handle U+0800..U+D7FF inline */
b<=0xed && // do not assume maxFastUChar>0xd7ff
U8_IS_VALID_LEAD3_AND_T1(b, t1=source[0]) &&
- (t2=(uint8_t)(source[1]-0x80)) <= 0x3f
+ (t2 = static_cast<uint8_t>(source[1] - 0x80)) <= 0x3f
) {
c=((b&0xf)<<6)|(t1&0x3f);
source+=2;
@@ -5438,7 +5438,7 @@ ucnv_DBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
} else {
if( /* handle U+0080..U+07FF inline */
b>=0xc2 &&
- (t1=(uint8_t)(*source-0x80)) <= 0x3f
+ (t1 = static_cast<uint8_t>(*source - 0x80)) <= 0x3f
) {
c=b&0x1f;
++source;
@@ -5486,7 +5486,7 @@ moreBytes:
utf8->toULength=toULength;
utf8->mode=toULimit;
pToUArgs->source=(char *)source;
- pFromUArgs->target=(char *)target;
+ pFromUArgs->target = reinterpret_cast<char*>(target);
return;
}
}
@@ -5512,7 +5512,7 @@ moreBytes:
}
utf8->toULength=toULength;
pToUArgs->source=(char *)source;
- pFromUArgs->target=(char *)target;
+ pFromUArgs->target = reinterpret_cast<char*>(target);
*pErrorCode=U_ILLEGAL_CHAR_FOUND;
return;
}
@@ -5534,15 +5534,15 @@ moreBytes:
/* from the first if in the loop we know that targetCapacity>0 */
if(value<=0xff) {
/* this is easy because we know that there is enough space */
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
--targetCapacity;
} else /* length==2 */ {
- *target++=(uint8_t)(value>>8);
+ *target++ = static_cast<uint8_t>(value >> 8);
if(2<=targetCapacity) {
- *target++=(uint8_t)value;
+ *target++ = static_cast<uint8_t>(value);
targetCapacity-=2;
} else {
- cnv->charErrorBuffer[0]=(char)value;
+ cnv->charErrorBuffer[0] = static_cast<char>(value);
cnv->charErrorBufferLength=1;
/* target overflow */
@@ -5586,7 +5586,7 @@ unassigned:
/* a mapping was written to the target, continue */
/* recalculate the targetCapacity after an extension mapping */
- targetCapacity=(int32_t)(pFromUArgs->targetLimit-(char *)target);
+ targetCapacity = static_cast<int32_t>(pFromUArgs->targetLimit - reinterpret_cast<char*>(target));
continue;
}
}
@@ -5619,7 +5619,7 @@ unassigned:
/* write back the updated pointers */
pToUArgs->source=(char *)source;
- pFromUArgs->target=(char *)target;
+ pFromUArgs->target = reinterpret_cast<char*>(target);
}
/* miscellaneous ------------------------------------------------------------ */
@@ -5634,7 +5634,7 @@ ucnv_MBCSGetStarters(const UConverter* cnv,
state0=cnv->sharedData->mbcs.stateTable[cnv->sharedData->mbcs.dbcsOnlyState];
for(i=0; i<256; ++i) {
/* all bytes that cause a state transition from state 0 are lead bytes */
- starters[i]= (UBool)MBCS_ENTRY_IS_TRANSITION(state0[i]);
+ starters[i] = static_cast<UBool>(MBCS_ENTRY_IS_TRANSITION(state0[i]));
}
}
@@ -5644,7 +5644,7 @@ ucnv_MBCSGetStarters(const UConverter* cnv,
*/
U_CFUNC UBool
ucnv_MBCSIsLeadByte(UConverterSharedData *sharedData, char byte) {
- return (UBool)MBCS_ENTRY_IS_TRANSITION(sharedData->mbcs.stateTable[0][(uint8_t)byte]);
+ return MBCS_ENTRY_IS_TRANSITION(sharedData->mbcs.stateTable[0][(uint8_t)byte]);
}
static void U_CALLCONV
@@ -5663,11 +5663,11 @@ ucnv_MBCSWriteSub(UConverterFromUnicodeArgs *pArgs,
(cnv->invalidUCharBuffer[0]<=0xff))
) {
/* select subChar1 if it is set (not 0) and the unmappable Unicode code point is up to U+00ff (IBM MBCS behavior) */
- subchar=(char *)&cnv->subChar1;
+ subchar = reinterpret_cast<char*>(&cnv->subChar1);
length=1;
} else {
/* select subChar in all other cases */
- subchar=(char *)cnv->subChars;
+ subchar = reinterpret_cast<char*>(cnv->subChars);
length=cnv->subCharLen;
}
@@ -5701,7 +5701,7 @@ ucnv_MBCSWriteSub(UConverterFromUnicodeArgs *pArgs,
return;
}
subchar=buffer;
- length=(int32_t)(p-buffer);
+ length = static_cast<int32_t>(p - buffer);
}
ucnv_cbFromUWriteBytes(pArgs, subchar, length, offsetIndex, pErrorCode);