ICU-900 Fixed some compiler warnings.

X-SVN-Rev: 8681
This commit is contained in:
George Rhoten 2002-05-23 22:10:23 +00:00
parent d04898abdb
commit 08df62745a
14 changed files with 78 additions and 68 deletions

View file

@ -250,7 +250,7 @@ static int printConverters(const char *pname, const char *lookfor,
if (U_FAILURE(err)) {
printf("%s", name);
UnicodeString str(name, uprv_strlen(name) + 1);
UnicodeString str(name, (int32_t)(uprv_strlen(name) + 1));
putchar('\t');
u_wmsg(stderr, "cantGetAliases", str.getBuffer(),
u_wmsg_errorName(err));
@ -264,7 +264,7 @@ static int printConverters(const char *pname, const char *lookfor,
const char *alias = ucnv_getAlias(name, a, &err);
if (U_FAILURE(err)) {
UnicodeString str(name, uprv_strlen(name) + 1);
UnicodeString str(name, (int32_t)(uprv_strlen(name) + 1));
putchar('\t');
u_wmsg(stderr, "cantGetAliases", str.getBuffer(),
u_wmsg_errorName(err));
@ -506,7 +506,7 @@ static UBool convertFile(const char *pname,
convfrom = ucnv_open(fromcpage, &err);
if (U_FAILURE(err)) {
UnicodeString str(fromcpage, uprv_strlen(fromcpage) + 1);
UnicodeString str(fromcpage, (int32_t)(uprv_strlen(fromcpage) + 1));
initMsg(pname);
u_wmsg(stderr, "cantOpenFromCodeset", str.getBuffer(),
u_wmsg_errorName(err));
@ -521,7 +521,7 @@ static UBool convertFile(const char *pname,
convto = ucnv_open(tocpage, &err);
if (U_FAILURE(err)) {
UnicodeString str(tocpage, uprv_strlen(tocpage) + 1);
UnicodeString str(tocpage, (int32_t)(uprv_strlen(tocpage) + 1));
initMsg(pname);
u_wmsg(stderr, "cantOpenToCodeset", str.getBuffer(),
u_wmsg_errorName(err));
@ -578,12 +578,12 @@ static UBool convertFile(const char *pname,
ucnv_toUnicode(convfrom, &unibufp, unibufp + bufsz, &cbufp,
cbufp + rd, fromoffsets, flush, &err);
infoffset += cbufp - buf;
infoffset += (uint32_t)(cbufp - buf);
if (U_FAILURE(err)) {
char pos[32];
sprintf(pos, "%u", infoffset - 1);
UnicodeString str(pos, uprv_strlen(pos) + 1);
UnicodeString str(pos, (int32_t)(uprv_strlen(pos) + 1));
initMsg(pname);
u_wmsg(stderr, "problemCvtToU", str.getBuffer(), u_wmsg_errorName(err));
willexit = 1;
@ -595,7 +595,7 @@ static UBool convertFile(const char *pname,
if (flush && !willexit && cbufp != (buf + rd)) {
char pos[32];
sprintf(pos, "%u", infoffset);
UnicodeString str(pos, uprv_strlen(pos) + 1);
UnicodeString str(pos, (uprv_strlen(pos) + 1));
initMsg(pname);
u_wmsg(stderr, "premEndInput", str.getBuffer());
willexit = 1;
@ -604,9 +604,9 @@ static UBool convertFile(const char *pname,
// Prepare to transliterate and convert.
if (t) {
u.setTo(unibuf, unibufp - unibuf); // Copy into string.
u.setTo(unibuf, (int32_t)(unibufp - unibuf)); // Copy into string.
} else {
u.setTo(unibuf, unibufp - unibuf, bufsz); // Share the buffer.
u.setTo(unibuf, (int32_t)(unibufp - unibuf), (int32_t)(bufsz)); // Share the buffer.
}
// Transliterate if needed.
@ -641,17 +641,17 @@ static UBool convertFile(const char *pname,
char pos[32];
uint32_t erroffset =
dataOffset(bufp - buf - 1, fromoffsets, bufsz, tooffsets, tobufsz);
int32_t ferroffset = infoffset - (unibufp - unibufu) + erroffset;
dataOffset((int32_t)(bufp - buf - 1), fromoffsets, (int32_t)(bufsz), tooffsets, (int32_t)(tobufsz));
int32_t ferroffset = (int32_t)(infoffset - (unibufp - unibufu) + erroffset);
if ((int32_t) ferroffset < 0) {
ferroffset = outfoffset + (bufp - buf);
ferroffset = (int32_t)(outfoffset + (bufp - buf));
errtag = "problemCvtFromUOut";
} else {
errtag = "problemCvtFromU";
}
sprintf(pos, "%u", ferroffset);
UnicodeString str(pos, uprv_strlen(pos) + 1);
UnicodeString str(pos, (int32_t)(uprv_strlen(pos) + 1));
initMsg(pname);
u_wmsg(stderr, errtag, str.getBuffer(),
u_wmsg_errorName(err));
@ -663,7 +663,7 @@ static UBool convertFile(const char *pname,
if (flush && !willexit && unibufbp != (unibufu + (size_t) (unibufp - unibufu))) {
char pos[32];
sprintf(pos, "%u", infoffset);
UnicodeString str(pos, uprv_strlen(pos) + 1);
UnicodeString str(pos, (int32_t)(uprv_strlen(pos) + 1));
initMsg(pname);
u_wmsg(stderr, "premEnd", str.getBuffer());
willexit = 1;
@ -673,7 +673,7 @@ static UBool convertFile(const char *pname,
rd = (size_t) (bufp - buf);
outfoffset += (wr = fwrite(buf, 1, rd, outfile));
outfoffset += (int32_t)(wr = fwrite(buf, 1, rd, outfile));
if (wr != rd) {
UnicodeString str(strerror(errno), "");
initMsg(pname);
@ -684,7 +684,7 @@ static UBool convertFile(const char *pname,
if (willexit) {
goto error_exit;
}
} while ((ulen -= bufsz) > 0);
} while ((ulen -= (int32_t)(bufsz)) > 0);
} while (!flush); // Stop when we have flushed the
// converters (this means that it's
// the end of output)
@ -726,7 +726,7 @@ static void usage(const char *pname, int ecode) {
msg =
ures_getStringByKey(gBundle, ecode ? "lcUsageWord" : "ucUsageWord",
&msgLen, &err);
UnicodeString upname(pname, uprv_strlen(pname) + 1);
UnicodeString upname(pname, (int32_t)(uprv_strlen(pname) + 1));
UnicodeString mname(msg, msgLen + 1);
res = u_wmsg(fp, "usage", mname.getBuffer(), upname.getBuffer());

View file

@ -230,7 +230,7 @@ U_CAPI const UChar *u_wmsg_errorName(UErrorCode err)
textMsg = error;
}
msg = (UChar*)malloc((strlen(textMsg)+1)*sizeof(msg[0]));
u_charsToUChars(textMsg, msg, strlen(textMsg)+1);
u_charsToUChars(textMsg, msg, (int32_t)(strlen(textMsg)+1));
}
if(err>=0)

View file

@ -32,7 +32,7 @@ u_locbund_new(const char *loc)
if(result == 0)
return 0;
len = (loc == 0 ? strlen(uloc_getDefault()) : strlen(loc));
len = (int32_t)(loc == 0 ? strlen(uloc_getDefault()) : strlen(loc));
result->fLocale = (char*) uprv_malloc(len + 1);
if(result->fLocale == 0) {
uprv_free(result);

View file

@ -325,7 +325,7 @@ u_vsnprintf(UChar *buffer,
/* convert from the default codepage to Unicode */
pattern = ufmt_defaultCPToUnicode(patternSpecification,
strlen(patternSpecification));
(int32_t)strlen(patternSpecification));
if(pattern == 0) {
return 0;
}
@ -473,7 +473,7 @@ u_sprintf_string_handler(u_localized_string *output,
/* convert from the default codepage to Unicode */
if (arg)
s = ufmt_defaultCPToUnicode(arg, strlen(arg));
s = ufmt_defaultCPToUnicode(arg, (int32_t)strlen(arg));
else {
s = gNullStr;
}

View file

@ -276,7 +276,7 @@ u_vfprintf( UFILE *f,
/* convert from the default codepage to Unicode */
pattern = ufmt_defaultCPToUnicode(patternSpecification,
strlen(patternSpecification));
(int32_t)strlen(patternSpecification));
if(pattern == 0) {
return 0;
}
@ -380,7 +380,7 @@ u_printf_string_handler(UFILE *stream,
/* convert from the default codepage to Unicode */
if (arg) {
s = ufmt_defaultCPToUnicode(arg, strlen(arg));
s = ufmt_defaultCPToUnicode(arg, (int32_t)strlen(arg));
}
else {
s = gNullStr;

View file

@ -290,14 +290,16 @@ static void TestBreakIteratorSafeClone(void)
{
log_err("FAIL: Iterator can't be cloned with run-time size\n");
}
if (brk) ubrk_close(brk);
if (brk)
ubrk_close(brk);
/* size one byte too small - should allocate & let us know */
--bufferSize;
if (0 == (brk = ubrk_safeClone(someIterators[i], 0, &bufferSize, &status)) || status != U_SAFECLONE_ALLOCATED_ERROR)
{
log_err("FAIL: Cloned Iterator failed to deal correctly with too-small buffer size\n");
}
if (brk) ubrk_close(brk);
if (brk)
ubrk_close(brk);
status = U_ZERO_ERROR;
bufferSize = U_BRK_SAFECLONE_BUFFERSIZE;
@ -306,14 +308,15 @@ static void TestBreakIteratorSafeClone(void)
{
log_err("FAIL: Cloned Iterator failed to deal correctly with null buffer pointer\n");
}
if (brk) ubrk_close(brk);
if (brk)
ubrk_close(brk);
status = U_ZERO_ERROR;
/* Mis-aligned buffer pointer. */
{
char stackBuf[U_BRK_SAFECLONE_BUFFERSIZE+sizeof(void *)];
void *p;
int offset;
int32_t offset;
brk = ubrk_safeClone(someIterators[i], &stackBuf[1], &bufferSize, &status);
if (U_FAILURE(status) || brk == 0) {
@ -322,14 +325,15 @@ static void TestBreakIteratorSafeClone(void)
if (status == U_SAFECLONE_ALLOCATED_ERROR) {
log_err("FAIL: Cloned Iterator allocated when using a mis-aligned buffer.\n");
}
offset = (char *)&p-(char*)brk;
offset = (int32_t)((char *)&p-(char*)brk);
if (offset < 0) {
offset = -offset;
}
if (offset % sizeof(void *) != 0) {
log_err("FAIL: Cloned Iterator failed to align correctly with misaligned buffer pointer\n");
}
if (brk) ubrk_close(brk);
if (brk)
ubrk_close(brk);
}

View file

@ -74,41 +74,47 @@ static int strncmp_nullcheck( const char* s1,
const char* s2,
int n )
{
if ( ( (int)strlen(s2)>=n) && s2[n] != 0 ) return 3; /* null check fails */
else return strncmp ( s1, s2, n );
if (((int)strlen(s2) >= n) && s2[n] != 0) {
return 3; /* null check fails */
}
else {
return strncmp ( s1, s2, n );
}
}
static void getNextLevel( const char* name,
int* nameLen,
const char** nextName )
{
/* Get the next component of the name */
*nextName = strchr(name, TEST_SEPARATOR);
/* Get the next component of the name */
*nextName = strchr(name, TEST_SEPARATOR);
if( *nextName != 0 )
if( *nextName != 0 )
{
char n[255];
*nameLen = (*nextName) - name;
(*nextName)++; /* skip '/' */
strncpy(n, name, *nameLen);
n[*nameLen] = 0;
/* printf("->%s-< [%d] -> [%s]\n", name, *nameLen, *nextName);*/
char n[255];
*nameLen = (int)((*nextName) - name);
(*nextName)++; /* skip '/' */
strncpy(n, name, *nameLen);
n[*nameLen] = 0;
/*printf("->%s-< [%d] -> [%s]\n", name, *nameLen, *nextName);*/
}
else {
*nameLen = (int)strlen(name);
}
else *nameLen = strlen(name);
}
static TestNode *createTestNode( )
{
TestNode *newNode;
TestNode *newNode;
newNode = (TestNode*)malloc ( sizeof ( TestNode ) );
newNode = (TestNode*)malloc ( sizeof ( TestNode ) );
newNode->name[0] = '\0';
newNode->test = NULL;
newNode->sibling = NULL;
newNode->child = NULL;
newNode->name[0] = '\0';
newNode->test = NULL;
newNode->sibling = NULL;
newNode->child = NULL;
return newNode;
return newNode;
}
void cleanUpTestTree(TestNode *tn) {
@ -124,8 +130,8 @@ void cleanUpTestTree(TestNode *tn) {
void addTest ( TestNode** root,
TestFunctionPtr test,
const char* name )
TestFunctionPtr test,
const char* name )
{
TestNode *newNode;

View file

@ -411,7 +411,7 @@ addFile(const char *filename, UBool sourceTOC, UBool verbose) {
FileStream *file;
/* store the pathname */
length=uprv_strlen(filename)+1;
length = (uint32_t)(uprv_strlen(filename) + 1);
s=allocString(length);
uprv_memcpy(s, filename, length);
files[fileCount].pathname=s;
@ -419,7 +419,7 @@ addFile(const char *filename, UBool sourceTOC, UBool verbose) {
/* get the basename */
s=(char *)findBasename(s);
files[fileCount].basename=s;
length=uprv_strlen(s)+1;
length = (uint32_t)(uprv_strlen(s) + 1);
files[fileCount].basenameLength=length;
basenameTotal+=length;
@ -451,7 +451,7 @@ addFile(const char *filename, UBool sourceTOC, UBool verbose) {
/* get and store the basename */
filename=findBasename(filename);
length=uprv_strlen(filename)+1;
length = (uint32_t)(uprv_strlen(filename) + 1);
s=allocString(length);
uprv_memcpy(s, filename, length);
files[fileCount].basename=s;

View file

@ -871,7 +871,7 @@ generateData(const char *dataDir) {
groupWords[0]=(uint16_t)lines[i].code;
/* offset */
offset=lines[i].s-stringStore;
offset = (uint32_t)(lines[i].s - stringStore);
groupWords[1]=(uint16_t)(offset>>16);
groupWords[2]=(uint16_t)(offset);
udata_writeBlock(pData, groupWords, 6);
@ -1174,7 +1174,7 @@ addToken(uint8_t *s, int16_t length) {
uprv_memcpy(stringStart, s, length);
stringStart[length]=0;
return stringStart-stringStore;
return (uint32_t)(stringStart - stringStore);
}
static void

View file

@ -283,7 +283,7 @@ unicodeDataLineFn(void *context,
/* ignore First and Last entries for ranges */
if( *fields[1][0]=='<' &&
(length=(fields[1][1]-fields[1][0]))>=9 &&
(length=(int32_t)(fields[1][1]-fields[1][0]))>=9 &&
(0==uprv_memcmp(", First>", fields[1][1]-8, 8) || 0==uprv_memcmp(", Last>", fields[1][1]-7, 7))
) {
return;

View file

@ -150,7 +150,7 @@ upvec_setValue(uint32_t *pv,
}
/* count the number of row cells to move after the last row, and move them */
count=(pv+UPVEC_HEADER_LENGTH+rows*columns)-(lastRow+columns);
count = (int32_t)((pv+UPVEC_HEADER_LENGTH+rows*columns)-(lastRow+columns));
if(count>0) {
uprv_memmove(
lastRow+(1+splitFirstRow+splitLastRow)*columns,
@ -162,7 +162,7 @@ upvec_setValue(uint32_t *pv,
/* split the first row, and move the firstRow pointer to the second part */
if(splitFirstRow) {
/* copy all affected rows up one and move the lastRow pointer */
count=(lastRow-firstRow)+columns;
count = (int32_t)((lastRow-firstRow)+columns);
uprv_memmove(firstRow+columns, firstRow, count*4);
lastRow+=columns;

View file

@ -107,13 +107,13 @@ ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* err){
UChar* target=NULL;
const char* source=NULL;
char cbuf[MAX_IN_BUF] = {'\0'};
int numRead=0;
int offset=0;
int32_t numRead=0;
int32_t offset=0;
const char* sourceLimit =NULL;
pTarget = buf->buffer;
/* check if we arrived here without exhausting the buffer*/
if(buf->currentPos<buf->bufLimit){
offset= buf->bufLimit-buf->currentPos;
offset = (int32_t)(buf->bufLimit-buf->currentPos);
memmove(buf->buffer,buf->currentPos,offset* sizeof(UChar));
}
@ -171,7 +171,7 @@ ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* err){
ucnv_getInvalidChars(buf->conv,context,&len,err);
context[len]= 0 ; /* null terminate the buffer */
pos = source-cbuf-len;
pos = (int32_t)(source - cbuf - len);
/* for pre-context */
start = (pos <=CONTEXT_LEN)? 0 : (pos - (CONTEXT_LEN-1));
@ -183,7 +183,7 @@ ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* err){
/* for post-context */
start = pos+len;
stop = ((pos+CONTEXT_LEN)<= (sourceLimit-cbuf) )? (pos+(CONTEXT_LEN-1)) : (sourceLimit-cbuf);
stop = (int32_t)(((pos+CONTEXT_LEN)<= (sourceLimit-cbuf) )? (pos+(CONTEXT_LEN-1)) : (sourceLimit-cbuf));
memcpy(postContext,source,stop-start);
/* null terminate the buffer */
@ -219,7 +219,7 @@ ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* err){
(UBool)(buf->remaining==0),err);
}
numRead= target-pTarget;
numRead = (int32_t)(target - pTarget);
#if DEBUG
@ -291,7 +291,7 @@ ucbuf_getcx(UCHARBUF* buf,UErrorCode* err) {
}
/* Determine the amount of data in the buffer */
length = buf->bufLimit-buf->currentPos;
length = (int32_t)(buf->bufLimit - buf->currentPos);
/* The longest escape sequence is \Uhhhhhhhh; make sure
we have at least that many characters */
@ -299,7 +299,7 @@ ucbuf_getcx(UCHARBUF* buf,UErrorCode* err) {
/* fill the buffer */
ucbuf_fillucbuf(buf,err);
length = buf->bufLimit-buf->buffer;
length = (int32_t)(buf->bufLimit - buf->buffer);
}
/* Process the escape */

View file

@ -188,7 +188,7 @@ U_CAPI void U_EXPORT2
udata_writeString(UNewDataMemory *pData, const char *s, int32_t length) {
if(pData!=NULL && pData->file!=NULL) {
if(length==-1) {
length=uprv_strlen(s);
length=(int32_t)uprv_strlen(s);
}
if(length>0) {
T_FileStream_write(pData->file, s, length);

View file

@ -62,7 +62,7 @@ u_parseDelimitedFile(const char *filename, char delimiter,
}
while(T_FileStream_readLine(file, line, sizeof(line))!=NULL) {
length=uprv_strlen(line);
length=(int32_t)uprv_strlen(line);
/* remove trailing newline characters */
while(length>0 && (line[length-1]=='\r' || line[length-1]=='\n')) {