diff --git a/icu4c/source/common/digitlst.cpp b/icu4c/source/common/digitlst.cpp index 578428d1930..3e2f0fe9809 100644 --- a/icu4c/source/common/digitlst.cpp +++ b/icu4c/source/common/digitlst.cpp @@ -516,9 +516,8 @@ DigitList::initializeLONG_MIN_REP() { if (LONG_MIN_REP_LENGTH == 0) { - // THIS ASSUMES A 32-BIT LONG_MIN VALUE char buf[LONG_DIGITS]; - sprintf(buf, "%d", T_INT32_MIN); + sprintf(buf, "%d", INT32_MIN); LONG_MIN_REP_LENGTH = strlen(buf) - 1; // assert(LONG_MIN_REP_LENGTH == LONG_DIGITS); for (int32_t i=1; i<=LONG_MIN_REP_LENGTH; ++i) LONG_MIN_REP[i-1] = buf[i]; diff --git a/icu4c/source/common/scsu.c b/icu4c/source/common/scsu.c index f5c4fc24769..5b3dd7cceff 100644 --- a/icu4c/source/common/scsu.c +++ b/icu4c/source/common/scsu.c @@ -1385,7 +1385,7 @@ scsu_findStaticWindow(int32_t c) static int32_t scsu_getLRDefinedWindow(const UnicodeCompressor *comp) { - int32_t leastRU = T_INT32_MAX; + int32_t leastRU = INT32_MAX; int32_t whichWindow = INVALIDWINDOW; int32_t i; diff --git a/icu4c/source/common/unicode/umachine.h b/icu4c/source/common/unicode/umachine.h index eaeb5e04c76..8ff7f406081 100644 --- a/icu4c/source/common/unicode/umachine.h +++ b/icu4c/source/common/unicode/umachine.h @@ -68,6 +68,40 @@ #endif #define U_CAPI U_CFUNC U_EXPORT +/*===========================================================================*/ +/* limits for int32_t etc., like in POSIX inttypes.h */ +/*===========================================================================*/ + +#ifndef INT8_MIN +# define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +# define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +# define INT32_MIN (-2147483647-1) +#endif + +#ifndef INT8_MAX +# define INT8_MAX (127) +#endif +#ifndef INT16_MAX +# define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +# define INT32_MAX (2147483647) +#endif + +#ifndef UINT8_MAX +# define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +# define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +# define UINT32_MAX (4294967295U)... +#endif + /*===========================================================================*/ /* Boolean data type */ /*===========================================================================*/ diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h index 7ae55340789..00a9cd15898 100644 --- a/icu4c/source/common/unicode/unistr.h +++ b/icu4c/source/common/unicode/unistr.h @@ -1334,7 +1334,7 @@ public: * @stable */ inline UnicodeString& remove(UTextOffset start, - int32_t length = T_INT32_MAX); + int32_t length = INT32_MAX); /** * Remove the characters in the range @@ -1345,7 +1345,7 @@ public: * @stable */ inline UnicodeString& removeBetween(UTextOffset start, - UTextOffset limit = T_INT32_MAX); + UTextOffset limit = INT32_MAX); /* Length operations */ @@ -1603,7 +1603,7 @@ public: * @stable */ int32_t numDisplayCells(UTextOffset start = 0, - int32_t length = T_INT32_MAX, + int32_t length = INT32_MAX, bool_t asian = TRUE) const; diff --git a/icu4c/source/i18n/decimfmt.cpp b/icu4c/source/i18n/decimfmt.cpp index 417c6d23764..4455b509a5d 100644 --- a/icu4c/source/i18n/decimfmt.cpp +++ b/icu4c/source/i18n/decimfmt.cpp @@ -481,12 +481,12 @@ DecimalFormat::format(int32_t number, if (number < 0) // This can only happen if number == Long.MIN_VALUE { - int32_t cutoff = T_INT32_MIN / fMultiplier; + int32_t cutoff = INT32_MIN / fMultiplier; useDouble = (number < cutoff); } else { - int32_t cutoff = T_INT32_MAX / fMultiplier; + int32_t cutoff = INT32_MAX / fMultiplier; useDouble = (number > cutoff); } // use double to format the number instead so we don't get out diff --git a/icu4c/source/i18n/digitlst.cpp b/icu4c/source/i18n/digitlst.cpp index 578428d1930..3e2f0fe9809 100644 --- a/icu4c/source/i18n/digitlst.cpp +++ b/icu4c/source/i18n/digitlst.cpp @@ -516,9 +516,8 @@ DigitList::initializeLONG_MIN_REP() { if (LONG_MIN_REP_LENGTH == 0) { - // THIS ASSUMES A 32-BIT LONG_MIN VALUE char buf[LONG_DIGITS]; - sprintf(buf, "%d", T_INT32_MIN); + sprintf(buf, "%d", INT32_MIN); LONG_MIN_REP_LENGTH = strlen(buf) - 1; // assert(LONG_MIN_REP_LENGTH == LONG_DIGITS); for (int32_t i=1; i<=LONG_MIN_REP_LENGTH; ++i) LONG_MIN_REP[i-1] = buf[i]; diff --git a/icu4c/source/i18n/uniset.cpp b/icu4c/source/i18n/uniset.cpp index befe229fdd7..6cc14576de0 100644 --- a/icu4c/source/i18n/uniset.cpp +++ b/icu4c/source/i18n/uniset.cpp @@ -976,9 +976,9 @@ void UnicodeSet::doUnion(UnicodeString& c1, const UnicodeString& c2) { // one of the operands. We can append all of the remaining characters // in the other operand without doing any extra work. if (i < c1.length()) - result.append(c1, i, T_INT32_MAX); + result.append(c1, i, INT32_MAX); if (j < c2.length()) - result.append(c2, j, T_INT32_MAX); + result.append(c2, j, INT32_MAX); c1 = result; } diff --git a/icu4c/source/test/intltest/calregts.cpp b/icu4c/source/test/intltest/calregts.cpp index ddab9649817..642c0c95661 100644 --- a/icu4c/source/test/intltest/calregts.cpp +++ b/icu4c/source/test/intltest/calregts.cpp @@ -1248,11 +1248,11 @@ CalendarRegressionTest::test4031502() calendar->adoptTimeZone(TimeZone::createTimeZone("GMT")); - calendar->setTime(makeDate(T_INT32_MIN),status); + calendar->setTime(makeDate(INT32_MIN),status); int32_t year1 = calendar->get(Calendar::YEAR,status); int32_t era1 = calendar->get(Calendar::ERA,status); - calendar->setTime(makeDate(T_INT32_MAX),status); + calendar->setTime(makeDate(INT32_MAX),status); int32_t year2 = calendar->get(Calendar::YEAR,status); int32_t era2 = calendar->get(Calendar::ERA,status); diff --git a/icu4c/source/test/intltest/numrgts.cpp b/icu4c/source/test/intltest/numrgts.cpp index 301c5d3f126..5829d3a2e15 100644 --- a/icu4c/source/test/intltest/numrgts.cpp +++ b/icu4c/source/test/intltest/numrgts.cpp @@ -1793,15 +1793,15 @@ void NumberFormatRegressionTest::Test4162198(void) { // for some reason, DBL_MAX will not round trip. (bug in sprintf/atof) - double dbl = T_INT32_MAX * 1000.0; + double dbl = INT32_MAX * 1000.0; UErrorCode status = U_ZERO_ERROR; NumberFormat *f = NumberFormat::createInstance(status); if(U_FAILURE(status)) { errln("Couldn't create number format"); return; } - f->setMaximumFractionDigits(T_INT32_MAX); - f->setMaximumIntegerDigits(T_INT32_MAX); + f->setMaximumFractionDigits(INT32_MAX); + f->setMaximumIntegerDigits(INT32_MAX); UnicodeString s; f->format(dbl,s); logln(UnicodeString("The number ") + dbl + " formatted to " + s); @@ -2167,7 +2167,7 @@ void NumberFormatRegressionTest::Test4216742(void) { UErrorCode status = U_ZERO_ERROR; DecimalFormat *fmt = (DecimalFormat*) NumberFormat::createInstance(Locale::US, status); failure(status, "createInstance"); - int32_t DATA[] = { T_INT32_MIN, T_INT32_MAX, -100000000, 100000000 }; + int32_t DATA[] = { INT32_MIN, INT32_MAX, -100000000, 100000000 }; int DATA_length = sizeof(DATA) / sizeof(DATA[0]); for (int i=0; i