ICU-7780 fix various compiler warnings

X-SVN-Rev: 28301
This commit is contained in:
Andy Heninger 2010-07-12 18:03:29 +00:00
parent c4dc5051de
commit 74e297291f
38 changed files with 226 additions and 206 deletions

View file

@ -191,7 +191,6 @@ u_topNBytesOfDouble(double* d, int n)
return (char*)(d + 1) - n;
#endif
}
#endif
static char*
u_bottomNBytesOfDouble(double* d, int n)
@ -202,6 +201,22 @@ u_bottomNBytesOfDouble(double* d, int n)
return (char*)d;
#endif
}
#endif /* !IEEE_754 */
#if IEEE_754
static UBool
u_signBit(double d) {
uint8_t hiByte;
#if U_IS_BIG_ENDIAN
hiByte = *(uint8_t *)&d;
#else
hiByte = *(((uint8_t *)&d) + sizeof(double) - 1);
#endif
return (hiByte & 0x80) != 0;
}
#endif
#if defined (U_DEBUG_FAKETIME)
/* Override the clock to test things without having to move the system clock.
@ -468,20 +483,17 @@ U_CAPI double U_EXPORT2
uprv_fmax(double x, double y)
{
#if IEEE_754
int32_t lowBits;
/* first handle NaN*/
if(uprv_isNaN(x) || uprv_isNaN(y))
return uprv_getNaN();
/* check for -0 and 0*/
lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&x, sizeof(uint32_t));
if(x == 0.0 && y == 0.0 && (lowBits & SIGN))
if(x == 0.0 && y == 0.0 && u_signBit(x))
return y;
#endif
/* this should work for all flt point w/o NaN and Infpecial cases */
/* this should work for all flt point w/o NaN and Inf special cases */
return (x > y ? x : y);
}
@ -489,15 +501,12 @@ U_CAPI double U_EXPORT2
uprv_fmin(double x, double y)
{
#if IEEE_754
int32_t lowBits;
/* first handle NaN*/
if(uprv_isNaN(x) || uprv_isNaN(y))
return uprv_getNaN();
/* check for -0 and 0*/
lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&y, sizeof(uint32_t));
if(x == 0.0 && y == 0.0 && (lowBits & SIGN))
if(x == 0.0 && y == 0.0 && u_signBit(y))
return y;
#endif
@ -517,16 +526,13 @@ U_CAPI double U_EXPORT2
uprv_trunc(double d)
{
#if IEEE_754
int32_t lowBits;
/* handle error cases*/
if(uprv_isNaN(d))
return uprv_getNaN();
if(uprv_isInfinite(d))
return uprv_getInfinity();
lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&d, sizeof(uint32_t));
if( (d == 0.0 && (lowBits & SIGN)) || d < 0)
if(u_signBit(d)) /* Signbit() picks up -0.0; d<0 does not. */
return ceil(d);
else
return floor(d);

View file

