ICU-98 define and use POSIX INT32_MAX etc., matching int32_t etc.
X-SVN-Rev: 1032
This commit is contained in:
parent
15fa18bc56
commit
50eb0cfdf0
@ -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];
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 */
|
||||
/*===========================================================================*/
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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];
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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<DATA_length; ++i) {
|
||||
char buf[64];
|
||||
|
@ -153,8 +153,8 @@ IntlTestNumberFormat::testFormat(char *par)
|
||||
tryIt(9.99999999999996);
|
||||
tryIt(9.999999999999996);
|
||||
|
||||
tryIt((int32_t)T_INT32_MIN);
|
||||
tryIt((int32_t)T_INT32_MAX);
|
||||
tryIt((int32_t)INT32_MIN);
|
||||
tryIt((int32_t)INT32_MAX);
|
||||
tryIt((double)LONG_MIN);
|
||||
tryIt((double)LONG_MAX);
|
||||
tryIt((double)LONG_MIN - 1.0);
|
||||
|
@ -663,7 +663,7 @@ TimeZoneRegressionTest::Test4154525()
|
||||
0, BAD,
|
||||
-1, BAD,
|
||||
60*60*1000, GOOD,
|
||||
T_INT32_MIN, BAD,
|
||||
INT32_MIN, BAD,
|
||||
// Integer.MAX_VALUE, ?, // no upper limit on DST savings at this time
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user