From b4853d0331f421c3664b99c3f309b96bcc77aa31 Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Wed, 11 Nov 2009 15:47:22 +0000 Subject: [PATCH] ICU-7222 Remove Windows x64 warnings by casting explicitly. X-SVN-Rev: 26870 --- icu4c/source/common/brkeng.cpp | 4 +- icu4c/source/common/brkiter.cpp | 2 +- icu4c/source/common/ubidiln.c | 2 +- icu4c/source/common/ucasemap.c | 2 +- icu4c/source/common/ucnv2022.c | 4 +- icu4c/source/common/ucnv_lmb.c | 22 ++--- icu4c/source/common/ucnvisci.c | 2 +- icu4c/source/common/ucnvsel.cpp | 6 +- icu4c/source/common/uloc.c | 17 ++-- icu4c/source/common/uloc_tag.c | 88 ++++++++++---------- icu4c/source/common/unicode/unistr.h | 5 ++ icu4c/source/common/uniset.cpp | 6 +- icu4c/source/common/uresbund.c | 2 +- icu4c/source/common/ustring.c | 10 +-- icu4c/source/i18n/coleitr.cpp | 8 +- icu4c/source/i18n/coll.cpp | 2 +- icu4c/source/i18n/colldata.cpp | 2 +- icu4c/source/i18n/csr2022.cpp | 4 +- icu4c/source/i18n/dtfmtsym.cpp | 4 +- icu4c/source/i18n/inputext.cpp | 6 +- icu4c/source/i18n/plurrule.cpp | 2 +- icu4c/source/i18n/ucal.cpp | 2 +- icu4c/source/i18n/ucol.cpp | 116 +++++++++++++-------------- icu4c/source/i18n/ucol_elm.cpp | 11 ++- icu4c/source/i18n/ucol_res.cpp | 2 +- icu4c/source/i18n/ucol_sit.cpp | 6 +- icu4c/source/i18n/ucol_tok.cpp | 2 +- icu4c/source/i18n/ucurr.cpp | 6 +- icu4c/source/i18n/uspoof_conf.cpp | 8 +- icu4c/source/i18n/uspoof_impl.cpp | 6 +- icu4c/source/i18n/zonemeta.cpp | 4 +- icu4c/source/i18n/zstrfmt.cpp | 2 +- 32 files changed, 183 insertions(+), 182 deletions(-) diff --git a/icu4c/source/common/brkeng.cpp b/icu4c/source/common/brkeng.cpp index 2419be5f6c..6d1fa36698 100644 --- a/icu4c/source/common/brkeng.cpp +++ b/icu4c/source/common/brkeng.cpp @@ -1,6 +1,6 @@ /** ************************************************************************************ - * Copyright (C) 2006-2007, International Business Machines Corporation and others. * + * Copyright (C) 2006-2009, International Business Machines Corporation and others. * * All Rights Reserved. * ************************************************************************************ */ @@ -262,7 +262,7 @@ ICULanguageBreakFactory::loadDictionaryFor(UScriptCode script, int32_t /*breakTy UChar* extStart=u_strchr(dictfname, 0x002e); int len = 0; if(extStart!=NULL){ - len = extStart-dictfname; + len = (int)(extStart-dictfname); u_UCharsToChars(extStart+1, ext, sizeof(ext)); // nul terminates the buff u_UCharsToChars(dictfname, dictnbuff, len); } diff --git a/icu4c/source/common/brkiter.cpp b/icu4c/source/common/brkiter.cpp index 3cbfbf9d69..c4a1736471 100644 --- a/icu4c/source/common/brkiter.cpp +++ b/icu4c/source/common/brkiter.cpp @@ -100,7 +100,7 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, int32_t kind, UChar* extStart=u_strchr(brkfname, 0x002e); int len = 0; if(extStart!=NULL){ - len = extStart-brkfname; + len = (int)(extStart-brkfname); u_UCharsToChars(extStart+1, ext, sizeof(ext)); // nul terminates the buff u_UCharsToChars(brkfname, fnbuff, len); } diff --git a/icu4c/source/common/ubidiln.c b/icu4c/source/common/ubidiln.c index 279812ac88..6ddf322224 100644 --- a/icu4c/source/common/ubidiln.c +++ b/icu4c/source/common/ubidiln.c @@ -696,7 +696,7 @@ ubidi_getRuns(UBiDi *pBiDi, UErrorCode *pErrorCode) { const UChar *start=pBiDi->text, *limit=start+pBiDi->length, *pu; for(pu=start; puruns[runIndex].insertRemove--; } } diff --git a/icu4c/source/common/ucasemap.c b/icu4c/source/common/ucasemap.c index cddc080f1f..67f5787d48 100644 --- a/icu4c/source/common/ucasemap.c +++ b/icu4c/source/common/ucasemap.c @@ -472,7 +472,7 @@ caseMap(const UCaseMap *csm, /* get the string length */ if(srcLength==-1) { - srcLength=uprv_strlen((const char *)src); + srcLength=(int32_t)uprv_strlen((const char *)src); } /* check for overlapping source and destination */ diff --git a/icu4c/source/common/ucnv2022.c b/icu4c/source/common/ucnv2022.c index 41334d9e90..5c034461b0 100644 --- a/icu4c/source/common/ucnv2022.c +++ b/icu4c/source/common/ucnv2022.c @@ -2091,7 +2091,7 @@ escape: if(myData->version==0 && myData->key==0 && U_SUCCESS(*err) && myData->isEmptySegment) { *err = U_ILLEGAL_ESCAPE_SEQUENCE; args->converter->toUCallbackReason = UCNV_IRREGULAR; - args->converter->toULength = toULengthBefore + (mySource - mySourceBefore); + args->converter->toULength = (int8_t)(toULengthBefore + (mySource - mySourceBefore)); } } @@ -3272,7 +3272,7 @@ escape: if(myData->key==0 && U_SUCCESS(*err) && myData->isEmptySegment) { *err = U_ILLEGAL_ESCAPE_SEQUENCE; args->converter->toUCallbackReason = UCNV_IRREGULAR; - args->converter->toULength = toULengthBefore + (mySource - mySourceBefore); + args->converter->toULength = (int8_t)(toULengthBefore + (mySource - mySourceBefore)); } } diff --git a/icu4c/source/common/ucnv_lmb.c b/icu4c/source/common/ucnv_lmb.c index db9aa808a8..fc9a79e578 100644 --- a/icu4c/source/common/ucnv_lmb.c +++ b/icu4c/source/common/ucnv_lmb.c @@ -784,7 +784,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, UChar uniChar; ulmbcs_byte_t LMBCS[ULMBCS_CHARSIZE_MAX]; ulmbcs_byte_t * pLMBCS; - int bytes_written; + int32_t bytes_written; UBool groups_tried[ULMBCS_GRP_LAST+1]; UConverterDataLMBCS * extraInfo = (UConverterDataLMBCS *) args->converter->extraInfo; int sourceIndex = 0; @@ -847,7 +847,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, { pLMBCS += LMBCSConvertUni(pLMBCS,uniChar); - bytes_written = pLMBCS - LMBCS; + bytes_written = (int32_t)(pLMBCS - LMBCS); } else if (group == ULMBCS_GRP_CTRL) /* (Strategy 2B) */ { @@ -862,12 +862,12 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, *pLMBCS++ = ULMBCS_GRP_CTRL; *pLMBCS++ = (ulmbcs_byte_t ) (uniChar & 0x00FF); } - bytes_written = pLMBCS - LMBCS; + bytes_written = (int32_t)(pLMBCS - LMBCS); } else if (group < ULMBCS_GRP_UNICODE) /* (Strategy 2C) */ { /* a specific converter has been identified - use it */ - bytes_written = LMBCSConversionWorker ( + bytes_written = (int32_t)LMBCSConversionWorker ( extraInfo, group, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } @@ -879,7 +879,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, if (extraInfo->OptGroup != 1 && ULMBCS_AMBIGUOUS_MATCH(group, extraInfo->OptGroup)) { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, extraInfo->OptGroup, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } @@ -888,7 +888,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, && (extraInfo->localeConverterIndex) && (ULMBCS_AMBIGUOUS_MATCH(group, extraInfo->localeConverterIndex))) { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, extraInfo->localeConverterIndex, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } @@ -897,7 +897,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, && (lastConverterIndex) && (ULMBCS_AMBIGUOUS_MATCH(group, lastConverterIndex))) { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, lastConverterIndex, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); @@ -920,7 +920,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, { if (extraInfo->OptGrpConverter [grp_ix] && !groups_tried [grp_ix]) { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, grp_ix, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } @@ -929,7 +929,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, to be single byte (Strategy 3E) */ if (!bytes_written && grp_start == ULMBCS_GRP_L1) { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, ULMBCS_GRP_EXCEPT, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } @@ -939,7 +939,7 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, { pLMBCS += LMBCSConvertUni(pLMBCS, uniChar); - bytes_written = pLMBCS - LMBCS; + bytes_written = (int32_t)(pLMBCS - LMBCS); } } } @@ -1215,7 +1215,7 @@ _LMBCSToUnicodeWithOffsets(UConverterToUnicodeArgs* args, *(args->target)++ = uniChar; if(args->offsets) { - *(args->offsets)++ = saveSource - pStartLMBCS; + *(args->offsets)++ = (int32_t)(saveSource - pStartLMBCS); } } else if (uniChar == 0xfffe) diff --git a/icu4c/source/common/ucnvisci.c b/icu4c/source/common/ucnvisci.c index ece3b5d964..411085226c 100644 --- a/icu4c/source/common/ucnvisci.c +++ b/icu4c/source/common/ucnvisci.c @@ -1428,7 +1428,7 @@ static void UConverter_toUnicode_ISCII_OFFSETS_LOGIC(UConverterToUnicodeArgs *ar if (data->currentDeltaToUnicode == PNJ_DELTA && data->prevToUnicodeStatus != 0 && uset_contains(PNJ_CONSONANT_SET, data->prevToUnicodeStatus) && (*toUnicodeStatus + PNJ_DELTA) == PNJ_SIGN_VIRAMA && (targetUniChar + PNJ_DELTA) == data->prevToUnicodeStatus) { /* Consonant clusters C + HALANT + C should be encoded as ADHAK + C */ - offset = source-args->source - 3; + offset = (int)(source-args->source - 3); tempTargetUniChar = PNJ_ADHAK; /* This is necessary to avoid some compiler warnings. */ WRITE_TO_TARGET_TO_U(args,source,target,args->offsets,offset,tempTargetUniChar,0,err); WRITE_TO_TARGET_TO_U(args,source,target,args->offsets,offset,data->prevToUnicodeStatus,0,err); diff --git a/icu4c/source/common/ucnvsel.cpp b/icu4c/source/common/ucnvsel.cpp index 3a8b2bbc50..bdd4e9a8fe 100644 --- a/icu4c/source/common/ucnvsel.cpp +++ b/icu4c/source/common/ucnvsel.cpp @@ -183,7 +183,7 @@ ucnvsel_open(const char* const* converterList, int32_t converterListSize, int32_t i; for (i = 0; i < converterListSize; i++) { totalSize += - uprv_strlen(converterList != NULL ? converterList[i] : ucnv_getAvailableName(i)) + 1; + (int32_t)uprv_strlen(converterList != NULL ? converterList[i] : ucnv_getAvailableName(i)) + 1; } // 4-align the totalSize to 4-align the size of the serialized form int32_t encodingStrPadding = totalSize & 3; @@ -633,7 +633,7 @@ static const char* U_CALLCONV ucnvsel_next_encoding(UEnumeration* enumerator, result = sel->encodings[((Enumerator*)(enumerator->context))->index[cur] ]; ((Enumerator*)(enumerator->context))->cur++; if (resultLength) { - *resultLength = uprv_strlen(result); + *resultLength = (int32_t)uprv_strlen(result); } return result; } @@ -799,7 +799,7 @@ ucnvsel_selectForUTF8(const UConverterSelector* sel, uprv_memset(mask, ~0, columns *4); if (length < 0) { - length = uprv_strlen(s); + length = (int32_t)uprv_strlen(s); } const char *limit = s + length; diff --git a/icu4c/source/common/uloc.c b/icu4c/source/common/uloc.c index a6ca9bf2e8..ffff5d7f45 100644 --- a/icu4c/source/common/uloc.c +++ b/icu4c/source/common/uloc.c @@ -1628,7 +1628,7 @@ _canonicalize(const char* localeID, if(len == I_DEFAULT_LENGTH && uprv_strncmp(origLocaleID, i_default, len) == 0) { const char *d = uloc_getDefault(); - len = uprv_strlen(d); + len = (int32_t)uprv_strlen(d); if (name != NULL) { uprv_strncpy(name, d, len); @@ -3427,7 +3427,7 @@ createTagStringWithAlternates( */ appendTag( unknownLanguage, - uprv_strlen(unknownLanguage), + (int32_t)uprv_strlen(unknownLanguage), tagBuffer, &tagLength); } @@ -3455,7 +3455,7 @@ createTagStringWithAlternates( */ appendTag( unknownLanguage, - uprv_strlen(unknownLanguage), + (int32_t)uprv_strlen(unknownLanguage), tagBuffer, &tagLength); } @@ -3728,7 +3728,7 @@ parseTagString( uprv_strcpy( lang, unknownLanguage); - *langLength = uprv_strlen(lang); + *langLength = (int32_t)uprv_strlen(lang); } else if (_isIDSeparator(*position)) { ++position; @@ -4113,7 +4113,7 @@ _uloc_addLikelySubtags(const char* localeID, /* Find the length of the trailing portion. */ trailing = &localeID[trailingIndex]; - trailingLength = uprv_strlen(trailing); + trailingLength = (int32_t)uprv_strlen(trailing); CHECK_TRAILING_VARIANT_SIZE(trailing, trailingLength); @@ -4132,8 +4132,7 @@ _uloc_addLikelySubtags(const char* localeID, err); if (resultLength == 0) { - const int32_t localIDLength = - uprv_strlen(localeID); + const int32_t localIDLength = (int32_t)uprv_strlen(localeID); /* * If we get here, we need to return localeID. @@ -4219,7 +4218,7 @@ _uloc_minimizeSubtags(const char* localeID, /* Find the spot where the variants begin, if any. */ trailing = &localeID[trailingIndex]; - trailingLength = uprv_strlen(trailing); + trailingLength = (int32_t)uprv_strlen(trailing); CHECK_TRAILING_VARIANT_SIZE(trailing, trailingLength); @@ -4390,7 +4389,7 @@ _uloc_minimizeSubtags(const char* localeID, /** * If we got here, return the locale ID parameter. **/ - const int32_t localeIDLength = uprv_strlen(localeID); + const int32_t localeIDLength = (int32_t)uprv_strlen(localeID); uprv_memcpy( minimizedLocaleID, diff --git a/icu4c/source/common/uloc_tag.c b/icu4c/source/common/uloc_tag.c index ee82cd06ba..729ac2deb2 100644 --- a/icu4c/source/common/uloc_tag.c +++ b/icu4c/source/common/uloc_tag.c @@ -206,7 +206,7 @@ _isLanguageSubtag(const char* s, int32_t len) { * / 5*8ALPHA ; or registered language subtag */ if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len >= 2 && len <= 8 && _isAlphaString(s, len)) { return TRUE; @@ -221,7 +221,7 @@ _isExtlangSubtag(const char* s, int32_t len) { * *2("-" 3ALPHA) ; permanently reserved */ if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len == 3 && _isAlphaString(s, len)) { return TRUE; @@ -235,7 +235,7 @@ _isScriptSubtag(const char* s, int32_t len) { * script = 4ALPHA ; ISO 15924 code */ if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len == 4 && _isAlphaString(s, len)) { return TRUE; @@ -250,7 +250,7 @@ _isRegionSubtag(const char* s, int32_t len) { * / 3DIGIT ; UN M.49 code */ if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len == 2 && _isAlphaString(s, len)) { return TRUE; @@ -268,7 +268,7 @@ _isVariantSubtag(const char* s, int32_t len) { * / (DIGIT 3alphanum) */ if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len >= 5 && len <= 8 && _isAlphaString(s, len)) { return TRUE; @@ -285,7 +285,7 @@ _isExtensionSingleton(const char* s, int32_t len) { * extension = singleton 1*("-" (2*8alphanum)) */ if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len == 1 && ISALPHA(*s) && (uprv_tolower(*s) != PRIVATEUSE)) { return TRUE; @@ -299,7 +299,7 @@ _isExtensionSubtag(const char* s, int32_t len) { * extension = singleton 1*("-" (2*8alphanum)) */ if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len >= 2 && len <= 8 && _isAlphaNumericString(s, len)) { return TRUE; @@ -313,7 +313,7 @@ _isExtensionSubtags(const char* s, int32_t len) { const char *pSubtag = NULL; if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } while ((p - s) < len) { @@ -321,7 +321,7 @@ _isExtensionSubtags(const char* s, int32_t len) { if (pSubtag == NULL) { return FALSE; } - if (!_isExtensionSubtag(pSubtag, p - pSubtag)) { + if (!_isExtensionSubtag(pSubtag, (int32_t)(p - pSubtag))) { return FALSE; } pSubtag = NULL; @@ -333,7 +333,7 @@ _isExtensionSubtags(const char* s, int32_t len) { if (pSubtag == NULL) { return FALSE; } - return _isExtensionSubtag(pSubtag, p - pSubtag); + return _isExtensionSubtag(pSubtag, (int32_t)(p - pSubtag)); } static UBool @@ -342,7 +342,7 @@ _isPrivateuseValueSubtag(const char* s, int32_t len) { * privateuse = "x" 1*("-" (1*8alphanum)) */ if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len >= 1 && len <= 8 && _isAlphaNumericString(s, len)) { return TRUE; @@ -356,7 +356,7 @@ _isPrivateuseValueSubtags(const char* s, int32_t len) { const char *pSubtag = NULL; if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } while ((p - s) < len) { @@ -364,7 +364,7 @@ _isPrivateuseValueSubtags(const char* s, int32_t len) { if (pSubtag == NULL) { return FALSE; } - if (!_isPrivateuseValueSubtag(pSubtag, p - pSubtag)) { + if (!_isPrivateuseValueSubtag(pSubtag, (int32_t)(p - pSubtag))) { return FALSE; } pSubtag = NULL; @@ -376,13 +376,13 @@ _isPrivateuseValueSubtags(const char* s, int32_t len) { if (pSubtag == NULL) { return FALSE; } - return _isPrivateuseValueSubtag(pSubtag, p - pSubtag); + return _isPrivateuseValueSubtag(pSubtag, (int32_t)(p - pSubtag)); } static UBool _isLDMLKey(const char* s, int32_t len) { if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len == 2 && _isAlphaNumericString(s, len)) { return TRUE; @@ -393,7 +393,7 @@ _isLDMLKey(const char* s, int32_t len) { static UBool _isLDMLType(const char* s, int32_t len) { if (len < 0) { - len = uprv_strlen(s); + len = (int32_t)uprv_strlen(s); } if (len >= 3 && len <= 8 && _isAlphaNumericString(s, len)) { return TRUE; @@ -477,8 +477,8 @@ _addExtensionToList(ExtensionListEntry **first, ExtensionListEntry *ext, UBool l /* special handling for locale to bcp conversion */ int32_t len, curlen; - len = uprv_strlen(ext->key); - curlen = uprv_strlen(cur->key); + len = (int32_t)uprv_strlen(ext->key); + curlen = (int32_t)uprv_strlen(cur->key); if (len == 1 && curlen == 1) { if (*(ext->key) == *(cur->key)) { @@ -563,7 +563,7 @@ _ldmlKeyToBCP47(const char* key, int32_t keyLen, int32_t bcpKeyLen; if (keyLen < 0) { - keyLen = uprv_strlen(key); + keyLen = (int32_t)uprv_strlen(key); } if (keyLen >= sizeof(keyBuf)) { @@ -626,7 +626,7 @@ _bcp47ToLDMLKey(const char* bcpKey, int32_t bcpKeyLen, UResourceBundle *keyMap; if (bcpKeyLen < 0) { - bcpKeyLen = uprv_strlen(bcpKey); + bcpKeyLen = (int32_t)uprv_strlen(bcpKey); } if (bcpKeyLen >= sizeof(bcpKeyBuf)) { @@ -665,7 +665,7 @@ _bcp47ToLDMLKey(const char* bcpKey, int32_t bcpKeyLen, if (uprv_strcmp(bcpKeyBuf, tmpBcpKeyBuf) == 0) { /* found a matching BCP47 key */ resKey = ures_getKey(keyMap); - resultLen = uprv_strlen(resKey); + resultLen = (int32_t)uprv_strlen(resKey); break; } if (!ures_hasNext(rb)) { @@ -707,7 +707,7 @@ _ldmlTypeToBCP47(const char* key, int32_t keyLen, UBool isTimezone = FALSE; if (keyLen < 0) { - keyLen = uprv_strlen(key); + keyLen = (int32_t)uprv_strlen(key); } if (keyLen >= sizeof(keyBuf)) { /* no known valid LDML key exceeding 21 */ @@ -726,7 +726,7 @@ _ldmlTypeToBCP47(const char* key, int32_t keyLen, } if (typeLen < 0) { - typeLen = uprv_strlen(type); + typeLen = (int32_t)uprv_strlen(type); } if (typeLen >= sizeof(typeBuf)) { *status = U_ILLEGAL_ARGUMENT_ERROR; @@ -792,7 +792,7 @@ _bcp47ToLDMLType(const char* key, int32_t keyLen, int32_t copyLen; if (keyLen < 0) { - keyLen = uprv_strlen(key); + keyLen = (int32_t)uprv_strlen(key); } if (keyLen >= sizeof(keyBuf)) { @@ -810,7 +810,7 @@ _bcp47ToLDMLType(const char* key, int32_t keyLen, if (bcpTypeLen < 0) { - bcpTypeLen = uprv_strlen(bcpType); + bcpTypeLen = (int32_t)uprv_strlen(bcpType); } if (bcpTypeLen >= sizeof(bcpTypeBuf)) { @@ -849,7 +849,7 @@ _bcp47ToLDMLType(const char* key, int32_t keyLen, if (uprv_strcmp(bcpTypeBuf, tmpBcpTypeBuf) == 0) { /* found a matching BCP47 type */ resType = ures_getKey(typeMap); - resultLen = uprv_strlen(resType); + resultLen = (int32_t)uprv_strlen(resType); break; } if (!ures_hasNext(rb)) { @@ -926,7 +926,7 @@ _appendLanguageToLanguageTag(const char* localeID, char* appendAt, int32_t capac for (i = 0; DEPRECATEDLANGS[i] != NULL; i += 2) { if (uprv_strcmp(buf, DEPRECATEDLANGS[i]) == 0) { uprv_strcpy(buf, DEPRECATEDLANGS[i + 1]); - len = uprv_strlen(buf); + len = (int32_t)uprv_strlen(buf); break; } } @@ -1111,7 +1111,7 @@ _appendVariantsToLanguageTag(const char* localeID, char* appendAt, int32_t capac *(appendAt + reslen) = SEP; } reslen++; - varLen = uprv_strlen(var->variant); + varLen = (int32_t)uprv_strlen(var->variant); if (reslen < capacity) { uprv_memcpy(appendAt + reslen, var->variant, uprv_min(varLen, capacity - reslen)); } @@ -1179,7 +1179,7 @@ _appendKeywordsToLanguageTag(const char* localeID, char* appendAt, int32_t capac continue; } - keylen = uprv_strlen(key); + keylen = (int32_t)uprv_strlen(key); isLDMLKeyword = (keylen > 1); if (isLDMLKeyword) { @@ -1270,7 +1270,7 @@ _appendKeywordsToLanguageTag(const char* localeID, char* appendAt, int32_t capac /* write out the sorted BCP47 extensions and private use */ ext = firstExt; while (ext != NULL) { - if (uprv_strlen(ext->key) > 1 && !startLDMLExtension) { + if ((int32_t)uprv_strlen(ext->key) > 1 && !startLDMLExtension) { /* write LDML singleton extension */ if (reslen < capacity) { *(appendAt + reslen) = SEP; @@ -1287,7 +1287,7 @@ _appendKeywordsToLanguageTag(const char* localeID, char* appendAt, int32_t capac *(appendAt + reslen) = SEP; } reslen++; - len = uprv_strlen(ext->key); + len = (int32_t)uprv_strlen(ext->key); if (reslen < capacity) { uprv_memcpy(appendAt + reslen, ext->key, uprv_min(len, capacity - reslen)); } @@ -1296,7 +1296,7 @@ _appendKeywordsToLanguageTag(const char* localeID, char* appendAt, int32_t capac *(appendAt + reslen) = SEP; } reslen++; - len = uprv_strlen(ext->value); + len = (int32_t)uprv_strlen(ext->value); if (reslen < capacity) { uprv_memcpy(appendAt + reslen, ext->value, uprv_min(len, capacity - reslen)); } @@ -1360,10 +1360,10 @@ _appendLDMLExtensionAsKeywords(const char* ldmlext, ExtensionListEntry** appendT if (pBcpKey == NULL) { pBcpKey = p; - bcpKeyLen = pSep - p; + bcpKeyLen = (int32_t)(pSep - p); } else { pBcpType = p; - bcpTypeLen = pSep - p; + bcpTypeLen = (int32_t)(pSep - p); /* BCP key to locale key */ len = _bcp47ToLDMLKey(pBcpKey, bcpKeyLen, buf + bufIdx, bufSize - bufIdx - 1, status); @@ -1474,7 +1474,7 @@ _appendKeywords(ULanguageTag* langtag, char* appendAt, int32_t capacity, UErrorC if (U_SUCCESS(*status)) { type = ultag_getPrivateUse(langtag); - if (uprv_strlen(type) > 0) { + if ((int32_t)uprv_strlen(type) > 0) { /* add private use as a keyword */ kwd = uprv_malloc(sizeof(ExtensionListEntry)); if (kwd == NULL) { @@ -1506,7 +1506,7 @@ _appendKeywords(ULanguageTag* langtag, char* appendAt, int32_t capacity, UErrorC reslen++; /* key */ - len = uprv_strlen(kwd->key); + len = (int32_t)uprv_strlen(kwd->key); if (reslen < capacity) { uprv_memcpy(appendAt + reslen, kwd->key, uprv_min(len, capacity - reslen)); } @@ -1519,7 +1519,7 @@ _appendKeywords(ULanguageTag* langtag, char* appendAt, int32_t capacity, UErrorC reslen++; /* type */ - len = uprv_strlen(kwd->value); + len = (int32_t)uprv_strlen(kwd->value); if (reslen < capacity) { uprv_memcpy(appendAt + reslen, kwd->value, uprv_min(len, capacity - reslen)); } @@ -1584,7 +1584,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta } if (tagLen < 0) { - tagLen = uprv_strlen(tag); + tagLen = (int32_t)uprv_strlen(tag); } /* copy the entire string */ @@ -1661,7 +1661,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta } else { pNext = pSep + 1; } - subtagLen = pSep - pSubtag; + subtagLen = (int32_t)(pSep - pSubtag); if (next & LANG) { if (_isLanguageSubtag(pSubtag, subtagLen)) { @@ -1884,7 +1884,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta } else { pNext = pSep + 1; } - subtagLen = pSep - pSubtag; + subtagLen = (int32_t)(pSep - pSubtag); if (_isPrivateuseValueSubtag(pSubtag, subtagLen)) { pLastGoodPosition = pSep; @@ -1924,7 +1924,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta } if (parsedLen != NULL) { - *parsedLen = pLastGoodPosition - t->buf; + *parsedLen = (int32_t)(pLastGoodPosition - t->buf); } return t; @@ -2160,7 +2160,7 @@ uloc_forLanguageTag(const char* langtag, /* language */ subtag = ultag_getExtlangSize(lt) > 0 ? ultag_getExtlang(lt, 0) : ultag_getLanguage(lt); if (uprv_strcmp(subtag, LANG_UND) != 0) { - len = uprv_strlen(subtag); + len = (int32_t)uprv_strlen(subtag); if (len > 0) { if (reslen < localeIDCapacity) { uprv_memcpy(localeID, subtag, uprv_min(len, localeIDCapacity - reslen)); @@ -2171,7 +2171,7 @@ uloc_forLanguageTag(const char* langtag, /* script */ subtag = ultag_getScript(lt); - len = uprv_strlen(subtag); + len = (int32_t)uprv_strlen(subtag); if (len > 0) { if (reslen < localeIDCapacity) { *(localeID + reslen) = LOCALE_SEP; @@ -2195,7 +2195,7 @@ uloc_forLanguageTag(const char* langtag, /* region */ subtag = ultag_getRegion(lt); - len = uprv_strlen(subtag); + len = (int32_t)uprv_strlen(subtag); if (len > 0) { if (reslen < localeIDCapacity) { *(localeID + reslen) = LOCALE_SEP; diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h index 50de6e0320..953e9ed9a5 100644 --- a/icu4c/source/common/unicode/unistr.h +++ b/icu4c/source/common/unicode/unistr.h @@ -4047,8 +4047,13 @@ UnicodeString::extract(int32_t start, { // This dstSize value will be checked explicitly +#if defined(__GNUC__) // Ticket #7039: Clip length to the maximum valid length to the end of addressable memory given the starting address + // This is only an issue when using GCC and certain optimizations are turned on. return extract(start, _length, dst, dst!=0 ? ((dst >= (char*)((size_t)-1) - UINT32_MAX) ? (((char*)UINT32_MAX) - dst) : UINT32_MAX) : 0, codepage); +#else + return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage); +#endif } #endif diff --git a/icu4c/source/common/uniset.cpp b/icu4c/source/common/uniset.cpp index 0f90aa5457..4ff3f6b271 100644 --- a/icu4c/source/common/uniset.cpp +++ b/icu4c/source/common/uniset.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 1999-2008, International Business Machines +* Copyright (C) 1999-2009, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -2208,7 +2208,7 @@ int32_t UnicodeSet::spanUTF8(const char *s, int32_t length, USetSpanCondition sp return (int32_t)(bmpSet->spanUTF8(s0, length, spanCondition)-s0); } if(length<0) { - length=uprv_strlen(s); + length=(int32_t)uprv_strlen(s); } if(length==0) { return 0; @@ -2249,7 +2249,7 @@ int32_t UnicodeSet::spanBackUTF8(const char *s, int32_t length, USetSpanConditio return bmpSet->spanBackUTF8(s0, length, spanCondition); } if(length<0) { - length=uprv_strlen(s); + length=(int32_t)uprv_strlen(s); } if(length==0) { return 0; diff --git a/icu4c/source/common/uresbund.c b/icu4c/source/common/uresbund.c index 35c44a0a1e..b135b95485 100644 --- a/icu4c/source/common/uresbund.c +++ b/icu4c/source/common/uresbund.c @@ -253,7 +253,7 @@ static void initCache(UErrorCode *status) { /** INTERNAL: sets the name (locale) of the resource bundle to given name */ static void setEntryName(UResourceDataEntry *res, char *name, UErrorCode *status) { - int32_t len = uprv_strlen(name); + int32_t len = (int32_t)uprv_strlen(name); if(res->fName != NULL && res->fName != res->fNameBuffer) { uprv_free(res->fName); } diff --git a/icu4c/source/common/ustring.c b/icu4c/source/common/ustring.c index 562f0f674e..4793ae15d2 100644 --- a/icu4c/source/common/ustring.c +++ b/icu4c/source/common/ustring.c @@ -1373,12 +1373,12 @@ u_unescape(const char *src, UChar *dest, int32_t destCapacity) { if (src != segment) { if (dest != NULL) { _appendUChars(dest + i, destCapacity - i, - segment, src - segment); + segment, (int32_t)(src - segment)); } - i += src - segment; + i += (int32_t)(src - segment); } ++src; /* advance past '\\' */ - c32 = u_unescapeAt(_charPtr_charAt, &lenParsed, uprv_strlen(src), (void*)src); + c32 = (UChar32)u_unescapeAt(_charPtr_charAt, &lenParsed, (int32_t)uprv_strlen(src), (void*)src); if (lenParsed == 0) { goto err; } @@ -1396,9 +1396,9 @@ u_unescape(const char *src, UChar *dest, int32_t destCapacity) { if (src != segment) { if (dest != NULL) { _appendUChars(dest + i, destCapacity - i, - segment, src - segment); + segment, (int32_t)(src - segment)); } - i += src - segment; + i += (int32_t)(src - segment); } if (dest != NULL && i < destCapacity) { dest[i] = 0; diff --git a/icu4c/source/i18n/coleitr.cpp b/icu4c/source/i18n/coleitr.cpp index b0b113199d..1dc79d9c09 100644 --- a/icu4c/source/i18n/coleitr.cpp +++ b/icu4c/source/i18n/coleitr.cpp @@ -99,10 +99,8 @@ UBool CollationElementIterator::operator==( // the constructor and setText always sets a length // and we only compare the string not the contents of the normalization // buffer - int thislength = m_data_->iteratordata_.endp - - m_data_->iteratordata_.string; - int thatlength = that.m_data_->iteratordata_.endp - - that.m_data_->iteratordata_.string; + int thislength = (int)(m_data_->iteratordata_.endp - m_data_->iteratordata_.string); + int thatlength = (int)(that.m_data_->iteratordata_.endp - that.m_data_->iteratordata_.string); if (thislength != thatlength) { return FALSE; @@ -400,7 +398,7 @@ const CollationElementIterator& CollationElementIterator::operator=( // checking only UCOL_ITER_HASLEN is not enough here as we may be in // the normalization buffer - length = othercoliter->endp - othercoliter->string; + length = (int)(othercoliter->endp - othercoliter->string); ucolelem->reset_ = otherucolelem->reset_; ucolelem->isWritable = TRUE; diff --git a/icu4c/source/i18n/coll.cpp b/icu4c/source/i18n/coll.cpp index 1a5f43aa58..86f423ed3a 100644 --- a/icu4c/source/i18n/coll.cpp +++ b/icu4c/source/i18n/coll.cpp @@ -743,7 +743,7 @@ public: if(index < availableLocaleListCount) { result = availableLocaleList[index++].getName(); if(resultLength != NULL) { - *resultLength = uprv_strlen(result); + *resultLength = (int32_t)uprv_strlen(result); } } else { if(resultLength != NULL) { diff --git a/icu4c/source/i18n/colldata.cpp b/icu4c/source/i18n/colldata.cpp index 73f4df542d..c5349d2b60 100644 --- a/icu4c/source/i18n/colldata.cpp +++ b/icu4c/source/i18n/colldata.cpp @@ -467,7 +467,7 @@ private: UHashtable *cache; }; -U_CFUNC void deleteChars(void */*obj*/) +U_CFUNC void deleteChars(void * /*obj*/) { // char *chars = (char *) obj; // All the key strings are owned by the diff --git a/icu4c/source/i18n/csr2022.cpp b/icu4c/source/i18n/csr2022.cpp index 68e5ff61fd..84d9495057 100644 --- a/icu4c/source/i18n/csr2022.cpp +++ b/icu4c/source/i18n/csr2022.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** - * Copyright (C) 2005-2008, International Business Machines + * Copyright (C) 2005-2009, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** */ @@ -44,7 +44,7 @@ int32_t CharsetRecog_2022::match_2022(const uint8_t *text, int32_t textLen, cons escN = 0; while(escN < escapeSequences_length) { const uint8_t *seq = escapeSequences[escN]; - int32_t seq_length = uprv_strlen((const char *) seq); + int32_t seq_length = (int32_t)uprv_strlen((const char *) seq); if (textLen-i >= seq_length) { j = 1; diff --git a/icu4c/source/i18n/dtfmtsym.cpp b/icu4c/source/i18n/dtfmtsym.cpp index 61755b05ca..b6ec89519a 100644 --- a/icu4c/source/i18n/dtfmtsym.cpp +++ b/icu4c/source/i18n/dtfmtsym.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 1997-2008, International Business Machines Corporation and * +* Copyright (C) 1997-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -1397,7 +1397,7 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError } else { fGmtHourFormatsCount = GMT_HOUR_COUNT; fGmtHourFormats[GMT_NEGATIVE_HM].setTo(TRUE, sep + 1, -1); - fGmtHourFormats[GMT_POSITIVE_HM].setTo(FALSE, resStr, sep - resStr); + fGmtHourFormats[GMT_POSITIVE_HM].setTo(FALSE, resStr, (int32_t)(sep - resStr)); // CLDR 1.5 does not have GMT offset pattern including second field. // For now, append "ss" to the end. diff --git a/icu4c/source/i18n/inputext.cpp b/icu4c/source/i18n/inputext.cpp index 7df3df11fd..e5a8ee1868 100644 --- a/icu4c/source/i18n/inputext.cpp +++ b/icu4c/source/i18n/inputext.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** - * Copyright (C) 2005-2008, International Business Machines + * Copyright (C) 2005-2009, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** */ @@ -51,14 +51,14 @@ void InputText::setText(const char *in, int32_t len) fInputLen = 0; fC1Bytes = FALSE; fRawInput = (const uint8_t *) in; - fRawLength = len == -1? uprv_strlen(in) : len; + fRawLength = len == -1? (int32_t)uprv_strlen(in) : len; } void InputText::setDeclaredEncoding(const char* encoding, int32_t len) { if(encoding) { if (len == -1) { - len = uprv_strlen(encoding); + len = (int32_t)uprv_strlen(encoding); } len += 1; // to make place for the \0 at the end. diff --git a/icu4c/source/i18n/plurrule.cpp b/icu4c/source/i18n/plurrule.cpp index 103c26de91..666c827702 100644 --- a/icu4c/source/i18n/plurrule.cpp +++ b/icu4c/source/i18n/plurrule.cpp @@ -498,7 +498,7 @@ PluralRules::getRuleFromResource(const Locale& locale, UErrorCode& errCode) { int32_t keyLen; resLen=0; s=ures_getNextString(setRes, &resLen, (const char**)&key, &errCode); - keyLen = uprv_strlen(key); + keyLen = (int32_t)uprv_strlen(key); u_charsToUChars(key, result+len, keyLen); len += keyLen; result[len++]=COLON; diff --git a/icu4c/source/i18n/ucal.cpp b/icu4c/source/i18n/ucal.cpp index fbbcb8f002..b4c0690413 100644 --- a/icu4c/source/i18n/ucal.cpp +++ b/icu4c/source/i18n/ucal.cpp @@ -608,7 +608,7 @@ ucal_getKeywordValuesForLocale(const char * /* key */, const char* locale, UBool if (U_SUCCESS(*status) && !commonlyUsed) { // If not commonlyUsed, add other available values for (int32_t i = 0; CAL_TYPES[i] != NULL; i++) { - if (!ulist_containsString(values, CAL_TYPES[i], uprv_strlen(CAL_TYPES[i]))) { + if (!ulist_containsString(values, CAL_TYPES[i], (int32_t)uprv_strlen(CAL_TYPES[i]))) { ulist_addItemEndList(values, CAL_TYPES[i], FALSE, status); if (U_FAILURE(*status)) { break; diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index 4ca2d0547d..17339e1762 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -190,7 +190,7 @@ inline void loadState(collIterate *data, const collIterateState *backup, else { /* backwards direction */ uint32_t temp = backup->buffersize - - (data->pos - backup->bufferaddress); + (uint32_t)(data->pos - backup->bufferaddress); data->pos = data->writableBuffer + (data->writableBufSize - temp); } } @@ -1567,7 +1567,7 @@ void collPrevIterNormalize(collIterate *data) pStart = data->fcdPosition + 1; } - normLen = unorm_normalize(pStart, (pEnd - pStart) + 1, UNORM_NFD, 0, + normLen = unorm_normalize(pStart, (int32_t)((pEnd - pStart) + 1), UNORM_NFD, 0, data->writableBuffer, 0, &status); if (data->writableBufSize <= normLen) { @@ -1589,7 +1589,7 @@ void collPrevIterNormalize(collIterate *data) */ pStartNorm = data->writableBuffer + (data->writableBufSize - normLen); *(pStartNorm - 1) = 0; - unorm_normalize(pStart, (pEnd - pStart) + 1, UNORM_NFD, 0, pStartNorm, + unorm_normalize(pStart, (int32_t)((pEnd - pStart) + 1), UNORM_NFD, 0, pStartNorm, normLen, &status); if (data->offsetBuffer == NULL) { @@ -1599,7 +1599,7 @@ void collPrevIterNormalize(collIterate *data) data->offsetBuffer = (int32_t *) uprv_malloc(sizeof(int32_t) * len); data->offsetStore = data->offsetBuffer; } else if(data->offsetBufferSize < (int32_t) normLen) { - int32_t storeIX = data->offsetStore - data->offsetBuffer; + int32_t storeIX = (int32_t)(data->offsetStore - data->offsetBuffer); int32_t *tob = (int32_t *) uprv_realloc(data->offsetBuffer, sizeof(int32_t) * (normLen + 1)); if (tob != NULL) { @@ -1625,33 +1625,33 @@ void collPrevIterNormalize(collIterate *data) * of the rest of the marks. */ int32_t firstMarkOffset = 0; - int32_t trailOffset = data->pos - data->string + 1; + int32_t trailOffset = (int32_t)(data->pos - data->string + 1); int32_t trailCount = normLen - 1; if (data->fcdPosition != NULL) { - int32_t baseOffset = data->fcdPosition - data->string; + int32_t baseOffset = (int32_t)(data->fcdPosition - data->string); UChar baseChar = *data->fcdPosition; firstMarkOffset = baseOffset + 1; /* - * If the base character is the start of a contraction, forward processing - * will normalize the marks while checking for the contraction, which means - * that the offset of the first mark will the same as the other marks. - * - * **** THIS IS PROBABLY NOT A COMPLETE TEST **** - */ - if (baseChar >= 0x100) { - uint32_t baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->mapping, baseChar); + * If the base character is the start of a contraction, forward processing + * will normalize the marks while checking for the contraction, which means + * that the offset of the first mark will the same as the other marks. + * + * **** THIS IS PROBABLY NOT A COMPLETE TEST **** + */ + if (baseChar >= 0x100) { + uint32_t baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->mapping, baseChar); - if (baseOrder == UCOL_NOT_FOUND && data->coll->UCA) { - baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->UCA->mapping, baseChar); - } + if (baseOrder == UCOL_NOT_FOUND && data->coll->UCA) { + baseOrder = UTRIE_GET32_FROM_LEAD(&data->coll->UCA->mapping, baseChar); + } - if (baseOrder > UCOL_NOT_FOUND && getCETag(baseOrder) == CONTRACTION_TAG) { - firstMarkOffset = trailOffset; - } - } + if (baseOrder > UCOL_NOT_FOUND && getCETag(baseOrder) == CONTRACTION_TAG) { + firstMarkOffset = trailOffset; + } + } *(data->offsetStore++) = baseOffset; } @@ -2081,7 +2081,7 @@ static inline UChar * insertBufferEnd(collIterate *data, UChar *pNull, UChar *str, int32_t length) { - uint32_t size = pNull - data->writableBuffer; + uint32_t size = (uint32_t)(pNull - data->writableBuffer); UChar *newbuffer; if (data->writableBuffer + data->writableBufSize > pNull + length + 1) { @@ -2139,7 +2139,7 @@ inline void normalizeNextContraction(collIterate *data) pEnd = data->fcdPosition; - normLen = unorm_normalize(pStart, pEnd - pStart, UNORM_NFD, 0, buffer, 0, + normLen = unorm_normalize(pStart, (int32_t)(pEnd - pStart), UNORM_NFD, 0, buffer, 0, &status); if (buffersize <= normLen + strsize) { @@ -2159,7 +2159,7 @@ inline void normalizeNextContraction(collIterate *data) status = U_ZERO_ERROR; pStartNorm = buffer + strsize; /* null-termination will be added here */ - unorm_normalize(pStart, pEnd - pStart, UNORM_NFD, 0, pStartNorm, + unorm_normalize(pStart, (int32_t)(pEnd - pStart), UNORM_NFD, 0, pStartNorm, normLen + 1, &status); data->pos = data->writableBuffer + strsize; @@ -2289,7 +2289,7 @@ inline UChar getNextNormalizedChar(collIterate *data) /* fcdposition shifted even when there's no normalization, if we don't input the rest into this, we'll get the wrong position when we reach the end of the writableBuffer */ - int32_t length = data->fcdPosition - data->pos + 1; + int32_t length = (int32_t)(data->fcdPosition - data->pos + 1); data->pos = insertBufferEnd(data, pEndWritableBuffer, data->pos - 1, length); // Check if data->pos received a null pointer @@ -2586,7 +2586,7 @@ inline void normalizePrevContraction(collIterate *data, UErrorCode *status) pStart = data->fcdPosition + 1; } - normLen = unorm_normalize(pStart, pEnd - pStart, UNORM_NFD, 0, data->writableBuffer, 0, + normLen = unorm_normalize(pStart, (int32_t)(pEnd - pStart), UNORM_NFD, 0, data->writableBuffer, 0, &localstatus); if (nulltermsize <= normLen) { @@ -2610,7 +2610,7 @@ inline void normalizePrevContraction(collIterate *data, UErrorCode *status) */ pStartNorm = data->writableBuffer + (nulltermsize - normLen); *(pStartNorm - 1) = 0; - unorm_normalize(pStart, pEnd - pStart, UNORM_NFD, 0, pStartNorm, normLen, + unorm_normalize(pStart, (int32_t)(pEnd - pStart), UNORM_NFD, 0, pStartNorm, normLen, status); data->pos = data->writableBuffer + nulltermsize; @@ -3527,7 +3527,7 @@ uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE, /* we have exhausted the buffer */ int32_t newsize = 0; if(source->pos) { // actually dealing with a position - newsize = source->pos - source->string + 1; + newsize = (int32_t)(source->pos - source->string + 1); } else { // iterator newsize = 4 * UCOL_MAX_BUFFER; } @@ -3573,15 +3573,15 @@ uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE, temp.flags &= ~UCOL_ITER_NORM; temp.flags |= source->flags & UCOL_FORCE_HAN_IMPLICIT; - rawOffset = temp.pos - temp.string; // should always be zero? + rawOffset = (int32_t)(temp.pos - temp.string); // should always be zero? CE = ucol_IGetNextCE(coll, &temp, status); if (source->extendCEs) { endCEBuffer = source->extendCEs + source->extendCEsSize; - CECount = (source->CEpos - source->extendCEs)/sizeof(uint32_t); + CECount = (int32_t)((source->CEpos - source->extendCEs)/sizeof(uint32_t)); } else { endCEBuffer = source->CEs + UCOL_EXPAND_CE_BUFFER_SIZE; - CECount = (source->CEpos - source->CEs)/sizeof(uint32_t); + CECount = (int32_t)((source->CEpos - source->CEs)/sizeof(uint32_t)); } if (source->offsetBuffer == NULL) { @@ -3642,7 +3642,7 @@ uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE, } if (offsetBias >= 0 && source->offsetStore >= &source->offsetBuffer[source->offsetBufferSize]) { - int32_t storeIX = source->offsetStore - source->offsetBuffer; + int32_t storeIX = (int32_t)(source->offsetStore - source->offsetBuffer); int32_t *tob = (int32_t *) uprv_realloc(source->offsetBuffer, sizeof(int32_t) * (source->offsetBufferSize + UCOL_EXPAND_CE_BUFFER_EXTEND_SIZE)); @@ -3665,9 +3665,9 @@ uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE, } if ((temp.flags & UCOL_ITER_INNORMBUF) != 0) { - rawOffset = temp.fcdPosition - temp.string; + rawOffset = (int32_t)(temp.fcdPosition - temp.string); } else { - rawOffset = temp.pos - temp.string; + rawOffset = (int32_t)(temp.pos - temp.string); } CE = ucol_IGetNextCE(coll, &temp, status); @@ -4206,7 +4206,7 @@ uint8_t *reallocateBuffer(uint8_t **secondaries, uint8_t *secStart, uint8_t *sec fprintf(stderr, "."); #endif uint8_t *newStart = NULL; - uint32_t offset = *secondaries-secStart; + uint32_t offset = (uint32_t)(*secondaries-secStart); if(secStart==second) { newStart=(uint8_t*)uprv_malloc(newSize); @@ -5149,7 +5149,7 @@ ucol_calcSortKey(const UCollator *coll, finished = TRUE; break; } else { /* It's much nicer if we can actually reallocate */ - int32_t sks = sortKeySize+(primaries - primStart)+(secondaries - secStart)+(tertiaries - terStart)+(cases-caseStart)+(quads-quadStart); + int32_t sks = sortKeySize+(int32_t)((primaries - primStart)+(secondaries - secStart)+(tertiaries - terStart)+(cases-caseStart)+(quads-quadStart)); primStart = reallocateBuffer(&primaries, *result, prim, &resultLength, 2*sks, status); if(U_SUCCESS(*status)) { *result = primStart; @@ -5173,8 +5173,8 @@ ucol_calcSortKey(const UCollator *coll, uint32_t frenchStartOffset = 0, frenchEndOffset = 0; if (frenchStartPtr != NULL) { - frenchStartOffset = frenchStartPtr - secStart; - frenchEndOffset = frenchEndPtr - secStart; + frenchStartOffset = (uint32_t)(frenchStartPtr - secStart); + frenchEndOffset = (uint32_t)(frenchEndPtr - secStart); } secStart = reallocateBuffer(&secondaries, secStart, second, &secSize, 2*secSize, status); terStart = reallocateBuffer(&tertiaries, terStart, tert, &terSize, 2*terSize, status); @@ -5197,7 +5197,7 @@ ucol_calcSortKey(const UCollator *coll, /* bailing out would not be too productive */ if(U_SUCCESS(*status)) { - sortKeySize += (primaries - primStart); + sortKeySize += (uint32_t)(primaries - primStart); /* we have done all the CE's, now let's put them together to form a key */ if(compareSec == 0) { if (count2 > 0) { @@ -5207,7 +5207,7 @@ ucol_calcSortKey(const UCollator *coll, } *secondaries++ = (uint8_t)(UCOL_COMMON_BOT2 + (count2-1)); } - uint32_t secsize = secondaries-secStart; + uint32_t secsize = (uint32_t)(secondaries-secStart); if(!isFrenchSec) { // Regular situation, we know the length of secondaries sortKeySize += secsize; if(sortKeySize <= resultLength) { @@ -5256,7 +5256,7 @@ ucol_calcSortKey(const UCollator *coll, } if(doCase) { - uint32_t casesize = cases - caseStart; + uint32_t casesize = (uint32_t)(cases - caseStart); sortKeySize += casesize; if(sortKeySize <= resultLength) { *(primaries++) = UCOL_LEVELTERMINATOR; @@ -5297,7 +5297,7 @@ ucol_calcSortKey(const UCollator *coll, *tertiaries++ = (uint8_t)(tertiaryBottom + (count3-1)); } } - uint32_t tersize = tertiaries - terStart; + uint32_t tersize = (uint32_t)(tertiaries - terStart); sortKeySize += tersize; if(sortKeySize <= resultLength) { *(primaries++) = UCOL_LEVELTERMINATOR; @@ -5329,7 +5329,7 @@ ucol_calcSortKey(const UCollator *coll, } *quads++ = (uint8_t)(UCOL_COMMON_BOT4 + (count4-1)); } - uint32_t quadsize = quads - quadStart; + uint32_t quadsize = (uint32_t)(quads - quadStart); sortKeySize += quadsize; if(sortKeySize <= resultLength) { *(primaries++) = UCOL_LEVELTERMINATOR; @@ -5662,7 +5662,7 @@ ucol_calcSortKeySimpleTertiary(const UCollator *coll, finished = TRUE; break; } else { /* It's much nicer if we can actually reallocate */ - int32_t sks = sortKeySize+(primaries - primStart)+(secondaries - secStart)+(tertiaries - terStart); + int32_t sks = sortKeySize+(int32_t)((primaries - primStart)+(secondaries - secStart)+(tertiaries - terStart)); primStart = reallocateBuffer(&primaries, *result, prim, &resultLength, 2*sks, status); if(U_SUCCESS(*status)) { *result = primStart; @@ -5692,7 +5692,7 @@ ucol_calcSortKeySimpleTertiary(const UCollator *coll, } if(U_SUCCESS(*status)) { - sortKeySize += (primaries - primStart); + sortKeySize += (uint32_t)(primaries - primStart); /* we have done all the CE's, now let's put them together to form a key */ if (count2 > 0) { while (count2 > UCOL_BOT_COUNT2) { @@ -5701,7 +5701,7 @@ ucol_calcSortKeySimpleTertiary(const UCollator *coll, } *secondaries++ = (uint8_t)(UCOL_COMMON_BOT2 + (count2-1)); } - uint32_t secsize = secondaries-secStart; + uint32_t secsize = (uint32_t)(secondaries-secStart); sortKeySize += secsize; if(sortKeySize <= resultLength) { *(primaries++) = UCOL_LEVELTERMINATOR; @@ -5740,7 +5740,7 @@ ucol_calcSortKeySimpleTertiary(const UCollator *coll, *tertiaries++ = (uint8_t)(tertiaryBottom + (count3-1)); } } - uint32_t tersize = tertiaries - terStart; + uint32_t tersize = (uint32_t)(tertiaries - terStart); sortKeySize += tersize; if(sortKeySize <= resultLength) { *(primaries++) = UCOL_LEVELTERMINATOR; @@ -7386,9 +7386,9 @@ UCollationResult ucol_checkIdent(collIterate *sColl, collIterate *tColl, UBoo unorm_closeIter(sNIt); unorm_closeIter(tNIt); } else { - sLen = (sColl->flags & UCOL_ITER_HASLEN) ? sColl->endp - sColl->string : -1; + sLen = (sColl->flags & UCOL_ITER_HASLEN) ? (int32_t)(sColl->endp - sColl->string) : -1; sBuf = sColl->string; - tLen = (tColl->flags & UCOL_ITER_HASLEN) ? tColl->endp - tColl->string : -1; + tLen = (tColl->flags & UCOL_ITER_HASLEN) ? (int32_t)(tColl->endp - tColl->string) : -1; tBuf = tColl->string; if (normalize) { @@ -7507,7 +7507,7 @@ void ucol_CEBuf_Expand(ucol_CEBuf *b, collIterate *ci, UErrorCode *status) { uint32_t *newBuf; ci->flags |= UCOL_ITER_ALLOCATED; - oldSize = b->pos - b->buf; + oldSize = (uint32_t)(b->pos - b->buf); newSize = oldSize * 2; newBuf = (uint32_t *)uprv_malloc(newSize * sizeof(uint32_t)); if(newBuf == NULL) { @@ -7549,8 +7549,8 @@ static UCollationResult ucol_compareUsingSortKeys(collIterate *sColl, UChar *target = NULL; int32_t result = UCOL_EQUAL; UChar sStackBuf[256], tStackBuf[256]; - int32_t sourceLength = (sColl->flags&UCOL_ITER_HASLEN)?(sColl->endp-sColl->string):-1; - int32_t targetLength = (tColl->flags&UCOL_ITER_HASLEN)?(tColl->endp-tColl->string):-1; + int32_t sourceLength = (sColl->flags&UCOL_ITER_HASLEN)?(int32_t)(sColl->endp-sColl->string):-1; + int32_t targetLength = (tColl->flags&UCOL_ITER_HASLEN)?(int32_t)(tColl->endp-tColl->string):-1; // TODO: Handle long strings. Do the same in ucol_checkIdent. if(sColl->flags & UCOL_USE_ITERATOR) { @@ -7566,11 +7566,11 @@ static UCollationResult ucol_compareUsingSortKeys(collIterate *sColl, while(tColl->iterator->hasNext(tColl->iterator)) { *tBufp++ = (UChar)tColl->iterator->next(tColl->iterator); } - sourceLength = sBufp - source; - targetLength = tBufp - target; + sourceLength = (int32_t)(sBufp - source); + targetLength = (int32_t)(tBufp - target); } else { // no iterators - sourceLength = (sColl->flags&UCOL_ITER_HASLEN)?(sColl->endp-sColl->string):-1; - targetLength = (tColl->flags&UCOL_ITER_HASLEN)?(tColl->endp-tColl->string):-1; + sourceLength = (sColl->flags&UCOL_ITER_HASLEN)?(int32_t)(sColl->endp-sColl->string):-1; + targetLength = (tColl->flags&UCOL_ITER_HASLEN)?(int32_t)(tColl->endp-tColl->string):-1; source = sColl->string; target = tColl->string; } @@ -8625,7 +8625,7 @@ ucol_strcoll( const UCollator *coll, UTRACE_EXIT_VALUE(UCOL_EQUAL); return UCOL_EQUAL; } - equalLength = pSrc - source; + equalLength = (int32_t)(pSrc - source); } else { @@ -8647,7 +8647,7 @@ ucol_strcoll( const UCollator *coll, pSrc++; pTarg++; } - equalLength = pSrc - source; + equalLength = (int32_t)(pSrc - source); // If we made it all the way through both strings, we are done. They are == if ((pSrc ==pSrcEnd || (pSrcEnd size = (UCA->lastEndExpansionCE - UCA->endExpansionCE) - + 2; + maxet->size = (int32_t)(UCA->lastEndExpansionCE - UCA->endExpansionCE) + 2; maxet->position = maxet->size - 1; maxet->endExpansionCE = (uint32_t *)uprv_malloc(sizeof(uint32_t) * maxet->size); @@ -497,10 +496,10 @@ static int uprv_uca_setMaxExpansion(uint32_t endexpansion, } if (*start == endexpansion) { - result = start - pendexpansionce; + result = (int)(start - pendexpansionce); } else if (*limit == endexpansion) { - result = limit - pendexpansionce; + result = (int)(limit - pendexpansionce); } if (result > -1) { @@ -515,7 +514,7 @@ static int uprv_uca_setMaxExpansion(uint32_t endexpansion, /* we'll need to squeeze the value into the array. initial implementation. */ /* shifting the subarray down by 1 */ - int shiftsize = (pendexpansionce + pos) - start; + int shiftsize = (int)((pendexpansionce + pos) - start); uint32_t *shiftpos = start + 1; uint8_t *sizeshiftpos = pexpansionsize + (shiftpos - pendexpansionce); diff --git a/icu4c/source/i18n/ucol_res.cpp b/icu4c/source/i18n/ucol_res.cpp index 4b51039790..7e783000e2 100644 --- a/icu4c/source/i18n/ucol_res.cpp +++ b/icu4c/source/i18n/ucol_res.cpp @@ -827,7 +827,7 @@ ucol_getKeywordValuesForLocale(const char* /*key*/, const char* locale, char *value = NULL; ulist_resetList(values); while ((value = (char *)ulist_getNext(values)) != NULL) { - if (!ulist_containsString(results, value, uprv_strlen(value))) { + if (!ulist_containsString(results, value, (int32_t)uprv_strlen(value))) { ulist_addItemEndList(results, value, FALSE, status); if (U_FAILURE(*status)) { break; diff --git a/icu4c/source/i18n/ucol_sit.cpp b/icu4c/source/i18n/ucol_sit.cpp index 18fa447f3f..afeae90bcf 100644 --- a/icu4c/source/i18n/ucol_sit.cpp +++ b/icu4c/source/i18n/ucol_sit.cpp @@ -292,7 +292,7 @@ const char* ucol_sit_readOption(const char *start, CollatorSpec *spec, if(*start == options[i].optionStart) { spec->entries[i].start = start; const char* end = options[i].action(spec, options[i].attr, start+1, status); - spec->entries[i].len = end - start; + spec->entries[i].len = (int32_t)(end - start); return end; } } @@ -325,7 +325,7 @@ ucol_sit_readSpecs(CollatorSpec *s, const char *string, } } if(U_FAILURE(*status)) { - parseError->offset = string - definition; + parseError->offset = (int32_t)(string - definition); } return string; } @@ -508,7 +508,7 @@ ucol_openFromShortString( const char *definition, } if(U_FAILURE(*status)) { - parseError->offset = string - definition; + parseError->offset = (int32_t)(string - definition); ucol_close(result); return NULL; } diff --git a/icu4c/source/i18n/ucol_tok.cpp b/icu4c/source/i18n/ucol_tok.cpp index 2de20f40f1..11e1bd6e6f 100644 --- a/icu4c/source/i18n/ucol_tok.cpp +++ b/icu4c/source/i18n/ucol_tok.cpp @@ -673,7 +673,7 @@ uint8_t ucol_uprv_tok_readAndSetOption(UColTokenParser *src, UErrorCode *status) break; } } - src->current = u_memchr(src->current, 0x005d, src->end-src->current); + src->current = u_memchr(src->current, 0x005d, (int32_t)(src->end-src->current)); return result; } diff --git a/icu4c/source/i18n/ucurr.cpp b/icu4c/source/i18n/ucurr.cpp index 856c89d964..bca260a48b 100644 --- a/icu4c/source/i18n/ucurr.cpp +++ b/icu4c/source/i18n/ucurr.cpp @@ -2181,10 +2181,10 @@ U_CAPI UEnumeration *U_EXPORT2 ucurr_getKeywordValuesForLocale(const char *key, } else { hasTo = TRUE; } - if (isPrefRegion && !hasTo && !ulist_containsString(values, curID, uprv_strlen(curID))) { + if (isPrefRegion && !hasTo && !ulist_containsString(values, curID, (int32_t)uprv_strlen(curID))) { // Currently active currency for the target country ulist_addItemEndList(values, curID, TRUE, status); - } else if (!ulist_containsString(otherValues, curID, uprv_strlen(curID)) && !commonlyUsed) { + } else if (!ulist_containsString(otherValues, curID, (int32_t)uprv_strlen(curID)) && !commonlyUsed) { ulist_addItemEndList(otherValues, curID, TRUE, status); } else { uprv_free(curID); @@ -2205,7 +2205,7 @@ U_CAPI UEnumeration *U_EXPORT2 ucurr_getKeywordValuesForLocale(const char *key, char *value = NULL; ulist_resetList(otherValues); while ((value = (char *)ulist_getNext(otherValues)) != NULL) { - if (!ulist_containsString(values, value, uprv_strlen(value))) { + if (!ulist_containsString(values, value, (int32_t)uprv_strlen(value))) { char *tmpValue = (char *)uprv_malloc(sizeof(char) * ULOC_KEYWORDS_CAPACITY); uprv_memcpy(tmpValue, value, uprv_strlen(value) + 1); ulist_addItemEndList(values, tmpValue, TRUE, status); diff --git a/icu4c/source/i18n/uspoof_conf.cpp b/icu4c/source/i18n/uspoof_conf.cpp index f7e03056c4..4f8c12bfa3 100644 --- a/icu4c/source/i18n/uspoof_conf.cpp +++ b/icu4c/source/i18n/uspoof_conf.cpp @@ -416,7 +416,7 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) { previousKey = key; } SpoofDataHeader *rawData = fSpoofImpl->fSpoofData->fRawData; - rawData->fCFUKeys = (char *)keys - (char *)rawData; + rawData->fCFUKeys = (int32_t)((char *)keys - (char *)rawData); rawData->fCFUKeysSize = numKeys; fSpoofImpl->fSpoofData->fCFUKeys = keys; @@ -435,7 +435,7 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) { values[i] = static_cast(value); } rawData = fSpoofImpl->fSpoofData->fRawData; - rawData->fCFUStringIndex = (char *)values - (char *)rawData; + rawData->fCFUStringIndex = (int32_t)((char *)values - (char *)rawData); rawData->fCFUStringIndexSize = numValues; fSpoofImpl->fSpoofData->fCFUValues = values; @@ -452,7 +452,7 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) { fStringTable->extract(strings, stringsLength+1, status); rawData = fSpoofImpl->fSpoofData->fRawData; U_ASSERT(rawData->fCFUStringTable == 0); - rawData->fCFUStringTable = (char *)strings - (char *)rawData; + rawData->fCFUStringTable = (int32_t)((char *)strings - (char *)rawData); rawData->fCFUStringTableLen = stringsLength; fSpoofImpl->fSpoofData->fCFUStrings = strings; @@ -480,7 +480,7 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) { previousLength = length; } rawData = fSpoofImpl->fSpoofData->fRawData; - rawData->fCFUStringLengths = (char *)stringLengths - (char *)rawData; + rawData->fCFUStringLengths = (int32_t)((char *)stringLengths - (char *)rawData); // Note: StringLengthsSize in the raw data is the number of complete entries, // each consisting of a pair of 16 bit values, hence the divide by 2. rawData->fCFUStringLengthsSize = lengthTableLength / 2; diff --git a/icu4c/source/i18n/uspoof_impl.cpp b/icu4c/source/i18n/uspoof_impl.cpp index b3320ca8a5..3cc69b81ab 100644 --- a/icu4c/source/i18n/uspoof_impl.cpp +++ b/icu4c/source/i18n/uspoof_impl.cpp @@ -132,7 +132,7 @@ int32_t SpoofImpl::confusableLookup(UChar32 inChar, int32_t tableMask, UChar *de int32_t *limit = low + fSpoofData->fRawData->fCFUKeysSize; UChar32 midc; do { - int32_t delta = (limit-low)/2; + int32_t delta = ((int32_t)(limit-low))/2; mid = low + delta; midc = *mid & 0x1fffff; if (inChar == midc) { @@ -182,7 +182,7 @@ int32_t SpoofImpl::confusableLookup(UChar32 inChar, int32_t tableMask, UChar *de foundKey: int32_t stringLen = USPOOF_KEY_LENGTH_FIELD(keyFlags) + 1; - int32_t keyTableIndex = mid - fSpoofData->fCFUKeys; + int32_t keyTableIndex = (int32_t)(mid - fSpoofData->fCFUKeys); // Value is either a UChar (for strings of length 1) or // an index into the string table (for longer strings) @@ -283,7 +283,7 @@ void SpoofImpl::setAllowedLocales(const char *localesList, UErrorCode &status) { if (trimmedEnd <= locStart) { break; } - const char *locale = uprv_strndup(locStart, trimmedEnd + 1 - locStart); + const char *locale = uprv_strndup(locStart, (int32_t)(trimmedEnd + 1 - locStart)); localeListCount++; // We have one locale from the locales list. diff --git a/icu4c/source/i18n/zonemeta.cpp b/icu4c/source/i18n/zonemeta.cpp index 4a5dcc7776..6eee776fd1 100644 --- a/icu4c/source/i18n/zonemeta.cpp +++ b/icu4c/source/i18n/zonemeta.cpp @@ -688,9 +688,9 @@ ZoneMeta::createMetaToOlsonMap(void) { int32_t mzidLen = 0; int32_t territoryLen = 0; if (territory) { - mzidLen = territory - mzid; + mzidLen = (int32_t)(territory - mzid); territory++; - territoryLen = uprv_strlen(territory); + territoryLen = (int32_t)uprv_strlen(territory); } if (mzidLen > 0 && territoryLen > 0) { int32_t tzidLen; diff --git a/icu4c/source/i18n/zstrfmt.cpp b/icu4c/source/i18n/zstrfmt.cpp index d9c68625fb..28716b3c44 100644 --- a/icu4c/source/i18n/zstrfmt.cpp +++ b/icu4c/source/i18n/zstrfmt.cpp @@ -329,7 +329,7 @@ TextTrieMap::addChildNode(CharacterNode *parent, UChar c, UErrorCode &status) { // Ensure capacity. Grow fNodes[] if needed. if (fNodesCount == fNodesCapacity) { - int32_t parentIndex = (parent - fNodes); + int32_t parentIndex = (int32_t)(parent - fNodes); if (!growNodes()) { status = U_MEMORY_ALLOCATION_ERROR; return NULL;