diff --git a/.github/workflows/icu4c.yml b/.github/workflows/icu4c.yml index 01a1fda21082..668094141bf1 100644 --- a/.github/workflows/icu4c.yml +++ b/.github/workflows/icu4c.yml @@ -149,7 +149,8 @@ jobs: PREFIX: /tmp/icu-prefix CC: gcc-10 CXX: g++-10 - CXXFLAGS: -std=c++17 -Wextra + CXXFLAGS: -std=c++17 -Wextra -Werror + CFLAGS: -Werror run: | mkdir build; cd build; diff --git a/icu4c/source/common/ucnvmbcs.cpp b/icu4c/source/common/ucnvmbcs.cpp index 6b4d1491a2a6..3faf2ad5da09 100644 --- a/icu4c/source/common/ucnvmbcs.cpp +++ b/icu4c/source/common/ucnvmbcs.cpp @@ -3144,13 +3144,14 @@ ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs, } if(c<0) { - if(U_SUCCESS(*pErrorCode) && source==sourceLimit && lastSourcetoUBytes)) { /* incomplete character byte sequence */ uint8_t *bytes=cnv->toUBytes; cnv->toULength = static_cast(source - lastSource); do { *bytes++=*lastSource++; - } while(lastSourcetoUBytes[sizeof(cnv->toUBytes)-1])); *pErrorCode=U_TRUNCATED_CHAR_FOUND; } else if(U_FAILURE(*pErrorCode)) { /* callback(illegal) */ diff --git a/icu4c/source/common/ucurr.cpp b/icu4c/source/common/ucurr.cpp index 282199257376..dc41e027af61 100644 --- a/icu4c/source/common/ucurr.cpp +++ b/icu4c/source/common/ucurr.cpp @@ -372,12 +372,7 @@ struct CReg : public icu::UMemory { CReg(const char16_t* _iso, const char* _id) : next(nullptr) { - int32_t len = static_cast(uprv_strlen(_id)); - if (len > static_cast(sizeof(id) - 1)) { - len = (sizeof(id)-1); - } - uprv_strncpy(id, _id, len); - id[len] = 0; + uprv_strncpy(id, _id, sizeof(id)-1); u_memcpy(iso, _iso, ISO_CURRENCY_CODE_LENGTH); iso[ISO_CURRENCY_CODE_LENGTH] = 0; } diff --git a/icu4c/source/common/ushape.cpp b/icu4c/source/common/ushape.cpp index 0843889d2dd4..0d5b00fb3d43 100644 --- a/icu4c/source/common/ushape.cpp +++ b/icu4c/source/common/ushape.cpp @@ -28,6 +28,7 @@ #include "ubidi_props.h" #include "uassert.h" +#include /* * This implementation is designed for 16-bit Unicode strings. * The main assumption is that the Arabic characters and their @@ -747,6 +748,10 @@ handleGeneratedSpaces(char16_t *dest, int32_t sourceLength, } } + if (static_cast((sourceLength + 1)) > (std::numeric_limits::max() / U_SIZEOF_UCHAR)) { + *pErrorCode = U_MEMORY_ALLOCATION_ERROR; + return 0; + } tempbuffer = static_cast(uprv_malloc((sourceLength + 1) * U_SIZEOF_UCHAR)); /* Test for nullptr */ if(tempbuffer == nullptr) { diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index f74446b43765..c58563e8de25 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -828,9 +828,9 @@ Calendar::operator=(const Calendar &right) fWeekendCease = right.fWeekendCease; fWeekendCeaseMillis = right.fWeekendCeaseMillis; fNextStamp = right.fNextStamp; - uprv_strncpy(validLocale, right.validLocale, sizeof(validLocale)); - uprv_strncpy(actualLocale, right.actualLocale, sizeof(actualLocale)); + uprv_strncpy(validLocale, right.validLocale, sizeof(validLocale)-1); validLocale[sizeof(validLocale)-1] = 0; + uprv_strncpy(actualLocale, right.actualLocale, sizeof(actualLocale)-1); actualLocale[sizeof(validLocale)-1] = 0; } diff --git a/icu4c/source/i18n/decNumber.cpp b/icu4c/source/i18n/decNumber.cpp index 96ad3d7f986a..6be3ade48aba 100644 --- a/icu4c/source/i18n/decNumber.cpp +++ b/icu4c/source/i18n/decNumber.cpp @@ -2829,6 +2829,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberShift(decNumber *res, const decNumber #if defined(__clang__) || U_GCC_MAJOR_MINOR >= 406 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" #endif U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *res, const decNumber *rhs, decContext *set) { diff --git a/icu4c/source/i18n/formattedvalue.cpp b/icu4c/source/i18n/formattedvalue.cpp index aacd6ac70e09..64642b4c9473 100644 --- a/icu4c/source/i18n/formattedvalue.cpp +++ b/icu4c/source/i18n/formattedvalue.cpp @@ -193,6 +193,10 @@ ucfpos_close(UConstrainedFieldPosition* ptr) { } +#if defined(__clang__) || U_GCC_MAJOR_MINOR >= 406 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wreturn-local-addr" +#endif U_CAPI const char16_t* U_EXPORT2 ufmtval_getString( const UFormattedValue* ufmtval, @@ -213,6 +217,9 @@ ufmtval_getString( // defined to return memory owned by the ufmtval argument. return readOnlyAlias.getBuffer(); } +#if defined(__clang__) || U_GCC_MAJOR_MINOR >= 406 +#pragma GCC diagnostic pop +#endif U_CAPI UBool U_EXPORT2 diff --git a/icu4c/source/i18n/number_rounding.cpp b/icu4c/source/i18n/number_rounding.cpp index 8f1aa453ada4..ebcbc08b8e88 100644 --- a/icu4c/source/i18n/number_rounding.cpp +++ b/icu4c/source/i18n/number_rounding.cpp @@ -283,6 +283,8 @@ FractionPrecision Precision::constructFraction(int32_t minFrac, int32_t maxFrac) settings.fMaxFrac = static_cast(maxFrac); settings.fMinSig = -1; settings.fMaxSig = -1; + settings.fPriority = UNUM_ROUNDING_PRIORITY_RELAXED; + settings.fRetain = false; PrecisionUnion union_; union_.fracSig = settings; return {RND_FRACTION, union_}; @@ -294,6 +296,8 @@ Precision Precision::constructSignificant(int32_t minSig, int32_t maxSig) { settings.fMaxFrac = -1; settings.fMinSig = static_cast(minSig); settings.fMaxSig = static_cast(maxSig); + settings.fPriority = UNUM_ROUNDING_PRIORITY_RELAXED; + settings.fRetain = false; PrecisionUnion union_; union_.fracSig = settings; return {RND_SIGNIFICANT, union_}; diff --git a/icu4c/source/i18n/number_skeletons.cpp b/icu4c/source/i18n/number_skeletons.cpp index 562a8663d057..588030cab10a 100644 --- a/icu4c/source/i18n/number_skeletons.cpp +++ b/icu4c/source/i18n/number_skeletons.cpp @@ -1015,6 +1015,10 @@ blueprint_helpers::parseExponentSignOption(const StringSegment& segment, MacroPr return true; } +#if defined(__clang__) || U_GCC_MAJOR_MINOR >= 406 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdangling-pointer" +#endif void blueprint_helpers::parseCurrencyOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status) { // Unlike ICU4J, have to check length manually because ICU4C CurrencyUnit does not check it for us @@ -1034,6 +1038,9 @@ void blueprint_helpers::parseCurrencyOption(const StringSegment& segment, MacroP // Slicing is OK macros.unit = currency; // NOLINT } +#if defined(__clang__) || U_GCC_MAJOR_MINOR >= 406 +#pragma GCC diagnostic pop +#endif void blueprint_helpers::generateCurrencyOption(const CurrencyUnit& currency, UnicodeString& sb, UErrorCode&) { diff --git a/icu4c/source/test/cintltst/cbiditst.c b/icu4c/source/test/cintltst/cbiditst.c index 8b0a01057045..ee80366090aa 100644 --- a/icu4c/source/test/cintltst/cbiditst.c +++ b/icu4c/source/test/cintltst/cbiditst.c @@ -4730,6 +4730,7 @@ checkMaps(UBiDi *pBiDi, int32_t stringIndex, const char *src, const char *dest, ); testOK = false; } + memset(getIndexMap, 0, sizeof(getIndexMap)); for (i = 0; i < srcLen; i++) { idx = ubidi_getVisualIndex(pBiDi, i, &rc); assertSuccessful("ubidi_getVisualIndex", &rc); diff --git a/icu4c/source/test/cintltst/custrtrn.c b/icu4c/source/test/cintltst/custrtrn.c index 7987dacc9ff6..6a7890baec35 100644 --- a/icu4c/source/test/cintltst/custrtrn.c +++ b/icu4c/source/test/cintltst/custrtrn.c @@ -1527,7 +1527,7 @@ static void Test_strToJavaModifiedUTF8(void) { 0xee, 0x80, 0x81, 0xee, 0x80, 0x82, 0xee, 0x80, 0x83, 0xed, 0xa0, 0x80, 0xed, 0xb0, 0x80, 0xed, 0xb0, 0x80, 0xed, 0xa0, 0x80, 0xc0, 0x80, 0xed, 0xaf, 0xbf, 0xed, 0xbf, 0xbf, - 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0xc3, 0xad, 0xe0, 0xb8, 0x8e, 0x6f + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0xc3, 0xad, 0xe0, 0xb8, 0x8e, 0x6f, 0 }; static const UChar shortSrc[]={ 0xe01, 0xe1, 0x61 @@ -1554,7 +1554,7 @@ static void Test_strToJavaModifiedUTF8(void) { p=u_strToJavaModifiedUTF8(dest, (int32_t)sizeof(dest), &length, src, UPRV_LENGTHOF(src), &errorCode); if( U_FAILURE(errorCode) || p!=dest || - length!=UPRV_LENGTHOF(expected) || 0!=memcmp(dest, expected, length) || + length!=(UPRV_LENGTHOF(expected)-1) || 0!=memcmp(dest, expected, length) || dest[length]!=0 ) { log_err("u_strToJavaModifiedUTF8(normal) failed - %s\n", u_errorName(errorCode)); @@ -1565,18 +1565,18 @@ static void Test_strToJavaModifiedUTF8(void) { p=u_strToJavaModifiedUTF8(dest, (int32_t)sizeof(dest), NULL, src, UPRV_LENGTHOF(src), &errorCode); if( U_FAILURE(errorCode) || p!=dest || - 0!=memcmp(dest, expected, UPRV_LENGTHOF(expected)) || - dest[UPRV_LENGTHOF(expected)]!=0 + 0!=memcmp(dest, expected, (UPRV_LENGTHOF(expected)-1)) || + dest[(UPRV_LENGTHOF(expected)-1)]!=0 ) { log_err("u_strToJavaModifiedUTF8(normal, pLength=NULL) failed - %s\n", u_errorName(errorCode)); } memset(dest, 0xff, sizeof(dest)); errorCode=U_ZERO_ERROR; length=-5; - p=u_strToJavaModifiedUTF8(dest, UPRV_LENGTHOF(expected), &length, + p=u_strToJavaModifiedUTF8(dest, (UPRV_LENGTHOF(expected)-1), &length, src, UPRV_LENGTHOF(src), &errorCode); if( errorCode!=U_STRING_NOT_TERMINATED_WARNING || p!=dest || - length!=UPRV_LENGTHOF(expected) || 0!=memcmp(dest, expected, length) || + length!=(UPRV_LENGTHOF(expected)-1) || 0!=memcmp(dest, expected, length) || dest[length]!=(char)0xff ) { log_err("u_strToJavaModifiedUTF8(tight) failed - %s\n", u_errorName(errorCode)); @@ -1604,10 +1604,10 @@ static void Test_strToJavaModifiedUTF8(void) { memset(dest, 0xff, sizeof(dest)); errorCode=U_ZERO_ERROR; length=-5; - p=u_strToJavaModifiedUTF8(dest, UPRV_LENGTHOF(expected)/2, &length, + p=u_strToJavaModifiedUTF8(dest, (UPRV_LENGTHOF(expected)-1)/2, &length, src, UPRV_LENGTHOF(src), &errorCode); if( errorCode!=U_BUFFER_OVERFLOW_ERROR || - length!=UPRV_LENGTHOF(expected) || dest[UPRV_LENGTHOF(expected)/2]!=(char)0xff + length!=(UPRV_LENGTHOF(expected)-1) || dest[(UPRV_LENGTHOF(expected)-1)/2]!=(char)0xff ) { log_err("u_strToJavaModifiedUTF8(overflow) failed - %s\n", u_errorName(errorCode)); } @@ -1617,7 +1617,7 @@ static void Test_strToJavaModifiedUTF8(void) { p=u_strToJavaModifiedUTF8(NULL, 0, &length, src, UPRV_LENGTHOF(src), &errorCode); if( errorCode!=U_BUFFER_OVERFLOW_ERROR || - length!=UPRV_LENGTHOF(expected) || dest[0]!=(char)0xff + length!=(UPRV_LENGTHOF(expected)-1) || dest[0]!=(char)0xff ) { log_err("u_strToJavaModifiedUTF8(pure preflighting) failed - %s\n", u_errorName(errorCode)); } diff --git a/icu4c/source/test/cintltst/hpmufn.c b/icu4c/source/test/cintltst/hpmufn.c index f27e57939959..959a4cbd8ba0 100644 --- a/icu4c/source/test/cintltst/hpmufn.c +++ b/icu4c/source/test/cintltst/hpmufn.c @@ -116,7 +116,7 @@ static void * U_CALLCONV myMemRealloc(const void *context, void *mem, size_t siz } retPtr = realloc(p, size+sizeof(ctest_AlignedMemory)); if (retPtr != NULL) { - p += sizeof(ctest_AlignedMemory); + retPtr += sizeof(ctest_AlignedMemory); } return retPtr; } diff --git a/icu4c/source/test/cintltst/uformattedvaluetst.c b/icu4c/source/test/cintltst/uformattedvaluetst.c index edc745a3a888..5cc086d3e3b0 100644 --- a/icu4c/source/test/cintltst/uformattedvaluetst.c +++ b/icu4c/source/test/cintltst/uformattedvaluetst.c @@ -143,7 +143,7 @@ static void AssertAllPartsEqual( UErrorCode status = U_ZERO_ERROR; - char message[256]; + char message[257]; uprv_strncpy(message, messagePrefix, 256); int32_t prefixEnd = (int32_t)uprv_strlen(messagePrefix); message[prefixEnd++] = ':'; diff --git a/icu4c/source/test/intltest/caltest.cpp b/icu4c/source/test/intltest/caltest.cpp index bae5eac77bc6..502f6b69ac51 100644 --- a/icu4c/source/test/intltest/caltest.cpp +++ b/icu4c/source/test/intltest/caltest.cpp @@ -2442,7 +2442,7 @@ void CalendarTest::TestRepeatedWallTime() { calFirst.setRepeatedWallTimeOption(UCAL_WALLTIME_FIRST); for (int32_t i = 0; RPDATA[i].tzid != nullptr; i++) { - char buf[32]; + char buf[33]; TimeZone *tz = TimeZone::createTimeZone(RPDATA[i].tzid); // UCAL_WALLTIME_LAST @@ -2544,7 +2544,7 @@ void CalendarTest::TestSkippedWallTime() { for (int32_t i = 0; SKDATA[i].tzid != nullptr; i++) { UDate d; - char buf[32]; + char buf[33]; TimeZone *tz = TimeZone::createTimeZone(SKDATA[i].tzid); for (int32_t j = 0; j < 2; j++) { @@ -3824,7 +3824,7 @@ void CalendarTest::TestAddAcrossZoneTransition() { if (!AAZTDATA[i].expected.isEquivalentTo(cal, status)) { CalFields res(cal, status); TEST_CHECK_STATUS; - char buf[32]; + char buf[33]; const char *optDisp = AAZTDATA[i].skippedWTOpt == UCAL_WALLTIME_FIRST ? "FIRST" : AAZTDATA[i].skippedWTOpt == UCAL_WALLTIME_LAST ? "LAST" : "NEXT_VALID"; dataerrln(UnicodeString("Error: base:") + AAZTDATA[i].base.toString(buf, sizeof(buf)) + ", tz:" + AAZTDATA[i].zone diff --git a/icu4c/source/test/intltest/rbbitst.cpp b/icu4c/source/test/intltest/rbbitst.cpp index 0ad50993b65f..1fe1cadcfb45 100644 --- a/icu4c/source/test/intltest/rbbitst.cpp +++ b/icu4c/source/test/intltest/rbbitst.cpp @@ -4584,7 +4584,7 @@ void RBBITest::RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name UErrorCode status = U_ZERO_ERROR; u_charName(c, U_EXTENDED_CHAR_NAME, cName, sizeof(cName), &status); - char buffer[200]; + char buffer[280]; auto ret = snprintf(buffer, sizeof(buffer), "%4s %3i : %1s %1s %10s %-*s %-40s %-40s", currentLineFlag.c_str(), diff --git a/icu4c/source/test/iotest/stream.cpp b/icu4c/source/test/iotest/stream.cpp index 1b6303f1ee3e..907914daf3a5 100644 --- a/icu4c/source/test/iotest/stream.cpp +++ b/icu4c/source/test/iotest/stream.cpp @@ -76,7 +76,7 @@ static void U_CALLCONV TestStream() return; } ucnv_close(defConv); - strncpy(defConvName, ucnv_getDefaultName(), UPRV_LENGTHOF(defConvName)); + strncpy(defConvName, ucnv_getDefaultName(), UPRV_LENGTHOF(defConvName)-1); ucnv_setDefaultName("UTF-8"); static const char * const TESTSTRING = "\x20\x74\x48\x69\x73\xCE\xBC\xE2\x80\x82\x20\x6D\x75\x20\x77\x6F\x72\x6C\x64"; diff --git a/icu4c/source/tools/ctestfw/ctest.c b/icu4c/source/tools/ctestfw/ctest.c index 3ae9694a8308..7634526ad4e5 100644 --- a/icu4c/source/tools/ctestfw/ctest.c +++ b/icu4c/source/tools/ctestfw/ctest.c @@ -181,7 +181,9 @@ static TestNode *createTestNode(const char* name, int32_t nameLen) newNode->sibling = NULL; newNode->child = NULL; - strncpy( newNode->name, name, nameLen ); + if (nameLen > 0) { + strncpy( newNode->name, name, nameLen ); + } newNode->name[nameLen] = 0; return newNode; diff --git a/icu4c/source/tools/icuexportdata/icuexportdata.cpp b/icu4c/source/tools/icuexportdata/icuexportdata.cpp index 987a6bc7f6f8..0a96c9e0e62a 100644 --- a/icu4c/source/tools/icuexportdata/icuexportdata.cpp +++ b/icu4c/source/tools/icuexportdata/icuexportdata.cpp @@ -331,13 +331,13 @@ void dumpGeneralCategoryMask(FILE* f) { fprintf(f, "mask_for = \"General_Category\"\n"); - uint32_t minValue = u_getIntPropertyMinValue(UCHAR_GENERAL_CATEGORY); + int32_t minValue = u_getIntPropertyMinValue(UCHAR_GENERAL_CATEGORY); U_ASSERT(minValue >= 0); - uint32_t maxValue = u_getIntPropertyMaxValue(UCHAR_GENERAL_CATEGORY); + int32_t maxValue = u_getIntPropertyMaxValue(UCHAR_GENERAL_CATEGORY); U_ASSERT(maxValue >= 0); fprintf(f, "values = [\n"); - for (uint32_t v = minValue; v <= maxValue; v++) { + for (int32_t v = minValue; v <= maxValue; v++) { dumpValueEntry(uproperty, U_MASK(v), true, f); // We want to dump these masks "in order", which means they diff --git a/icu4c/source/tools/makeconv/genmbcs.cpp b/icu4c/source/tools/makeconv/genmbcs.cpp index 774cdc6045d1..5b909b574df4 100644 --- a/icu4c/source/tools/makeconv/genmbcs.cpp +++ b/icu4c/source/tools/makeconv/genmbcs.cpp @@ -113,9 +113,9 @@ hexDigit(uint8_t digit) { } static inline char * -printBytes(char *buffer, const uint8_t *bytes, int32_t length) { +printBytes(char *buffer, size_t bufferLength, const uint8_t *bytes, int32_t length) { char *s=buffer; - while(length>0) { + while(length>0 && (static_cast(s-buffer) < bufferLength-3)) { *s++ = hexDigit(static_cast(*bytes >> 4)); *s++ = hexDigit(static_cast(*bytes & 0xf)); ++bytes; @@ -400,7 +400,7 @@ MBCSAddToUnicode(MBCSData *mbcsData, if(MBCS_ENTRY_IS_TRANSITION(entry)) { if(i==length) { fprintf(stderr, "error: byte sequence too short, ends in non-final state %hu: 0x%s (U+%x)\n", - static_cast(state), printBytes(buffer, bytes, length), static_cast(c)); + static_cast(state), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(c)); return false; } state = static_cast(MBCS_ENTRY_TRANSITION_STATE(entry)); @@ -408,21 +408,21 @@ MBCSAddToUnicode(MBCSData *mbcsData, } else { if(i(length - i), state, printBytes(buffer, bytes, length), static_cast(c)); + static_cast(length - i), state, printBytes(buffer, sizeof(buffer), bytes, length), static_cast(c)); return false; } switch(MBCS_ENTRY_FINAL_ACTION(entry)) { case MBCS_STATE_ILLEGAL: fprintf(stderr, "error: byte sequence ends in illegal state at U+%04x<->0x%s\n", - static_cast(c), printBytes(buffer, bytes, length)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length)); return false; case MBCS_STATE_CHANGE_ONLY: fprintf(stderr, "error: byte sequence ends in state-change-only at U+%04x<->0x%s\n", - static_cast(c), printBytes(buffer, bytes, length)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length)); return false; case MBCS_STATE_UNASSIGNED: fprintf(stderr, "error: byte sequence ends in unassigned state at U+%04x<->0x%s\n", - static_cast(c), printBytes(buffer, bytes, length)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length)); return false; case MBCS_STATE_FALLBACK_DIRECT_16: case MBCS_STATE_VALID_DIRECT_16: @@ -437,11 +437,11 @@ MBCSAddToUnicode(MBCSData *mbcsData, } if(flag>=0) { fprintf(stderr, "error: duplicate codepage byte sequence at U+%04x<->0x%s see U+%04x\n", - static_cast(c), printBytes(buffer, bytes, length), static_cast(old)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(old)); return false; } else if(VERBOSE) { fprintf(stderr, "duplicate codepage byte sequence at U+%04x<->0x%s see U+%04x\n", - static_cast(c), printBytes(buffer, bytes, length), static_cast(old)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(old)); } /* * Continue after the above warning @@ -467,16 +467,16 @@ MBCSAddToUnicode(MBCSData *mbcsData, if((old=mbcsData->unicodeCodeUnits[offset])!=0xfffe || (old=removeFallback(mbcsData, offset))!=-1) { if(flag>=0) { fprintf(stderr, "error: duplicate codepage byte sequence at U+%04x<->0x%s see U+%04x\n", - static_cast(c), printBytes(buffer, bytes, length), static_cast(old)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(old)); return false; } else if(VERBOSE) { fprintf(stderr, "duplicate codepage byte sequence at U+%04x<->0x%s see U+%04x\n", - static_cast(c), printBytes(buffer, bytes, length), static_cast(old)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(old)); } } if(c>=0x10000) { fprintf(stderr, "error: code point does not fit into valid-16-bit state at U+%04x<->0x%s\n", - static_cast(c), printBytes(buffer, bytes, length)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length)); return false; } if(flag>0) { @@ -505,11 +505,11 @@ MBCSAddToUnicode(MBCSData *mbcsData, } if(flag>=0) { fprintf(stderr, "error: duplicate codepage byte sequence at U+%04x<->0x%s see U+%04x\n", - static_cast(c), printBytes(buffer, bytes, length), static_cast(real)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(real)); return false; } else if(VERBOSE) { fprintf(stderr, "duplicate codepage byte sequence at U+%04x<->0x%s see U+%04x\n", - static_cast(c), printBytes(buffer, bytes, length), static_cast(real)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(real)); } } if(flag>0) { @@ -543,7 +543,7 @@ MBCSAddToUnicode(MBCSData *mbcsData, default: /* reserved, must never occur */ fprintf(stderr, "internal error: byte sequence reached reserved action code, entry 0x%02x: 0x%s (U+%x)\n", - static_cast(entry), printBytes(buffer, bytes, length), static_cast(c)); + static_cast(entry), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(c)); return false; } @@ -699,7 +699,7 @@ MBCSAddFromUnicode(MBCSData *mbcsData, (!IGNORE_SISO_CHECK && (*bytes==0xe || *bytes==0xf)) ) { fprintf(stderr, "error: illegal mapping to SI or SO for SI/SO codepage: U+%04x<->0x%s\n", - static_cast(c), printBytes(buffer, bytes, length)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length)); return false; } @@ -738,7 +738,7 @@ MBCSAddFromUnicode(MBCSData *mbcsData, if(newTop>MBCS_MAX_STAGE_2_TOP) { fprintf(stderr, "error: too many stage 2 entries at U+%04x<->0x%s\n", - static_cast(c), printBytes(buffer, bytes, length)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length)); return false; } @@ -786,7 +786,7 @@ MBCSAddFromUnicode(MBCSData *mbcsData, if (newTop > MBCS_STAGE_3_MBCS_SIZE * static_cast(maxCharLength)) { fprintf(stderr, "error: too many code points at U+%04x<->0x%s\n", - static_cast(c), printBytes(buffer, bytes, length)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length)); return false; } /* each block has 16*maxCharLength bytes */ @@ -881,11 +881,11 @@ MBCSAddFromUnicode(MBCSData *mbcsData, if((mbcsData->stage2[idx+(nextOffset>>MBCS_STAGE_2_SHIFT)]&(1UL<<(16+(c&0xf))))!=0 || old!=0) { if(flag>=0) { fprintf(stderr, "error: duplicate Unicode code point at U+%04x<->0x%s see 0x%02x\n", - static_cast(c), printBytes(buffer, bytes, length), static_cast(old)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(old)); return false; } else if(VERBOSE) { fprintf(stderr, "duplicate Unicode code point at U+%04x<->0x%s see 0x%02x\n", - static_cast(c), printBytes(buffer, bytes, length), static_cast(old)); + static_cast(c), printBytes(buffer, sizeof(buffer), bytes, length), static_cast(old)); } /* continue after the above warning if the precision of the mapping is unspecified */