From 287852e706f0ddf293a21e652099163e7e7fd0d1 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Thu, 4 Nov 2004 21:51:57 +0000 Subject: [PATCH] ICU-3905 Fix some compiler warnings X-SVN-Rev: 16754 --- icu4c/source/common/ucnvdisp.c | 2 +- icu4c/source/common/udata.c | 73 +++++++++++++++--------------- icu4c/source/common/ustrenum.cpp | 4 +- icu4c/source/tools/gencmn/gencmn.c | 62 ++++++++++++------------- 4 files changed, 70 insertions(+), 71 deletions(-) diff --git a/icu4c/source/common/ucnvdisp.c b/icu4c/source/common/ucnvdisp.c index ffcc332123..07196b3e79 100644 --- a/icu4c/source/common/ucnvdisp.c +++ b/icu4c/source/common/ucnvdisp.c @@ -65,7 +65,7 @@ ucnv_getDisplayName(const UConverter *cnv, } else { /* convert the internal name into a Unicode string */ *pErrorCode=U_ZERO_ERROR; - length=uprv_strlen(cnv->sharedData->staticData->name); + length=(int32_t)uprv_strlen(cnv->sharedData->staticData->name); u_charsToUChars(cnv->sharedData->staticData->name, displayName, uprv_min(length, displayNameCapacity)); } return u_terminateUChars(displayName, displayNameCapacity, length, pErrorCode); diff --git a/icu4c/source/common/udata.c b/icu4c/source/common/udata.c index 27b65e1dfd..35936500a2 100644 --- a/icu4c/source/common/udata.c +++ b/icu4c/source/common/udata.c @@ -358,7 +358,7 @@ static void TinyString_init(TinyString *This) { static void TinyString_append(TinyString *This, const char *what) { int32_t newLen; - newLen = This->length + uprv_strlen(what); + newLen = This->length + (int32_t)uprv_strlen(what); if (newLen >= This->fCapacity) { int32_t newCapacity = newLen * 2; char *newBuf = (char *)uprv_malloc(newCapacity+1); @@ -481,7 +481,7 @@ static void udata_pathiter_init(UDataPathIterator *iter, const char *path, const } iter->packageStub[0] = U_FILE_SEP_CHAR; uprv_strcpy(iter->packageStub+1, pkg); - iter->packageStubLen = uprv_strlen(iter->packageStub); + iter->packageStubLen = (int32_t)uprv_strlen(iter->packageStub); #ifdef UDATA_DEBUG fprintf(stderr, "STUB=%s [%d]\n", iter->packageStub, iter->packageStubLen); @@ -490,7 +490,7 @@ static void udata_pathiter_init(UDataPathIterator *iter, const char *path, const /** Item **/ iter->basename = findBasename(item); - iter->basenameLen = uprv_strlen(iter->basename); + iter->basenameLen = (int32_t)uprv_strlen(iter->basename); if(iter->basename == NULL) { iter->nextPath = NULL; @@ -503,7 +503,7 @@ static void udata_pathiter_init(UDataPathIterator *iter, const char *path, const iter->itemPath[0] = 0; iter->nextPath = iter->path; } else { - int32_t itemPathLen = iter->basename-item; + int32_t itemPathLen = (int32_t)(iter->basename-item); if (itemPathLen >= U_DATA_PATHITER_BUFSIZ) { char *t = (char *)uprv_malloc(itemPathLen+1); if (t != NULL) { @@ -534,7 +534,7 @@ static void udata_pathiter_init(UDataPathIterator *iter, const char *path, const * Get an upper bound of possible string size, and make sure that the buffer * is big enough (sum of length of each piece, 2 extra delimiters, + trailing NULL) */ { - int32_t maxPathLen = uprv_strlen(iter->path) + uprv_strlen(item) + uprv_strlen(iter->suffix) + iter->packageStubLen + 3; + int32_t maxPathLen = (int32_t)uprv_strlen(iter->path) + uprv_strlen(item) + uprv_strlen(iter->suffix) + iter->packageStubLen + 3; iter->pathBuffer = iter->pathBufferA; if (maxPathLen >= U_DATA_PATHITER_BUFSIZ) { iter->pathBuffer = (char *)uprv_malloc(maxPathLen); @@ -586,16 +586,16 @@ static const char *udata_pathiter_next(UDataPathIterator *iter, int32_t *outPath if(iter->nextPath == iter->itemPath) { /* we were processing item's path. */ iter->nextPath = iter->path; /* start with regular path next tm. */ - pathLen = uprv_strlen(path); + pathLen = (int32_t)uprv_strlen(path); } else { /* fix up next for next time */ iter->nextPath = uprv_strchr(path, U_PATH_SEP_CHAR); if(iter->nextPath == NULL) { /* segment: entire path */ - pathLen = uprv_strlen(path); + pathLen = (int32_t)uprv_strlen(path); } else { /* segment: until next segment */ - pathLen = iter->nextPath - path; + pathLen = (int32_t)(iter->nextPath - path); if(*iter->nextPath) { /* skip divider */ iter->nextPath ++; } @@ -671,7 +671,7 @@ static const char *udata_pathiter_next(UDataPathIterator *iter, int32_t *outPath { uprv_strcpy(iter->pathBuffer + pathLen, iter->suffix); - pathLen += uprv_strlen(iter->suffix); + pathLen += (int32_t)uprv_strlen(iter->suffix); } } @@ -1126,37 +1126,36 @@ doOpenChoice(const char *path, const char *type, const char *name, if(path==NULL) { - TinyString_append(&pkgName, U_ICUDATA_NAME); + TinyString_append(&pkgName, U_ICUDATA_NAME); } else { const char *pkg; const char *first; pkg = uprv_strrchr(path, U_FILE_SEP_CHAR); first = uprv_strchr(path, U_FILE_SEP_CHAR); - if(uprv_pathIsAbsolute(path) || - (pkg != first)) { /* more than one slash in the path- not a tree name */ - /* see if this is an /absolute/path/to/package path */ - if(pkg) { - TinyString_append(&pkgName, pkg+1); + if(uprv_pathIsAbsolute(path) || (pkg != first)) { /* more than one slash in the path- not a tree name */ + /* see if this is an /absolute/path/to/package path */ + if(pkg) { + TinyString_append(&pkgName, pkg+1); + } else { + TinyString_append(&pkgName, path); + } } else { - TinyString_append(&pkgName, path); + treeChar = uprv_strchr(path, U_TREE_SEPARATOR); + if(treeChar) { + TinyString_append(&treeName, treeChar+1); /* following '-' */ + if(!isICUData) { + TinyString_appendn(&pkgName, path, (int32_t)(treeChar-path)); + } else { + TinyString_append(&pkgName, U_ICUDATA_NAME); + } + } else { + if(!isICUData) { + TinyString_append(&pkgName, path); + } else { + TinyString_append(&pkgName, U_ICUDATA_NAME); + } + } } - } else { - treeChar = uprv_strchr(path, U_TREE_SEPARATOR); - if(treeChar) { - TinyString_append(&treeName, treeChar+1); /* following '-' */ - if(!isICUData) { - TinyString_appendn(&pkgName, path, treeChar-path); - } else { - TinyString_append(&pkgName, U_ICUDATA_NAME); - } - } else { - if(!isICUData) { - TinyString_append(&pkgName, path); - } else { - TinyString_append(&pkgName, U_ICUDATA_NAME); - } - } - } } #ifdef UDATA_DEBUG @@ -1174,11 +1173,11 @@ doOpenChoice(const char *path, const char *type, const char *name, tocEntrySuffixIndex = tocEntryName.length; if(treeName.s[0]) { - TinyString_append(&tocEntryName, U_TREE_ENTRY_SEP_STRING); - TinyString_append(&tocEntryName, treeName.s); + TinyString_append(&tocEntryName, U_TREE_ENTRY_SEP_STRING); + TinyString_append(&tocEntryName, treeName.s); - TinyString_append(&tocEntryPath, U_FILE_SEP_STRING); - TinyString_append(&tocEntryPath, treeName.s); + TinyString_append(&tocEntryPath, U_FILE_SEP_STRING); + TinyString_append(&tocEntryPath, treeName.s); } TinyString_append(&oldIndFileName, "_"); diff --git a/icu4c/source/common/ustrenum.cpp b/icu4c/source/common/ustrenum.cpp index 25267f2289..22db32b87c 100644 --- a/icu4c/source/common/ustrenum.cpp +++ b/icu4c/source/common/ustrenum.cpp @@ -95,7 +95,7 @@ UnicodeString * StringEnumeration::setChars(const char *s, int32_t length, UErrorCode &status) { if(U_SUCCESS(status) && s!=NULL) { if(length<0) { - length=uprv_strlen(s); + length=(int32_t)uprv_strlen(s); } UChar *buffer=unistr.getBuffer(length+1); @@ -269,7 +269,7 @@ ucharstrenum_next(UEnumeration* en, } const char* result = ((const char**)e->uenum.context)[e->index++]; if (resultLength) { - *resultLength = uprv_strlen(result); + *resultLength = (int32_t)uprv_strlen(result); } return result; } diff --git a/icu4c/source/tools/gencmn/gencmn.c b/icu4c/source/tools/gencmn/gencmn.c index c984defb8a..5e83a5c615 100644 --- a/icu4c/source/tools/gencmn/gencmn.c +++ b/icu4c/source/tools/gencmn/gencmn.c @@ -593,44 +593,44 @@ allocString(uint32_t length) { static char * pathToFullPath(const char *path) { - int32_t length; - int32_t newLength; - char *fullPath; - int32_t n; + int32_t length; + int32_t newLength; + char *fullPath; + int32_t n; - length = (uint32_t)(uprv_strlen(path) + 1); - newLength = (length + 1 + uprv_strlen(options[10].value)); - fullPath = uprv_malloc(newLength); - if(options[10].doesOccur) { - uprv_strcpy(fullPath, options[10].value); - uprv_strcat(fullPath, U_FILE_SEP_STRING); - } else { - fullPath[0] = 0; - } - n = uprv_strlen(fullPath); - uprv_strcat(fullPath, path); - - if(!embed) { + length = (uint32_t)(uprv_strlen(path) + 1); + newLength = (length + 1 + (int32_t)uprv_strlen(options[10].value)); + fullPath = uprv_malloc(newLength); + if(options[10].doesOccur) { + uprv_strcpy(fullPath, options[10].value); + uprv_strcat(fullPath, U_FILE_SEP_STRING); + } else { + fullPath[0] = 0; + } + n = (int32_t)uprv_strlen(fullPath); + uprv_strcat(fullPath, path); + + if(!embed) { #if (U_FILE_ALT_SEP_CHAR != U_TREE_ENTRY_SEP_CHAR) #if (U_FILE_ALT_SEP_CHAR != U_FILE_SEP_CHAR) - /* replace tree separator (such as '/') with file sep char (such as ':' or '\\') */ - for(;fullPath[n];n++) { - if(fullPath[n] == U_FILE_ALT_SEP_CHAR) { - fullPath[n] = U_FILE_SEP_CHAR; - } - } + /* replace tree separator (such as '/') with file sep char (such as ':' or '\\') */ + for(;fullPath[n];n++) { + if(fullPath[n] == U_FILE_ALT_SEP_CHAR) { + fullPath[n] = U_FILE_SEP_CHAR; + } + } #endif #endif #if (U_FILE_SEP_CHAR != U_TREE_ENTRY_SEP_CHAR) - /* replace tree separator (such as '/') with file sep char (such as ':' or '\\') */ - for(;fullPath[n];n++) { - if(fullPath[n] == U_TREE_ENTRY_SEP_CHAR) { - fullPath[n] = U_FILE_SEP_CHAR; - } - } + /* replace tree separator (such as '/') with file sep char (such as ':' or '\\') */ + for(;fullPath[n];n++) { + if(fullPath[n] == U_TREE_ENTRY_SEP_CHAR) { + fullPath[n] = U_FILE_SEP_CHAR; + } + } #endif - } - return fullPath; + } + return fullPath; } static int