ICU-5821 Fix for i5/OS

X-SVN-Rev: 22325
This commit is contained in:
George Rhoten 2007-08-09 00:04:00 +00:00
parent d1a120a97c
commit 0781890fa8
3 changed files with 26 additions and 19 deletions

View file

@ -952,8 +952,9 @@ void RBBITableBuilder::setAdd(UVector *dest, UVector *source) {
dest->setElementAt(*sourceBuff++, di++);
destBuff++;
}
// This check may not work on machines with segmented memory, like i5/OS.
else if (*destBuff < *sourceBuff) {
// This check is required for machines with segmented memory, like i5/OS.
// Direct pointer comparison is not recommended.
else if (uprv_memcmp(destBuff, sourceBuff, sizeof(void *)) < 0) {
dest->setElementAt(*destBuff++, di++);
}
else { /* *sourceBuff < *destBuff */

View file

@ -88,6 +88,9 @@ static char gStrBuf[256];
#define kDEFAULT "Default"
#define kMAX_CUSTOM_HOUR 23
#define kMAX_CUSTOM_MIN 59
#define MINUS 0x002D
#define PLUS 0x002B
#define ZERO_DIGIT 0x0030
// Static data and constants
@ -1171,9 +1174,9 @@ TimeZone::createCustomTimeZone(const UnicodeString& id)
int32_t hour = 0;
int32_t min = 0;
if (id[pos.getIndex()] == 0x002D /*'-'*/)
if (id[pos.getIndex()] == MINUS /*'-'*/)
negative = TRUE;
else if (id[pos.getIndex()] != 0x002B /*'+'*/)
else if (id[pos.getIndex()] != PLUS /*'+'*/)
return 0;
pos.setIndex(pos.getIndex() + 1);
@ -1235,24 +1238,24 @@ TimeZone::createCustomTimeZone(const UnicodeString& id)
UnicodeString tzRFC(GMT_ID);
if (hour|min) {
if (negative) {
tzRFC += (UChar)'-';
tzRFC += (UChar)MINUS;
} else {
tzRFC += (UChar)'+';
tzRFC += (UChar)PLUS;
}
if (hour < 10) {
tzRFC += (UChar)'0';
tzRFC += (UChar)ZERO_DIGIT;
} else {
tzRFC += (UChar)('0' + hour/10);
tzRFC += (UChar)(ZERO_DIGIT + hour/10);
}
tzRFC += (UChar)('0' + hour%10);
tzRFC += (UChar)(ZERO_DIGIT + hour%10);
if (min < 10) {
tzRFC += (UChar)'0';
tzRFC += (UChar)ZERO_DIGIT;
} else {
tzRFC += (UChar)('0' + min/10);
tzRFC += (UChar)(ZERO_DIGIT + min/10);
}
tzRFC += (UChar)('0' + min%10);
tzRFC += (UChar)(ZERO_DIGIT + min%10);
}
int32_t offset = (hour * 60 + min) * 60 * 1000;

View file

@ -762,28 +762,31 @@ UnicodeString& TimeZoneTest::formatMinutes(int32_t min, UnicodeString& rv, UBool
{
rv.remove();
char sign = '+';
if (min < 0) { sign = '-'; min = -min; }
UChar sign = 0x002B;
if (min < 0) {
sign = 0x002D;
min = -min;
}
int h = min/60;
min = min%60;
rv += UChar(sign);
rv += (UChar)(sign);
if(h >= 10)
rv += UChar(0x0030 + (h/10));
rv += (UChar)(0x0030 + (h/10));
else
rv += "0";
rv += UChar(0x0030 + (h%10));
rv += (UChar)(0x0030 + (h%10));
if (insertSep)
rv += ":";
if(min >= 10)
rv += UChar(0x0030 + (min/10));
rv += (UChar)(0x0030 + (min/10));
else
rv += "0";
rv += UChar(0x0030 + (min%10));
rv += (UChar)(0x0030 + (min%10));
return rv;
}