ICU-5445 Fix some compiler warnings

X-SVN-Rev: 20809
This commit is contained in:
George Rhoten 2006-12-19 06:06:30 +00:00
parent 45d40393ce
commit 202e0f66a7
16 changed files with 67 additions and 63 deletions

View file

@ -323,7 +323,7 @@ foundBest:
int32_t remaining = rangeEnd - (current+wordLength);
UChar32 pc = utext_current32(text);
int32_t chars = 0;
while (TRUE) {
for (;;) {
utext_next32(text);
uc = utext_current32(text);
// TODO: Here we're counting on the fact that the SA languages are all

View file

@ -1603,7 +1603,7 @@ setParaRunsOnly(UBiDi *pBiDi, const UChar *text, int32_t length,
if(U_FAILURE(*pErrorCode)) {
goto cleanup1;
}
ubidi_getRuns(pBiDi);
ubidi_getRuns(pBiDi, pErrorCode);
/* check if some runs must be split, count how many splits */
addedRuns=0;
runCount=pBiDi->runCount;

View file

@ -153,7 +153,7 @@ typedef struct Run {
#define IS_EVEN_RUN(x) (((x)&INDEX_ODD_BIT)==0)
U_CFUNC UBool
ubidi_getRuns(UBiDi *pBiDi);
ubidi_getRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
/** BiDi control code points */
enum {

View file

@ -25,6 +25,7 @@
#include "unicode/uchar.h"
#include "unicode/ubidi.h"
#include "ubidiimp.h"
#include "uassert.h"
/*
* General remarks about the functions in this file:
@ -354,7 +355,7 @@ ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode) {
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
return -1;
} else if(!IS_VALID_PARA_OR_LINE(pBiDi) ||
(pBiDi->runCount<0 && !ubidi_getRuns(pBiDi))) {
(pBiDi->runCount<0 && !ubidi_getRuns(pBiDi, pErrorCode))) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
return -1;
} else {
@ -364,9 +365,11 @@ ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode) {
U_CAPI UBiDiDirection U_EXPORT2
ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
int32_t *pLogicalStart, int32_t *pLength) {
int32_t *pLogicalStart, int32_t *pLength)
{
UErrorCode status = U_ZERO_ERROR;
if( !IS_VALID_PARA_OR_LINE(pBiDi) || runIndex<0 ||
(pBiDi->runCount==-1 && !ubidi_getRuns(pBiDi)) ||
(pBiDi->runCount==-1 && !ubidi_getRuns(pBiDi, &status)) ||
runIndex>=pBiDi->runCount
) {
return UBIDI_LTR;
@ -517,7 +520,7 @@ reorderLine(UBiDi *pBiDi, UBiDiLevel minLevel, UBiDiLevel maxLevel) {
/* compute the runs array --------------------------------------------------- */
static int32_t getRunFromLogicalIndex(UBiDi *pBiDi, int32_t logicalIndex) {
static int32_t getRunFromLogicalIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *status) {
Run *runs=pBiDi->runs;
int32_t runCount=pBiDi->runCount, visualStart=0, i, length, logicalStart;
@ -530,8 +533,8 @@ static int32_t getRunFromLogicalIndex(UBiDi *pBiDi, int32_t logicalIndex) {
visualStart+=length;
}
/* we should never get here */
i=length+25;
i/=(i-length-25); /* force program crash */
U_ASSERT(FALSE);
*status = U_INDEX_OUTOFBOUNDS_ERROR;
return 0;
}
@ -547,7 +550,7 @@ static int32_t getRunFromLogicalIndex(UBiDi *pBiDi, int32_t logicalIndex) {
* negative number of BiDi control characters within this run.
*/
U_CFUNC UBool
ubidi_getRuns(UBiDi *pBiDi) {
ubidi_getRuns(UBiDi *pBiDi, UErrorCode *pErrorCode) {
if(pBiDi->direction!=UBIDI_MIXED) {
/* simple, single-run case - this covers length==0 */
/* pBiDi->paraLevel is ok even for contextual multiple paragraphs */
@ -686,7 +689,7 @@ ubidi_getRuns(UBiDi *pBiDi) {
*limit=start+pBiDi->insertPoints.size;
int32_t runIndex;
for(point=start; point<limit; point++) {
runIndex=getRunFromLogicalIndex(pBiDi, point->pos);
runIndex=getRunFromLogicalIndex(pBiDi, point->pos, pErrorCode);
pBiDi->runs[runIndex].insertRemove|=point->flag;
}
}
@ -697,7 +700,7 @@ ubidi_getRuns(UBiDi *pBiDi) {
const UChar *start=pBiDi->text, *limit=start+pBiDi->length, *pu;
for(pu=start; pu<limit; pu++) {
if(IS_BIDI_CONTROL_CHAR(*pu)) {
runIndex=getRunFromLogicalIndex(pBiDi, pu-start);
runIndex=getRunFromLogicalIndex(pBiDi, pu-start, pErrorCode);
pBiDi->runs[runIndex].insertRemove--;
}
}
@ -892,7 +895,7 @@ ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
visualIndex=pBiDi->length-logicalIndex-1;
break;
default:
if(pBiDi->runCount<0 && !ubidi_getRuns(pBiDi)) {
if(pBiDi->runCount<0 && !ubidi_getRuns(pBiDi, pErrorCode)) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
return 0;
} else {
@ -1005,7 +1008,7 @@ ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
else if(pBiDi->direction==UBIDI_RTL) {
return pBiDi->length-visualIndex-1;
}
if(pBiDi->runCount<0 && !ubidi_getRuns(pBiDi)) {
if(pBiDi->runCount<0 && !ubidi_getRuns(pBiDi, pErrorCode)) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
return 0;
}

View file

@ -363,7 +363,7 @@ int32_t StringSearch::handleNext(int32_t position, UErrorCode &status)
}
ucol_setOffset(m_strsrch_->textIter, position, &status);
while (TRUE) {
for (;;) {
if (m_search_->isCanonicalMatch) {
// can't use exact here since extra accents are allowed.
usearch_handleNextCanonical(m_strsrch_, &status);
@ -426,7 +426,7 @@ int32_t StringSearch::handlePrev(int32_t position, UErrorCode &status)
setMatchNotFound();
return USEARCH_DONE;
}
while (TRUE) {
for (;;) {
if (m_search_->isCanonicalMatch) {
// can't use exact here since extra accents are allowed.
usearch_handlePreviousCanonical(m_strsrch_, &status);

View file

@ -2314,9 +2314,9 @@ uint32_t getDiscontiguous(const UCollator *coll, collIterate *source,
backupState(source, &discState);
//*tempdb = *(source->pos - 1);
*tempdb = peekCharacter(source, -1);
tempdb ++;
while (TRUE) {
*tempdb = peekCharacter(source, -1);
tempdb++;
for (;;) {
UChar *UCharOffset;
UChar schar,
tchar;

View file

@ -1140,7 +1140,7 @@ inline int32_t getPreviousBaseOffset(const UChar *text,
int32_t textoffset)
{
if (textoffset > 0) {
while (TRUE) {
for (;;) {
int32_t result = textoffset;
UTF_BACK_1(text, 0, textoffset);
int32_t temp = textoffset;
@ -3200,7 +3200,7 @@ UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status)
setColEIterOffset(coleiter, textoffset);
while (TRUE) {
for (;;) {
// finding the last pattern ce match, imagine composite characters
// for example: search for pattern A in text \u00C0
// we'll have to skip \u0300 the grave first before we get to A
@ -3496,7 +3496,7 @@ UBool usearch_handlePreviousCanonical(UStringSearch *strsrch,
int32_t firstce = UCOL_NULLORDER;
setColEIterOffset(coleiter, textoffset);
while (TRUE) {
for (;;) {
// finding the first pattern ce match, imagine composite
// characters. for example: search for pattern \u0300 in text
// \u00C0, we'll have to skip A first before we get to

View file

@ -214,7 +214,7 @@ doTests(UBiDi *pBiDi, UBiDi *pLine, UBool countRunsFirst) {
}
}
static const char columns[62] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static const char columns[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
#define TABLE_SIZE 256
static UBool tablesInitialized = FALSE;

View file

@ -1818,7 +1818,7 @@ static void TestSortKeyValidity(void)
/* en_US has no tailorings */
UCollator *coll = ucol_open("en_US", &status);
/* tailored locales */
char locale[][6] = {"fr_FR\0", "ko_KR\0", "sh_YU\0", "th_TH\0", "zh_CN\0"};
char locale[][6] = {"fr_FR", "ko_KR", "sh_YU", "th_TH", "zh_CN"};
FileStream *file = getFractionalUCA();
char line[1024];
UChar codepoints[10];

View file

@ -2554,7 +2554,7 @@ static void TestUResourceBundle() {
continue;
}
rb1 = ures_open(NULL, oldLoc, &status);
if (U_FAILURE(U_ZERO_ERROR)) {
if (U_FAILURE(status)) {
log_err("ures_open(%s) failed %s\n", oldLoc, u_errorName(status));
}
@ -2562,7 +2562,7 @@ static void TestUResourceBundle() {
status = U_ZERO_ERROR;
rb2 = ures_open(NULL, newLoc, &status);
if (U_FAILURE(U_ZERO_ERROR)) {
if (U_FAILURE(status)) {
log_err("ures_open(%s) failed %s\n", oldLoc, u_errorName(status));
}
us2 = ures_getLocale(rb2, &status);

View file

@ -2904,7 +2904,7 @@ static void TestVariableTopSetting(void) {
/* this test will fail when normalization is turned on */
/* therefore we always turn off exhaustive mode for it */
if(1) { /* QUICK > 0*/
{ /* QUICK > 0*/
log_verbose("Slide variable top over UCARules\n");
rulesLen = ucol_getRulesEx(coll, UCOL_FULL_RULES, rulesCopy, 0);
rulesCopy = (UChar *)malloc((rulesLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar));
@ -2928,7 +2928,7 @@ static void TestVariableTopSetting(void) {
specs = src.parsedToken.flags;
startOfRules = FALSE;
if(0) {
{
log_verbose("%04X %d ", *(rulesCopy+chOffset), chLen);
}
if(strength == UCOL_PRIMARY) {

View file

@ -34,25 +34,26 @@ log_err("Failure at file %s, line %d, error = %s\n", __FILE__, __LINE__, u_error
#define TEST_ASSERT(expr) {if ((expr)==FALSE) { \
log_err("Test Failure at file %s, line %d\n", __FILE__, __LINE__);}}
#define TEST_ASSERT_STRING(expected, actual, nulTerm) { \
char buf_inside_macro[120]; \
int32_t len = (int32_t)strlen(expected); \
UBool success; \
if (nulTerm) { \
u_austrncpy(buf_inside_macro, (actual), len+1); \
buf_inside_macro[len+2] = 0; \
success = (strcmp((expected), buf_inside_macro) == 0); \
} else { \
u_austrncpy(buf_inside_macro, (actual), len); \
buf_inside_macro[len+1] = 0; \
success = (strncmp((expected), buf_inside_macro, len) == 0); \
} \
if (success == FALSE) { \
log_err("Failure at file %s, line %d, expected \"%s\", got \"%s\"\n", \
__FILE__, __LINE__, (expected), buf_inside_macro); \
} \
static void test_assert_string(const char *expected, const UChar *actual, UBool nulTerm, const char *file, int line) {
char buf_inside_macro[120];
int32_t len = (int32_t)strlen(expected);
UBool success;
if (nulTerm) {
u_austrncpy(buf_inside_macro, (actual), len+1);
buf_inside_macro[len+2] = 0;
success = (strcmp((expected), buf_inside_macro) == 0);
} else {
u_austrncpy(buf_inside_macro, (actual), len);
buf_inside_macro[len+1] = 0;
success = (strncmp((expected), buf_inside_macro, len) == 0);
}
if (success == FALSE) {
log_err("Failure at file %s, line %d, expected \"%s\", got \"%s\"\n",
file, line, (expected), buf_inside_macro);
}
}
#define TEST_ASSERT_STRING(expected, actual, nulTerm) test_assert_string(expected, actual, nulTerm, __FILE__, __LINE__)

View file

@ -149,7 +149,7 @@ void CanonicalIteratorTest::TestBasic() {
UnicodeString testStr = CharsToUnicodeString(testArray[i][0]);
it.setSource(testStr, status);
set->removeAll();
while (TRUE) {
for (;;) {
//UnicodeString *result = new UnicodeString(it.next());
UnicodeString result(it.next());
if (result.isBogus()) {
@ -187,7 +187,7 @@ void CanonicalIteratorTest::characterTest(UnicodeString &s, UChar32 ch, Canonica
it.setSource(s, status);
while (TRUE) {
for (;;) {
UnicodeString item = it.next();
if (item.isBogus()) break;
if (item == s) gotSource = TRUE;

View file

@ -154,7 +154,7 @@ IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, cons
const UChar* trg = target.getBuffer();
UCollationResult compareResultIter = (UCollationResult)result;
if(1) {
{
UCharIterator sIter, tIter;
uiter_setString(&sIter, src, sLen);
uiter_setString(&tIter, trg, tLen);
@ -202,7 +202,7 @@ IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, cons
}
/* testing the partial sortkeys */
if(1) { /*!QUICK*/
{ /*!QUICK*/
int32_t partialSizes[] = { 3, 1, 2, 4, 8, 20, 80 }; /* just size 3 in the quick mode */
int32_t partialSizesSize = 1;
if(!quick) {

View file

@ -914,7 +914,7 @@ public:
return;
#endif
#if 1
#if 0
// debugging code,
int m;
for (m=0; m<4000; m++) {
@ -961,13 +961,13 @@ public:
// Keep this data here to avoid static initialization.
FormatThreadTestData kPercentFormatTestData[] =
{
FormatThreadTestData((double)5.0, UnicodeString("500%", "")),
FormatThreadTestData( 1.0, UnicodeString("100%", "")),
FormatThreadTestData( 0.26, UnicodeString("26%", "")),
FormatThreadTestData((double)5.0, CharsToUnicodeString("500\\u00a0%")),
FormatThreadTestData( 1.0, CharsToUnicodeString("100\\u00a0%")),
FormatThreadTestData( 0.26, CharsToUnicodeString("26\\u00a0%")),
FormatThreadTestData(
16384.99, CharsToUnicodeString("1\\u00a0638\\u00a0499%") ), // U+00a0 = NBSP
16384.99, CharsToUnicodeString("1\\u00a0638\\u00a0499\\u00a0%")), // U+00a0 = NBSP
FormatThreadTestData(
81890.23, CharsToUnicodeString("8\\u00a0189\\u00a0023%" )),
81890.23, CharsToUnicodeString("8\\u00a0189\\u00a0023\\u00a0%")),
};
int32_t kPercentFormatTestDataLength =
(int32_t)(sizeof(kPercentFormatTestData) / sizeof(kPercentFormatTestData[0]));

View file

@ -280,15 +280,15 @@ ures_enumDependencies(const UDataSwapper *ds,
return;
}
if(U_CHARSET_FAMILY==U_EBCDIC_FAMILY) {
// swap to EBCDIC
// our swapper is probably not the right one, but
// the function uses it only for printing errors
uprv_ebcdicFromAscii(ds, localeID, stringLength, localeID, pErrorCode);
if(U_FAILURE(*pErrorCode)) {
return;
}
#if (U_CHARSET_FAMILY==U_EBCDIC_FAMILY)
// swap to EBCDIC
// our swapper is probably not the right one, but
// the function uses it only for printing errors
uprv_ebcdicFromAscii(ds, localeID, stringLength, localeID, pErrorCode);
if(U_FAILURE(*pErrorCode)) {
return;
}
#endif
#if U_CHARSET_FAMILY!=U_ASCII_FAMILY && U_CHARSET_FAMILY!=U_EBCDIC_FAMILY
# error Unknown U_CHARSET_FAMILY value!
#endif