@ -730,7 +730,7 @@ int32_t RuleBasedBreakIterator::following(int32_t offset) {
utext_setNativeIndex(fText, offset);
if (offset==0 ||
offset==1 && utext_getNativeIndex(fText)==0) {
(offset==1 && utext_getNativeIndex(fText)==0)) {
return next();
}
result = previous();
@ -1189,12 +1189,10 @@ int32_t RuleBasedBreakIterator::handlePrevious(const RBBIStateTable *statetable)
for (;;) {
if (c == U_SENTINEL) {
// Reached end of input string.
if (mode == RBBI_END ||
*(int32_t *)fData->fHeader->fFormatVersion == 1 ) {
if (mode == RBBI_END) {
// We have already run the loop one last time with the
// character set to the psueudo {eof} value. Now it is time
// to unconditionally bail out.
// (Or we have an old format binary rule file that does not support {eof}.)
if (lookaheadResult < result) {
// We ran off the end of the string with a pending look-ahead match.
// Treat this as if the look-ahead condition had been met, and return

View file

@ -1,6 +1,6 @@
/*
***************************************************************************
* Copyright (C) 1999-2008 International Business Machines Corporation *
* Copyright (C) 1999-2010 International Business Machines Corporation *
* and others. All rights reserved. *
***************************************************************************
*/
@ -74,13 +74,14 @@ void RBBIDataWrapper::init(const RBBIDataHeader *data, UErrorCode &status) {
return;
}
fHeader = data;
if (fHeader->fMagic != 0xb1a0 ||
!(fHeader->fFormatVersion[0] == 3 || // ICU 3.4
*(int32_t *)fHeader->fFormatVersion == 1)) // ICU 3.2 and earlier.
if (fHeader->fMagic != 0xb1a0 || fHeader->fFormatVersion[0] != 3)
{
status = U_INVALID_FORMAT_ERROR;
return;
}
// Note: in ICU version 3.2 and earlier, there was a formatVersion 1
// that is no longer supported. At that time fFormatVersion was
// an int32_t field, rather than an array of 4 bytes.
fDontFreeData = FALSE;
fUDataMem = NULL;
@ -320,9 +321,8 @@ ubrk_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outD
//
const uint8_t *inBytes =(const uint8_t *)inData+headerSize;
RBBIDataHeader *rbbiDH = (RBBIDataHeader *)inBytes;
UBool formatVersionOne = ds->readUInt32(*(int32_t *)rbbiDH->fFormatVersion) == 1;
if (ds->readUInt32(rbbiDH->fMagic) != 0xb1a0 ||
!(formatVersionOne || rbbiDH->fFormatVersion[0] == 3) ||
if (ds->readUInt32(rbbiDH->fMagic) != 0xb1a0 ||
rbbiDH->fFormatVersion[0] != 3 ||
ds->readUInt32(rbbiDH->fLength) < sizeof(RBBIDataHeader))
{
udata_printError(ds, "ubrk_swap(): RBBI Data header is invalid.\n");
@ -433,15 +433,11 @@ ubrk_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outD
outBytes+ds->readUInt32(rbbiDH->fStatusTable), status);
// And, last, the header.
// For the old version one format, the entire header consists of int32_t values.
// For the newer formats, the fDataFormat field is an array of four bytes.
// Swap the whole thing as int32_t, then, for the newer format, re-swap the one field.
// It is all int32_t values except for fFormataVersion, which is an array of four bytes.
// Swap the whole thing as int32_t, then re-swap the one field.
//
ds->swapArray32(ds, inBytes, sizeof(RBBIDataHeader), outBytes, status);
if (formatVersionOne == FALSE) {
ds->swapArray32(ds, outputDH->fFormatVersion, 4, outputDH->fFormatVersion, status);
}
ds->swapArray32(ds, outputDH->fFormatVersion, 4, outputDH->fFormatVersion, status);
return totalSize;
}

View file

@ -2,7 +2,7 @@
//
// file: rbbiscan.cpp
//
// Copyright (C) 2002-2008, International Business Machines Corporation and others.
// Copyright (C) 2002-2010, International Business Machines Corporation and others.
// All Rights Reserved.
//
// This file contains the Rule Based Break Iterator Rule Builder functions for
@ -802,7 +802,7 @@ UChar32 RBBIRuleScanner::nextCharLL() {
if (ch == chCR ||
ch == chNEL ||
ch == chLS ||
ch == chLF && fLastChar != chCR) {
(ch == chLF && fLastChar != chCR)) {
// Character is starting a new line. Bump up the line number, and
// reset the column to 0.
fLineNum++;

View file

@ -3938,7 +3938,9 @@ ucnv_MBCSFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
uint32_t stage2Entry;
uint32_t asciiRoundtrips;
uint32_t value;
uint8_t si_value[2], so_value[2], si_value_length, so_value_length;
uint8_t si_value[2] = {0, 0};
uint8_t so_value[2] = {0, 0};
uint8_t si_value_length, so_value_length;
int32_t length = 0, prevLength;
uint8_t unicodeMask;

View file

@ -1539,7 +1539,7 @@ UnicodeString::cloneArrayIfNeeded(int32_t newCapacity,
*/
if(forceClone ||
fFlags & kBufferIsReadonly ||
fFlags & kRefCounted && refCount() > 1 ||
(fFlags & kRefCounted && refCount() > 1) ||
newCapacity > getCapacity()
) {
// check growCapacity for default value and use of the stack buffer
@ -1569,7 +1569,7 @@ UnicodeString::cloneArrayIfNeeded(int32_t newCapacity,
// allocate a new array
if(allocate(growCapacity) ||
newCapacity < growCapacity && allocate(newCapacity)
(newCapacity < growCapacity && allocate(newCapacity))
) {
if(doCopyArray && oldArray != 0) {
// copy the contents

View file

@ -101,8 +101,8 @@ BasicTimeZone::hasEquivalentTransitions(/*const*/ BasicTimeZone& tz, UDate start
if (ignoreDstAmount) {
if (tr1.getTo()->getRawOffset() + tr1.getTo()->getDSTSavings()
!= tr2.getTo()->getRawOffset() + tr2.getTo()->getDSTSavings()
|| tr1.getTo()->getDSTSavings() != 0 && tr2.getTo()->getDSTSavings() == 0
|| tr1.getTo()->getDSTSavings() == 0 && tr2.getTo()->getDSTSavings() != 0) {
|| (tr1.getTo()->getDSTSavings() != 0 && tr2.getTo()->getDSTSavings() == 0)
|| (tr1.getTo()->getDSTSavings() == 0 && tr2.getTo()->getDSTSavings() != 0)) {
return FALSE;
}
} else {

View file

@ -3190,8 +3190,8 @@ int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue,
// not unique. For example, last several days in the previous month
// is week 5, and the rest of week is week 1.
int32_t result = startValue;
if (work->get(field, status) != startValue
&& field != UCAL_WEEK_OF_MONTH && delta > 0 || U_FAILURE(status)) {
if ((work->get(field, status) != startValue
&& field != UCAL_WEEK_OF_MONTH && delta > 0 ) || U_FAILURE(status)) {
#if defined (U_DEBUG_CAL)
fprintf(stderr, "getActualHelper(fld %d) - got %d (not %d) - %s\n", field, work->get(field,status), startValue, u_errorName(status));
#endif

View file

@ -385,8 +385,8 @@ UBool
DateIntervalInfo::stringNumeric(int32_t fieldWidth, int32_t anotherFieldWidth,
char patternLetter) {
if ( patternLetter == 'M' ) {
if ( fieldWidth <= 2 && anotherFieldWidth > 2 ||
fieldWidth > 2 && anotherFieldWidth <= 2 ) {
if ( (fieldWidth <= 2 && anotherFieldWidth > 2) ||
(fieldWidth > 2 && anotherFieldWidth <= 2 )) {
return true;
}
}

View file

@ -110,7 +110,6 @@ NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) {
buffer[count] = '\0'; // Make sure it is null terminated.
return NumberingSystem::createInstanceByName(buffer,status);
} else { // Find the default numbering system for this locale.
const char *ln = inLocale.getName();
UResourceBundle *resource = ures_open(NULL, inLocale.getName(), &status);
UResourceBundle *numberElementsRes = ures_getByKey(resource,gNumberElements,NULL,&status);
const UChar *defaultNSName =

View file

@ -51,7 +51,7 @@ static UBool arrayEqual(const void *a1, const void *a2, int32_t size) {
if (a1 == NULL && a2 == NULL) {
return TRUE;
}
if (a1 != NULL && a2 == NULL || a1 == NULL && a2 != NULL) {
if ((a1 != NULL && a2 == NULL) || (a1 == NULL && a2 != NULL)) {
return FALSE;
}
if (a1 == a2) {
@ -608,9 +608,9 @@ OlsonTimeZone::hasSameRules(const TimeZone &other) const {
// If the pointers are not equal, the zones may still
// be equal if their rules and transitions are equal
if (finalZone == NULL && z->finalZone != NULL
|| finalZone != NULL && z->finalZone == NULL
|| finalZone != NULL && z->finalZone != NULL && *finalZone != *z->finalZone) {
if ((finalZone == NULL && z->finalZone != NULL)
|| (finalZone != NULL && z->finalZone == NULL)
|| (finalZone != NULL && z->finalZone != NULL && *finalZone != *z->finalZone)) {
return FALSE;
}

View file

@ -2338,7 +2338,7 @@ void RegexCompile::compileInterval(int32_t InitOp, int32_t LoopOp)
fRXPat->fCompiledPat->addElement(op, *fStatus);
if ((fIntervalLow & 0xff000000) != 0 ||
fIntervalUpper > 0 && (fIntervalUpper & 0xff000000) != 0) {
(fIntervalUpper > 0 && (fIntervalUpper & 0xff000000) != 0)) {
error(U_REGEX_NUMBER_TOO_BIG);
}
@ -3656,7 +3656,7 @@ UChar32 RegexCompile::nextCharLL() {
if (ch == chCR ||
ch == chNEL ||
ch == chLS ||
ch == chLF && fLastChar != chCR) {
(ch == chLF && fLastChar != chCR)) {
// Character is starting a new line. Bump up the line number, and
// reset the column to 0.
fLineNum++;

View file

@ -681,8 +681,8 @@ UBool RegexMatcher::find() {
// c will be -1 (U_SENTINEL) at end of text, in which case we
// skip this next block (so we don't have a negative array index)
// and handle end of text in the following block.
if (c >= 0 && (c<256 && fPattern->fInitialChars8->contains(c) ||
c>=256 && fPattern->fInitialChars->contains(c))) {
if (c >= 0 && ((c<256 && fPattern->fInitialChars8->contains(c)) ||
(c>=256 && fPattern->fInitialChars->contains(c)))) {
MatchAt(startPos, FALSE, fDeferredStatus);
if (U_FAILURE(fDeferredStatus)) {
return FALSE;
@ -970,8 +970,8 @@ UBool RegexMatcher::findUsingChunk() {
for (;;) {
int32_t pos = startPos;
U16_NEXT(inputBuf, startPos, fActiveLimit, c); // like c = inputBuf[startPos++];
if (c<256 && fPattern->fInitialChars8->contains(c) ||
c>=256 && fPattern->fInitialChars->contains(c)) {
if ((c<256 && fPattern->fInitialChars8->contains(c)) ||
(c>=256 && fPattern->fInitialChars->contains(c))) {
MatchChunkAt(pos, FALSE, fDeferredStatus);
if (U_FAILURE(fDeferredStatus)) {
return FALSE;
@ -3175,7 +3175,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
case URX_BACKSLASH_G: // Test for position at end of previous match
if (!((fMatch && fp->fInputIdx==fMatchEnd) || fMatch==FALSE && fp->fInputIdx==fActiveStart)) {
if (!((fMatch && fp->fInputIdx==fMatchEnd) || (fMatch==FALSE && fp->fInputIdx==fActiveStart))) {
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
}
break;
@ -4292,10 +4292,10 @@ GC_Done:
break;
}
UChar32 c = UTEXT_NEXT32(fInputText);
if ((c & 0x7f) <= 0x29) { // Fast filter of non-new-line-s
if ((c == 0x0a) || // 0x0a is newline in both modes.
((opValue & 2) == 0) && // IF not UNIX_LINES mode
(c<=0x0d && c>=0x0a) || c==0x85 ||c==0x2028 || c==0x2029) {
if ((c & 0x7f) <= 0x29) { // Fast filter of non-new-line-s
if ((c == 0x0a) || // 0x0a is newline in both modes.
(((opValue & 2) == 0) && // IF not UNIX_LINES mode
(c<=0x0d && c>=0x0a)) || c==0x85 ||c==0x2028 || c==0x2029) {
// char is a line ending. Exit the scanning loop.
break;
}
@ -4876,7 +4876,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
case URX_BACKSLASH_G: // Test for position at end of previous match
if (!((fMatch && fp->fInputIdx==fMatchEnd) || fMatch==FALSE && fp->fInputIdx==fActiveStart)) {
if (!((fMatch && fp->fInputIdx==fMatchEnd) || (fMatch==FALSE && fp->fInputIdx==fActiveStart))) {
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
}
break;
@ -5961,10 +5961,10 @@ GC_Done:
}
UChar32 c;
U16_NEXT(inputBuf, ix, fActiveLimit, c); // c = inputBuf[ix++]
if ((c & 0x7f) <= 0x29) { // Fast filter of non-new-line-s
if ((c == 0x0a) || // 0x0a is newline in both modes.
((opValue & 2) == 0) && // IF not UNIX_LINES mode
(c<=0x0d && c>=0x0a) || c==0x85 ||c==0x2028 || c==0x2029) {
if ((c & 0x7f) <= 0x29) { // Fast filter of non-new-line-s
if ((c == 0x0a) || // 0x0a is newline in both modes.
(((opValue & 2) == 0) && // IF not UNIX_LINES mode
((c<=0x0d && c>=0x0a) || c==0x85 || c==0x2028 || c==0x2029))) {
// char is a line ending. Put the input pos back to the
// line ending char, and exit the scanning loop.
U16_BACK_1(inputBuf, 0, ix);

View file

@ -245,7 +245,7 @@ SelectFormat::format(const Formattable& obj,
UnicodeString&
SelectFormat::format(const UnicodeString& keyword,
UnicodeString& appendTo,
FieldPosition& pos,
FieldPosition& /*pos */,
UErrorCode& status) const {
if (U_FAILURE(status)) return appendTo;

View file

@ -531,13 +531,13 @@ SimpleTimeZone::getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32
// Now we need some adjustment
if (savingsDST > 0) {
if ((nonExistingTimeOpt & kStdDstMask) == kStandard
|| (nonExistingTimeOpt & kStdDstMask) != kDaylight && (nonExistingTimeOpt & kFormerLatterMask) != kLatter) {
|| ((nonExistingTimeOpt & kStdDstMask) != kDaylight && (nonExistingTimeOpt & kFormerLatterMask) != kLatter)) {
date -= getDSTSavings();
recalc = TRUE;
}
} else {
if ((duplicatedTimeOpt & kStdDstMask) == kDaylight
|| (duplicatedTimeOpt & kStdDstMask) != kStandard && (duplicatedTimeOpt & kFormerLatterMask) == kFormer) {
|| ((duplicatedTimeOpt & kStdDstMask) != kStandard && (duplicatedTimeOpt & kFormerLatterMask) == kFormer)) {
date -= getDSTSavings();
recalc = TRUE;
}

View file

@ -175,14 +175,12 @@ UBool
TimeUnitFormat::operator==(const Format& other) const {
if (typeid(*this) == typeid(other)) {
TimeUnitFormat* fmt = (TimeUnitFormat*)&other;
UBool ret = ( (fNumberFormat && fmt->fNumberFormat &&
*fNumberFormat == *fmt->fNumberFormat ||
fNumberFormat == fmt->fNumberFormat ) &&
fLocale == fmt->fLocale &&
(fPluralRules && fmt->fPluralRules &&
*fPluralRules == *fmt->fPluralRules ||
fPluralRules == fmt->fPluralRules) &&
fStyle == fmt->fStyle);
UBool ret = ( ((fNumberFormat && fmt->fNumberFormat && *fNumberFormat == *fmt->fNumberFormat)
|| fNumberFormat == fmt->fNumberFormat )
&& fLocale == fmt->fLocale
&& ((fPluralRules && fmt->fPluralRules && *fPluralRules == *fmt->fPluralRules)
|| fPluralRules == fmt->fPluralRules)
&& fStyle == fmt->fStyle);
if (ret) {
for (TimeUnit::UTimeUnitFields i = TimeUnit::UTIMEUNIT_YEAR;
i < TimeUnit::UTIMEUNIT_FIELD_COUNT && ret;
@ -724,7 +722,7 @@ TimeUnitFormat::setLocale(const Locale& locale, UErrorCode& status) {
void
TimeUnitFormat::setNumberFormat(const NumberFormat& format, UErrorCode& status){
if (U_FAILURE(status) || fNumberFormat && format == *fNumberFormat) {
if (U_FAILURE(status) || (fNumberFormat && format == *fNumberFormat)) {
return;
}
delete fNumberFormat;

View file

@ -72,10 +72,10 @@ TimeZoneTransition::operator==(const TimeZoneTransition& that) const {
if (fTime != that.fTime) {
return FALSE;
}
if (fFrom == NULL && that.fFrom == NULL
|| fFrom != NULL && that.fFrom != NULL && *fFrom == *(that.fFrom)) {
if (fTo == NULL && that.fTo == NULL
|| fTo != NULL && that.fTo != NULL && *fTo == *(that.fTo)) {
if ((fFrom == NULL && that.fFrom == NULL)
|| (fFrom != NULL && that.fFrom != NULL && *fFrom == *(that.fFrom))) {
if ((fTo == NULL && that.fTo == NULL)
|| (fTo != NULL && that.fTo != NULL && *fTo == *(that.fTo))) {
return TRUE;
}
}

View file

@ -4308,8 +4308,8 @@ int32_t ucol_getSortKeySize(const UCollator *coll, collIterate *s, int32_t curre
primary1 = (uint8_t)(order >> 8);
if(shifted && ((notIsContinuation && order <= variableTopValue && primary1 > 0)
|| (!notIsContinuation && wasShifted))
if((shifted && ((notIsContinuation && order <= variableTopValue && primary1 > 0)
|| (!notIsContinuation && wasShifted)))
|| (wasShifted && primary1 == 0)) { /* amendment to the UCA says that primary ignorables */
/* and other ignorables should be removed if following a shifted code point */
if(primary1 == 0) { /* if we were shifted and we got an ignorable code point */
@ -4750,8 +4750,8 @@ ucol_calcSortKey(const UCollator *coll,
primary1 = scriptOrder[primary1];
}*/
if(shifted && ((notIsContinuation && order <= variableTopValue && primary1 > 0)
|| (!notIsContinuation && wasShifted))
if((shifted && ((notIsContinuation && order <= variableTopValue && primary1 > 0)
|| (!notIsContinuation && wasShifted)))
|| (wasShifted && primary1 == 0)) /* amendment to the UCA says that primary ignorables */
{
/* and other ignorables should be removed if following a shifted code point */
@ -5596,8 +5596,8 @@ static inline
UBool isShiftedCE(uint32_t CE, uint32_t LVT, UBool *wasShifted) {
UBool notIsContinuation = !isContinuation(CE);
uint8_t primary1 = (uint8_t)((CE >> 24) & 0xFF);
if(LVT && ((notIsContinuation && (CE & 0xFFFF0000)<= LVT && primary1 > 0)
|| (!notIsContinuation && *wasShifted))
if((LVT && ((notIsContinuation && (CE & 0xFFFF0000)<= LVT && primary1 > 0)
|| (!notIsContinuation && *wasShifted)))
|| (*wasShifted && primary1 == 0)) /* amendment to the UCA says that primary ignorables */
{
// The stuff below should probably be in the sortkey code... maybe not...
@ -7743,7 +7743,7 @@ ucol_strcollRegular(collIterate *sColl, collIterate *tColl, UErrorCode *status)
sCE = sCEs.buf;
tCE = tCEs.buf;
for(;;) {
while(secS == 0 && secS != UCOL_NO_MORE_CES || (isContinuation(secS) && !sInShifted)) {
while((secS == 0 && secS != UCOL_NO_MORE_CES) || (isContinuation(secS) && !sInShifted)) {
secS = *(sCE++);
if(isContinuation(secS)) {
if(!sInShifted) {
@ -7759,7 +7759,7 @@ ucol_strcollRegular(collIterate *sColl, collIterate *tColl, UErrorCode *status)
secS &= UCOL_PRIMARYMASK;
while(secT == 0 && secT != UCOL_NO_MORE_CES || (isContinuation(secT) && !tInShifted)) {
while((secT == 0 && secT != UCOL_NO_MORE_CES) || (isContinuation(secT) && !tInShifted)) {
secT = *(tCE++);
if(isContinuation(secT)) {
if(!tInShifted) {
@ -8384,8 +8384,8 @@ ucol_strcoll( const UCollator *coll,
// These values should already be set by the code above.
//pSrc = source + equalLength; /* point to the first differing chars */
//pTarg = target + equalLength;
if (pSrc != source+sourceLength && ucol_unsafeCP(*pSrc, coll) ||
pTarg != target+targetLength && ucol_unsafeCP(*pTarg, coll))
if ((pSrc != source+sourceLength && ucol_unsafeCP(*pSrc, coll)) ||
(pTarg != target+targetLength && ucol_unsafeCP(*pTarg, coll)))
{
// We are stopped in the middle of a contraction.
// Scan backwards through the == part of the string looking for the start of the contraction.

View file

@ -347,10 +347,10 @@ static void ucol_inv_getGapPositions(UColTokenParser *src, UColTokListHeader *lh
lh->gapsLo[0] = (t1 & UCOL_PRIMARYMASK) | (t2 & UCOL_PRIMARYMASK) >> 16;
lh->gapsLo[1] = (t1 & UCOL_SECONDARYMASK) << 16 | (t2 & UCOL_SECONDARYMASK) << 8;
lh->gapsLo[2] = (UCOL_TERTIARYORDER(t1)) << 24 | (UCOL_TERTIARYORDER(t2)) << 16;
uint32_t primaryCE = t1 & UCOL_PRIMARYMASK | (t2 & UCOL_PRIMARYMASK) >> 16;
uint32_t primaryCE = (t1 & UCOL_PRIMARYMASK) | ((t2 & UCOL_PRIMARYMASK) >> 16);
primaryCE = uprv_uca_getImplicitFromRaw(uprv_uca_getRawFromImplicit(primaryCE)+1);
t1 = primaryCE & UCOL_PRIMARYMASK | 0x0505;
t1 = (primaryCE & UCOL_PRIMARYMASK) | 0x0505;
t2 = (primaryCE << 16) & UCOL_PRIMARYMASK; // | UCOL_CONTINUATION_MARKER;
lh->gapsHi[0] = (t1 & UCOL_PRIMARYMASK) | (t2 & UCOL_PRIMARYMASK) >> 16;

View file

@ -614,8 +614,8 @@ ucol_setReqValidLocales(UCollator *coll, char *requestedLocaleToAdopt, char *val
#define getCETag(CE) (((CE)&UCOL_TAG_MASK)>>UCOL_TAG_SHIFT)
#define isContraction(CE) (isSpecial((CE)) && (getCETag((CE)) == CONTRACTION_TAG))
#define isPrefix(CE) (isSpecial((CE)) && (getCETag((CE)) == SPEC_PROC_TAG))
#define constructContractCE(tag, CE) (UCOL_SPECIAL_FLAG | ((tag)<<UCOL_TAG_SHIFT) | ((CE))&0xFFFFFF)
#define constructSpecProcCE(CE) (UCOL_SPECIAL_FLAG | (SPEC_PROC_TAG<<UCOL_TAG_SHIFT) | ((CE))&0xFFFFFF)
#define constructContractCE(tag, CE) (UCOL_SPECIAL_FLAG | ((tag)<<UCOL_TAG_SHIFT) | ((CE)&0xFFFFFF))
#define constructSpecProcCE(CE) (UCOL_SPECIAL_FLAG | (SPEC_PROC_TAG<<UCOL_TAG_SHIFT) | ((CE)&0xFFFFFF))
#define getContractOffset(CE) ((CE)&0xFFFFFF)
#define getExpansionOffset(CE) (((CE)&0x00FFFFF0)>>4)
#define getExpansionCount(CE) ((CE)&0xF)

View file

@ -629,7 +629,7 @@ uint8_t ucol_uprv_tok_readAndSetOption(UColTokenParser *src, UErrorCode *status)
if(optionArg) {
for(j = 0; j<rulesOptions[i].subSize; j++) {
if(u_strncmpNoCase(optionArg, rulesOptions[i].subopts[j].subName, rulesOptions[i].subopts[j].subLen) == 0) {
result = UCOL_TOK_SUCCESS | rulesOptions[i].subopts[j].attrVal + 1;
result = UCOL_TOK_SUCCESS | (rulesOptions[i].subopts[j].attrVal + 1);
}
}
}
@ -1438,12 +1438,12 @@ inline UColToken *getVirginBefore(UColTokenParser *src, UColToken *sourceToken,
UColToken key;
if((baseCE & 0xFF000000) >= (consts->UCA_PRIMARY_IMPLICIT_MIN<<24) && (baseCE & 0xFF000000) <= (consts->UCA_PRIMARY_IMPLICIT_MAX<<24) ) { /* implicits - */
uint32_t primary = baseCE & UCOL_PRIMARYMASK | (baseContCE & UCOL_PRIMARYMASK) >> 16;
uint32_t primary = (baseCE & UCOL_PRIMARYMASK) | ((baseContCE & UCOL_PRIMARYMASK) >> 16);
uint32_t raw = uprv_uca_getRawFromImplicit(primary);
ch = uprv_uca_getCodePointFromRaw(raw-1);
uint32_t primaryCE = uprv_uca_getImplicitFromRaw(raw-1);
CE = primaryCE & UCOL_PRIMARYMASK | 0x0505;
SecondCE = (primaryCE << 16) & UCOL_PRIMARYMASK | UCOL_CONTINUATION_MARKER;
CE = (primaryCE & UCOL_PRIMARYMASK) | 0x0505;
SecondCE = ((primaryCE << 16) & UCOL_PRIMARYMASK) | UCOL_CONTINUATION_MARKER;
src->parsedToken.charsOffset = (uint32_t)(src->extraCurrent - src->source);
*src->extraCurrent++ = 0xFFFE;
@ -1865,12 +1865,13 @@ uint32_t ucol_tok_assembleTokenList(UColTokenParser *src, UParseError *parseErro
uint32_t CE = UCOL_NOT_FOUND, SecondCE = UCOL_NOT_FOUND;
UCAConstants *consts = (UCAConstants *)((uint8_t *)src->UCA->image + src->UCA->image->UCAConsts);
if((baseCE & 0xFF000000) >= (consts->UCA_PRIMARY_IMPLICIT_MIN<<24) && (baseCE & 0xFF000000) <= (consts->UCA_PRIMARY_IMPLICIT_MAX<<24) ) { /* implicits - */
uint32_t primary = baseCE & UCOL_PRIMARYMASK | (baseContCE & UCOL_PRIMARYMASK) >> 16;
if((baseCE & 0xFF000000) >= (consts->UCA_PRIMARY_IMPLICIT_MIN<<24) &&
(baseCE & 0xFF000000) <= (consts->UCA_PRIMARY_IMPLICIT_MAX<<24) ) { /* implicits - */
uint32_t primary = (baseCE & UCOL_PRIMARYMASK) | ((baseContCE & UCOL_PRIMARYMASK) >> 16);
uint32_t raw = uprv_uca_getRawFromImplicit(primary);
uint32_t primaryCE = uprv_uca_getImplicitFromRaw(raw-1);
CE = primaryCE & UCOL_PRIMARYMASK | 0x0505;
SecondCE = (primaryCE << 16) & UCOL_PRIMARYMASK | UCOL_CONTINUATION_MARKER;
CE = (primaryCE & UCOL_PRIMARYMASK) | 0x0505;
SecondCE = ((primaryCE << 16) & UCOL_PRIMARYMASK) | UCOL_CONTINUATION_MARKER;
} else {
/*int32_t invPos = ucol_inv_getPrevCE(baseCE, baseContCE, &CE, &SecondCE, strength);*/
ucol_inv_getPrevCE(src, baseCE, baseContCE, &CE, &SecondCE, strength);

View file

@ -271,7 +271,7 @@ inline uint64_t processCE(UCollationElements *elems, uint32_t ce)
// **** the *second* CE is marked as a continuation, so ****
// **** we always have to peek ahead to know how long ****
// **** the primary is... ****
if (elems->pce->toShift && (elems->pce->variableTop > ce && primary != 0)
if ((elems->pce->toShift && elems->pce->variableTop > ce && primary != 0)
|| (elems->pce->isShifted && primary == 0)) {
if (primary == 0) {

View file

@ -1048,7 +1048,7 @@ uregex_replaceAll(URegularExpression *regexp2,
return 0;
}
if (replacementText == NULL || replacementLength < -1 ||
destBuf == NULL && destCapacity > 0 ||
(destBuf == NULL && destCapacity > 0) ||
destCapacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
@ -1122,7 +1122,7 @@ uregex_replaceFirst(URegularExpression *regexp2,
return 0;
}
if (replacementText == NULL || replacementLength < -1 ||
destBuf == NULL && destCapacity > 0 ||
(destBuf == NULL && destCapacity > 0) ||
destCapacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
@ -1247,7 +1247,7 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
}
if (replacementText == NULL || replacementLength < -1 ||
destCapacity == NULL || destBuf == NULL ||
*destBuf == NULL && *destCapacity > 0 ||
(*destBuf == NULL && *destCapacity > 0) ||
*destCapacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
@ -1485,7 +1485,7 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp,
}
if (destCapacity == NULL || destBuf == NULL ||
*destBuf == NULL && *destCapacity > 0 ||
(*destBuf == NULL && *destCapacity > 0) ||
*destCapacity < 0)
{
*status = U_ILLEGAL_ARGUMENT_ERROR;
@ -1783,7 +1783,7 @@ uregex_split(URegularExpression *regexp2,
if (validateRE(regexp, status) == FALSE) {
return 0;
}
if (destBuf == NULL && destCapacity > 0 ||
if ((destBuf == NULL && destCapacity > 0) ||
destCapacity < 0 ||
destFields == NULL ||
destFieldsCapacity < 1 ) {

View file

@ -2698,13 +2698,13 @@ static void TestConvertExFromUTF8_C5F0() {
UErrorCode errorCode;
int32_t i;
static const unsigned char bad_utf8[2]={ 0xC5, 0xF0 };
static const char bad_utf8[2]={ (char)0xC5, (char)0xF0 };
/* Expect "&#65533;&#65533;" (2x U+FFFD as decimal NCRs) */
static const unsigned char twoNCRs[16]={
static const char twoNCRs[16]={
0x26, 0x23, 0x36, 0x35, 0x35, 0x33, 0x33, 0x3B,
0x26, 0x23, 0x36, 0x35, 0x35, 0x33, 0x33, 0x3B
};
static const unsigned char twoFFFD[6]={
static const char twoFFFD[6]={
(char)0xef, (char)0xbf, (char)0xbd,
(char)0xef, (char)0xbf, (char)0xbd
};

View file

@ -150,7 +150,7 @@ void addNormTest(TestNode** root)
addTest(root, &TestNextPrevious, "tsnorm/cnormtst/TestNextPrevious");
addTest(root, &TestFCNFKCClosure, "tsnorm/cnormtst/TestFCNFKCClosure");
addTest(root, &TestComposition, "tsnorm/cnormtst/TestComposition");
addTest(root, &TestComposition, "tsnorm/cnormtst/TestGetDecomposition");
addTest(root, &TestGetDecomposition, "tsnorm/cnormtst/TestGetDecomposition");
}
static const char* const modeStrings[]={

View file

@ -2651,13 +2651,10 @@ TestICCRunout() {
const char *cnvName = "ibm-1363";
UErrorCode status = U_ZERO_ERROR;
const uint8_t sourceData[] = { 0xa2, 0xae, 0xa2 };
UChar expectUData[] = { 0x00a1, 0x001a };
const uint8_t *source = sourceData;
const uint8_t *sourceLim = sourceData+sizeof(sourceData);
UChar targetBuf[256];
UChar *target = targetBuf;
UChar *targetLim = target+256;
const char sourceData[] = { (char)0xa2, (char)0xae, (char)0xa2 };
/* UChar expectUData[] = { 0x00a1, 0x001a }; */
const char *source = sourceData;
const char *sourceLim = sourceData+sizeof(sourceData);
UChar c1, c2, c3;
UConverter *cnv=ucnv_open(cnvName, &status);
if(U_FAILURE(status)) {
@ -2666,6 +2663,10 @@ TestICCRunout() {
}
#if 0
{
UChar targetBuf[256];
UChar *target = targetBuf;
UChar *targetLim = target+256;
ucnv_toUnicode(cnv, &target, targetLim, &source, sourceLim, NULL, TRUE, &status);
log_info("After convert: target@%d, source@%d, status%s\n",
@ -2676,6 +2677,7 @@ TestICCRunout() {
} else {
}
}
#endif
c1=ucnv_getNextUChar(cnv, &source, sourceLim, &status);
@ -5120,11 +5122,14 @@ TestLMBCS() {
errorCode=U_ZERO_ERROR;
/* negative source request should always return U_ILLEGAL_ARGUMENT_ERROR */
ucnv_fromUnicode(cnv, &pLOut,pLOut+1,&pUIn,pUIn-1,off,FALSE, &errorCode);
pUIn++;
ucnv_fromUnicode(cnv, &pLOut, pLOut+1, &pUIn, pUIn-1, off, FALSE, &errorCode);
if (errorCode != U_ILLEGAL_ARGUMENT_ERROR)
{
log_err("Unexpected Error on negative source request to ucnv_fromUnicode: %s\n", u_errorName(errorCode));
}
pUIn--;
errorCode=U_ZERO_ERROR;
ucnv_toUnicode(cnv, &pUOut,pUOut+1,(const char **)&pLIn,(const char *)(pLIn-1),off,FALSE, &errorCode);
if (errorCode != U_ILLEGAL_ARGUMENT_ERROR)

View file

@ -2487,7 +2487,7 @@ void NumberFormatRegressionTest::Test4216742(void) {
} else {
double d = num.getType() == Formattable::kDouble ?
num.getDouble() : (double) num.getLong();
if (d > 0 != DATA[i] > 0) {
if ((d > 0) != (DATA[i] > 0)) {
errln(UnicodeString("\"") + str + "\" parse(x " +
fmt->getMultiplier() +
") => " + toString(num));

View file

@ -1,5 +1,5 @@
/********************************************************************
* Copyright (c) 1999-2009, International Business Machines
* Copyright (c) 1999-2010, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************
* Date Name Description
@ -723,7 +723,7 @@ void RBBIAPITest::TestRuleStatus() {
}
if (UBRK_LINE_SOFT >= UBRK_LINE_SOFT_LIMIT ||
UBRK_LINE_HARD >= UBRK_LINE_HARD_LIMIT ||
UBRK_LINE_HARD > UBRK_LINE_SOFT && UBRK_LINE_HARD < UBRK_LINE_SOFT_LIMIT ) {
(UBRK_LINE_HARD > UBRK_LINE_SOFT && UBRK_LINE_HARD < UBRK_LINE_SOFT_LIMIT)) {
errln("UBRK_LINE_* constants from header are inconsistent.");
}
}

View file

@ -3601,11 +3601,11 @@ int32_t RBBILineMonkey::next(int32_t startPos) {
// NU x CL, NU x CP and NU x IS are not matched here so that they will
// fall into LB 17 and the more general number regular expression.
//
if (!fNU->contains(prevChar) && fCL->contains(thisChar) ||
!fNU->contains(prevChar) && fCP->contains(thisChar) ||
fEX->contains(thisChar) ||
!fNU->contains(prevChar) && fIS->contains(thisChar) ||
!fNU->contains(prevChar) && fSY->contains(thisChar)) {
if ((!fNU->contains(prevChar) && fCL->contains(thisChar)) ||
(!fNU->contains(prevChar) && fCP->contains(thisChar)) ||
fEX->contains(thisChar) ||
(!fNU->contains(prevChar) && fIS->contains(thisChar)) ||
(!fNU->contains(prevChar) && fSY->contains(thisChar))) {
continue;
}
@ -3708,10 +3708,10 @@ int32_t RBBILineMonkey::next(int32_t startPos) {
}
// LB 22
if (fAL->contains(prevChar) && fIN->contains(thisChar) ||
fID->contains(prevChar) && fIN->contains(thisChar) ||
fIN->contains(prevChar) && fIN->contains(thisChar) ||
fNU->contains(prevChar) && fIN->contains(thisChar) ) {
if ((fAL->contains(prevChar) && fIN->contains(thisChar)) ||
(fID->contains(prevChar) && fIN->contains(thisChar)) ||
(fIN->contains(prevChar) && fIN->contains(thisChar)) ||
(fNU->contains(prevChar) && fIN->contains(thisChar)) ) {
continue;
}
@ -3719,9 +3719,9 @@ int32_t RBBILineMonkey::next(int32_t startPos) {
// LB 23 ID x PO
// AL x NU
// NU x AL
if (fID->contains(prevChar) && fPO->contains(thisChar) ||
fAL->contains(prevChar) && fNU->contains(thisChar) ||
fNU->contains(prevChar) && fAL->contains(thisChar) ) {
if ((fID->contains(prevChar) && fPO->contains(thisChar)) ||
(fAL->contains(prevChar) && fNU->contains(thisChar)) ||
(fNU->contains(prevChar) && fAL->contains(thisChar)) ) {
continue;
}
@ -3729,9 +3729,9 @@ int32_t RBBILineMonkey::next(int32_t startPos) {
// PR x ID
// PR x AL
// PO x AL
if (fPR->contains(prevChar) && fID->contains(thisChar) ||
fPR->contains(prevChar) && fAL->contains(thisChar) ||
fPO->contains(prevChar) && fAL->contains(thisChar) ) {
if ((fPR->contains(prevChar) && fID->contains(thisChar)) ||
(fPR->contains(prevChar) && fAL->contains(thisChar)) ||
(fPO->contains(prevChar) && fAL->contains(thisChar)) ) {
continue;
}
@ -4560,7 +4560,7 @@ void RBBITest::RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name
if (breakPos <= i ||
breakPos < lastBreakPos ||
breakPos > testText.length() ||
breakPos > lastBreakPos && lastBreakPos > i ) {
(breakPos > lastBreakPos && lastBreakPos > i)) {
errln("%s break monkey test: "
"Out of range value returned by BreakIterator::following().\n"
"Random seed=%d index=%d; following returned %d; lastbreak=%d",

View file

@ -82,8 +82,8 @@ void StringTest::TestSizeofTypes(void) {
void StringTest::TestCharsetFamily(void) {
unsigned char c='A';
if( U_CHARSET_FAMILY==U_ASCII_FAMILY && c!=0x41 ||
U_CHARSET_FAMILY==U_EBCDIC_FAMILY && c!=0xc1
if( (U_CHARSET_FAMILY==U_ASCII_FAMILY && c!=0x41) ||
(U_CHARSET_FAMILY==U_EBCDIC_FAMILY && c!=0xc1)
) {
errln("TestCharsetFamily: U_CHARSET_FAMILY needs to be fixed in platform.h");
}

View file

@ -29,8 +29,7 @@
#include "unicode/gregocal.h"
#include <stdio.h>
#define E_WITH_ACUTE ((UChar)0x00E9)
#define A_WITH_GRAVE ((UChar)0x00E0)
#define E_WITH_ACUTE ((char)0x00E9)
static const char E_ACCENTED[]={E_WITH_ACUTE,0};
void

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2006, International Business Machines Corporation and
* Copyright (c) 1997-2010, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -255,19 +255,19 @@ PUtilTest::testPositiveInfinity(void)
errln("FAIL: isNegativeInfinity(+Infinity) returned TRUE, should be FALSE.");
}
if(pinf > DBL_MAX != TRUE) {
if((pinf > DBL_MAX) != TRUE) {
errln("FAIL: +Infinity > DBL_MAX returned FALSE, should be TRUE.");
}
if(pinf > DBL_MIN != TRUE) {
if((pinf > DBL_MIN) != TRUE) {
errln("FAIL: +Infinity > DBL_MIN returned FALSE, should be TRUE.");
}
if(pinf > ninf != TRUE) {
if((pinf > ninf) != TRUE) {
errln("FAIL: +Infinity > -Infinity returned FALSE, should be TRUE.");
}
if(pinf > ten != TRUE) {
if((pinf > ten) != TRUE) {
errln("FAIL: +Infinity > 10.0 returned FALSE, should be TRUE.");
}
}
@ -293,19 +293,19 @@ PUtilTest::testNegativeInfinity(void)
errln("FAIL: isPositiveInfinity(-Infinity) returned TRUE, should be FALSE.");
}
if(ninf < DBL_MAX != TRUE) {
if((ninf < DBL_MAX) != TRUE) {
errln("FAIL: -Infinity < DBL_MAX returned FALSE, should be TRUE.");
}
if(ninf < DBL_MIN != TRUE) {
if((ninf < DBL_MIN) != TRUE) {
errln("FAIL: -Infinity < DBL_MIN returned FALSE, should be TRUE.");
}
if(ninf < pinf != TRUE) {
if((ninf < pinf) != TRUE) {
errln("FAIL: -Infinity < +Infinity returned FALSE, should be TRUE.");
}
if(ninf < ten != TRUE) {
if((ninf < ten) != TRUE) {
errln("FAIL: -Infinity < 10.0 returned FALSE, should be TRUE.");
}
}
@ -325,23 +325,23 @@ PUtilTest::testZero(void)
nzero *= -1;
if(pzero == nzero != TRUE) {
if((pzero == nzero) != TRUE) {
errln("FAIL: 0.0 == -0.0 returned FALSE, should be TRUE.");
}
if(pzero > nzero != FALSE) {
if((pzero > nzero) != FALSE) {
errln("FAIL: 0.0 > -0.0 returned TRUE, should be FALSE.");
}
if(pzero >= nzero != TRUE) {
if((pzero >= nzero) != TRUE) {
errln("FAIL: 0.0 >= -0.0 returned FALSE, should be TRUE.");
}
if(pzero < nzero != FALSE) {
if((pzero < nzero) != FALSE) {
errln("FAIL: 0.0 < -0.0 returned TRUE, should be FALSE.");
}
if(pzero <= nzero != TRUE) {
if((pzero <= nzero) != TRUE) {
errln("FAIL: 0.0 <= -0.0 returned FALSE, should be TRUE.");
}
#ifndef OS400 /* OS/400 will generate divide by zero exception MCH1214 */
@ -400,19 +400,19 @@ PUtilTest::NaNGT(void)
double nan = uprv_getNaN();
double ten = 10.0;
if(nan > nan != FALSE) {
if((nan > nan) != FALSE) {
logln("WARNING: NaN > NaN returned TRUE, should be FALSE");
}
if(nan > pinf != FALSE) {
if((nan > pinf) != FALSE) {
logln("WARNING: NaN > +Infinity returned TRUE, should be FALSE");
}
if(nan > ninf != FALSE) {
if((nan > ninf) != FALSE) {
logln("WARNING: NaN > -Infinity returned TRUE, should be FALSE");
}
if(nan > ten != FALSE) {
if((nan > ten) != FALSE) {
logln("WARNING: NaN > 10.0 returned TRUE, should be FALSE");
}
}
@ -427,19 +427,19 @@ PUtilTest::NaNLT(void)
double nan = uprv_getNaN();
double ten = 10.0;
if(nan < nan != FALSE) {
if((nan < nan) != FALSE) {
logln("WARNING: NaN < NaN returned TRUE, should be FALSE");
}
if(nan < pinf != FALSE) {
if((nan < pinf) != FALSE) {
logln("WARNING: NaN < +Infinity returned TRUE, should be FALSE");
}
if(nan < ninf != FALSE) {
if((nan < ninf) != FALSE) {
logln("WARNING: NaN < -Infinity returned TRUE, should be FALSE");
}
if(nan < ten != FALSE) {
if((nan < ten) != FALSE) {
logln("WARNING: NaN < 10.0 returned TRUE, should be FALSE");
}
}
@ -454,19 +454,19 @@ PUtilTest::NaNGTE(void)
double nan = uprv_getNaN();
double ten = 10.0;
if(nan >= nan != FALSE) {
if((nan >= nan) != FALSE) {
logln("WARNING: NaN >= NaN returned TRUE, should be FALSE");
}
if(nan >= pinf != FALSE) {
if((nan >= pinf) != FALSE) {
logln("WARNING: NaN >= +Infinity returned TRUE, should be FALSE");
}
if(nan >= ninf != FALSE) {
if((nan >= ninf) != FALSE) {
logln("WARNING: NaN >= -Infinity returned TRUE, should be FALSE");
}
if(nan >= ten != FALSE) {
if((nan >= ten) != FALSE) {
logln("WARNING: NaN >= 10.0 returned TRUE, should be FALSE");
}
}
@ -481,19 +481,19 @@ PUtilTest::NaNLTE(void)
double nan = uprv_getNaN();
double ten = 10.0;
if(nan <= nan != FALSE) {
if((nan <= nan) != FALSE) {
logln("WARNING: NaN <= NaN returned TRUE, should be FALSE");
}
if(nan <= pinf != FALSE) {
if((nan <= pinf) != FALSE) {
logln("WARNING: NaN <= +Infinity returned TRUE, should be FALSE");
}
if(nan <= ninf != FALSE) {
if((nan <= ninf) != FALSE) {
logln("WARNING: NaN <= -Infinity returned TRUE, should be FALSE");
}
if(nan <= ten != FALSE) {
if((nan <= ten) != FALSE) {
logln("WARNING: NaN <= 10.0 returned TRUE, should be FALSE");
}
}
@ -508,19 +508,19 @@ PUtilTest::NaNE(void)
double nan = uprv_getNaN();
double ten = 10.0;
if(nan == nan != FALSE) {
if((nan == nan) != FALSE) {
logln("WARNING: NaN == NaN returned TRUE, should be FALSE");
}
if(nan == pinf != FALSE) {
if((nan == pinf) != FALSE) {
logln("WARNING: NaN == +Infinity returned TRUE, should be FALSE");
}
if(nan == ninf != FALSE) {
if((nan == ninf) != FALSE) {
logln("WARNING: NaN == -Infinity returned TRUE, should be FALSE");
}
if(nan == ten != FALSE) {
if((nan == ten) != FALSE) {
logln("WARNING: NaN == 10.0 returned TRUE, should be FALSE");
}
}
@ -535,19 +535,19 @@ PUtilTest::NaNNE(void)
double nan = uprv_getNaN();
double ten = 10.0;
if(nan != nan != TRUE) {
if((nan != nan) != TRUE) {
logln("WARNING: NaN != NaN returned FALSE, should be TRUE");
}
if(nan != pinf != TRUE) {
if((nan != pinf) != TRUE) {
logln("WARNING: NaN != +Infinity returned FALSE, should be TRUE");
}
if(nan != ninf != TRUE) {
if((nan != ninf) != TRUE) {
logln("WARNING: NaN != -Infinity returned FALSE, should be TRUE");
}
if(nan != ten != TRUE) {
if((nan != ten) != TRUE) {
logln("WARNING: NaN != 10.0 returned FALSE, should be TRUE");
}
}

View file

@ -1130,7 +1130,7 @@ TimeZoneRuleTest::TestGetSimpleRules(void) {
if (initial == NULL) {
errln("FAIL: initial rule must not be NULL");
break;
} else if (!(std == NULL && dst == NULL || std != NULL && dst != NULL)) {
} else if (!((std == NULL && dst == NULL) || (std != NULL && dst != NULL))) {
errln("FAIL: invalid std/dst pair.");
break;
}

View file

@ -481,12 +481,16 @@ void UObjectTest::testIDs()
void UObjectTest::testUMemory() {
// additional tests for code coverage
#if U_OVERRIDE_CXX_ALLOCATION && U_HAVE_PLACEMENT_NEW
UAlignedMemory stackMemory[sizeof(UnicodeString)/sizeof(UAlignedMemory)+1];
union {
UAlignedMemory align_;
char bytes_[sizeof(UnicodeString)];
} stackMemory;
char *bytes = stackMemory.bytes_;
UnicodeString *p;
enum { len=20 };
p=new(stackMemory) UnicodeString(len, (UChar32)0x20ac, len);
if((void *)p!=(void *)stackMemory) {
p=new(bytes) UnicodeString(len, (UChar32)0x20ac, len);
if((void *)p!=(void *)bytes) {
errln("placement new did not place the object at the expected address");
}
if(p->length()!=len || p->charAt(0)!=0x20ac || p->charAt(len-1)!=0x20ac) {
@ -523,7 +527,11 @@ void UObjectTest::testUMemory() {
*/
// destroy object and delete space manually
p->~UnicodeString();
UnicodeString::operator delete(p, stackMemory);
// You normally wouldn't call an operator delete for object placed on the
// stack with a placement new().
// This overload of delete is a nop, and is called here for code coverage purposes.
UnicodeString::operator delete(p, bytes);
// Jitterbug 4452, for coverage
UnicodeString *pa = new UnicodeString[2];

View file

@ -824,7 +824,7 @@ void UTextTest::TestAccessNoClone(const UnicodeString &us, UText *ut, int cpCoun
// or whether the lead surrogate of the pair is extracted.
// It's a buffer overflow error in either case.
TEST_ASSERT(buf[0] == us.charAt(0) ||
buf[0] == 0x5555 && U_IS_SUPPLEMENTARY(us.char32At(0)));
(buf[0] == 0x5555 && U_IS_SUPPLEMENTARY(us.char32At(0))));
TEST_ASSERT(buf[1] == 0x5555);
if (us.length() == 1) {
TEST_ASSERT(status == U_STRING_NOT_TERMINATED_WARNING);

View file

@ -1,6 +1,6 @@
/*
************************************************************************
* Copyright (c) 1997-2009, International Business Machines
* Copyright (c) 1997-2010, International Business Machines
* Corporation and others. All Rights Reserved.
************************************************************************
*/
@ -271,7 +271,7 @@ utimer_loopUntilDone(double thresholdTimeVal,
for(;currentVal<thresholdTimeVal;){
fn(param);
currentVal = utimer_getElapsedSeconds(&timer);
*loopCount++;
(*loopCount)++;
}
return currentVal;
}

View file

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1999-2009, International Business Machines
* Copyright (C) 1999-2010, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -272,7 +272,7 @@ main(int argc, char* argv[]) {
const char *filename = 0;
const char *ext = 0;
if (!locale || !tostdout) {
if (!locale[0] || !tostdout) {
filename = uprv_strrchr(arg, U_FILE_SEP_CHAR);
#if U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR
@ -345,7 +345,7 @@ main(int argc, char* argv[]) {
printCString(out, converter, "\n// derb(8) by Vladimir Weinstein and Yves Arrouye\n\n", -1);
if (locale) {
if (locale[0]) {
printCString(out, converter, locale, -1);
} else {
printCString(out, converter, filename, (int32_t)(ext - filename));

View file

@ -623,14 +623,22 @@ getOutFilename(const char *inFilename, const char *destdir, char *outFilename, c
#ifdef CAN_GENERATE_OBJECTS
static void
getArchitecture(uint16_t *pCPU, uint16_t *pBits, UBool *pIsBigEndian, const char *optMatchArch) {
int64_t buffer[256];
union {
char bytes[2048];
#ifdef U_ELF
Elf32_Ehdr header32;
/* Elf32_Ehdr and ELF64_Ehdr are identical for the necessary fields. */
#elif defined(U_WINDOWS)
IMAGE_FILE_HEADER header;
#endif
} buffer;
const char *filename;
FileStream *in;
int32_t length;
#ifdef U_ELF
/* Pointer to ELF header. Elf32_Ehdr and ELF64_Ehdr are identical for the necessary fields. */
const Elf32_Ehdr *pHeader32;
#elif defined(U_WINDOWS)
const IMAGE_FILE_HEADER *pHeader;
#else
@ -668,26 +676,25 @@ getArchitecture(uint16_t *pCPU, uint16_t *pBits, UBool *pIsBigEndian, const char
fprintf(stderr, "genccode: unable to open match-arch file %s\n", filename);
exit(U_FILE_ACCESS_ERROR);
}
length=T_FileStream_read(in, buffer, sizeof(buffer));
length=T_FileStream_read(in, buffer.bytes, sizeof(buffer.bytes));
#ifdef U_ELF
if(length<sizeof(Elf32_Ehdr)) {
fprintf(stderr, "genccode: match-arch file %s is too short\n", filename);
exit(U_UNSUPPORTED_ERROR);
}
pHeader32=(const Elf32_Ehdr *)buffer;
if(
pHeader32->e_ident[0]!=ELFMAG0 ||
pHeader32->e_ident[1]!=ELFMAG1 ||
pHeader32->e_ident[2]!=ELFMAG2 ||
pHeader32->e_ident[3]!=ELFMAG3 ||
pHeader32->e_ident[EI_CLASS]<ELFCLASS32 || pHeader32->e_ident[EI_CLASS]>ELFCLASS64
buffer.header32.e_ident[0]!=ELFMAG0 ||
buffer.header32.e_ident[1]!=ELFMAG1 ||
buffer.header32.e_ident[2]!=ELFMAG2 ||
buffer.header32.e_ident[3]!=ELFMAG3 ||
buffer.header32.e_ident[EI_CLASS]<ELFCLASS32 || buffer.header32.e_ident[EI_CLASS]>ELFCLASS64
) {
fprintf(stderr, "genccode: match-arch file %s is not an ELF object file, or not supported\n", filename);
exit(U_UNSUPPORTED_ERROR);
}
*pBits= pHeader32->e_ident[EI_CLASS]==ELFCLASS32 ? 32 : 64; /* only 32 or 64: see check above */
*pBits= buffer.header32.e_ident[EI_CLASS]==ELFCLASS32 ? 32 : 64; /* only 32 or 64: see check above */
#ifdef U_ELF64
if(*pBits!=32 && *pBits!=64) {
fprintf(stderr, "genccode: currently only supports 32-bit and 64-bit ELF format\n");
@ -700,20 +707,21 @@ getArchitecture(uint16_t *pCPU, uint16_t *pBits, UBool *pIsBigEndian, const char
}
#endif
*pIsBigEndian=(UBool)(pHeader32->e_ident[EI_DATA]==ELFDATA2MSB);
*pIsBigEndian=(UBool)(buffer.header32.e_ident[EI_DATA]==ELFDATA2MSB);
if(*pIsBigEndian!=U_IS_BIG_ENDIAN) {
fprintf(stderr, "genccode: currently only same-endianness ELF formats are supported\n");
exit(U_UNSUPPORTED_ERROR);
}
/* TODO: Support byte swapping */
*pCPU=pHeader32->e_machine;
*pCPU=buffer.header32.e_machine;
#elif defined(U_WINDOWS)
if(length<sizeof(IMAGE_FILE_HEADER)) {
fprintf(stderr, "genccode: match-arch file %s is too short\n", filename);
exit(U_UNSUPPORTED_ERROR);
}
pHeader=(const IMAGE_FILE_HEADER *)buffer;
/* TODO: Use buffer.header. Keep aliasing legal. */
pHeader=(const IMAGE_FILE_HEADER *)buffer.bytes;
*pCPU=pHeader->Machine;
/*
* The number of bits is implicit with the Machine value.