for (attr = firstAttr; attr; attr = attr->next) {
sink.Append("-", 1);
sink.Append(
- attr->attribute, uprv_strlen(attr->attribute));
+ attr->attribute, static_cast<int32_t>(uprv_strlen(attr->attribute)));
}
} else {
sink.Append("-", 1);
- sink.Append(ext->key, uprv_strlen(ext->key));
+ sink.Append(ext->key, static_cast<int32_t>(uprv_strlen(ext->key)));
sink.Append("-", 1);
- sink.Append(ext->value, uprv_strlen(ext->value));
+ sink.Append(ext->value, static_cast<int32_t>(uprv_strlen(ext->value)));
}
}
}
willexit = FALSE;
// input file offset at the beginning of the next buffer
- infoffset += rd;
+ infoffset += static_cast<uint32_t>(rd);
rd = fread(buf, 1, bufsz, infile);
if (ferror(infile) != 0) {
// input file offset of the current byte buffer +
// byte buffer offset of where the current Unicode buffer is converted from +
// fromoffsets[Unicode offset]
- ferroffset = infoffset + (prevbufp - buf) + fromoffset;
+ ferroffset = static_cast<int32_t>(infoffset + (prevbufp - buf) + fromoffset);
errtag = "problemCvtFromU";
} else {
// Do not use fromoffsets if (t != NULL) because the Unicode text may
#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
#if defined(_MSC_VER)
// Ignore warning 4661 as LocalPointerBase does not use operator== or operator!=
-#pragma warning(suppress: 4661)
+#pragma warning(push)
+#pragma warning(disable: 4661)
#endif
template class U_I18N_API LocalPointerBase<int32_t>;
template class U_I18N_API LocalMemory<int32_t>;
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
#endif
class U_I18N_API EraRules : public UMemory {
#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
#if defined(_MSC_VER)
// Ignore warning 4661 as LocalPointerBase does not use operator== or operator!=
-#pragma warning(suppress: 4661)
+#pragma warning(push)
+#pragma warning(disable: 4661)
#endif
template class U_I18N_API LocalPointerBase<CurrencyPluralInfo>;
template class U_I18N_API LocalPointer<CurrencyPluralInfo>;
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
#endif
namespace number {
#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
#if defined(_MSC_VER)
// Ignore warning 4661 as LocalPointerBase does not use operator== or operator!=
-#pragma warning(suppress: 4661)
+#pragma warning(push)
+#pragma warning(disable : 4661)
#endif
template class U_I18N_API LocalPointerBase<number::impl::AdoptingModifierStore>;
template class U_I18N_API LocalPointer<number::impl::AdoptingModifierStore>;
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
#endif
namespace number {
CompactUnicodeString(const UnicodeString& text)
: fBuffer(text.length() + 1) {
- memcpy(fBuffer.getAlias(), text.getBuffer(), sizeof(UChar) * text.length());
+ uprv_memcpy(fBuffer.getAlias(), text.getBuffer(), sizeof(UChar) * text.length());
fBuffer[text.length()] = 0;
}
UBool isNotEOF;
/* skip all leading ws in the input */
- while( (isNotEOF = ufile_getch(input, &c)) && (c == pad || u_isWhitespace(c)) )
+ while( ((isNotEOF = ufile_getch(input, &c)) == TRUE) && (c == pad || u_isWhitespace(c)) )
{
count++;
}
if (U_SUCCESS(localStatus)) {
/* skip all leading ws in the input */
- while( (isNotEOF = ufile_getch(input, &c)) && (count < symbolLen && c == plusSymbol[count]) )
+ while( ((isNotEOF = ufile_getch(input, &c)) == TRUE) && (count < symbolLen && c == plusSymbol[count]) )
{
count++;
}
return -1;
while( (info->fWidth == -1 || count < info->fWidth)
- && (isNotEOF = ufile_getch(input, &c))
+ && ((isNotEOF = ufile_getch(input, &c)) == TRUE)
&& (!info->fIsString || (c != info->fPadChar && !u_isWhitespace(c))))
{
count = 0;
while( (info->fWidth == -1 || count < info->fWidth)
- && (isNotEOF = ufile_getch(input, &c))
+ && ((isNotEOF = ufile_getch(input, &c)) == TRUE)
&& (!info->fIsString || (c != info->fPadChar && !u_isWhitespace(c))))
{
/* grab characters one at a time and make sure they are in the scanset */
while(chLeft > 0) {
- if ((isNotEOF = ufile_getch32(input, &c)) && uset_contains(scanset, c)) {
+ if ( ((isNotEOF = ufile_getch32(input, &c)) == TRUE) && uset_contains(scanset, c) ) {
readCharacter = TRUE;
if (!info->fSkipArg) {
int32_t idx = 0;
UParseError parseError;
UErrorCode status = U_ZERO_ERROR;
UCollator* coll=0;
- u_charsToUChars(rulesArr[i],rules,uprv_strlen(rulesArr[i])+1);
- u_charsToUChars(preContextArr[i],preContextExp,uprv_strlen(preContextArr[i])+1);
- u_charsToUChars(postContextArr[i],postContextExp,uprv_strlen(postContextArr[i])+1);
+ u_charsToUChars(rulesArr[i], rules, (int32_t)uprv_strlen(rulesArr[i]) + 1);
+ u_charsToUChars(preContextArr[i], preContextExp, (int32_t)uprv_strlen(preContextArr[i]) + 1);
+ u_charsToUChars(postContextArr[i], postContextExp, (int32_t)uprv_strlen(postContextArr[i]) + 1);
/* clean up stuff in parseError */
- u_memset(parseError.preContext,0x0000,U_PARSE_CONTEXT_LEN);
- u_memset(parseError.postContext,0x0000,U_PARSE_CONTEXT_LEN);
+ u_memset(parseError.preContext, 0x0000, U_PARSE_CONTEXT_LEN);
+ u_memset(parseError.postContext, 0x0000, U_PARSE_CONTEXT_LEN);
/* open the rules and test */
- coll = ucol_openRules(rules,u_strlen(rules),UCOL_OFF,UCOL_DEFAULT_STRENGTH,&parseError,&status);
+ coll = ucol_openRules(rules, u_strlen(rules), UCOL_OFF, UCOL_DEFAULT_STRENGTH, &parseError, &status);
(void)coll; /* Suppress set but not used warning. */
if(u_strcmp(parseError.preContext,preContextExp)!=0){
log_err_status(status, "preContext in UParseError for ucol_openRules does not match: \"%s\"\n",
if ((level & 1) == 0) {
return FALSE;
}
- len = strlen(mates1Chars);
+ len = (int)strlen(mates1Chars);
for (k = 0; k < len; k++) {
if ((c1 == mates1Chars[k]) && (c2 == mates2Chars[k])) {
return TRUE;
const char* option, UBiDiLevel level) {
int32_t actualLen;
if (strcmp(mode, "UBIDI_REORDER_INVERSE_NUMBERS_AS_L") == 0)
- actualLen = strlen(destChars);
+ actualLen = (int32_t)strlen(destChars);
else
actualLen = ubidi_getResultLength(pBiDi);
if (actualLen != destLen) {
ubidi_setReorderingOptions(pBiDi, option==0 ? UBIDI_OPTION_REMOVE_CONTROLS
: UBIDI_OPTION_INSERT_MARKS);
for (i = 0, nCases = UPRV_LENGTHOF(testCases); i < nCases; i++) {
- srcLen = strlen(testCases[i].textIn);
+ srcLen = (int32_t)strlen(testCases[i].textIn);
pseudoToU16(srcLen, testCases[i].textIn, src);
for(j = 0; j < 2; j++) {
log_verbose("Now doing test for option %d, case %d, level %d\n",
for (tc = 0; tc < TC_COUNT; tc++) {
const char *srcChars = textIn[tc];
- srcLen = strlen(srcChars);
+ srcLen = (int32_t)strlen(srcChars);
pseudoToU16(srcLen, srcChars, src);
for (mode = 0; mode < MODES_COUNT; mode++) {
for (tc = 0; tc < CONTEXT_COUNT; tc++) {
cc = contextData[tc];
- proLength = strlen(cc.prologue);
+ proLength = (int32_t)strlen(cc.prologue);
pseudoToU16(proLength, cc.prologue, prologue);
- epiLength = strlen(cc.epilogue);
+ epiLength = (int32_t)strlen(cc.epilogue);
pseudoToU16(epiLength, cc.epilogue, epilogue);
/* in the call below, prologue and epilogue are swapped to show
that the next call will override this call */
testOK &= assertSuccessful("swapped ubidi_setContext", &rc);
ubidi_setContext(pBiDi, prologue, -1, epilogue, -1, &rc);
testOK &= assertSuccessful("regular ubidi_setContext", &rc);
- srcLen = strlen(cc.source);
+ srcLen = (int32_t)strlen(cc.source);
pseudoToU16(srcLen, cc.source, src);
ubidi_setPara(pBiDi, src, srcLen, cc.paraLevel, NULL, &rc);
testOK &= assertSuccessful("ubidi_setPara", &rc);
int32_t len;
bidi = ubidi_open();
- len = uprv_strlen(TEXT);
+ len = (int32_t)uprv_strlen(TEXT);
pseudoToU16(len, TEXT, src);
ubidi_setPara(bidi, src, len, UBIDI_DEFAULT_LTR , NULL, &status);
if (U_FAILURE(status)) {
ALLList = ulist_getListFromEnum(ALL);
for (j = 0; j < size; j++) {
if ((value = uenum_next(all, &valueLength, &status)) != NULL && U_SUCCESS(status)) {
- if (!ulist_containsString(ALLList, value, uprv_strlen(value))) {
+ if (!ulist_containsString(ALLList, value, (int32_t)uprv_strlen(value))) {
log_err("Locale %s have %s not in ALL\n", loc, value);
matchAll = FALSE;
break;
/*Reads in the file*/
- while(!feof(ucs_file_in)&&(i+=fread(ucs_file_buffer+i, sizeof(UChar), 1, ucs_file_in)))
+ while(!feof(ucs_file_in)&&(i+=(int32_t)fread(ucs_file_buffer+i, sizeof(UChar), 1, ucs_file_in)))
{
myUChar = ucs_file_buffer[i-1];
NULL,
targetcapacity2,
output_cp_buffer,
- strlen(output_cp_buffer),
+ (int32_t)strlen(output_cp_buffer),
&err);
/*if there is an buffer overflow then trap the values and pass them and make the actual call*/
uchar2,
targetsize+1,
output_cp_buffer,
- strlen(output_cp_buffer),
+ (int32_t)strlen(output_cp_buffer),
&err);
if(U_FAILURE(err))
log_err("\nFAILURE: ucnv_fromUChars with targetLength 0 is expected to fail and throw U_BUFFER_OVERFLOW_ERROR\n");
}
/*toUChars with error conditions*/
- targetsize = ucnv_toUChars(myConverter, uchar2, targetsize, output_cp_buffer, strlen(output_cp_buffer), &err);
+ targetsize = ucnv_toUChars(myConverter, uchar2, targetsize, output_cp_buffer, (int32_t)strlen(output_cp_buffer), &err);
if(targetsize != 0){
log_err("\nFAILURE: ucnv_toUChars with err != U_ZERO_ERROR is expected to fail and return 0\n");
}
err=U_ZERO_ERROR;
- targetsize = ucnv_toUChars(myConverter, uchar2, -1, output_cp_buffer, strlen(output_cp_buffer), &err);
+ targetsize = ucnv_toUChars(myConverter, uchar2, -1, output_cp_buffer, (int32_t)strlen(output_cp_buffer), &err);
if(targetsize != 0 || err != U_ILLEGAL_ARGUMENT_ERROR){
log_err("\nFAILURE: ucnv_toUChars with targetsize < 0 is expected to throw U_ILLEGAL_ARGUMENT_ERROR and return 0\n");
}
log_err("\nFAILURE: ucnv_toUChars with sourceLength 0 is expected to return 0\n");
}
targetcapacity2=0;
- targetsize = ucnv_toUChars(myConverter, NULL, targetcapacity2, output_cp_buffer, strlen(output_cp_buffer), &err);
+ targetsize = ucnv_toUChars(myConverter, NULL, targetcapacity2, output_cp_buffer, (int32_t)strlen(output_cp_buffer), &err);
if (err != U_STRING_NOT_TERMINATED_WARNING) {
log_err("\nFAILURE: ucnv_toUChars(targetLength)->%s instead of U_STRING_NOT_TERMINATED_WARNING\n",
u_errorName(err));
for(i=0; i<UPRV_LENGTHOF(badUTF8); ++i) {
/* truncated sequence? */
- int32_t length=strlen(badUTF8[i]);
+ int32_t length = (int32_t)strlen(badUTF8[i]);
if(!isOneTruncatedUTF8(badUTF8[i], length)) {
continue;
}
expectLength=char0Length;
for(i=0; i<UPRV_LENGTHOF(badUTF8); ++i) {
- int32_t length=strlen(badUTF8[i]);
+ int32_t length = (int32_t)strlen(badUTF8[i]);
memcpy(utf8+utf8Length, badUTF8[i], length);
utf8Length+=length;
strPtr = u_strstr(strDateTime, minutesStr);
if ( strPtr != NULL ) {
- int32_t beginIndex = strPtr - strDateTime;
+ int32_t beginIndex = (int32_t)(strPtr - strDateTime);
if ( fp.beginIndex != beginIndex ) {
log_err("UFieldPosition beginIndex %d, expected %d, in udat_format timeStyle SHORT dateStyle (%d | UDAT_RELATIVE)\n", fp.beginIndex, beginIndex, *stylePtr );
}
UErrorCode status = U_ZERO_ERROR;
UChar *result=NULL;
int32_t resultlength, resultlengthout;
- int32_t patternSize = strlen(expected) + 1;
+ int32_t patternSize = (int32_t)strlen(expected) + 1;
pattern=(UChar*)malloc(sizeof(UChar) * patternSize);
u_unescape(expected, pattern, patternSize);
UChar *value=NULL;
int32_t resultlength, resultlengthout;
UErrorCode status = U_ZERO_ERROR;
- int32_t valueLen, valueSize = strlen(expected) + 1;
+ int32_t valueLen, valueSize = (int32_t)strlen(expected) + 1;
value=(UChar*)malloc(sizeof(UChar) * valueSize);
valueLen = u_unescape(expected, value, valueSize);
UChar* isoCode = (UChar*)malloc(sizeof(UChar) * (uprv_strlen(usdCode) + 1));
/* testing available codes with no time ranges */
- u_charsToUChars(eurCode, isoCode, uprv_strlen(usdCode) + 1);
+ u_charsToUChars(eurCode, isoCode, (int32_t)uprv_strlen(usdCode) + 1);
if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
log_data_err("FAIL: ISO code (%s) is not found.\n", eurCode);
}
- u_charsToUChars(usdCode, isoCode, uprv_strlen(zzzCode) + 1);
+ u_charsToUChars(usdCode, isoCode, (int32_t)uprv_strlen(zzzCode) + 1);
if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
log_data_err("FAIL: ISO code (%s) is not found.\n", usdCode);
}
- u_charsToUChars(zzzCode, isoCode, uprv_strlen(zzzCode) + 1);
+ u_charsToUChars(zzzCode, isoCode, (int32_t)uprv_strlen(zzzCode) + 1);
if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == TRUE) {
log_err("FAIL: ISO code (%s) is reported as available, but it doesn't exist.\n", zzzCode);
}
- u_charsToUChars(lastCode, isoCode, uprv_strlen(zzzCode) + 1);
+ u_charsToUChars(lastCode, isoCode, (int32_t)uprv_strlen(zzzCode) + 1);
if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
log_data_err("FAIL: ISO code (%s) is not found.\n", lastCode);
}
"-foo-bar-baz-foo-bar-baz-foo-bar-baz-foo-bar-baz"
"-foo-barz"
;
- static const size_t len = sizeof name - 1; // Without NUL terminator.
+ static const size_t len = sizeof(name) - 1; // Without NUL terminator.
- int32_t reslen = uloc_canonicalize(name, buffer, len, &status);
+ int32_t reslen = uloc_canonicalize(name, buffer, (int32_t)len, &status);
if (U_FAILURE(status)) {
log_err("FAIL: uloc_canonicalize(%s) => %s, expected !U_FAILURE()\n",
if (data->uerror == U_BUFFER_OVERFLOW_ERROR ||
data->uerror == U_STRING_NOT_TERMINATED_WARNING)
{
- return strlen(data->expected);
+ return (int32_t)strlen(data->expected);
}
else
{
}
else if (data->bufferSize < 0)
{
- return strlen(data->expected) + 1;
+ return (int32_t)strlen(data->expected) + 1;
}
else
{
static const char inloc[] = "C";
static const char expected[] = "en-US-u-va-posix";
- const int32_t expected_len = uprv_strlen(expected);
+ const int32_t expected_len = (int32_t)uprv_strlen(expected);
/* Before ICU-20132 was fixed, calling uloc_toLanguageTag() with a too small
* buffer would not immediately return the buffer size actually needed, but
locale[0] = 0;
expParsedLen = langtag_to_locale[i].len;
if (expParsedLen == FULL_LENGTH) {
- expParsedLen = uprv_strlen(langtag_to_locale[i].bcpID);
+ expParsedLen = (int32_t)uprv_strlen(langtag_to_locale[i].bcpID);
}
uloc_forLanguageTag(langtag_to_locale[i].bcpID, locale, sizeof(locale), &parsedLen, &status);
if (U_FAILURE(status)) {
}
}
-static void TestMaxVariable() {
+static void TestMaxVariable(void) {
UErrorCode status = U_ZERO_ERROR;
UColReorderCode oldMax, max;
UCollator *coll;
return;
}
- uiter_setString(&iter, text, length);
+ uiter_setString(&iter, text, (int32_t)length);
actualSortKeyLen = ucol_nextSortKeyPart(
ucol, &iter, (uint32_t*)uStateInfo,
- textSortKey, lenSortKey, &status
+ textSortKey, (int32_t)lenSortKey, &status
);
if (actualSortKeyLen == lenSortKey) {
}
}
-static void TestMessageWithUnusedArgNumber() {
+static void TestMessageWithUnusedArgNumber(void) {
UErrorCode errorCode = U_ZERO_ERROR;
U_STRING_DECL(pattern, "abc {1} def", 11);
UChar x[2] = { 0x78, 0 }; // "x"
ALLList = ulist_getListFromEnum(ALL);
for (j = 0; j < size; j++) {
if ((value = uenum_next(all, &valueLength, &status)) != NULL && U_SUCCESS(status)) {
- if (!ulist_containsString(ALLList, value, uprv_strlen(value))) {
+ if (!ulist_containsString(ALLList, value, (int32_t)uprv_strlen(value))) {
log_err("Locale %s have %s not in ALL\n", loc, value);
matchAll = FALSE;
break;
/* instead of sprintf(resource, "a%i", i); */
a = ures_getByKeyWithFallback(alias, resource, a, &status);
result = tres_getString(a, -1, NULL, &len, &status);
- u_charsToUChars(expects[i], expected, strlen(expects[i])+1);
+ u_charsToUChars(expects[i], expected, (int32_t)strlen(expects[i])+1);
if(U_FAILURE(status) || !result || u_strcmp(result, expected)) {
log_err("CLDR style aliases failed resource with name \"%s\" resource, exp %s, got %S (%s)\n", resource, expects[i], result, myErrorName(status));
status = U_ZERO_ERROR;
}
/* Make sure that you can format normal fraction digits. */
unum_formatDouble(fmt, 123.456, buffer, UPRV_LENGTHOF(buffer), NULL, &status);
- u_unescape(expectedFirst, expectedBuf, strlen(expectedFirst)+1);
+ u_unescape(expectedFirst, expectedBuf, (int32_t)strlen(expectedFirst)+1);
if (u_strcmp(buffer, expectedBuf) != 0) {
log_err("Error: unum_formatDouble didn't return %s\n", expectedFirst);
}
/* Make sure that you can format 2 fraction digits. */
unum_setAttribute(fmt, UNUM_FRACTION_DIGITS, 2);
unum_formatDouble(fmt, 123.456, buffer, UPRV_LENGTHOF(buffer), NULL, &status);
- u_unescape(expectedSecond, expectedBuf, strlen(expectedSecond)+1);
+ u_unescape(expectedSecond, expectedBuf, (int32_t)strlen(expectedSecond)+1);
if (u_strcmp(buffer, expectedBuf) != 0) {
log_err("Error: unum_formatDouble didn't return %s\n", expectedSecond);
}
/* Make sure that you can format more fraction digits. */
unum_setAttribute(fmt, UNUM_FRACTION_DIGITS, 3);
unum_formatDouble(fmt, 123.456, buffer, UPRV_LENGTHOF(buffer), NULL, &status);
- u_unescape(expectedThird, expectedBuf, strlen(expectedThird)+1);
+ u_unescape(expectedThird, expectedBuf, (int32_t)strlen(expectedThird)+1);
if (u_strcmp(buffer, expectedBuf) != 0) {
log_err("Error: unum_formatDouble didn't return %s\n", expectedThird);
}
int32_t numCode;
for (i = 0; NUMCODE_TESTDATA[i].alphaCode; i++) {
- int32_t length = uprv_strlen(NUMCODE_TESTDATA[i].alphaCode);
+ int32_t length = (int32_t)uprv_strlen(NUMCODE_TESTDATA[i].alphaCode);
u_charsToUChars(NUMCODE_TESTDATA[i].alphaCode, code, length + 1); // +1 includes the NUL
numCode = ucurr_getNumericCode(code);
if (numCode != NUMCODE_TESTDATA[i].numericCode) {
out16[0]=0x55aa;
uDestLen=0;
u_strFromUTF8WithSub(out16, UPRV_LENGTHOF(out16), &uDestLen,
- (const char *)withTrail8, uprv_strlen((const char *)withTrail8),
+ (const char *)withTrail8, (int32_t)uprv_strlen((const char *)withTrail8),
0x50005, &numSubstitutions,
&err);
if(U_FAILURE(err) || uDestLen!=u_strlen(withTrail16Sub50005) ||
*pb!=(char)0xff;
pb+=srcLength+1, pu+=destLength0+1, ++number
) {
- srcLength=uprv_strlen(pb);
+ srcLength=(int32_t)uprv_strlen(pb);
destLength0=u_strlen(pu);
/* preflighting with NUL-termination */
static void TestJB5273(){
static const char INVALID_DOMAIN_NAME[] = "xn--m\\u00FCller.de";
UChar invalid_idn[25] = {'\0'};
- int32_t len = u_unescape(INVALID_DOMAIN_NAME, invalid_idn, strlen(INVALID_DOMAIN_NAME));
+ int32_t len = u_unescape(INVALID_DOMAIN_NAME, invalid_idn, (int32_t)strlen(INVALID_DOMAIN_NAME));
UChar output[50] = {'\0'};
UErrorCode status = U_ZERO_ERROR;
UParseError prsError;
log_err("uidna_labelToASCII_UTF8() failed: %s\n", u_errorName(errorCode));
}
errorCode = U_ZERO_ERROR;
- length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8),
+ length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, (int32_t)strlen(fA_sharps8),
dest8, UPRV_LENGTHOF(dest8), &info, &errorCode);
if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fa_sharps8, 5) ||
!info.isTransitionalDifferent || info.errors != 0
log_err("uidna_labelToUnicodeUTF8() failed: %s\n", u_errorName(errorCode));
}
errorCode = U_ZERO_ERROR;
- length = uidna_nameToASCII_UTF8(uts46, fA_sharps8, strlen(fA_sharps8),
+ length = uidna_nameToASCII_UTF8(uts46, fA_sharps8, (int32_t)strlen(fA_sharps8),
dest8, 4, &info, &errorCode);
if( errorCode != U_STRING_NOT_TERMINATED_WARNING ||
length != 4 || 0 != memcmp(dest8, fass8, 4) ||
log_err("uidna_labelToASCII_UTF8(dest=NULL) failed: %s\n", u_errorName(errorCode));
}
errorCode = U_ZERO_ERROR;
- length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8),
+ length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, (int32_t)strlen(fA_sharps8),
dest8, -1, &info, &errorCode);
if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("uidna_labelToUnicodeUTF8(capacity<0) failed: %s\n", u_errorName(errorCode));
}
errorCode = U_ZERO_ERROR;
- length = uidna_nameToASCII_UTF8(uts46, dest8, strlen(fA_sharps8),
+ length = uidna_nameToASCII_UTF8(uts46, dest8, (int32_t)strlen(fA_sharps8),
dest8, 4, &info, &errorCode);
if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("uidna_nameToASCII_UTF8(src==dest!=NULL) failed: %s\n", u_errorName(errorCode));
}
targetLimit = target;
target = dest;
- printUSeq(target, targetLimit-target);
+ printUSeq(target, (int)(targetLimit-target));
while(target<targetLimit){
if(*exp!=*target){
log_err("did not get the expected output. \\u%04X != \\u%04X (got)\n", *exp, *target);
targetLimit = target;
target = dest;
- printUSeq(target, targetLimit-target);
+ printUSeq(target, (int)(targetLimit-target));
while(target<targetLimit){
if(*exp!=*target){
#include "toolutil.h"
#include "uinvchar.h"
#include <stdio.h>
+#if U_PLATFORM_USES_ONLY_WIN32_API
+#include "wintz.h"
+#endif
/* See the comments on U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC. */
static void TestSignedRightShiftIsArithmetic(void) {
#if U_PLATFORM_USES_ONLY_WIN32_API
log_verbose("Testing uprv_detectWindowsTimeZone() ....\n");
{
- char* timezone = uprv_detectWindowsTimeZone();
+ const char* timezone = uprv_detectWindowsTimeZone();
if (timezone == NULL) {
log_err("ERROR: uprv_detectWindowsTimeZone failed (returned NULL).\n");
} else {
status = U_ZERO_ERROR; \
re = uregex_openC(pattern, flags, NULL, &status); \
TEST_ASSERT_SUCCESS(status); \
- srcString = (UChar *)malloc((strlen(testString)+2)*sizeof(UChar)); \
- u_uastrncpy(srcString, testString, strlen(testString)+1); \
+ int32_t testStringLen = (int32_t)strlen(testString); \
+ srcString = (UChar *)malloc( (testStringLen + 2) * sizeof(UChar) ); \
+ u_uastrncpy(srcString, testString, testStringLen + 1); \
uregex_setText(re, srcString, -1, &status); \
TEST_ASSERT_SUCCESS(status); \
if (U_SUCCESS(status)) {
status = U_ZERO_ERROR;
uregex_setText(re, text1, -1, &status);
memset(buf, -1, sizeof(buf));
- resultSz = uregex_replaceFirst(re, replText, -1, buf, strlen("Replace <aa> x1x x...x."), &status);
+ resultSz = uregex_replaceFirst(re, replText, -1, buf, (int32_t)strlen("Replace <aa> x1x x...x."), &status);
TEST_ASSERT(status == U_STRING_NOT_TERMINATED_WARNING);
TEST_ASSERT_STRING("Replace <aa> x1x x...x.", buf, FALSE);
TEST_ASSERT(resultSz == (int32_t)strlen("Replace xaax x1x x...x."));
*/
status = U_ZERO_ERROR;
memset(buf, -1, sizeof(buf));
- resultSz = uregex_replaceFirst(re, replText, -1, buf, strlen("Replace <aa> x1x x...x."), &status);
+ resultSz = uregex_replaceFirst(re, replText, -1, buf, (int32_t)strlen("Replace <aa> x1x x...x."), &status);
TEST_ASSERT(status == U_STRING_NOT_TERMINATED_WARNING);
TEST_ASSERT_STRING("Replace <aa> x1x x...x.", buf, FALSE);
TEST_ASSERT(resultSz == (int32_t)strlen("Replace xaax x1x x...x."));
/* Buffer too small by one */
status = U_ZERO_ERROR;
memset(buf, -1, sizeof(buf));
- resultSz = uregex_replaceFirst(re, replText, -1, buf, strlen("Replace <aa> x1x x...x.")-1, &status);
+ resultSz = uregex_replaceFirst(re, replText, -1, buf, (int32_t)strlen("Replace <aa> x1x x...x.")-1, &status);
TEST_ASSERT(status == U_BUFFER_OVERFLOW_ERROR);
TEST_ASSERT_STRING("Replace <aa> x1x x...x", buf, FALSE);
TEST_ASSERT(resultSz == (int32_t)strlen("Replace xaax x1x x...x."));
u_uastrncpy(text2, "No match here.", UPRV_LENGTHOF(text2));
u_uastrncpy(replText, "<$1>", UPRV_LENGTHOF(replText));
u_uastrncpy(replText2, "<<$1>>", UPRV_LENGTHOF(replText2));
- expectedResultSize = strlen(expectedResult);
- expectedResultSize2 = strlen(expectedResult2);
+ expectedResultSize = (int32_t)strlen(expectedResult);
+ expectedResultSize2 = (int32_t)strlen(expectedResult2);
status = U_ZERO_ERROR;
re = uregex_openC(pattern, 0, NULL, &status);
*/
status = U_ZERO_ERROR;
memset(buf, -1, sizeof(buf));
- resultSize = uregex_replaceAll(re, replText, -1, buf, strlen("Replace xaax x1x x...x."), &status);
+ resultSize = uregex_replaceAll(re, replText, -1, buf, (int32_t)strlen("Replace xaax x1x x...x."), &status);
TEST_ASSERT(status == U_STRING_NOT_TERMINATED_WARNING);
TEST_ASSERT_STRING("Replace <aa> <1> <...>.", buf, FALSE);
TEST_ASSERT(resultSize == (int32_t)strlen("Replace <aa> <1> <...>."));
TEST_ASSERT_STRING("tag-b", fields[3], TRUE);
TEST_ASSERT_STRING(" third", fields[4], TRUE);
TEST_ASSERT(fields[5] == NULL);
- spaceNeeded = strlen("first .tag-a. second.tag-b. third."); /* "." at NUL positions */
+ spaceNeeded = (int32_t)strlen("first .tag-a. second.tag-b. third."); /* "." at NUL positions */
TEST_ASSERT(spaceNeeded == requiredCapacity);
}
}
TEST_ASSERT_STRING(" second<tag-b> third", fields[1], TRUE);
TEST_ASSERT(!memcmp(&fields[2],&minus1,sizeof(UChar*)));
- spaceNeeded = strlen("first . second<tag-b> third."); /* "." at NUL positions */
+ spaceNeeded = (int32_t)strlen("first . second<tag-b> third."); /* "." at NUL positions */
TEST_ASSERT(spaceNeeded == requiredCapacity);
}
TEST_ASSERT_STRING(" second<tag-b> third", fields[2], TRUE);
TEST_ASSERT(!memcmp(&fields[3],&minus1,sizeof(UChar*)));
- spaceNeeded = strlen("first .tag-a. second<tag-b> third."); /* "." at NUL positions */
+ spaceNeeded = (int32_t)strlen("first .tag-a. second<tag-b> third."); /* "." at NUL positions */
TEST_ASSERT(spaceNeeded == requiredCapacity);
}
TEST_ASSERT_STRING(" third", fields[4], TRUE);
TEST_ASSERT(!memcmp(&fields[5],&minus1,sizeof(UChar*)));
- spaceNeeded = strlen("first .tag-a. second.tag-b. third."); /* "." at NUL positions */
+ spaceNeeded = (int32_t)strlen("first .tag-a. second.tag-b. third."); /* "." at NUL positions */
TEST_ASSERT(spaceNeeded == requiredCapacity);
}
/* Split, end of text is a field delimiter. */
status = U_ZERO_ERROR;
- sz = strlen("first <tag-a> second<tag-b>");
+ sz = (int32_t)strlen("first <tag-a> second<tag-b>");
uregex_setText(re, textToSplit, sz, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT(fields[5] == NULL);
TEST_ASSERT(fields[8] == NULL);
TEST_ASSERT(!memcmp(&fields[9],&minus1,sizeof(UChar*)));
- spaceNeeded = strlen("first .tag-a. second.tag-b.."); /* "." at NUL positions */
+ spaceNeeded = (int32_t)strlen("first .tag-a. second.tag-b.."); /* "." at NUL positions */
TEST_ASSERT(spaceNeeded == requiredCapacity);
}
}
/* Split, end of text is a field delimiter. */
status = U_ZERO_ERROR;
- uregex_setText(re, textToSplit, strlen("first <tag-a> second<tag-b>"), &status);
+ uregex_setText(re, textToSplit, (int32_t)strlen("first <tag-a> second<tag-b>"), &status);
TEST_ASSERT_SUCCESS(status);
/* The TEST_ASSERT_SUCCESS call above should change too... */
#include "uarrsort.h"
static void
-SortTest() {
+SortTest(void) {
uint16_t small[]={ 8, 1, 2, 5, 4, 3, 7, 6 };
int32_t medium[]={ 10, 8, 1, 2, 5, 5, -1, 6, 4, 3, 9, 7, 5 };
uint32_t large[]={ 21, 10, 20, 19, 11, 12, 13, 10, 10, 10, 10,
return ucol_strcoll(coll, leftLine->s, STR_LEN, rightLine->s, STR_LEN);
}
-static void StableSortTest() {
+static void StableSortTest(void) {
UErrorCode errorCode=U_ZERO_ERROR;
UCollator *coll;
Line *lines, *p;
TEST_ASSERT_NE(f, NULL);
confusables = malloc(3000000);
if (f != NULL) {
- confusablesLength = fread(confusables, 1, 3000000, f);
+ confusablesLength = (int)fread(confusables, 1, 3000000, f);
fclose(f);
}
TEST_ASSERT_NE(f, NULL);
confusablesWholeScript = malloc(1000000);
if (f != NULL) {
- confusablesWholeScriptLength = fread(confusablesWholeScript, 1, 1000000, f);
+ confusablesWholeScriptLength = (int)fread(confusablesWholeScript, 1, 1000000, f);
fclose(f);
}
int32_t needLen;
FILE *f;
char fnbuf[FILENAME_BUFFER];
- const char* directory= ctest_dataSrcDir();
- needLen = uprv_strlen(directory)+uprv_strlen(TDSRCPATH)+uprv_strlen(filename)+1;
+ const char* directory = ctest_dataSrcDir();
+ needLen = (int32_t)(uprv_strlen(directory) + uprv_strlen(TDSRCPATH) + uprv_strlen(filename) + 1);
if(needLen > FILENAME_BUFFER) {
log_err("FAIL: Could not load %s. Filename buffer overflow, needed %d but buffer is %d\n",
filename, needLen, FILENAME_BUFFER);
return;
}
if(compareToChar!=NULL) {
- u_charsToUChars(compareToChar[i], buf, strlen(compareToChar[i])+1);
+ u_charsToUChars(compareToChar[i], buf, (int32_t)strlen(compareToChar[i])+1);
if(u_strncmp(ustr,buf,len)) {
int j;
log_err("%s:%d: FAIL: ustring #%d expected '%s' got '%s'\n", __FILE__, line, i, compareToChar[i], austrdup(ustr));
char message[256];
uprv_strncpy(message, messagePrefix, 256);
- int32_t prefixEnd = uprv_strlen(messagePrefix);
+ int32_t prefixEnd = (int32_t)uprv_strlen(messagePrefix);
message[prefixEnd++] = ':';
message[prefixEnd++] = ' ';
U_ASSERT(prefixEnd < 256);
const StringAndValue data[], int32_t dataLength) {
BytesTrie::State state;
for(int32_t i=0; i<dataLength; ++i) {
- int32_t stringLength= (i&1) ? -1 : strlen(data[i].s);
+ int32_t stringLength= (i&1) ? -1 : static_cast<int32_t>(strlen(data[i].s));
UStringTrieResult result;
if( !USTRINGTRIE_HAS_VALUE(result=trie.next(data[i].s, stringLength)) ||
result!=trie.current()
errln("trie value for %s changes when repeating current()/getValue()", data[i].s);
}
trie.reset();
- stringLength=strlen(data[i].s);
+ stringLength = static_cast<int32_t>(strlen(data[i].s));
result=trie.current();
for(int32_t j=0; j<stringLength; ++j) {
if(!USTRINGTRIE_HAS_NEXT(result)) {
trie.resetToState(noState);
}
const char *expectedString=data[i].s;
- int32_t stringLength=strlen(expectedString);
- int32_t partialLength=stringLength/3;
+ int32_t stringLength= static_cast<int32_t>(strlen(expectedString));
+ int32_t partialLength = stringLength / 3;
for(int32_t j=0; j<partialLength; ++j) {
if(!USTRINGTRIE_MATCHES(trie.next(expectedString[j]))) {
errln("trie.next()=USTRINGTRIE_NO_MATCH for a prefix of %s", data[i].s);
const StringAndValue data[], int32_t dataLength) {
for(int32_t i=0; i<dataLength; ++i) {
const char *expectedString=data[i].s;
- int32_t stringLength=strlen(expectedString);
+ int32_t stringLength = static_cast<int32_t>(strlen(expectedString));
if(!trie.next(expectedString, stringLength/2)) {
errln("trie.next(up to middle of string)=USTRINGTRIE_NO_MATCH for %s", data[i].s);
continue;
sprintf(tmp, "(%g==%g)", (double)lhs, (double)rhs); \
assertTrue(tmp, (lhs==rhs), FALSE, TRUE, __FILE__, __LINE__); }
+#if defined(_MSC_VER)
+// Ignore the noisy warning 4805 (comparisons between int and bool) in the function below as we use the ICU TRUE/FALSE macros
+// which are int values, whereas some of the DecimalQuantity methods return C++ bools.
+#pragma warning(push)
+#pragma warning(disable: 4805)
+#endif
void IntlTestDecimalFormatAPI::TestFixedDecimal() {
UErrorCode status = U_ZERO_ERROR;
ASSERT_EQUAL(FALSE, fd.isNegative());
}
+#if defined(_MSC_VER)
+// Re-enable 4805 warnings (comparisons between int and bool).
+#pragma warning(pop)
+#endif
void IntlTestDecimalFormatAPI::TestBadFastpath() {
UErrorCode status = U_ZERO_ERROR;
fileSize = ftell(f);
fileBuf = new char[fileSize];
fseek(f, 0, SEEK_SET);
- amtRead = fread(fileBuf, 1, fileSize, f);
+ amtRead = static_cast<int32_t>(fread(fileBuf, 1, fileSize, f));
if (amtRead != fileSize || fileSize <= 0) {
errln("Error reading test data file.");
goto cleanUpAndReturn;
}
const char* name = "idna_conf.txt"; // test data file
- int t = strlen(path) + strlen(name) + 1;
+ int t = static_cast<int>(strlen(path) + strlen(name) + 1);
char* absolute_name = new char[t];
strcpy(absolute_name, path);
strcat(absolute_name, name);
NULL, // dest,
0, // destCapacity,
source,
- source_len,
+ static_cast<int32_t>(source_len),
&status);
if (status == U_BUFFER_OVERFLOW_ERROR) {
// Buffer Overflow is expected from the preflight operation.
status = U_ZERO_ERROR;
UChar * dest = NULL;
dest = new UChar[ dest_len + 1];
- ucnv_toUChars(conv, dest, dest_len + 1, source, source_len, &status);
+ ucnv_toUChars(conv, dest, dest_len + 1, source, static_cast<int32_t>(source_len), &status);
// Do not know the "if possible" behavior of ucnv_toUChars()
// Do it by ourself.
dest[dest_len] = 0;
}
labelStart = delimiter;
- remainingLen = srcLength - (delimiter - src);
+ remainingLen = static_cast<int32_t>(srcLength - (delimiter - src));
}
}
}
labelStart = delimiter;
- remainingLen = srcLength - (delimiter - src);
+ remainingLen = static_cast<int32_t>(srcLength - (delimiter - src));
}
}
const char* IntlTest::getProperty(const char* prop) {
const char* val = NULL;
for (int32_t i = 0; i < numProps; i++) {
- int32_t plen = uprv_strlen(prop);
+ int32_t plen = static_cast<int32_t>(uprv_strlen(prop));
if ((int32_t)uprv_strlen(proplines[i]) > plen + 1
&& proplines[i][plen] == '='
&& uprv_strncmp(proplines[i], prop, plen) == 0) {
int32_t fileSize = ftell(f.getAlias());
LocalArray<char> fileBuf(new char[fileSize]);
fseek(f.getAlias(), 0, SEEK_SET);
- int32_t amt_read = fread(fileBuf.getAlias(), 1, fileSize, f.getAlias());
+ int32_t amt_read = static_cast<int32_t>(fread(fileBuf.getAlias(), 1, fileSize, f.getAlias()));
TEST_ASSERT_EQ(amt_read, fileSize);
TEST_ASSERT(fileSize>0);
if (amt_read != fileSize || fileSize <=0) {
status);
status.errIfFailureAndReset("\"%s\"", l.getName());
- assertEquals("set::size()", 2, result.size());
+ assertEquals("set::size()", 2, static_cast<int32_t>(result.size()));
assertTrue("set::find(\"calendar\")",
result.find("calendar") != result.end());
assertTrue("set::find(\"collation\")",
status);
status.errIfFailureAndReset("\"%s\"", l.getName());
- assertEquals("set::size()", 2, result.size());
+ assertEquals("set::size()", 2, static_cast<int32_t>(result.size()));
assertTrue("set::find(\"ca\")",
result.find("ca") != result.end());
assertTrue("set::find(\"co\")",
std::string out8;
Edits edits;
Edits *editsPtr = (mode == UNORM_NFC || mode == UNORM_NFKC) ? &edits : nullptr;
- StringByteSink<std::string> sink(&out8, exp8.length());
+ StringByteSink<std::string> sink(&out8, static_cast<int32_t>(exp8.length()));
norm2->normalizeUTF8(0, s8, sink, editsPtr, errorCode);
if (U_FAILURE(errorCode)) {
errln("Normalizer2.%s.normalizeUTF8(%s) failed: %s",
(int32_t)(out8.length() - s8.length()), edits.lengthDelta());
Edits::Iterator iter = edits.getCoarseIterator();
while (iter.next(errorCode)) {}
- pass &= assertEquals("edits source length", s8.length(), iter.sourceIndex());
- pass &= assertEquals("edits destination length", out8.length(), iter.destinationIndex());
+ pass &= assertEquals("edits source length", static_cast<int32_t>(s8.length()), iter.sourceIndex());
+ pass &= assertEquals("edits destination length", static_cast<int32_t>(out8.length()), iter.destinationIndex());
return pass;
}
{5, 5, u"5–5 britanskih funtov"}, // other + other -> other
};
for (auto& cas : cases) {
- UnicodeString message = Int64ToUnicodeString(cas.first);
+ UnicodeString message = Int64ToUnicodeString(static_cast<int64_t>(cas.first));
message += u" ";
- message += Int64ToUnicodeString(cas.second);
+ message += Int64ToUnicodeString(static_cast<int64_t>(cas.second));
status.setScope(message);
UnicodeString actual = lnrf.formatFormattableRange(cas.first, cas.second, status).toString(status);
assertEquals(message, cas.expected, actual);
}
double numDbl = dl.toDouble();
const char *decimalPoint = strchr(num, '.');
- int fractionDigitCount = decimalPoint == NULL ? 0 : (num + strlen(num) - 1) - decimalPoint;
+ int fractionDigitCount = decimalPoint == NULL ? 0 : static_cast<int>((num + strlen(num) - 1) - decimalPoint);
int fractionDigits = fractionDigitCount == 0 ? 0 : atoi(decimalPoint + 1);
FixedDecimal ni(numDbl, fractionDigitCount, fractionDigits);
}
test->fDumpExpansions = dumpExpansions;
test->fVerbose = verbose;
- test->fRandomGenerator.seed((uint32_t)seed);
- test->fLoopCount = loopCount;
+ test->fRandomGenerator.seed(static_cast<uint32_t>(seed));
+ test->fLoopCount = static_cast<int32_t>(loopCount);
test->setup(tests[i], status);
if (U_FAILURE(status)) {
dataerrln("%s:%d: error %s while starting test %s.", __FILE__, __LINE__, u_errorName(status), tests[i]);
printf("code alpha extend alphanum type word sent line name\n");
int nextExpectedIndex = 0;
utext_setNativeIndex(tstr, 0);
- for (int j = 0; j < utext_nativeLength(tstr); j=utext_getNativeIndex(tstr)) {
+ for (int j = 0; j < static_cast<int>(utext_nativeLength(tstr)); j=static_cast<int>(utext_getNativeIndex(tstr))) {
if (nextExpectedIndex < expectedCount && j >= expected[nextExpectedIndex] ) {
printf("------------------------------------------------ %d\n", j);
++nextExpectedIndex;
//
// Run the iterator backwards, verify that the same breaks are found.
//
- prevBP = utext_nativeLength(t->textToBreak)+2; // start with a phony value for the last break pos seen.
+ prevBP = static_cast<int32_t>(utext_nativeLength(t->textToBreak) + 2); // start with a phony value for the last break pos seen.
bp = t->bi->last();
while (bp != BreakIterator::DONE) {
if (prevBP == bp) {
}
// Check following()
- for (i=0; i < utext_nativeLength(t->textToBreak); i++) {
+ for (i=0; i < static_cast<int32_t>(utext_nativeLength(t->textToBreak)); i++) {
int32_t actualBreak = t->bi->following(i);
int32_t expectedBreak = BreakIterator::DONE;
- for (int32_t j=i+1; j <= utext_nativeLength(t->textToBreak); j++) {
+ for (int32_t j=i+1; j <= static_cast<int32_t>(utext_nativeLength(t->textToBreak)); j++) {
if (t->getExpectedBreak(j) != 0) {
expectedBreak = j;
break;
}
// Check preceding()
- for (i=utext_nativeLength(t->textToBreak); i>=0; i--) {
+ for (i=static_cast<int32_t>(utext_nativeLength(t->textToBreak)); i>=0; i--) {
int32_t actualBreak = t->bi->preceding(i);
int32_t expectedBreak = BreakIterator::DONE;
// Therefore, start looking at the expected break data not at i-1, but at
// the start of code point index - 1.
utext_setNativeIndex(t->textToBreak, i);
- int32_t j = utext_getNativeIndex(t->textToBreak) - 1;
+ int32_t j = static_cast<int32_t>(utext_getNativeIndex(t->textToBreak) - 1);
for (; j >= 0; j--) {
if (t->getExpectedBreak(j) != 0) {
expectedBreak = j;
fileSize = ftell(f);
fileBuf = new char[fileSize];
fseek(f, 0, SEEK_SET);
- amt_read = fread(fileBuf, 1, fileSize, f);
+ amt_read = static_cast<int>(fread(fileBuf, 1, fileSize, f));
if (amt_read != fileSize || fileSize <= 0) {
errln("Error reading test data file.");
goto cleanUpAndReturn;
REGEX_VERBOSE_TEXT(&input2);
utext_openUChars(&empty, NULL, 0, &status);
- int32_t input1Len = strlen("abcdef this is a test"); /* TODO: why not nativelen (input1) ? */
- int32_t input2Len = strlen("not abc");
+ int32_t input1Len = static_cast<int32_t>(strlen("abcdef this is a test")); /* TODO: why not nativelen (input1) ? */
+ int32_t input2Len = static_cast<int32_t>(strlen("not abc"));
//
fileSize = ftell(f);
fileBuf = new char[fileSize];
fseek(f, 0, SEEK_SET);
- amt_read = fread(fileBuf, 1, fileSize, f);
+ amt_read = static_cast<int32_t>(fread(fileBuf, 1, fileSize, f));
if (amt_read != fileSize || fileSize <= 0) {
errln("Error reading test data file.");
goto cleanUpAndReturn;
// Size of the original char * data (invariant charset) will be <= than the equivalent UTF-8
// because string.unescape() will only shrink it.
char * utf8Buffer = new char[uprv_strlen(data)+1];
- u_strToUTF8(utf8Buffer, uprv_strlen(data)+1, NULL, dataString.getBuffer(), dataString.length(), &status);
+ u_strToUTF8(utf8Buffer, static_cast<int32_t>(uprv_strlen(data)+1), NULL, dataString.getBuffer(), dataString.length(), &status);
REGEX_CHECK_STATUS;
ut = utext_openUTF8(ut, utf8Buffer, -1, &status);
REGEX_CHECK_STATUS;
msg = UnicodeString("ucasemap_utf8ToUpper/Greek(\"") + s16 + "\")";
char dest8[1000];
length = ucasemap_utf8ToUpper(csm.getAlias(), dest8, UPRV_LENGTHOF(dest8),
- s8.data(), s8.length(), &errorCode);
+ s8.data(), static_cast<int32_t>(s8.length()), &errorCode);
assertSuccess("ucasemap_utf8ToUpper", errorCode);
StringPiece result8(dest8, length);
UnicodeString result16From8 = UnicodeString::fromUTF8(result8);
memset(dest8b, 0x5A, UPRV_LENGTHOF(dest8b));
UErrorCode errorCode = U_ZERO_ERROR;
length = ucasemap_utf8ToUpper(csm.getAlias(), dest8b, cap,
- s8.data(), s8.length(), &errorCode);
+ s8.data(), static_cast<int32_t>(s8.length()), &errorCode);
assertEquals(msg + cap, expected8Length, length);
UErrorCode expectedErrorCode;
if (cap < expected8Length) {
std::string data_utf8;
data.toUTF8String(data_utf8);
#if !UCONFIG_NO_BREAK_ITERATION
- result = ucasemap_utf8ToTitle(csm.getAlias(), NULL, 0, data_utf8.c_str(), data_utf8.length(), errorCode);
+ result = ucasemap_utf8ToTitle(csm.getAlias(), NULL, 0, data_utf8.c_str(), static_cast<int32_t>(data_utf8.length()), errorCode);
if (errorCode.get() != U_BUFFER_OVERFLOW_ERROR || result != (int32_t)data_utf8.length()) {
errln("%s:%d ucasemap_toTitle(\"hello world\") failed: "
"expected (U_BUFFER_OVERFLOW_ERROR, %d), got (%s, %d)",
u8" AÄA\u0308A\u0308\u00ad\u0323Ä\u0323,\u00ad\u1100\u1161가\u11A8가\u3133 ";
std::string expected = u8" aääạ\u0308ạ\u0308,가각갃 ";
std::string result;
- StringByteSink<std::string> sink(&result, expected.length());
+ StringByteSink<std::string> sink(&result, static_cast<int32_t>(expected.length()));
Edits edits;
nfkc_cf->normalizeUTF8(0, src, sink, &edits, errorCode);
assertSuccess("normalizeUTF8 with Edits", errorCode.get());
std::string s8(u8"\u1100\u1161\u11A7\u1100\u314F\u11A7가\u11A7");
std::string expected8(u8"가\u11A7가\u11A7가\u11A7");
std::string result8;
- StringByteSink<std::string> sink(&result8, expected8.length());
+ StringByteSink<std::string> sink(&result8, static_cast<int32_t>(expected8.length()));
nfkc->normalizeUTF8(0, s8, sink, nullptr, errorCode);
assertSuccess("normalizeUTF8(LV+11A7)", errorCode.get());
assertEquals("normalizeUTF8(LV+11A7)", expected8.c_str(), result8.c_str());
}
static inline int32_t slen(const void *s, UBool isUTF16) {
- return isUTF16 ? u_strlen((const UChar *)s) : strlen((const char *)s);
+ return isUTF16 ? u_strlen((const UChar *)s) : static_cast<int32_t>(strlen((const char *)s));
}
/*
for(int i = 0; i < lcidCount; i += 1) {
UErrorCode status = U_ZERO_ERROR;
WCHAR longDateFormat[81], longTimeFormat[81], wdBuffer[256], wtBuffer[256];
+ DWORD value = 0;
int32_t calType = 0;
// NULL localeID means ICU didn't recognize this locale
GetLocaleInfoW(lcidRecords[i].lcid, LOCALE_SLONGDATE, longDateFormat, 81);
GetLocaleInfoW(lcidRecords[i].lcid, LOCALE_STIMEFORMAT, longTimeFormat, 81);
- GetLocaleInfoW(lcidRecords[i].lcid, LOCALE_RETURN_NUMBER|LOCALE_ICALENDARTYPE, (LPWSTR) calType, sizeof(int32_t));
+ GetLocaleInfoW(lcidRecords[i].lcid, LOCALE_RETURN_NUMBER|LOCALE_ICALENDARTYPE, (LPWSTR)&value, sizeof(value)/sizeof(WCHAR));
+ calType = value;
char localeID[64];
uprv_strcpy(localeID, lcidRecords[i].localeID);
}
} else {
/* put -- out at 30 sp. */
- int spaces = FLAG_INDENT-(strlen(root->name)+depth);
+ int spaces = FLAG_INDENT - ((int)strlen(root->name) + depth);
if(spaces<0) spaces=0;
log_testinfo(" %*s[OK] ", spaces,"---");
}
keysInUse.insert(key);
}
});
- fKeysCount = keysInUse.size();
+ fKeysCount = static_cast<int32_t>(keysInUse.size());
}
int32_t keysCount = fUsePoolBundle->fKeysCount + fKeysCount;
errorCode=U_INTERNAL_PROGRAM_ERROR;
}
+#if defined(_MSC_VER)
+// Ignore warning 4127, conditional expression is constant. This is intentional below.
+#pragma warning(push)
+#pragma warning(disable: 4127)
+#endif
+
if(U_SIZEOF_WCHAR_T==sizeof(wchar_t)) {
//printf("U_SIZEOF_WCHAR_T: %d\n", U_SIZEOF_WCHAR_T);
} else {
errorCode=U_INTERNAL_PROGRAM_ERROR;
}
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
+
printf("\n\nICU Initialization returned: %s\n", u_errorName(initStatus));
if (IN_STATIC_MODE(mode)) {
if (cmd == NULL) {
- length = uprv_strlen(pkgDataFlags[AR]) + uprv_strlen(pkgDataFlags[ARFLAGS]) + uprv_strlen(targetDir) +
- uprv_strlen(libFileNames[LIB_FILE_VERSION]) + uprv_strlen(objectFile) + uprv_strlen(pkgDataFlags[RANLIB]) + BUFFER_PADDING_SIZE;
+ length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[AR]) + uprv_strlen(pkgDataFlags[ARFLAGS]) + uprv_strlen(targetDir) +
+ uprv_strlen(libFileNames[LIB_FILE_VERSION]) + uprv_strlen(objectFile) + uprv_strlen(pkgDataFlags[RANLIB]) + BUFFER_PADDING_SIZE);
if ((cmd = (char *)uprv_malloc(sizeof(char) * length)) == NULL) {
fprintf(stderr, "Unable to allocate memory for command.\n");
return -1;
}
} else /* if (IN_DLL_MODE(mode)) */ {
if (cmd == NULL) {
- length = uprv_strlen(pkgDataFlags[GENLIB]) + uprv_strlen(pkgDataFlags[LDICUDTFLAGS]) +
+ length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[GENLIB]) + uprv_strlen(pkgDataFlags[LDICUDTFLAGS]) +
((uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_VERSION_TMP])) * 2) +
uprv_strlen(objectFile) + uprv_strlen(pkgDataFlags[LD_SONAME]) +
uprv_strlen(pkgDataFlags[LD_SONAME][0] == 0 ? "" : libFileNames[LIB_FILE_VERSION_MAJOR]) +
- uprv_strlen(pkgDataFlags[RPATH_FLAGS]) + uprv_strlen(pkgDataFlags[BIR_FLAGS]) + BUFFER_PADDING_SIZE;
+ uprv_strlen(pkgDataFlags[RPATH_FLAGS]) + uprv_strlen(pkgDataFlags[BIR_FLAGS]) + BUFFER_PADDING_SIZE);
#if U_PLATFORM == U_PF_CYGWIN
- length += uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_CYGWIN_VERSION]);
+ length += static_cast<int32_t>(uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_CYGWIN_VERSION]));
#elif U_PLATFORM == U_PF_MINGW
- length += uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_MINGW]);
+ length += static_cast<int32_t>(uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_MINGW]));
#endif
if ((cmd = (char *)uprv_malloc(sizeof(char) * length)) == NULL) {
fprintf(stderr, "Unable to allocate memory for command.\n");
uprv_strcpy(tempObjectFile, gencFilePath);
tempObjectFile[uprv_strlen(tempObjectFile)-1] = 'o';
- length = uprv_strlen(pkgDataFlags[COMPILER]) + uprv_strlen(pkgDataFlags[LIBFLAGS])
- + uprv_strlen(tempObjectFile) + uprv_strlen(gencFilePath) + BUFFER_PADDING_SIZE;
+ length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[COMPILER]) + uprv_strlen(pkgDataFlags[LIBFLAGS])
+ + uprv_strlen(tempObjectFile) + uprv_strlen(gencFilePath) + BUFFER_PADDING_SIZE);
cmd = (char *)uprv_malloc(sizeof(char) * length);
if (cmd == NULL) {
char *tmpGenlibFlagBuffer = NULL;
int32_t i, offset;
- length = uprv_strlen(flag) + 1;
+ length = static_cast<int32_t>(uprv_strlen(flag) + 1);
tmpGenlibFlagBuffer = (char *)uprv_malloc(length);
if (tmpGenlibFlagBuffer == NULL) {
/* Memory allocation error */
uprv_strcpy(tmpGenlibFlagBuffer, flag);
- offset = uprv_strlen(rm_cmd);
+ offset = static_cast<int32_t>(uprv_strlen(rm_cmd));
for (i = 0; i < (length - offset); i++) {
flag[i] = tmpGenlibFlagBuffer[offset + i];
}
flag = pkgDataFlags[BIR_FLAGS];
- length = uprv_strlen(pkgDataFlags[BIR_FLAGS]);
+ length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[BIR_FLAGS]));
for (int32_t i = 0; i < length; i++) {
if (flag[i] == MAP_FILE_EXT[count]) {
int32_t length = 0;
flag = pkgDataFlags[GENLIB];
- length = uprv_strlen(pkgDataFlags[GENLIB]);
+ length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[GENLIB]));
int32_t position = length - 1;
int32_t length = 0;
flag = pkgDataFlags[GENLIB];
- length = uprv_strlen(pkgDataFlags[GENLIB]);
+ length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[GENLIB]));
int32_t position = length - 1;
fprintf(stderr, "pkgdata: Error: absolute path encountered. Old style paths are not supported. Use relative paths such as 'fur.res' or 'translit%cfur.res'.\n\tBad path: '%s'\n", U_FILE_SEP_CHAR, s);
exit(U_ILLEGAL_ARGUMENT_ERROR);
}
- tmpLength = uprv_strlen(o->srcDir) +
- uprv_strlen(s) + 5; /* 5 is to add a little extra space for, among other things, PKGDATA_FILE_SEP_STRING */
+ /* The +5 is to add a little extra space for, among other things, PKGDATA_FILE_SEP_STRING */
+ tmpLength = static_cast<int32_t>(uprv_strlen(o->srcDir) + uprv_strlen(s) + 5);
if((tmp = (char *)uprv_malloc(tmpLength)) == NULL) {
fprintf(stderr, "pkgdata: Error: Unable to allocate tmp buffer size: %d\n", tmpLength);
exit(U_MEMORY_ALLOCATION_ERROR);
" {0, 0, 0, 0}\n"
" },\n"
" \"\", %lu, 0, {\n",
- (unsigned long)32-4-sizeof(UDataInfo),
- (unsigned long)fileCount,
+ static_cast<unsigned long>(32-4-sizeof(UDataInfo)),
+ static_cast<unsigned long>(fileCount),
entrypointName,
- (unsigned long)sizeof(UDataInfo),
+ static_cast<unsigned long>(sizeof(UDataInfo)),
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
U_SIZEOF_UCHAR,
- (unsigned long)fileCount
+ static_cast<unsigned long>(fileCount)
);
T_FileStream_writeLine(out, buffer);
resultLen = 0;
} else {
resultPtr = path;
- resultLen = basename - path;
+ resultLen = static_cast<int32_t>(basename - path);
if(resultLen<1) {
resultLen = 1; /* '/' or '/a' -> '/' */
}