ICU-535 fixed some compiler warnings

X-SVN-Rev: 2181
This commit is contained in:
George Rhoten 2000-08-11 01:27:17 +00:00
parent ab07fb2402
commit c094c8a0eb
13 changed files with 469 additions and 459 deletions

View file

@ -34,7 +34,7 @@ T_CString_toLowerCase(char* str)
{
uint32_t i=0;
while(str[i])
str[i++] = tolower(str[i]);
str[i++] = (char)tolower(str[i]);
return str;
}
@ -43,7 +43,7 @@ T_CString_toUpperCase(char* str)
{
uint32_t i=0;
while(str[i])
str[i++] = toupper(str[i]);
str[i++] = (char)toupper(str[i]);
return str;
}
@ -55,26 +55,26 @@ void T_CString_integerToString(char* buffer, int32_t i, int32_t radix)
int32_t num = 0;
int8_t digit;
char temp;
while (i>=radix)
{
num = i/radix;
digit = (int8_t)(i - num*radix);
buffer[length++] = (T_CString_itosOffset(digit));
buffer[length++] = (char)(T_CString_itosOffset(digit));
i = num;
}
buffer[length] = (T_CString_itosOffset(i));
buffer[length] = (char)(T_CString_itosOffset(i));
buffer[length+1] = '\0';
/*Reverses the string*/
for (i = 0; i < length; ++i, --length) {
temp = buffer[length];
buffer[length] = buffer[i];
buffer[i] = temp;
}
return;
}
@ -173,7 +173,7 @@ U_CAPI char *uprv_strdup(const char *src) {
char *dup = (char *) malloc(len);
if (dup) {
uprv_memcpy(dup, src, len);
uprv_memcpy(dup, src, len);
}
return dup;

View file

@ -17,9 +17,9 @@
* 3/4/97 aliu Tuned performance of CompactIntArray constructor,
* 05/07/97 helena Added isBogus()
* based on performance data indicating that this_obj was slow.
* 07/15/98 erm Synched with Java 1.2 CompactShortArray.java.
* 07/30/98 erm Added changes from 07/29/98 code review.
* 11/01/99 weiv Added getArray, getIndex and getCount based on Jitterbug 4
* 07/15/98 erm Synched with Java 1.2 CompactShortArray.java.
* 07/30/98 erm Added changes from 07/29/98 code review.
* 11/01/99 weiv Added getArray, getIndex and getCount based on Jitterbug 4
*===============================================================================
*/
#include "ucmp16.h"
@ -289,7 +289,7 @@ void ucmp16_close(CompactShortArray* this_obj)
}
}
CompactShortArray* setToBogus(CompactShortArray* this_obj)
static CompactShortArray* setToBogus(CompactShortArray* this_obj)
{
if(this_obj != NULL) {
if(!this_obj->fAlias) {
@ -486,14 +486,14 @@ int16_t ucmp16_getDefaultValue(const CompactShortArray* this_obj)
}
void touchBlock(CompactShortArray* this_obj,
static void touchBlock(CompactShortArray* this_obj,
int32_t i,
int16_t value)
{
this_obj->fHashes[i] = (this_obj->fHashes[i] + (value << 1)) | 1;
}
UBool blockTouched(const CompactShortArray* this_obj, int32_t i)
static UBool blockTouched(const CompactShortArray* this_obj, int32_t i)
{
return (UBool)(this_obj->fHashes[i] != 0);
}

View file

@ -372,7 +372,7 @@ void ucmp32_setRange(CompactIntArray* this_obj, UChar start, UChar end, int32_t
* inputHash[i] = XOR of values from i-count+1 to i
*/
int32_t ucmp32_findOverlappingPosition(CompactIntArray* this_obj,
static int32_t ucmp32_findOverlappingPosition(CompactIntArray* this_obj,
uint32_t start,
const UChar* tempIndex,
int32_t tempIndexCount,

View file

@ -289,7 +289,7 @@ void ucmp8_expand(CompactByteArray* this_obj)
* inputHash: an index of hashes for tempIndex, where
* inputHash[i] = XOR of values from i-count+1 to i
*/
int32_t
static int32_t
findOverlappingPosition(CompactByteArray* this_obj,
uint32_t start,
const UChar* tempIndex,

View file

@ -41,14 +41,14 @@ static int32_t ucnv_getAmbiguousCCSID (const UConverter* cnv);
/* Internal function : end */
static void T_UConverter_fromCodepageToCodepage (UConverter * outConverter,
UConverter * inConverter,
char **target,
const char *targetLimit,
const char **source,
const char *sourceLimit,
int32_t* offsets,
UBool flush,
UErrorCode * err);
UConverter * inConverter,
char **target,
const char *targetLimit,
const char **source,
const char *sourceLimit,
int32_t* offsets,
UBool flush,
UErrorCode * err);
const char* ucnv_getDefaultName ()
@ -62,7 +62,7 @@ void ucnv_setDefaultName (const char *converterName)
}
/*Calls through createConverter */
UConverter* ucnv_open (const char *name,
UErrorCode * err)
UErrorCode * err)
{
if (err == NULL || U_FAILURE (*err)) {
return NULL;
@ -73,7 +73,7 @@ UConverter* ucnv_open (const char *name,
/*Extracts the UChar* to a char* and calls through createConverter */
UConverter* ucnv_openU (const UChar * name,
UErrorCode * err)
UErrorCode * err)
{
char asciiName[UCNV_MAX_CONVERTER_NAME_LENGTH];
@ -92,8 +92,8 @@ UConverter* ucnv_openU (const UChar * name,
/*Assumes a $platform-#codepage.$CONVERTER_FILE_EXTENSION scheme and calls
*through createConverter*/
UConverter* ucnv_openCCSID (int32_t codepage,
UConverterPlatform platform,
UErrorCode * err)
UConverterPlatform platform,
UErrorCode * err)
{
char myName[UCNV_MAX_CONVERTER_NAME_LENGTH];
@ -260,9 +260,9 @@ ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorC
}
void ucnv_getSubstChars (const UConverter * converter,
char *mySubChar,
int8_t * len,
UErrorCode * err)
char *mySubChar,
int8_t * len,
UErrorCode * err)
{
if (U_FAILURE (*err))
return;
@ -280,9 +280,9 @@ void ucnv_getSubstChars (const UConverter * converter,
}
void ucnv_setSubstChars (UConverter * converter,
const char *mySubChar,
int8_t len,
UErrorCode * err)
const char *mySubChar,
int8_t len,
UErrorCode * err)
{
if (U_FAILURE (*err))
return;
@ -305,10 +305,10 @@ void ucnv_setSubstChars (UConverter * converter,
int32_t ucnv_getDisplayName (const UConverter * converter,
const char *displayLocale,
UChar * displayName,
int32_t displayNameCapacity,
UErrorCode * err)
const char *displayLocale,
UChar * displayName,
int32_t displayNameCapacity,
UErrorCode * err)
{
UChar stringToWriteBuffer[UCNV_MAX_CONVERTER_NAME_LENGTH];
UChar const *stringToWrite;
@ -322,9 +322,9 @@ int32_t ucnv_getDisplayName (const UConverter * converter,
rb = ures_open (NULL, displayLocale, err);
stringToWrite = ures_getStringByKey(rb,
converter->sharedData->staticData->name,
converter->sharedData->staticData->name,
&stringToWriteLength,
err);
err);
if (rb)
ures_close (rb);
@ -341,7 +341,7 @@ int32_t ucnv_getDisplayName (const UConverter * converter,
/*Hides the fallback to the internal name from the user */
if (*err == U_MISSING_RESOURCE_ERROR)
*err = U_ZERO_ERROR;
*err = U_ZERO_ERROR;
}
/*At this point we have a displayName and its length
@ -358,12 +358,10 @@ int32_t ucnv_getDisplayName (const UConverter * converter,
/*it doesn't fit */
*err = U_BUFFER_OVERFLOW_ERROR;
u_strncpy (displayName,
stringToWrite,
displayNameCapacity);
u_strncpy (displayName, stringToWrite, displayNameCapacity);
/*Zero terminates the string */
if (displayNameCapacity > 0)
displayName[displayNameCapacity - 1] = 0x0000;
displayName[displayNameCapacity - 1] = 0x0000;
}
/*if the user provided us with a with an outputLength
@ -447,7 +445,7 @@ const char* ucnv_getName (const UConverter * converter, UErrorCode * err)
}
int32_t ucnv_getCCSID (const UConverter * converter,
UErrorCode * err)
UErrorCode * err)
{
if (U_FAILURE (*err))
return -1;
@ -457,7 +455,7 @@ int32_t ucnv_getCCSID (const UConverter * converter,
UConverterPlatform ucnv_getPlatform (const UConverter * converter,
UErrorCode * err)
UErrorCode * err)
{
if (U_FAILURE (*err))
return UCNV_UNKNOWN;
@ -484,11 +482,11 @@ U_CAPI void U_EXPORT2
}
void ucnv_setToUCallBack (UConverter * converter,
UConverterToUCallback newAction,
void* newContext,
UConverterToUCallback *oldAction,
void** oldContext,
UErrorCode * err)
UConverterToUCallback newAction,
void* newContext,
UConverterToUCallback *oldAction,
void** oldContext,
UErrorCode * err)
{
if (U_FAILURE (*err))
return;
@ -498,12 +496,12 @@ void ucnv_setToUCallBack (UConverter * converter,
converter->toUContext = newContext;
}
void ucnv_setFromUCallBack (UConverter * converter,
UConverterFromUCallback newAction,
void* newContext,
UConverterFromUCallback *oldAction,
void** oldContext,
UErrorCode * err)
void ucnv_setFromUCallBack (UConverter * converter,
UConverterFromUCallback newAction,
void* newContext,
UConverterFromUCallback *oldAction,
void** oldContext,
UErrorCode * err)
{
if (U_FAILURE (*err))
@ -513,14 +511,15 @@ void ucnv_setFromUCallBack (UConverter * converter,
*oldContext = converter->fromUContext;
converter->fromUContext = newContext;
}
void ucnv_fromUnicode (UConverter * _this,
char **target,
const char *targetLimit,
const UChar ** source,
const UChar * sourceLimit,
int32_t* offsets,
UBool flush,
UErrorCode * err)
void ucnv_fromUnicode (UConverter * _this,
char **target,
const char *targetLimit,
const UChar ** source,
const UChar * sourceLimit,
int32_t* offsets,
UBool flush,
UErrorCode * err)
{
UConverterFromUnicodeArgs args;
/*
@ -543,11 +542,11 @@ void ucnv_fromUnicode (UConverter * _this,
int32_t myTargetIndex = 0;
flushInternalCharBuffer (_this,
(char *) *target,
&myTargetIndex,
targetLimit - *target,
offsets?&offsets:NULL,
err);
(char *) *target,
&myTargetIndex,
targetLimit - *target,
offsets?&offsets:NULL,
err);
*target += myTargetIndex;
if (U_FAILURE (*err)) return;
}
@ -562,7 +561,7 @@ void ucnv_fromUnicode (UConverter * _this,
args.size = sizeof(args);
if (offsets) {
if (_this->sharedData->impl->fromUnicodeWithOffsets != NULL) {
_this->sharedData->impl->fromUnicodeWithOffsets(&args, err);
_this->sharedData->impl->fromUnicodeWithOffsets(&args, err);
*source = args.source;
*target = args.target;
return;
@ -604,13 +603,13 @@ void ucnv_fromUnicode (UConverter * _this,
void ucnv_toUnicode (UConverter * _this,
UChar ** target,
const UChar * targetLimit,
const char **source,
const char *sourceLimit,
int32_t* offsets,
UBool flush,
UErrorCode * err)
UChar ** target,
const UChar * targetLimit,
const char **source,
const char *sourceLimit,
int32_t* offsets,
UBool flush,
UErrorCode * err)
{
UConverterToUnicodeArgs args;
/*
@ -632,14 +631,14 @@ void ucnv_toUnicode (UConverter * _this,
int32_t myTargetIndex = 0;
flushInternalUnicodeBuffer (_this,
*target,
&myTargetIndex,
targetLimit - *target,
offsets?&offsets:NULL,
err);
*target,
&myTargetIndex,
targetLimit - *target,
offsets?&offsets:NULL,
err);
*target += myTargetIndex;
if (U_FAILURE (*err))
return;
return;
}
args.converter = _this;
@ -652,10 +651,10 @@ void ucnv_toUnicode (UConverter * _this,
args.size = sizeof(args);
if (offsets) {
if (_this->sharedData->impl->toUnicodeWithOffsets != NULL) {
_this->sharedData->impl->toUnicodeWithOffsets(&args, err);
_this->sharedData->impl->toUnicodeWithOffsets(&args, err);
*source = args.source;
*target = args.target;
return;
return;
} else {
/* all code points are of the same length */
int32_t targetSize = targetLimit - *target;
@ -679,18 +678,18 @@ void ucnv_toUnicode (UConverter * _this,
/*calls the specific conversion routines */
_this->sharedData->impl->toUnicode(&args, err);
*source = args.source;
*target = args.target;
return;
}
int32_t ucnv_fromUChars (const UConverter * converter,
char *target,
int32_t targetSize,
const UChar * source,
int32_t sourceSize,
UErrorCode * err)
char *target,
int32_t targetSize,
const UChar * source,
int32_t sourceSize,
UErrorCode * err)
{
const UChar *mySource_limit;
int32_t mySourceLength = sourceSize;
@ -772,30 +771,31 @@ int32_t ucnv_fromUChars (const UConverter * converter,
*/
while (*err == U_INDEX_OUTOFBOUNDS_ERROR)
{
*err = U_ZERO_ERROR;
args.target = target2;
args.targetLimit = target2_limit;
args.converter->sharedData->impl->fromUnicode(&args, err);
{
*err = U_ZERO_ERROR;
args.target = target2;
args.targetLimit = target2_limit;
args.converter->sharedData->impl->fromUnicode(&args, err);
/*updates the output parameter to contain the number of char required */
targetCapacity += (args.target - target2) + 1; }
/*updates the output parameter to contain the number of char required */
targetCapacity += (args.target - target2) + 1;
}
/*We will set the erro code to U_BUFFER_OVERFLOW_ERROR only if
*nothing graver happened in the previous loop*/
(targetCapacity)--;
if (U_SUCCESS (*err))
*err = U_BUFFER_OVERFLOW_ERROR;
*err = U_BUFFER_OVERFLOW_ERROR;
}
return targetCapacity;
}
int32_t ucnv_toUChars (const UConverter * converter,
UChar * target,
int32_t targetSize,
const char *source,
int32_t sourceSize,
UErrorCode * err)
UChar * target,
int32_t targetSize,
const char *source,
int32_t sourceSize,
UErrorCode * err)
{
const char *mySource_limit = source + sourceSize;
UConverter myConverter;
@ -819,12 +819,12 @@ int32_t ucnv_toUChars (const UConverter * converter,
*if the user requires it
*/
if (targetSize >= 1)
{
target[0] = 0x0000;
return 1;
}
{
target[0] = 0x0000;
return 1;
}
else
return 0;
return 0;
}
/*makes a local copy of the UConverter */
@ -881,27 +881,27 @@ int32_t ucnv_toUChars (const UConverter * converter,
(in case the output is greater than CHUNK_SIZE) */
while (*err == U_INDEX_OUTOFBOUNDS_ERROR)
{
*err = U_ZERO_ERROR;
args.target = target2;
args.targetLimit = target2_limit;
args.converter->sharedData->impl->toUnicode(&args, err);
{
*err = U_ZERO_ERROR;
args.target = target2;
args.targetLimit = target2_limit;
args.converter->sharedData->impl->toUnicode(&args, err);
/*updates the output parameter to contain the number of char required */
targetCapacity += args.target - target2 + 1;
}
(targetCapacity)--; /*adjust for last one */
/*updates the output parameter to contain the number of char required */
targetCapacity += args.target - target2 + 1;
}
(targetCapacity)--; /*adjust for last one */
if (U_SUCCESS (*err))
*err = U_BUFFER_OVERFLOW_ERROR;
*err = U_BUFFER_OVERFLOW_ERROR;
}
return targetCapacity;
}
UChar32 ucnv_getNextUChar (UConverter * converter,
const char **source,
const char *sourceLimit,
UErrorCode * err)
UChar32 ucnv_getNextUChar(UConverter * converter,
const char **source,
const char *sourceLimit,
UErrorCode * err)
{
UConverterToUnicodeArgs args;
UChar32 ch;
@ -925,8 +925,8 @@ UChar32 ucnv_getNextUChar (UConverter * converter,
*UCharErrorBufferLength
*/
uprv_memmove (converter->UCharErrorBuffer,
converter->UCharErrorBuffer + i,
(converter->UCharErrorBufferLength - i) * sizeof (UChar));
converter->UCharErrorBuffer + i,
(converter->UCharErrorBufferLength - i) * sizeof (UChar));
converter->UCharErrorBufferLength -= (int8_t)i;
return myUChar;
}
@ -940,8 +940,7 @@ UChar32 ucnv_getNextUChar (UConverter * converter,
args.target = NULL;
args.targetLimit = NULL;
args.size = sizeof(args);
ch = converter->sharedData->impl->getNextUChar(&args,
err);
ch = converter->sharedData->impl->getNextUChar(&args, err);
*source = args.source;
return ch;
}
@ -959,16 +958,16 @@ UChar32 ucnv_getNextUChar (UConverter * converter,
* @param internal: used internally to store store state data across calls
* @param err: fills in an error status
*/
void
static void
T_UConverter_fromCodepageToCodepage (UConverter * outConverter,
UConverter * inConverter,
char **target,
const char *targetLimit,
const char **source,
const char *sourceLimit,
int32_t* offsets,
UBool flush,
UErrorCode * err)
UConverter * inConverter,
char **target,
const char *targetLimit,
const char **source,
const char *sourceLimit,
int32_t* offsets,
UBool flush,
UErrorCode * err)
{
UChar out_chunk[CHUNK_SIZE];
@ -989,50 +988,50 @@ T_UConverter_fromCodepageToCodepage (UConverter * outConverter,
{
out_chunk_alias = out_chunk;
ucnv_toUnicode (inConverter,
&out_chunk_alias,
out_chunk_limit,
source,
sourceLimit,
NULL,
flush,
err);
&out_chunk_alias,
out_chunk_limit,
source,
sourceLimit,
NULL,
flush,
err);
/*U_INDEX_OUTOFBOUNDS_ERROR means that the output "CHUNK" is full
*we will require at least another loop (it's a recoverable error)
*/
if (U_SUCCESS (*err) || (*err == U_INDEX_OUTOFBOUNDS_ERROR))
{
*err = U_ZERO_ERROR;
out_chunk_alias2 = out_chunk;
{
*err = U_ZERO_ERROR;
out_chunk_alias2 = out_chunk;
while ((out_chunk_alias2 != out_chunk_alias) && U_SUCCESS (*err))
{
ucnv_fromUnicode (outConverter,
target,
targetLimit,
&out_chunk_alias2,
out_chunk_alias,
NULL,
TRUE,
err);
while ((out_chunk_alias2 != out_chunk_alias) && U_SUCCESS (*err))
{
ucnv_fromUnicode (outConverter,
target,
targetLimit,
&out_chunk_alias2,
out_chunk_alias,
NULL,
TRUE,
err);
}
}
}
}
else
break;
break;
}
return;
}
int32_t ucnv_convert(const char *toConverterName,
const char *fromConverterName,
char *target,
int32_t targetSize,
const char *source,
int32_t sourceSize,
UErrorCode * err)
const char *fromConverterName,
char *target,
int32_t targetSize,
const char *source,
int32_t sourceSize,
UErrorCode * err)
{
const char *mySource = source;
const char *mySource_limit = source + sourceSize;
@ -1073,14 +1072,14 @@ int32_t ucnv_convert(const char *toConverterName,
if (targetSize > 0)
{
T_UConverter_fromCodepageToCodepage (outConverter,
inConverter,
&myTarget,
target + targetSize,
&mySource,
mySource_limit,
NULL,
TRUE,
err);
inConverter,
&myTarget,
target + targetSize,
&mySource,
mySource_limit,
NULL,
TRUE,
err);
}
@ -1105,27 +1104,27 @@ int32_t ucnv_convert(const char *toConverterName,
*/
while (*err == U_INDEX_OUTOFBOUNDS_ERROR)
{
*err = U_ZERO_ERROR;
target2_alias = target2;
T_UConverter_fromCodepageToCodepage (outConverter,
inConverter,
&target2_alias,
target2_limit,
&mySource,
mySource_limit,
NULL,
TRUE,
err);
{
*err = U_ZERO_ERROR;
target2_alias = target2;
T_UConverter_fromCodepageToCodepage (outConverter,
inConverter,
&target2_alias,
target2_limit,
&mySource,
mySource_limit,
NULL,
TRUE,
err);
/*updates the output parameter to contain the number of char required */
targetCapacity += (target2_alias - target2) + 1;
}
/*updates the output parameter to contain the number of char required */
targetCapacity += (target2_alias - target2) + 1;
}
/*We will set the erro code to U_BUFFER_OVERFLOW_ERROR only if
*nothing graver happened in the previous loop*/
(targetCapacity)--;
if (U_SUCCESS (*err))
*err = U_BUFFER_OVERFLOW_ERROR;
*err = U_BUFFER_OVERFLOW_ERROR;
}
ucnv_close (inConverter);
@ -1140,8 +1139,8 @@ UConverterType ucnv_getType(const UConverter* converter)
}
void ucnv_getStarters(const UConverter* converter,
UBool starters[256],
UErrorCode* err)
UBool starters[256],
UErrorCode* err)
{
if (err == NULL || U_FAILURE(*err)) {
return;
@ -1154,7 +1153,7 @@ void ucnv_getStarters(const UConverter* converter,
}
}
int32_t ucnv_getAmbiguousCCSID(const UConverter *cnv)
static int32_t ucnv_getAmbiguousCCSID(const UConverter *cnv)
{
UErrorCode status = U_ZERO_ERROR;
int32_t i = 0;
@ -1201,7 +1200,7 @@ void ucnv_fixFileSeparator(const UConverter *cnv,
UBool ucnv_isAmbiguous(const UConverter *cnv)
{
return (ucnv_getAmbiguousCCSID(cnv) == -1 ? FALSE : TRUE);
return (UBool)(ucnv_getAmbiguousCCSID(cnv) == -1 ? FALSE : TRUE);
}
void ucnv_setFallback(UConverter *cnv, UBool usesFallback)
@ -1216,9 +1215,9 @@ UBool ucnv_usesFallback(const UConverter *cnv)
void
ucnv_getInvalidChars (const UConverter * converter,
char *errBytes,
int8_t * len,
UErrorCode * err)
char *errBytes,
int8_t * len,
UErrorCode * err)
{
if (err == NULL || U_FAILURE(*err))
{
@ -1242,9 +1241,9 @@ ucnv_getInvalidChars (const UConverter * converter,
void
ucnv_getInvalidUChars (const UConverter * converter,
UChar *errChars,
int8_t * len,
UErrorCode * err)
UChar *errChars,
int8_t * len,
UErrorCode * err)
{
if (err == NULL || U_FAILURE(*err))
{

View file

@ -111,7 +111,7 @@ isCnvAcceptable(void *context,
#define DATA_TYPE "cnv"
UConverterSharedData *createConverterFromFile (const char *fileName, UErrorCode * err)
static UConverterSharedData *createConverterFromFile (const char *fileName, UErrorCode * err)
{
UDataMemory *data;
UConverterSharedData *sharedData;
@ -158,7 +158,7 @@ void
/*returns a converter type from a string
*/
const UConverterSharedData *
static const UConverterSharedData *
getAlgorithmicTypeFromName (const char *realName)
{
int i;

View file

@ -172,7 +172,7 @@ static void _lazyEvaluate_installedLocales(void);
*******************************************************************************/
const char* _findCharSeparator(const char* string)
static const char* _findCharSeparator(const char* string)
{
if (string == NULL) return NULL;
/*Keeps iterating until an ID separator is found*/
@ -182,7 +182,7 @@ const char* _findCharSeparator(const char* string)
}
int16_t _findIndex(const char* list, int32_t listLength, const char* key)
static int16_t _findIndex(const char* list, int32_t listLength, const char* key)
{
const char* anchor = list;
const char* listEnd = anchor + listLength;
@ -261,7 +261,7 @@ int32_t uloc_getParent(const char* localeID,
{
if (_isIDSeparator(localeID[offset++])) count++;
}
/*finds the second IDSeparator*/
while (offset && !_isIDSeparator(localeID[offset])) offset--;
@ -273,16 +273,16 @@ int32_t uloc_getParent(const char* localeID,
if (parentCapacity > i) parent[i] = localeID[i];
i++;
}
/*Sets the error code on case of need*/
if (i >= parentCapacity )
{
*err = U_BUFFER_OVERFLOW_ERROR;
}
if (parentCapacity>0) parent[uprv_min(i,parentCapacity-1)] = '\0';
return i+1;
}
@ -293,10 +293,10 @@ uloc_getLanguage(const char* localeID,
UErrorCode* err)
{
int i=0;
if (U_FAILURE(*err)) return 0;
if (localeID == NULL) localeID = uloc_getDefault();
/*Loop updates i to the size of the language
@ -307,17 +307,17 @@ uloc_getLanguage(const char* localeID,
i++;
localeID++;
}
if (i >= languageCapacity )
{
*err = U_BUFFER_OVERFLOW_ERROR;
}
if (languageCapacity > 0)
{
language[uprv_min(i,languageCapacity-1)] = '\0';
}
return i+1;
}
@ -328,7 +328,7 @@ int32_t uloc_getCountry(const char* localeID,
UErrorCode* err)
{
int i=0;
if (U_FAILURE(*err)) return 0;
if (localeID == NULL) localeID = uloc_getDefault();
@ -346,12 +346,12 @@ int32_t uloc_getCountry(const char* localeID,
localeID++;
}
}
if (i >= countryCapacity )
{
*err = U_BUFFER_OVERFLOW_ERROR;
}
if (countryCapacity > 0) {country[uprv_min(i,countryCapacity-1)] = '\0';}
return i+1;
}
@ -362,13 +362,13 @@ int32_t uloc_getVariant(const char* localeID,
UErrorCode* err)
{
int i=0;
if (U_FAILURE(*err)) return 0;
if (localeID == NULL) localeID = uloc_getDefault();
localeID = _findCharSeparator(localeID);
if (localeID) localeID = _findCharSeparator(++localeID);
if (localeID)
{
++localeID;
@ -380,15 +380,15 @@ int32_t uloc_getVariant(const char* localeID,
i++;
localeID++;
}
}
if (i >= variantCapacity )
{
*err = U_BUFFER_OVERFLOW_ERROR;
}
if (variantCapacity>0) {variant[uprv_min(i,variantCapacity-1)] = '\0';}
return i+1;
}
@ -402,7 +402,7 @@ int32_t uloc_getName(const char* localeID,
int varSze = 0;
int cntSze = 0;
UErrorCode int_err = U_ZERO_ERROR;
if (U_FAILURE(*err)) return 0;
/*First we preflight the components in order to ensure a valid return value*/
if (localeID == NULL) localeID = uloc_getDefault();
@ -416,7 +416,7 @@ int32_t uloc_getName(const char* localeID,
NULL ,
0,
&int_err);
int_err = U_ZERO_ERROR;
i = uloc_getLanguage(localeID,
NULL,
@ -429,9 +429,9 @@ int32_t uloc_getName(const char* localeID,
if (cntSze) i++;
if (varSze) i++;
i += cntSze + varSze;
int_err = U_ZERO_ERROR;
uloc_getLanguage(localeID,
name,
nameCapacity,
@ -441,25 +441,25 @@ int32_t uloc_getName(const char* localeID,
if ((nameCapacity>0) && cntSze)
{
if (U_SUCCESS(int_err)) uprv_strcat(name, "_");
uloc_getCountry(localeID,
name + uprv_strlen(name),
nameCapacity - uprv_strlen(name),
&int_err);
if (varSze)
{
if (U_SUCCESS(int_err)) uprv_strcat(name, "_");
uloc_getVariant(localeID,
name + uprv_strlen(name),
nameCapacity - uprv_strlen(name),
&int_err);
}
}
*err = int_err;
return i;
}
@ -468,7 +468,7 @@ const char* uloc_getISO3Language(const char* localeID)
int16_t offset;
char lang[TEMPBUFSIZE];
UErrorCode err = U_ZERO_ERROR;
if (localeID == NULL) localeID = uloc_getDefault();
uloc_getLanguage(localeID, lang, TEMPBUFSIZE, &err);
if (U_FAILURE(err)) return "";
@ -482,7 +482,7 @@ const char* uloc_getISO3Country(const char* localeID)
int16_t offset;
char cntry[TEMPBUFSIZE];
UErrorCode err = U_ZERO_ERROR;
if (localeID == NULL) localeID = uloc_getDefault();
uloc_getCountry(localeID, cntry, TEMPBUFSIZE, &err);
if (U_FAILURE(err)) return "";
@ -500,7 +500,7 @@ uint32_t uloc_getLCID(const char* localeID)
int32_t lcidLen = 0;
uint32_t result = 0;
UResourceBundle* bundle = ures_open(NULL, localeID, &err);
if (U_SUCCESS(err))
{
lcid = ures_getStringByKey(bundle, _kLocaleID, &lcidLen, &err);
@ -521,7 +521,7 @@ int32_t uloc_getDisplayLanguage(const char* locale,
UChar* language,
int32_t languageCapacity,
UErrorCode* status)
{
{
const UChar* result = NULL;
int32_t i = 0;
int langBufSize;
@ -534,29 +534,29 @@ int32_t uloc_getDisplayLanguage(const char* locale,
UBool done = FALSE;
if (U_FAILURE(*status)) return 0;
if (inLocale == NULL)
if (inLocale == NULL)
{
inLocale = uloc_getDefault();
isDefaultLocale = TRUE;
}
else if (uprv_strcmp(inLocale, uloc_getDefault()) == 0) isDefaultLocale = TRUE;
/*truncates the fallback mechanism if we start out with a defaultLocale*/
if (locale == NULL) locale = uloc_getDefault();
/*extracts the language*/
langBufSize = uloc_getLanguage(locale,
inLanguageBuffer,
TEMPBUFSIZE,
&err);
/*We need to implement a fallback mechanism here because we are getting keys out of a
tagged array, there is no capability of doing this with fallback through the resource
bundle API*/
if (langBufSize > 1)
{
do
@ -577,10 +577,10 @@ int32_t uloc_getDisplayLanguage(const char* locale,
}
else done = TRUE;
}
bundle = ures_open(NULL, inLocale, &err);
if (U_SUCCESS(err))
{
err = U_ZERO_ERROR;
@ -589,8 +589,8 @@ int32_t uloc_getDisplayLanguage(const char* locale,
inLanguageBuffer,
&err);
if (U_SUCCESS(err)) result = temp;
ures_close(bundle);
}
ures_close(bundle);
}
err = U_ZERO_ERROR;
@ -601,8 +601,8 @@ int32_t uloc_getDisplayLanguage(const char* locale,
inLocale = inLocaleBuffer;
} while ((result == NULL) && !done);
}
}
if (result)
{
@ -657,8 +657,8 @@ int32_t uloc_getDisplayCountry(const char* locale,
UBool done = FALSE;
if (U_FAILURE(*status)) return 0;
if (inLocale == NULL)
{
@ -674,7 +674,7 @@ int32_t uloc_getDisplayCountry(const char* locale,
cntryBufSize = uloc_getCountry(locale, inCountryBuffer, TEMPBUFSIZE, &err);
if (cntryBufSize > 1)
{
/*
@ -700,14 +700,14 @@ int32_t uloc_getDisplayCountry(const char* locale,
}
else done = TRUE;
}
bundle = ures_open(NULL, inLocale, &err);
if (U_SUCCESS(err))
{
const UChar* temp;
temp = ures_getTaggedArrayItem(bundle,
_kCountries,
inCountryBuffer,
@ -719,11 +719,11 @@ int32_t uloc_getDisplayCountry(const char* locale,
err = U_ZERO_ERROR;
uloc_getParent(inLocale, inLocaleBuffer, TEMPBUFSIZE, &err);
inLocale = inLocaleBuffer;
} while ((result == NULL) && !done);
}
if (result)
{
i = u_strlen(result)+1;
@ -811,10 +811,10 @@ int32_t uloc_getDisplayVariant(const char* locale,
err = U_ZERO_ERROR;
uloc_getVariant(locale, inVariant, varBufSize, &err);
}
uprv_strcpy(inVariantTag,"%%");
uprv_strcat(inVariantTag, inVariant);
/*We need to implement a fallback mechanism here because we are getting keys out of a
tagged array, there is no capability of doing this with fallback through the resource
bundle API*/
@ -825,7 +825,7 @@ int32_t uloc_getDisplayVariant(const char* locale,
As we iterate down the latter, if we hit the root locale ("")
we pass it to the resource bundle api so it checks default.txt
*/
if (inLocale[0] == '\0')
{
if (!isDefaultLocale)
@ -855,12 +855,12 @@ int32_t uloc_getDisplayVariant(const char* locale,
inLocale = inLocaleBuffer;
} while ((result == NULL) && !done);
}
if (result)
{
i = u_strlen(result)+1;
@ -955,9 +955,9 @@ int32_t uloc_getDisplayName(const char* locale,
if (varSze) i += cntSze + varSze + 5;
else i += cntSze + 3;
}
int_err = U_ZERO_ERROR;
result_size = uloc_getDisplayLanguage(locale,
inLocale,
result,
@ -1007,22 +1007,22 @@ int32_t uloc_getDisplayName(const char* locale,
const char*
uloc_getAvailable(int32_t offset)
{
if (_installedLocales == NULL) _lazyEvaluate_installedLocales();
if (offset > _installedLocalesCount) return NULL;
else return _installedLocales[offset];
}
int32_t uloc_countAvailable()
{
if (_installedLocales == NULL) _lazyEvaluate_installedLocales();
return _installedLocalesCount;
}
void _lazyEvaluate_installedLocales()
static void _lazyEvaluate_installedLocales()
{
UResourceBundle *index = NULL;
@ -1050,16 +1050,16 @@ void _lazyEvaluate_installedLocales()
i++;
}
{
umtx_lock(NULL);
if (_installedLocales == NULL)
{
_installedLocales = temp;
temp = NULL;
} else {
for (i = 0; i < _installedLocalesCount; i++) uprv_free(temp[i]);
uprv_free(temp);
}
umtx_unlock(NULL);
umtx_lock(NULL);
if (_installedLocales == NULL)
{
_installedLocales = temp;
temp = NULL;
} else {
for (i = 0; i < _installedLocalesCount; i++) uprv_free(temp[i]);
uprv_free(temp);
}
umtx_unlock(NULL);
}
ures_close(&installed);
@ -1077,17 +1077,17 @@ const char* const* uloc_getISOLanguages()
{
const char *from, *end;
char **to;
if (_isoLanguages == NULL)
{
{
umtx_lock(NULL);
if (_isoLanguages == NULL)
{
_isoLanguages = (char**) uprv_malloc(sizeof(char*)*(1+(sizeof(_languages) / 3)));
end = _languages + (sizeof(_languages));
from = _languages;
to = _isoLanguages;

View file

@ -59,8 +59,8 @@ BreakDictionary::~BreakDictionary()
#define SWAP32(x)
#define SWAP16(x)
#else
#define SWAP32(x) x = (x >> 24 & 0xff) | (x >> 8 & 0xff00) | (x << 8 & 0xff0000) | (x << 24 & 0xff000000)
#define SWAP16(x) x = (x << 8 & 0xff00) | (x >> 8 & 0xff)
#define SWAP32(x) x = (uint32_t)((x >> 24 & 0xff) | (x >> 8 & 0xff00) | (x << 8 & 0xff0000) | (x << 24 & 0xff000000))
#define SWAP16(x) x = (uint16_t)((x << 8 & 0xff00) | (x >> 8 & 0xff))
#endif
void
@ -69,7 +69,7 @@ BreakDictionary::readDictionaryFile(UMemoryStream* in)
int32_t l;
int32_t version;
int i;
int i;
// read in the version number (right now we just ignore it)
uprv_mstrm_read(in, &version, 4);

View file

@ -305,7 +305,7 @@ UChar
NormalizerIterator::next(void)
{
if (text != 0) {
return ((currentOffset < textLen) ? text[++currentOffset] : Normalizer::DONE);
return (UChar)((currentOffset < textLen) ? text[++currentOffset] : Normalizer::DONE);
}
return (UChar)cursor->next();
}
@ -791,45 +791,45 @@ RuleBasedCollator::constructFromBundle(const Locale & name,
ResourceBundle binary = rb.get("%%Collation", status); //This is the bundle that actually contains the collation data
realName = binary.getName();
if(U_SUCCESS(status)) {
UErrorCode intStatus = U_ZERO_ERROR;
constructFromCache(realName, intStatus); // check whether we already have this data in cache
if(U_SUCCESS(intStatus)) {
return realName;
}
int32_t inDataLen = 0;
const uint8_t *inData = binary.getBinary(inDataLen, status); //This got us the real binary data
UMemoryStream *ifs = uprv_mstrm_openBuffer(inData, inDataLen);
if (ifs == 0) {
status = U_FILE_ACCESS_ERROR;
return 0;
}
UErrorCode intStatus = U_ZERO_ERROR;
constructFromCache(realName, intStatus); // check whether we already have this data in cache
if(U_SUCCESS(intStatus)) {
return realName;
}
int32_t inDataLen = 0;
const uint8_t *inData = binary.getBinary(inDataLen, status); //This got us the real binary data
// The streamIn function does the actual work here...
RuleBasedCollatorStreamer::streamIn(this, ifs);
UMemoryStream *ifs = uprv_mstrm_openBuffer(inData, inDataLen);
if (!uprv_mstrm_error(ifs)) {
}
else if (data && data->isBogus()) {
status = U_MEMORY_ALLOCATION_ERROR;
delete data;
data = 0;
} else {
status = U_MISSING_RESOURCE_ERROR;
delete data;
data = 0;
}
if (ifs == 0) {
status = U_FILE_ACCESS_ERROR;
return 0;
}
// We constructed the data when streaming it in, so we own it
dataIsOwned = TRUE;
// The streamIn function does the actual work here...
RuleBasedCollatorStreamer::streamIn(this, ifs);
uprv_mstrm_close(ifs);
addToCache(realName); // add the newly constructed data to cache
return realName;
if (!uprv_mstrm_error(ifs)) {
}
else if (data && data->isBogus()) {
status = U_MEMORY_ALLOCATION_ERROR;
delete data;
data = 0;
} else {
status = U_MISSING_RESOURCE_ERROR;
delete data;
data = 0;
}
// We constructed the data when streaming it in, so we own it
dataIsOwned = TRUE;
uprv_mstrm_close(ifs);
addToCache(realName); // add the newly constructed data to cache
return realName;
} else {
status = U_MISSING_RESOURCE_ERROR;
return 0;
status = U_MISSING_RESOURCE_ERROR;
return 0;
}
} else {
return 0;
@ -890,13 +890,13 @@ RuleBasedCollator::RuleBasedCollator( const Locale& desiredLocale,
intStatus = U_ZERO_ERROR;
constructFromRules(RuleBasedCollator::DEFAULTRULES, intStatus);
if (intStatus == U_ZERO_ERROR) {
status = U_USING_DEFAULT_ERROR;
status = U_USING_DEFAULT_ERROR;
} else {
status = intStatus; // bubble back
status = intStatus; // bubble back
}
if (status == U_MEMORY_ALLOCATION_ERROR) {
return;
return;
}
}
data->realLocaleName = ResourceBundle::kDefaultFilename;
@ -933,11 +933,12 @@ RuleBasedCollator::constructFromFile( const Locale& locale,
delete data;
data = 0;
}
if(tryBinaryFile) {
char *binaryFilePath = createPathName(UnicodeString(u_getDataDirectory(),""),
localeFileName, UnicodeString(kFilenameSuffix,""));
char *binaryFilePath = createPathName(UnicodeString(u_getDataDirectory(),""),
localeFileName,
UnicodeString(kFilenameSuffix,""));
// Try to load up the collation from a binary file first
constructFromFile(binaryFilePath, status);
#ifdef COLLDEBUG
@ -1156,16 +1157,16 @@ RuleBasedCollator::getRules() const
// << endl;
// cerr << "Status " << u_errorName(status) << ", mPattern " << temp.mPattern << endl;
#endif
/* SRL have to add this because we now have the situation where
DEFAULT is loaded from a binary file w/ no rules. */
UErrorCode intStatus = U_ZERO_ERROR;
temp.constructFromRules(RuleBasedCollator::DEFAULTRULES, intStatus);
if(U_SUCCESS(intStatus) && (temp.mPattern != 0))
{
data->ruleTable = temp.getRules();
data->isRuleTableLoaded = TRUE;
}
/* SRL have to add this because we now have the situation where
DEFAULT is loaded from a binary file w/ no rules. */
UErrorCode intStatus = U_ZERO_ERROR;
temp.constructFromRules(RuleBasedCollator::DEFAULTRULES, intStatus);
if(U_SUCCESS(intStatus) && (temp.mPattern != 0))
{
data->ruleTable = temp.getRules();
data->isRuleTableLoaded = TRUE;
}
}
}
@ -1240,7 +1241,7 @@ RuleBasedCollator::compare(const UChar* source,
UBool isFrenchSec = data->isFrenchSec;
uint32_t pSOrder, pTOrder;
while(TRUE)
for(;;)
{
// Get the next collation element in each of the strings, unless
// we've been requested to skip it.
@ -1461,30 +1462,30 @@ RuleBasedCollator::compare(const UChar* source,
// It doesn't work much faster, and the code was broken
// so it's commented out. --srl
// UChar sourceDecomp[1024], targetDecomp[1024];
// int32_t sourceDecompLength = 1024;
// int32_t targetDecompLength = 1024;
// int32_t sourceDecompLength = 1024;
// int32_t targetDecompLength = 1024;
// int8_t comparison;
// Normalizer::EMode decompMode = getDecomposition();
// if (decompMode != Normalizer::NO_OP)
// {
// Normalizer::normalize(source, sourceLength, decompMode,
// 0, sourceDecomp, sourceDecompLength, status);
// Normalizer::normalize(target, targetLength, decompMode,
// 0, targetDecomp, targetDecompLength, status);
// comparison = u_strcmp(sourceDecomp,targetDecomp);
// }
// else
// {
// comparison = u_strcmp(source, target); /* ! */
// }
// Normalizer::EMode decompMode = getDecomposition();
// if (decompMode != Normalizer::NO_OP)
// {
// Normalizer::normalize(source, sourceLength, decompMode,
// 0, sourceDecomp, sourceDecompLength, status);
// Normalizer::normalize(target, targetLength, decompMode,
// 0, targetDecomp, targetDecompLength, status);
// comparison = u_strcmp(sourceDecomp,targetDecomp);
// }
// else
// {
// comparison = u_strcmp(source, target); /* ! */
// }
#else
UnicodeString sourceDecomp, targetDecomp;
UnicodeString sourceDecomp, targetDecomp;
int8_t comparison;
@ -1641,7 +1642,7 @@ RuleBasedCollator::getCollationKey( const UChar* source,
// iterate over the source, counting primary, secondary, and tertiary entries
while((order = getStrengthOrder((NormalizerIterator*)cursor1, status)) !=
CollationElementIterator::NULLORDER)
CollationElementIterator::NULLORDER)
{
int32_t secOrder = CollationElementIterator::secondaryOrder(order);
int32_t terOrder = CollationElementIterator::tertiaryOrder(order);
@ -2782,33 +2783,33 @@ RuleBasedCollator::chopLocale(UnicodeString& localeName)
uint8_t *
RuleBasedCollator::cloneRuleData(int32_t &length, UErrorCode &status)
{
UMemoryStream *memdata = 0;
uint8_t *data = 0;
UMemoryStream *memdata = 0;
uint8_t *data = 0;
if(U_FAILURE(status)) {
return NULL;
}
if(U_FAILURE(status)) {
return NULL;
}
memdata = uprv_mstrm_openNew(0);
memdata = uprv_mstrm_openNew(0);
if (memdata != 0) {
if (memdata != 0) {
RuleBasedCollatorStreamer::streamOut(this, memdata);
}
}
UBool err = uprv_mstrm_error(memdata) == 0;
UBool err = uprv_mstrm_error(memdata) == 0;
data = (uint8_t *)uprv_malloc(memdata->fPos);
if(data == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
uprv_mstrm_close(memdata);
length = 0;
return 0;
status = U_MEMORY_ALLOCATION_ERROR;
uprv_mstrm_close(memdata);
length = 0;
return 0;
} else {
uprv_memcpy(data, memdata->fStart, memdata->fPos);
length = memdata->fPos;
uprv_mstrm_close(memdata);
return data;
uprv_memcpy(data, memdata->fStart, memdata->fPos);
length = memdata->fPos;
uprv_mstrm_close(memdata);
return data;
}
}

View file

@ -97,7 +97,7 @@ void TestConvert()
const char* tmp_mytarget_use;
const char* tmp_consumed;
int flushCount = 0;
int flushCount = 0;
/******************************************************************
Checking Unicode -> ksc
@ -143,7 +143,6 @@ void TestConvert()
const int16_t CodePagesSubstitutionChars[NUM_CODEPAGE] =
{
(int16_t)0xAFFE
};
const char* CodePagesTestFiles[NUM_CODEPAGE] =
@ -327,8 +326,8 @@ void TestConvert()
/*Testing ucnv_convert()*/
{
int32_t targetLimit=0, sourceLimit=0, i=0, targetCapacity=0;
const char source[]={ (char)0x00, (char)0x04, (char)0x05, (char)0x06, (char)0xa2, (char)0xb4, (char)0x00};
const char expectedTarget[]={ (char)0x00, (char)0x37, (char)0x2d, (char)0x2e, (char)0x0e, (char)0x49, (char)0x62, (char)0x0f, (char)0x00};
const uint8_t source[]={ 0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
const uint8_t expectedTarget[]={ 0x00, 0x37, 0x2d, 0x2e, 0x0e, 0x49, 0x62, 0x0f, 0x00};
char *target;
sourceLimit=sizeof(source)/sizeof(source[0]);
err=U_ZERO_ERROR;
@ -376,46 +375,46 @@ void TestConvert()
}
/*Testing ucnv_open()*/
/* Note: These converters have been chosen because they do NOT
encode the Latin characters (U+0041, ...), and therefore are
highly unlikely to be chosen as system default codepages */
/* Note: These converters have been chosen because they do NOT
encode the Latin characters (U+0041, ...), and therefore are
highly unlikely to be chosen as system default codepages */
someConverters[0] = ucnv_open("ibm-1038", &err);
if (U_FAILURE(err)) { log_err("FAILURE! %s\n", myErrorName(err)); }
someConverters[1] = ucnv_open("ibm-1038", &err);
if (U_FAILURE(err)) { log_err("FAILURE! %s\n", myErrorName(err)); }
someConverters[2] = ucnv_open("ibm-1038", &err);
if (U_FAILURE(err)) { log_err("FAILURE! %s\n", myErrorName(err)); }
someConverters[3] = ucnv_open("ibm-834", &err);
if (U_FAILURE(err)) { log_err("FAILURE! %s\n", myErrorName(err)); }
someConverters[4] = ucnv_open("ibm-941", &err);
if (U_FAILURE(err)) { log_err("FAILURE! %s\n", myErrorName(err));}
/* Testing ucnv_flushCache() */
log_verbose("\n---Testing ucnv_flushCache...\n");
if ((flushCount=ucnv_flushCache())==0)
log_verbose("Flush cache ok\n");
else
log_err("Flush Cache failed [line %d], expect 0 got %d \n", __LINE__, flushCount);
/*testing ucnv_close() and ucnv_flushCache() */
ucnv_close(someConverters[0]);
ucnv_close(someConverters[0]);
ucnv_close(someConverters[1]);
ucnv_close(someConverters[2]);
ucnv_close(someConverters[3]);
if (j=(flushCount=ucnv_flushCache())==2)
if (j=(flushCount=ucnv_flushCache())==2)
log_verbose("Flush cache ok\n"); /*because first, second and third are same */
else
log_err("Flush Cache failed line %d, got %d expected 2 or there is an error in ucnv_close()\n",
__LINE__,
flushCount);
__LINE__,
flushCount);
ucnv_close(someConverters[4]);
if ( (flushCount=ucnv_flushCache())==1)
log_verbose("Flush cache ok\n");
@ -441,8 +440,8 @@ void TestConvert()
someConverters[3] = ucnv_openCCSID(949,UCNV_IBM,&err);
ucnv_close(ucnv_openCCSID(1051, UCNV_IBM, &err)); /* test for j350; ucnv_close(NULL) is safe */
if (U_FAILURE(err)){ log_err("FAILURE! %s\n", myErrorName(err));}
/* Testing ucnv_getName()*/
/* Testing ucnv_getName()*/
/*default code page */
ucnv_getName(someConverters[0], &err);
if(U_FAILURE(err)) {
@ -461,7 +460,7 @@ void TestConvert()
{
const char* defaultName=ucnv_getDefaultName();
log_verbose("getDefaultName returned %s\n", defaultName);
/*change the default name by setting it */
ucnv_setDefaultName("changed");
if(strcmp(ucnv_getDefaultName(), "changed")==0)
@ -471,7 +470,7 @@ void TestConvert()
/*set the default name back*/
ucnv_setDefaultName(defaultName);
}
ucnv_close(someConverters[0]);
ucnv_close(someConverters[1]);
ucnv_close(someConverters[2]);
@ -489,7 +488,7 @@ void TestConvert()
if (!ucs_file_in)
{
log_err("Couldn't open the Unicode file [%s]... Exiting...\n", ucs_file_name);
return;
return;
}
/*Creates a converter and testing ucnv_openCCSID(u_int code_page, platform, errstatus*/
@ -500,10 +499,10 @@ void TestConvert()
if (!myConverter || U_FAILURE(err))
{
log_err("Error creating the convertor \n");
return;
return;
}
/*testing for ucnv_getName() */
log_verbose("Testing ucnv_getName()...\n");
ucnv_getName(myConverter, &err);
@ -529,9 +528,9 @@ void TestConvert()
err=U_ZERO_ERROR;
}
/*Tests ucnv_getMaxCharSize() and ucnv_getMinCharSize()*/
log_verbose("Testing ucnv_getMaxCharSize()...\n");
if (ucnv_getMaxCharSize(myConverter)==CodePagesMaxChars[codepage_index])
log_verbose("Max byte per character OK\n");
@ -543,20 +542,20 @@ void TestConvert()
log_verbose("Min byte per character OK\n");
else
log_err("Min byte per character failed\n");
/*Testing for ucnv_getSubstChars() and ucnv_setSubstChars()*/
log_verbose("\n---Testing ucnv_getSubstChars...\n");
ii=4;
ucnv_getSubstChars(myConverter, myptr, &ii, &err);
for(x=0;x<ii;x++)
rest = (int16_t)(((unsigned char)rest << 8) + (unsigned char)myptr[x]);
if (rest==CodePagesSubstitutionChars[codepage_index])
log_verbose("Substitution character ok\n");
else
log_err("Substitution character failed.\n");
log_verbose("\n---Testing ucnv_setSubstChars RoundTrip Test ...\n");
ucnv_setSubstChars(myConverter, myptr, ii, &err);
if (U_FAILURE(err))
@ -564,12 +563,12 @@ void TestConvert()
ucnv_getSubstChars(myConverter,save, &ii, &err);
if (U_FAILURE(err))
{ log_err("FAILURE! %s\n", myErrorName(err)); }
if (strncmp(save, myptr, ii))
log_err("Saved substitution character failed\n");
else
log_verbose("Saved substitution character ok\n");
/*Testing for ucnv_getSubstChars() and ucnv_setSubstChars() with error conditions*/
log_verbose("\n---Testing ucnv_getSubstChars.. with len < minBytesPerChar\n");
ii=1;
@ -604,7 +603,7 @@ void TestConvert()
}
err=U_ZERO_ERROR;
/*------*/
/*resetState ucnv_reset()*/
log_verbose("\n---Testing ucnv_reset()..\n");
ucnv_reset(myConverter);
@ -767,7 +766,7 @@ void TestConvert()
if (BOM!=0xFEFF && BOM!=0xFFFE)
{
log_err("File Missing BOM...Bailing!\n");
return;
return;
}

View file

@ -79,7 +79,7 @@ void TestNumberFormat()
log_verbose("\nTesting unum_open(currency,NULL,status)\n");
style=UNUM_CURRENCY;
/* Can't hardcode the result to assume the default locale is "en_US". */
cur_def=unum_open(style, "en_US", &status);
cur_def=unum_open(style, "en_US", &status);
if(U_FAILURE(status))
log_err("Error: could not create NumberFormat using \n unum_open(currency, NULL, &status) %s\n",
myErrorName(status) );
@ -115,9 +115,9 @@ void TestNumberFormat()
if(U_FAILURE(status))
log_err("Error: could not clone unum_clone(def, &status): %s\n", myErrorName(status));
else
{
{
log_verbose("unum_clone() successful\n");
}
}
/*Testing unum_getAvailable() and unum_countAvailable()*/
log_verbose("\nTesting getAvailableLocales and countAvailable()\n");
@ -129,16 +129,15 @@ void TestNumberFormat()
log_verbose("The no: of locales where number formattting is applicable is %d\n", numlocales);
}
for(i=0;i<numlocales;i++)
{
{
log_verbose("%s\n", unum_getAvailable(i));
if (unum_getAvailable(i) == 0)
log_err("No locale for which number formatting patterns are applicable\n");
else
log_verbose("A locale %s for which number formatting patterns are applicable\n",unum_getAvailable(i));
}
if (unum_getAvailable(i) == 0)
log_err("No locale for which number formatting patterns are applicable\n");
else
log_verbose("A locale %s for which number formatting patterns are applicable\n",unum_getAvailable(i));
}
/*Testing unum_format() and unum_formatdouble()*/
temp1=(UChar*)malloc(sizeof(UChar) * 25);
u_uastrcpy(temp1, "$100,000,000.00");
@ -189,11 +188,11 @@ free(result);
/* Testing unum_parse() and unum_parseDouble() */
log_verbose("\nTesting unum_parseDouble()\n");
for (i = 0; i < 100000; i++)
{
/* for (i = 0; i < 100000; i++)
{*/
parsepos=0;
d1=unum_parseDouble(cur_def, result, u_strlen(result), &parsepos, &status);
}
/* }*/
if(U_FAILURE(status))
{
log_err("parse failed. The error is : %s\n", myErrorName(status));
@ -234,11 +233,11 @@ free(result);
log_verbose("\nTesting unum_parse()\n");
for (i = 0; i < 100000; i++)
{
/* for (i = 0; i < 100000; i++)
{*/
parsepos=0;
l1=unum_parse(per_fr, result, u_strlen(result), &parsepos, &status);
}
/* }*/
if(U_FAILURE(status))
{
log_err("parse failed. The error is : %s\n", myErrorName(status));

View file

@ -91,14 +91,14 @@ void TestCharLength()
int16_t i;
UBool multiple;
for(i=0; i<sizeof(codepoint)/sizeof(codepoint[0]); i=i+2){
for(i=0; i<sizeof(codepoint)/sizeof(codepoint[0]); i=(int16_t)(i+2)){
UChar32 c=codepoint[i+1];
if(UTF8_CHAR_LENGTH(c) != (uint16_t)codepoint[i]){
log_err("The no: of code units for %lx:- Expected: %d Got: %d\n", c, codepoint[i], UTF8_CHAR_LENGTH(c));
}else{
log_verbose("The no: of code units for %lx is %d\n",c, UTF8_CHAR_LENGTH(c) );
}
multiple=codepoint[i] == 1 ? FALSE : TRUE;
multiple=(UBool)(codepoint[i] == 1 ? FALSE : TRUE);
if(UTF8_NEED_MULTIPLE_UCHAR(c) != multiple){
log_err("ERROR: UTF8_NEED_MULTIPLE_UCHAR failed for %lx\n", c);
}
@ -164,7 +164,7 @@ void TestGetChar()
log_err("ERROR: UTF8_GET_CHAR_SAFE(strict) failed for offset=%ld. Expected:%lx Got:%lx\n", offset, result[i+2], c);
}
i=i+3;
i=(uint16_t)(i+3);
}
}
@ -213,8 +213,8 @@ void TestNextPrevChar(){
};
UChar32 c=0x0000;
uint32_t i=0;
uint32_t offset=0, setOffset=0;
@ -539,9 +539,9 @@ void TestAppendChar(){
uint16_t i, count=0;
uint8_t str[12];
uint32_t offset;
UChar32 c=0;
/* UChar32 c=0;*/
uint16_t size=sizeof(s)/sizeof(s[0]);
for(i=0; i<sizeof(test)/sizeof(test[0]); i=i+2){
for(i=0; i<sizeof(test)/sizeof(test[0]); i=(uint16_t)(i+2)){
uprv_memcpy(str, s, size);
offset=test[i];
if(count<13){

View file

@ -92,8 +92,8 @@ TimeZoneBoundaryTest::findDaylightBoundaryUsingDate(UDate d, const char* startMo
UDate maxdelta = max - expectedBoundary;
if (mindelta >= 0 &&
mindelta <= INTERVAL &&
mindelta >= 0 &&
mindelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
maxdelta >= 0 &&
maxdelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
else errln(UnicodeString("FAIL: Expected boundary at ") + expectedBoundary);
}
@ -143,8 +143,8 @@ TimeZoneBoundaryTest::findDaylightBoundaryUsingTimeZone(UDate d, UBool startsInD
UDate maxdelta = max - expectedBoundary;
if (mindelta >= 0 &&
mindelta <= INTERVAL &&
mindelta >= 0 &&
mindelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
maxdelta >= 0 &&
maxdelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
else errln(UnicodeString("FAIL: Expected boundary at ") + expectedBoundary);
}
@ -215,7 +215,8 @@ TimeZoneBoundaryTest::verifyDST(UDate d, TimeZone* time_zone, UBool expUseDaylig
void
TimeZoneBoundaryTest::TestBoundaries()
{
if (TRUE) {
#if 1
{
logln("--- Test a ---");
UDate d = date(97, Calendar::APRIL, 6);
TimeZone *z = TimeZone::createTimeZone("PST");
@ -226,7 +227,9 @@ TimeZoneBoundaryTest::TestBoundaries()
}
delete z;
}
if (TRUE) {
#endif
#if 1
{
logln("--- Test b ---");
TimeZone *tz;
TimeZone::setDefault(*(tz = TimeZone::createTimeZone("PST")));
@ -236,7 +239,9 @@ TimeZoneBoundaryTest::TestBoundaries()
logln("========================================");
findDaylightBoundaryUsingDate(date(97, 6, 1), "PDT", PST_1997_END);
}
if (TRUE) {
#endif
#if 1
{
logln("--- Test c ---");
logln("========================================");
TimeZone* z = TimeZone::createTimeZone("Australia/Adelaide");
@ -245,14 +250,18 @@ TimeZoneBoundaryTest::TestBoundaries()
findDaylightBoundaryUsingTimeZone(date(97, 6, 1), FALSE, 877797000000.0, z);
delete z;
}
if (TRUE) {
#endif
#if 1
{
logln("--- Test d ---");
logln("========================================");
findDaylightBoundaryUsingTimeZone(date(97, 0, 1), FALSE, PST_1997_BEG);
logln("========================================");
findDaylightBoundaryUsingTimeZone(date(97, 6, 1), TRUE, PST_1997_END);
}
if (FALSE) {
#endif
#if 0
{
logln("--- Test e ---");
TimeZone *z = TimeZone::createDefault();
logln(UnicodeString("") + z->getOffset(1, 97, 3, 4, 6, 0) + " " + date(97, 3, 4));
@ -261,6 +270,7 @@ TimeZoneBoundaryTest::TestBoundaries()
logln(UnicodeString("") + z->getOffset(1, 97, 3, 7, 2, 0) + " " + date(97, 3, 7));
delete z;
}
#endif
}
// -------------------------------------
@ -293,8 +303,8 @@ TimeZoneBoundaryTest::testUsingBinarySearch(SimpleTimeZone* tz, UDate d, UDate e
UDate maxdelta = max - expectedBoundary;
if (mindelta >= 0 &&
mindelta <= INTERVAL &&
mindelta >= 0 &&
mindelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
maxdelta >= 0 &&
maxdelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
else errln(UnicodeString("FAIL: Expected boundary at ") + expectedBoundary);
}
@ -306,8 +316,9 @@ TimeZoneBoundaryTest::testUsingBinarySearch(SimpleTimeZone* tz, UDate d, UDate e
void
TimeZoneBoundaryTest::TestNewRules()
{
UErrorCode status = U_ZERO_ERROR;
if (TRUE) {
#if 1
{
UErrorCode status = U_ZERO_ERROR;
SimpleTimeZone *tz;
logln("-----------------------------------------------------------------");
logln("Aug 2ndTues .. Mar 15");
@ -326,6 +337,7 @@ TimeZoneBoundaryTest::TestNewRules()
testUsingBinarySearch(tz, date(97, 6, 1), 874227600000.0);
delete tz;
}
#endif
}
// -------------------------------------