From 0ca13b73b09afab598556c03b77a6cb0ab4834b6 Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Thu, 3 May 2012 05:50:26 +0000 Subject: [PATCH] ICU-9292 Merge BEAM warning fixes from branch into trunk X-SVN-Rev: 31792 --- icu4c/source/common/bmpset.cpp | 4 ++-- icu4c/source/common/bytestriebuilder.cpp | 8 ++++---- icu4c/source/common/locdispnames.cpp | 4 ++-- icu4c/source/common/locmap.c | 6 +++--- icu4c/source/common/normalizer2impl.cpp | 4 +++- icu4c/source/common/normlzr.cpp | 4 +--- icu4c/source/common/uchar.c | 4 ++-- icu4c/source/common/ucharstriebuilder.cpp | 6 +++--- icu4c/source/common/ucnv2022.cpp | 4 ++-- icu4c/source/common/ucnv_ct.c | 2 +- icu4c/source/common/ucnvmbcs.c | 3 +-- icu4c/source/common/ucnvmbcs.h | 10 +++++----- icu4c/source/common/uloc.cpp | 4 ++-- icu4c/source/common/unicode/idna.h | 2 +- icu4c/source/common/uniset_props.cpp | 7 ++----- icu4c/source/common/uresdata.c | 8 ++++---- icu4c/source/common/ustrtrns.cpp | 4 ++-- icu4c/source/common/utrie.cpp | 4 ++-- icu4c/source/data/mappings/convrtrs.txt | 2 +- icu4c/source/extra/uconv/uconv.cpp | 6 ++++-- icu4c/source/extra/uconv/uwmsg.c | 7 +------ icu4c/source/i18n/bmsearch.cpp | 4 ++-- icu4c/source/i18n/buddhcal.cpp | 4 ++-- icu4c/source/i18n/calendar.cpp | 9 --------- icu4c/source/i18n/choicfmt.cpp | 6 +++--- icu4c/source/i18n/colldata.cpp | 4 ++-- icu4c/source/i18n/decNumber.c | 4 ++-- icu4c/source/i18n/digitlst.cpp | 4 ++-- icu4c/source/i18n/dtfmtsym.cpp | 4 ++-- icu4c/source/i18n/dtptngen.cpp | 2 +- icu4c/source/i18n/msgfmt.cpp | 19 +++++++++++++++++++ icu4c/source/i18n/plurrule.cpp | 6 ++---- icu4c/source/i18n/regexcmp.cpp | 4 ++-- icu4c/source/i18n/rematch.cpp | 12 ++++++------ icu4c/source/i18n/smpdtfmt.cpp | 23 ++++++++++++----------- icu4c/source/i18n/timezone.cpp | 8 -------- icu4c/source/i18n/tzfmt.cpp | 4 ++-- icu4c/source/i18n/ucol.cpp | 6 +++--- icu4c/source/i18n/ucol_res.cpp | 2 ++ icu4c/source/i18n/ucurr.cpp | 4 ++-- icu4c/source/i18n/unicode/msgfmt.h | 7 +++++++ icu4c/source/io/locbund.cpp | 4 +--- icu4c/source/layout/LookupProcessor.cpp | 7 ++++++- icu4c/source/tools/ctestfw/ctest.c | 2 +- icu4c/source/tools/gencnval/gencnval.c | 4 +--- icu4c/source/tools/genrb/parse.cpp | 7 +++---- icu4c/source/tools/genrb/ustr.h | 15 ++++++++++++++- icu4c/source/tools/genrb/wrtjava.c | 4 ++-- icu4c/source/tools/makeconv/genmbcs.cpp | 8 ++++---- icu4c/source/tools/makeconv/makeconv.c | 6 +++--- icu4c/source/tools/pkgdata/pkgdata.cpp | 9 +++++++-- icu4c/source/tools/toolutil/pkg_genc.c | 2 +- icu4c/source/tools/toolutil/pkg_gencmn.c | 4 +--- icu4c/source/tools/toolutil/ppucd.cpp | 7 ++++++- icu4c/source/tools/toolutil/swapimpl.cpp | 2 +- icu4c/source/tools/toolutil/ucmstate.c | 4 ++-- icu4c/source/tools/toolutil/uparse.c | 3 ++- 57 files changed, 176 insertions(+), 151 deletions(-) diff --git a/icu4c/source/common/bmpset.cpp b/icu4c/source/common/bmpset.cpp index 83cc9064f7e..b874436eced 100644 --- a/icu4c/source/common/bmpset.cpp +++ b/icu4c/source/common/bmpset.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2007-2011, International Business Machines +* Copyright (C) 2007-2012, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -107,7 +107,7 @@ static void set32x64Bits(uint32_t table[64], int32_t start, int32_t limit) { // limit<=0x800. If limit==0x800 then limitLead=32 and limitTrail=0. // In that case, bits=1<0xffffff) { intBytes[0]=(char)BytesTrie::kFiveByteValueLead; - intBytes[1]=(char)(i>>24); - intBytes[2]=(char)(i>>16); - intBytes[3]=(char)(i>>8); + intBytes[1]=(char)((uint32_t)i>>24); + intBytes[2]=(char)((uint32_t)i>>16); + intBytes[3]=(char)((uint32_t)i>>8); intBytes[4]=(char)i; length=5; // } else if(i<=BytesTrie::kMaxOneByteValue) { diff --git a/icu4c/source/common/locdispnames.cpp b/icu4c/source/common/locdispnames.cpp index 539224563b0..dd4445246fb 100644 --- a/icu4c/source/common/locdispnames.cpp +++ b/icu4c/source/common/locdispnames.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1997-2011, International Business Machines +* Copyright (C) 1997-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -282,7 +282,7 @@ static const char _kCountries[] = "Countries"; static const char _kVariants[] = "Variants"; static const char _kKeys[] = "Keys"; static const char _kTypes[] = "Types"; -static const char _kRootName[] = "root"; +//static const char _kRootName[] = "root"; static const char _kCurrency[] = "currency"; static const char _kCurrencies[] = "Currencies"; static const char _kLocaleDisplayPattern[] = "localeDisplayPattern"; diff --git a/icu4c/source/common/locmap.c b/icu4c/source/common/locmap.c index 205cea10589..9ebc70218e0 100644 --- a/icu4c/source/common/locmap.c +++ b/icu4c/source/common/locmap.c @@ -1,6 +1,6 @@ /* ********************************************************************** - * Copyright (C) 1996-2011, International Business Machines + * Copyright (C) 1996-2012, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * @@ -171,13 +171,13 @@ ILCID_POSIX_SUBTABLE(az) { ILCID_POSIX_ELEMENT_ARRAY(0x046d, ba, ba_RU) ILCID_POSIX_ELEMENT_ARRAY(0x0423, be, be_BY) -ILCID_POSIX_SUBTABLE(ber) { +/*ILCID_POSIX_SUBTABLE(ber) { {0x5f, "ber"}, {0x045f, "ber_Arab_DZ"}, {0x045f, "ber_Arab"}, {0x085f, "ber_Latn_DZ"}, {0x085f, "ber_Latn"} -}; +};*/ ILCID_POSIX_ELEMENT_ARRAY(0x0402, bg, bg_BG) diff --git a/icu4c/source/common/normalizer2impl.cpp b/icu4c/source/common/normalizer2impl.cpp index a6ef0c1b289..050b58169c7 100644 --- a/icu4c/source/common/normalizer2impl.cpp +++ b/icu4c/source/common/normalizer2impl.cpp @@ -657,8 +657,10 @@ void Normalizer2Impl::decomposeAndAppend(const UChar *src, const UChar *limit, if(limit==NULL) { // appendZeroCC() needs limit!=NULL limit=u_strchr(iter.codePointStart, 0); } - buffer.append(src, (int32_t)(iter.codePointStart-src), firstCC, prevCC, errorCode) && + + if (buffer.append(src, (int32_t)(iter.codePointStart-src), firstCC, prevCC, errorCode)) { buffer.appendZeroCC(iter.codePointStart, limit, errorCode); + } } // Note: hasDecompBoundary() could be implemented as aliases to diff --git a/icu4c/source/common/normlzr.cpp b/icu4c/source/common/normlzr.cpp index b9580537b23..7a5209f0154 100644 --- a/icu4c/source/common/normlzr.cpp +++ b/icu4c/source/common/normlzr.cpp @@ -1,7 +1,7 @@ /* ************************************************************************* * COPYRIGHT: - * Copyright (c) 1996-2011, International Business Machines Corporation and + * Copyright (c) 1996-2012, International Business Machines Corporation and * others. All Rights Reserved. ************************************************************************* */ @@ -65,8 +65,6 @@ Normalizer::Normalizer(const Normalizer ©) : init(); } -static const UChar _NUL=0; - void Normalizer::init() { UErrorCode errorCode=U_ZERO_ERROR; diff --git a/icu4c/source/common/uchar.c b/icu4c/source/common/uchar.c index 9cb5f0db196..6ce39e63509 100644 --- a/icu4c/source/common/uchar.c +++ b/icu4c/source/common/uchar.c @@ -560,7 +560,7 @@ uscript_hasScript(UChar32 c, UScriptCode sc) { if(scriptX>=UPROPS_SCRIPT_X_WITH_OTHER) { scx=scriptExtensions+scx[1]; } - if(sc>0x7fff) { + if(sc>=USCRIPT_CODE_LIMIT) { /* Guard against bogus input that would make us go past the Script_Extensions terminator. */ return FALSE; } @@ -603,7 +603,7 @@ uscript_getScriptExtensions(UChar32 c, do { sx=*scx++; if(lengthUCharsTrie::kMaxTwoUnitValue) { intUnits[0]=(UChar)(UCharsTrie::kThreeUnitValueLead); - intUnits[1]=(UChar)(i>>16); + intUnits[1]=(UChar)((uint32_t)i>>16); intUnits[2]=(UChar)i; length=3; // } else if(i<=UCharsTrie::kMaxOneUnitValue) { @@ -402,7 +402,7 @@ UCharsTrieBuilder::writeValueAndType(UBool hasValue, int32_t value, int32_t node int32_t length; if(value<0 || value>UCharsTrie::kMaxTwoUnitNodeValue) { intUnits[0]=(UChar)(UCharsTrie::kThreeUnitNodeValueLead); - intUnits[1]=(UChar)(value>>16); + intUnits[1]=(UChar)((uint32_t)value>>16); intUnits[2]=(UChar)value; length=3; } else if(value<=UCharsTrie::kMaxOneUnitNodeValue) { diff --git a/icu4c/source/common/ucnv2022.cpp b/icu4c/source/common/ucnv2022.cpp index 90b4532f100..2289e80c851 100644 --- a/icu4c/source/common/ucnv2022.cpp +++ b/icu4c/source/common/ucnv2022.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2000-2011, International Business Machines +* Copyright (C) 2000-2012, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * file name: ucnv2022.cpp @@ -78,7 +78,7 @@ #endif static const char SHIFT_IN_STR[] = "\x0F"; -static const char SHIFT_OUT_STR[] = "\x0E"; +// static const char SHIFT_OUT_STR[] = "\x0E"; #define CR 0x0D #define LF 0x0A diff --git a/icu4c/source/common/ucnv_ct.c b/icu4c/source/common/ucnv_ct.c index d51831de22b..7161d139a1e 100644 --- a/icu4c/source/common/ucnv_ct.c +++ b/icu4c/source/common/ucnv_ct.c @@ -293,7 +293,7 @@ _CompoundTextOpen(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorC return; } - myConverterData->state = 0; + myConverterData->state = (COMPOUND_TEXT_CONVERTERS)0; } else { *errorCode = U_MEMORY_ALLOCATION_ERROR; } diff --git a/icu4c/source/common/ucnvmbcs.c b/icu4c/source/common/ucnvmbcs.c index 4258dbdb096..159b5e5ca5a 100644 --- a/icu4c/source/common/ucnvmbcs.c +++ b/icu4c/source/common/ucnvmbcs.c @@ -1343,7 +1343,6 @@ reconstituteData(UConverterMBCSTable *mbcsTable, UErrorCode *pErrorCode) { uint16_t *stage1; uint32_t *stage2; - uint8_t *bytes; uint32_t dataLength=stage1Length*2+fullStage2Length*4+mbcsTable->fromUBytesLength; mbcsTable->reconstitutedData=(uint8_t *)uprv_malloc(dataLength); if(mbcsTable->reconstitutedData==NULL) { @@ -1362,7 +1361,7 @@ reconstituteData(UConverterMBCSTable *mbcsTable, stage2Length*4); mbcsTable->fromUnicodeTable=stage1; - mbcsTable->fromUnicodeBytes=bytes=(uint8_t *)(stage2+fullStage2Length); + mbcsTable->fromUnicodeBytes=(uint8_t *)(stage2+fullStage2Length); /* indexes into stage 2 count from the bottom of the fromUnicodeTable */ stage2=(uint32_t *)stage1; diff --git a/icu4c/source/common/ucnvmbcs.h b/icu4c/source/common/ucnvmbcs.h index 7875f826d2e..b960f825621 100644 --- a/icu4c/source/common/ucnvmbcs.h +++ b/icu4c/source/common/ucnvmbcs.h @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2000-2011, International Business Machines +* Copyright (C) 2000-2012, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -274,17 +274,17 @@ enum { #define MBCS_ENTRY_SET_STATE(entry, state) (int32_t)(((entry)&0x80ffffff)|((int32_t)(state)<<24L)) -#define MBCS_ENTRY_STATE(entry) (((entry)>>24)&0x7f) +#define MBCS_ENTRY_STATE(entry) ((((uint32_t)entry)>>24)&0x7f) #define MBCS_ENTRY_IS_TRANSITION(entry) ((entry)>=0) #define MBCS_ENTRY_IS_FINAL(entry) ((entry)<0) -#define MBCS_ENTRY_TRANSITION_STATE(entry) ((entry)>>24) +#define MBCS_ENTRY_TRANSITION_STATE(entry) (((uint32_t)entry)>>24) #define MBCS_ENTRY_TRANSITION_OFFSET(entry) ((entry)&0xffffff) -#define MBCS_ENTRY_FINAL_STATE(entry) (((entry)>>24)&0x7f) +#define MBCS_ENTRY_FINAL_STATE(entry) ((((uint32_t)entry)>>24)&0x7f) #define MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry) ((entry)<(int32_t)0x80100000) -#define MBCS_ENTRY_FINAL_ACTION(entry) (((entry)>>20)&0xf) +#define MBCS_ENTRY_FINAL_ACTION(entry) ((((uint32_t)entry)>>20)&0xf) #define MBCS_ENTRY_FINAL_VALUE(entry) ((entry)&0xfffff) #define MBCS_ENTRY_FINAL_VALUE_16(entry) (uint16_t)(entry) diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index 25caee1b564..42678feb48e 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -1009,7 +1009,7 @@ uloc_setKeywordValue(const char* keywordName, while(keywordStart[i-1] == ' ') { i--; } - U_ASSERT(i>=0); + U_ASSERT(i>=0 && irootRes); + rootType=(UResType)RES_GET_TYPE(pResData->rootRes); if(!URES_IS_TABLE(rootType)) { *errorCode=U_INVALID_FORMAT_ERROR; res_unload(pResData); @@ -559,7 +559,7 @@ res_findResource(const ResourceData *pResData, Resource r, char** path, const ch Resource t1 = r; Resource t2; int32_t indexR = 0; - UResType type = RES_GET_TYPE(t1); + UResType type = (UResType)RES_GET_TYPE(t1); /* if you come in with an empty path, you'll be getting back the same resource */ if(!uprv_strlen(pathP)) { @@ -611,7 +611,7 @@ res_findResource(const ResourceData *pResData, Resource r, char** path, const ch t2 = RES_BOGUS; } t1 = t2; - type = RES_GET_TYPE(t1); + type = (UResType)RES_GET_TYPE(t1); /* position pathP to next resource key/index */ pathP = *path; } diff --git a/icu4c/source/common/ustrtrns.cpp b/icu4c/source/common/ustrtrns.cpp index d702aa8fd6b..57cabd58e2a 100644 --- a/icu4c/source/common/ustrtrns.cpp +++ b/icu4c/source/common/ustrtrns.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2001-2011, International Business Machines +* Copyright (C) 2001-2012, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -1310,7 +1310,7 @@ u_strFromJavaModifiedUTF8WithSub( } /* Faster loop without ongoing checking for pSrcLimit and pDestLimit. */ - pSrcLimit = pSrc + srcLength; + pSrcLimit = (pSrc == NULL) ? NULL : pSrc + srcLength; for(;;) { count = (int32_t)(pDestLimit - pDest); srcLength = (int32_t)(pSrcLimit - pSrc); diff --git a/icu4c/source/common/utrie.cpp b/icu4c/source/common/utrie.cpp index eb97aaa55b1..b8caeb722b3 100644 --- a/icu4c/source/common/utrie.cpp +++ b/icu4c/source/common/utrie.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2001-2011, International Business Machines +* Copyright (C) 2001-2012, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -943,7 +943,7 @@ utrie_unserializeDummy(UTrie *trie, /* calculate the actual size of the dummy trie data */ /* max(Latin-1, block 0) */ - latin1Length= UTRIE_SHIFT<=8 ? 256 : UTRIE_DATA_BLOCK_LENGTH; + latin1Length= 256; /*UTRIE_SHIFT<=8 ? 256 : UTRIE_DATA_BLOCK_LENGTH;*/ trie->indexLength=UTRIE_BMP_INDEX_LENGTH+UTRIE_SURROGATE_BLOCK_COUNT; trie->dataLength=latin1Length; diff --git a/icu4c/source/data/mappings/convrtrs.txt b/icu4c/source/data/mappings/convrtrs.txt index 467afb5aa04..09f1a91dd74 100644 --- a/icu4c/source/data/mappings/convrtrs.txt +++ b/icu4c/source/data/mappings/convrtrs.txt @@ -931,7 +931,7 @@ macos-38_2-10.2 { UTR22* } x-mac-romania { MIME* } x-MacRomania { JAVA* } M macos-518-10.2 { UTR22* } x-mac-arabic { MIME* } x-MacArabic { JAVA* } MacArabic { JAVA } macos-1285-10.2 { UTR22* } x-mac-hebrew { MIME* } x-MacHebrew { JAVA* } MacHebrew { JAVA } -ibm-1051_P100-1995 { UTR22* } ibm-1051 { IBM* } hp-roman8 { IANA* } roman8 { IANA } r8 { IANA } csHPRoman8 { IANA } x-roman8 { JAVA} # HP Latin1 +ibm-1051_P100-1995 { UTR22* } ibm-1051 { IBM* } hp-roman8 { IANA* } roman8 { IANA } r8 { IANA } csHPRoman8 { IANA } x-roman8 { JAVA* } # HP Latin1 ibm-1276_P100-1995 { UTR22* } ibm-1276 { IBM* } Adobe-Standard-Encoding { IANA* } csAdobeStandardEncoding { IANA } # Different from ISO-Unicode-IBM-1276 (GCSGID: 1276) ibm-1006_P100-1995 { UTR22* } ibm-1006 { IBM* } IBM1006 { JAVA } cp1006 { JAVA* } 1006 { JAVA } x-IBM1006 { JAVA } # Urdu diff --git a/icu4c/source/extra/uconv/uconv.cpp b/icu4c/source/extra/uconv/uconv.cpp index 0bba48eafe1..54ce847580d 100644 --- a/icu4c/source/extra/uconv/uconv.cpp +++ b/icu4c/source/extra/uconv/uconv.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * -* Copyright (C) 1999-2011, International Business Machines +* Copyright (C) 1999-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************/ @@ -593,6 +593,7 @@ ConvertFile::convertFile(const char *pname, UConverter *convto = 0; UErrorCode err = U_ZERO_ERROR; UBool flush; + UBool closeFile = FALSE; const char *cbufp, *prevbufp; char *bufp; @@ -628,6 +629,7 @@ ConvertFile::convertFile(const char *pname, u_wmsg(stderr, "cantOpenInputF", str1.getBuffer(), str2.getBuffer()); return FALSE; } + closeFile = TRUE; } else { infilestr = "-"; infile = stdin; @@ -1051,7 +1053,7 @@ normal_exit: delete t; #endif - if (infile != stdin) { + if (closeFile) { fclose(infile); } diff --git a/icu4c/source/extra/uconv/uwmsg.c b/icu4c/source/extra/uconv/uwmsg.c index 61e6c463719..67c12885953 100644 --- a/icu4c/source/extra/uconv/uwmsg.c +++ b/icu4c/source/extra/uconv/uwmsg.c @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 1998-2004, International Business Machines Corporation +* Copyright (C) 1998-2012, International Business Machines Corporation * and others. All Rights Reserved. ********************************************************************** * @@ -84,7 +84,6 @@ finish: ucnv_close(converter); } -static const char *gPath = 0; static UResourceBundle *gBundle = NULL; U_STRING_DECL(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38); @@ -110,7 +109,6 @@ U_CFUNC UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err) return 0; } - gPath = uprv_strdup(path); gBundle = b; U_STRING_INIT(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38); @@ -143,9 +141,6 @@ U_CFUNC int u_wmsg(FILE *fp, const char *tag, ... ) if(U_FAILURE(err)) { -#if 0 - fprintf(stderr, "u_wmsg: failed to load tag [%s] [%s] [%s]!!\n", tag, u_errorName(err), gPath); -#endif return -1; } diff --git a/icu4c/source/i18n/bmsearch.cpp b/icu4c/source/i18n/bmsearch.cpp index 4d2dcc5c9cc..e6d81594fa8 100644 --- a/icu4c/source/i18n/bmsearch.cpp +++ b/icu4c/source/i18n/bmsearch.cpp @@ -1,6 +1,6 @@ /* ****************************************************************************** - * Copyright (C) 1996-2011, International Business Machines * + * Copyright (C) 1996-2012, International Business Machines * * Corporation and others. All Rights Reserved. * ****************************************************************************** */ @@ -306,7 +306,7 @@ void Target::setLast(int32_t last) bufferMin = 0; bufferMax = 1; - ceb[0].order = UCOL_NULLORDER; + ceb[0].order = (uint32_t)UCOL_NULLORDER; ceb[0].lowOffset = last; ceb[0].highOffset = last; diff --git a/icu4c/source/i18n/buddhcal.cpp b/icu4c/source/i18n/buddhcal.cpp index 92f726c3028..d61f68810da 100644 --- a/icu4c/source/i18n/buddhcal.cpp +++ b/icu4c/source/i18n/buddhcal.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2003-2008, International Business Machines Corporation and * +* Copyright (C) 2003-2012, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -24,7 +24,7 @@ U_NAMESPACE_BEGIN UOBJECT_DEFINE_RTTI_IMPLEMENTATION(BuddhistCalendar) -static const int32_t kMaxEra = 0; // only 1 era +//static const int32_t kMaxEra = 0; // only 1 era static const int32_t kBuddhistEraStart = -543; // 544 BC (Gregorian) diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index a8c014f858b..a5200899064 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -3186,7 +3186,6 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w // we're not possibly in the last week -must be ywoy return yearWoy; } - break; case UCAL_DATE: if((internalGet(UCAL_MONTH)==0) && @@ -3206,18 +3205,10 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w //within 1st week and in this month.. //return yearWoy+1; return yearWoy; - break; default: // assume the year is appropriate return yearWoy; - break; } - -#if defined (U_DEBUG_CAL) - fprintf(stderr, "%s:%d - forgot a return on field %s\n", __FILE__, __LINE__, fldName(bestField)); -#endif - - return yearWoy; } int32_t Calendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const diff --git a/icu4c/source/i18n/choicfmt.cpp b/icu4c/source/i18n/choicfmt.cpp index 58b440a7e4c..79a722bdfee 100644 --- a/icu4c/source/i18n/choicfmt.cpp +++ b/icu4c/source/i18n/choicfmt.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 1997-2011, International Business Machines Corporation and * +* Copyright (C) 1997-2012, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -64,8 +64,8 @@ static const UChar RIGHT_CURLY_BRACE = 0x7D; /*}*/ #endif #define INFINITY ((UChar)0x221E) -static const UChar gPositiveInfinity[] = {INFINITY, 0}; -static const UChar gNegativeInfinity[] = {MINUS, INFINITY, 0}; +//static const UChar gPositiveInfinity[] = {INFINITY, 0}; +//static const UChar gNegativeInfinity[] = {MINUS, INFINITY, 0}; #define POSITIVE_INF_STRLEN 1 #define NEGATIVE_INF_STRLEN 2 diff --git a/icu4c/source/i18n/colldata.cpp b/icu4c/source/i18n/colldata.cpp index 358b3ac4227..946568b1e1c 100644 --- a/icu4c/source/i18n/colldata.cpp +++ b/icu4c/source/i18n/colldata.cpp @@ -1,6 +1,6 @@ /* ****************************************************************************** - * Copyright (C) 1996-2011, International Business Machines * + * Copyright (C) 1996-2012, International Business Machines * * Corporation and others. All Rights Reserved. * ****************************************************************************** */ @@ -162,7 +162,7 @@ uint32_t CEList::get(int32_t index) const return ces[index]; } - return UCOL_NULLORDER; + return (uint32_t)UCOL_NULLORDER; } uint32_t &CEList::operator[](int32_t index) const diff --git a/icu4c/source/i18n/decNumber.c b/icu4c/source/i18n/decNumber.c index 5883c22b7f9..3cb8bd9900f 100644 --- a/icu4c/source/i18n/decNumber.c +++ b/icu4c/source/i18n/decNumber.c @@ -6063,11 +6063,11 @@ static decNumber * decCompareOp(decNumber *res, const decNumber *lhs, /* If total ordering then handle differing signs 'up front' */ if (op==COMPTOTAL) { /* total ordering */ - if (decNumberIsNegative(lhs) & !decNumberIsNegative(rhs)) { + if (decNumberIsNegative(lhs) && !decNumberIsNegative(rhs)) { result=-1; break; } - if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) { + if (!decNumberIsNegative(lhs) && decNumberIsNegative(rhs)) { result=+1; break; } diff --git a/icu4c/source/i18n/digitlst.cpp b/icu4c/source/i18n/digitlst.cpp index b885a17cb21..31361be5aa9 100644 --- a/icu4c/source/i18n/digitlst.cpp +++ b/icu4c/source/i18n/digitlst.cpp @@ -54,8 +54,8 @@ /* Only for 32 bit numbers. Ignore the negative sign. */ -static const char LONG_MIN_REP[] = "2147483648"; -static const char I64_MIN_REP[] = "9223372036854775808"; +//static const char LONG_MIN_REP[] = "2147483648"; +//static const char I64_MIN_REP[] = "9223372036854775808"; U_NAMESPACE_BEGIN diff --git a/icu4c/source/i18n/dtfmtsym.cpp b/icu4c/source/i18n/dtfmtsym.cpp index 0f5ba326fc8..e0a9165d153 100644 --- a/icu4c/source/i18n/dtfmtsym.cpp +++ b/icu4c/source/i18n/dtfmtsym.cpp @@ -171,9 +171,9 @@ static const char gNamesNumericTag[]="numeric"; static const char gAmPmMarkersTag[]="AmPmMarkers"; static const char gQuartersTag[]="quarters"; -static const char gZoneStringsTag[]="zoneStrings"; +// static const char gZoneStringsTag[]="zoneStrings"; -static const char gLocalPatternCharsTag[]="localPatternChars"; +// static const char gLocalPatternCharsTag[]="localPatternChars"; static const char gContextTransformsTag[]="contextTransforms"; diff --git a/icu4c/source/i18n/dtptngen.cpp b/icu4c/source/i18n/dtptngen.cpp index b4e39b50870..3cbfb195356 100644 --- a/icu4c/source/i18n/dtptngen.cpp +++ b/icu4c/source/i18n/dtptngen.cpp @@ -217,7 +217,7 @@ static const char* const Resource_Fields[] = { static const UChar UDATPG_ItemFormat[]= {0x7B, 0x30, 0x7D, 0x20, 0x251C, 0x7B, 0x32, 0x7D, 0x3A, 0x20, 0x7B, 0x31, 0x7D, 0x2524, 0}; // {0} \u251C{2}: {1}\u2524 -static const UChar repeatedPatterns[6]={CAP_G, CAP_E, LOW_Z, LOW_V, CAP_Q, 0}; // "GEzvQ" +//static const UChar repeatedPatterns[6]={CAP_G, CAP_E, LOW_Z, LOW_V, CAP_Q, 0}; // "GEzvQ" static const char DT_DateTimePatternsTag[]="DateTimePatterns"; static const char DT_DateTimeCalendarTag[]="calendar"; diff --git a/icu4c/source/i18n/msgfmt.cpp b/icu4c/source/i18n/msgfmt.cpp index bec283a08a0..9575f8e03c1 100644 --- a/icu4c/source/i18n/msgfmt.cpp +++ b/icu4c/source/i18n/msgfmt.cpp @@ -1734,6 +1734,15 @@ Format* MessageFormat::DummyFormat::clone() const { return new DummyFormat(); } +UnicodeString& MessageFormat::DummyFormat::format(const Formattable& obj, + UnicodeString& appendTo, + UErrorCode& status) const { + if (U_SUCCESS(status)) { + status = U_UNSUPPORTED_ERROR; + } + return appendTo; +} + UnicodeString& MessageFormat::DummyFormat::format(const Formattable&, UnicodeString& appendTo, FieldPosition&, @@ -1744,6 +1753,16 @@ UnicodeString& MessageFormat::DummyFormat::format(const Formattable&, return appendTo; } +UnicodeString& MessageFormat::DummyFormat::format(const Formattable&, + UnicodeString& appendTo, + FieldPositionIterator* posIter, + UErrorCode& status) const { + if (U_SUCCESS(status)) { + status = U_UNSUPPORTED_ERROR; + } + return appendTo; +} + void MessageFormat::DummyFormat::parseObject(const UnicodeString&, Formattable&, ParsePosition& ) const { diff --git a/icu4c/source/i18n/plurrule.cpp b/icu4c/source/i18n/plurrule.cpp index e343fef1481..2f80a54ec43 100644 --- a/icu4c/source/i18n/plurrule.cpp +++ b/icu4c/source/i18n/plurrule.cpp @@ -700,11 +700,10 @@ PluralRules::getRuleFromResource(const Locale& locale, UPluralType type, UErrorC UErrorCode status = U_ZERO_ERROR; char parentLocaleName[ULOC_FULLNAME_CAPACITY]; const char *curLocaleName=locale.getName(); - int32_t localeNameLen=0; uprv_strcpy(parentLocaleName, curLocaleName); - while ((localeNameLen=uloc_getParent(parentLocaleName, parentLocaleName, - ULOC_FULLNAME_CAPACITY, &status)) > 0) { + while (uloc_getParent(parentLocaleName, parentLocaleName, + ULOC_FULLNAME_CAPACITY, &status) > 0) { resLen=0; s = ures_getStringByKey(locRes.getAlias(), parentLocaleName, &resLen, &status); if (s != NULL) { @@ -1292,7 +1291,6 @@ RuleParser::getNextToken(const UnicodeString& ruleData, return; } } - break; default: status = U_UNEXPECTED_TOKEN; return; diff --git a/icu4c/source/i18n/regexcmp.cpp b/icu4c/source/i18n/regexcmp.cpp index 146d73cfafe..b17ef53c93d 100644 --- a/icu4c/source/i18n/regexcmp.cpp +++ b/icu4c/source/i18n/regexcmp.cpp @@ -3595,10 +3595,10 @@ static const UChar chDigit7 = 0x37; // '9' static const UChar chColon = 0x3A; // ':' static const UChar chE = 0x45; // 'E' static const UChar chQ = 0x51; // 'Q' -static const UChar chN = 0x4E; // 'N' +//static const UChar chN = 0x4E; // 'N' static const UChar chP = 0x50; // 'P' static const UChar chBackSlash = 0x5c; // '\' introduces a char escape -static const UChar chLBracket = 0x5b; // '[' +//static const UChar chLBracket = 0x5b; // '[' static const UChar chRBracket = 0x5d; // ']' static const UChar chUp = 0x5e; // '^' static const UChar chLowerP = 0x70; diff --git a/icu4c/source/i18n/rematch.cpp b/icu4c/source/i18n/rematch.cpp index 60b1372cdaa..b416f16c811 100644 --- a/icu4c/source/i18n/rematch.cpp +++ b/icu4c/source/i18n/rematch.cpp @@ -3099,7 +3099,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_BACKSLASH_B: // Test for word boundaries { UBool success = isWordBoundary(fp->fInputIdx); - success ^= (opValue != 0); // flip sense for \B + success ^= (UBool)(opValue != 0); // flip sense for \B if (!success) { fp = (REStackFrame *)fStack->popFrame(fFrameSize); } @@ -3110,7 +3110,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { case URX_BACKSLASH_BU: // Test for word boundaries, Unicode-style { UBool success = isUWordBoundary(fp->fInputIdx); - success ^= (opValue != 0); // flip sense for \B + success ^= (UBool)(opValue != 0); // flip sense for \B if (!success) { fp = (REStackFrame *)fStack->popFrame(fFrameSize); } @@ -3131,7 +3131,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) { UChar32 c = UTEXT_NEXT32(fInputText); int8_t ctype = u_charType(c); // TODO: make a unicode set for this. Will be faster. UBool success = (ctype == U_DECIMAL_DIGIT_NUMBER); - success ^= (opValue != 0); // flip sense for \D + success ^= (UBool)(opValue != 0); // flip sense for \D if (success) { fp->fInputIdx = UTEXT_GETNATIVEINDEX(fInputText); } else { @@ -4588,7 +4588,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_BACKSLASH_B: // Test for word boundaries { UBool success = isChunkWordBoundary((int32_t)fp->fInputIdx); - success ^= (opValue != 0); // flip sense for \B + success ^= (UBool)(opValue != 0); // flip sense for \B if (!success) { fp = (REStackFrame *)fStack->popFrame(fFrameSize); } @@ -4599,7 +4599,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu case URX_BACKSLASH_BU: // Test for word boundaries, Unicode-style { UBool success = isUWordBoundary(fp->fInputIdx); - success ^= (opValue != 0); // flip sense for \B + success ^= (UBool)(opValue != 0); // flip sense for \B if (!success) { fp = (REStackFrame *)fStack->popFrame(fFrameSize); } @@ -4619,7 +4619,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu U16_NEXT(inputBuf, fp->fInputIdx, fActiveLimit, c); int8_t ctype = u_charType(c); // TODO: make a unicode set for this. Will be faster. UBool success = (ctype == U_DECIMAL_DIGIT_NUMBER); - success ^= (opValue != 0); // flip sense for \D + success ^= (UBool)(opValue != 0); // flip sense for \D if (!success) { fp = (REStackFrame *)fStack->popFrame(fFrameSize); } diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index 040c361c3a5..01b819d2277 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -78,16 +78,17 @@ static const UChar PATTERN_CHAR_BASE = 0x40; // For time zones that have no names, use strings GMT+minutes and // GMT-minutes. For instance, in France the time zone is GMT+60. // Also accepted are GMT+H:MM or GMT-H:MM. -static const UChar gGmt[] = {0x0047, 0x004D, 0x0054, 0x0000}; // "GMT" -static const UChar gGmtPlus[] = {0x0047, 0x004D, 0x0054, 0x002B, 0x0000}; // "GMT+" -static const UChar gGmtMinus[] = {0x0047, 0x004D, 0x0054, 0x002D, 0x0000}; // "GMT-" -static const UChar gDefGmtPat[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0x0000}; /* GMT{0} */ -static const UChar gDefGmtNegHmsPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* -HH:mm:ss */ -static const UChar gDefGmtNegHmPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* -HH:mm */ -static const UChar gDefGmtPosHmsPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* +HH:mm:ss */ -static const UChar gDefGmtPosHmPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* +HH:mm */ -static const UChar gUt[] = {0x0055, 0x0054, 0x0000}; // "UT" -static const UChar gUtc[] = {0x0055, 0x0054, 0x0043, 0x0000}; // "UT" +// Currently not being used +//static const UChar gGmt[] = {0x0047, 0x004D, 0x0054, 0x0000}; // "GMT" +//static const UChar gGmtPlus[] = {0x0047, 0x004D, 0x0054, 0x002B, 0x0000}; // "GMT+" +//static const UChar gGmtMinus[] = {0x0047, 0x004D, 0x0054, 0x002D, 0x0000}; // "GMT-" +//static const UChar gDefGmtPat[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0x0000}; /* GMT{0} */ +//static const UChar gDefGmtNegHmsPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* -HH:mm:ss */ +//static const UChar gDefGmtNegHmPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* -HH:mm */ +//static const UChar gDefGmtPosHmsPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* +HH:mm:ss */ +//static const UChar gDefGmtPosHmPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* +HH:mm */ +//static const UChar gUt[] = {0x0055, 0x0054, 0x0000}; // "UT" +//static const UChar gUtc[] = {0x0055, 0x0054, 0x0043, 0x0000}; // "UT" typedef enum GmtPatSize { kGmtLen = 3, @@ -157,7 +158,7 @@ static const UChar SUPPRESS_NEGATIVE_PREFIX[] = {0xAB00, 0}; */ static const char gDateTimePatternsTag[]="DateTimePatterns"; -static const UChar gEtcUTC[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x54, 0x43, 0x00}; // "Etc/UTC" +//static const UChar gEtcUTC[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x54, 0x43, 0x00}; // "Etc/UTC" static const UChar QUOTE = 0x27; // Single quote /* diff --git a/icu4c/source/i18n/timezone.cpp b/icu4c/source/i18n/timezone.cpp index 799de79c055..429068e54b7 100644 --- a/icu4c/source/i18n/timezone.cpp +++ b/icu4c/source/i18n/timezone.cpp @@ -106,14 +106,6 @@ static const UChar WORLD[] = {0x30, 0x30, 0x31, 0x00}; /* "001" */ static const UChar GMT_ID[] = {0x47, 0x4D, 0x54, 0x00}; /* "GMT" */ static const UChar UNKNOWN_ZONE_ID[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0x00}; /* "Etc/Unknown" */ -static const UChar Z_STR[] = {0x7A, 0x00}; /* "z" */ -static const UChar ZZZZ_STR[] = {0x7A, 0x7A, 0x7A, 0x7A, 0x00}; /* "zzzz" */ -static const UChar Z_UC_STR[] = {0x5A, 0x00}; /* "Z" */ -static const UChar ZZZZ_UC_STR[] = {0x5A, 0x5A, 0x5A, 0x5A, 0x00}; /* "ZZZZ" */ -static const UChar V_STR[] = {0x76, 0x00}; /* "v" */ -static const UChar VVVV_STR[] = {0x76, 0x76, 0x76, 0x76, 0x00}; /* "vvvv" */ -static const UChar V_UC_STR[] = {0x56, 0x00}; /* "V" */ -static const UChar VVVV_UC_STR[] = {0x56, 0x56, 0x56, 0x56, 0x00}; /* "VVVV" */ static const int32_t GMT_ID_LENGTH = 3; static const int32_t UNKNOWN_ZONE_ID_LENGTH = 11; diff --git a/icu4c/source/i18n/tzfmt.cpp b/icu4c/source/i18n/tzfmt.cpp index 79210ad0e27..131d30b7ba0 100644 --- a/icu4c/source/i18n/tzfmt.cpp +++ b/icu4c/source/i18n/tzfmt.cpp @@ -36,7 +36,7 @@ static const char gHourFormatTag[]= "hourFormat"; static const UChar TZID_GMT[] = {0x0045, 0x0074, 0x0063, 0x002F, 0x0047, 0x004D, 0x0054, 0}; // Etc/GMT static const UChar DEFAULT_GMT_PATTERN[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0}; // GMT{0} -static const UChar DEFAULT_GMT_ZERO[] = {0x0047, 0x004D, 0x0054, 0}; // GMT +//static const UChar DEFAULT_GMT_ZERO[] = {0x0047, 0x004D, 0x0054, 0}; // GMT static const UChar DEFAULT_GMT_POSITIVE_HM[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // +HH:mm static const UChar DEFAULT_GMT_POSITIVE_HMS[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // +HH:mm:ss static const UChar DEFAULT_GMT_NEGATIVE_HM[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // -HH:mm @@ -1691,7 +1691,7 @@ TimeZoneFormat::parseAbuttingAsciiOffsetFields(const UnicodeString& text, ParseP U_ASSERT(maxDigits <= MAX_OFFSET_DIGITS); - int32_t digits[MAX_OFFSET_DIGITS]; + int32_t digits[MAX_OFFSET_DIGITS] = {}; int32_t numDigits = 0; int32_t idx = start; while (numDigits < maxDigits && idx < text.length()) { diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index 74940a7b153..e4d237b8afc 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -3577,7 +3577,7 @@ uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE, IInit_collIterate(coll, UCharOffset, noChars, &temp, status); if(U_FAILURE(*status)) { - return UCOL_NULLORDER; + return (uint32_t)UCOL_NULLORDER; } temp.flags &= ~UCOL_ITER_NORM; temp.flags |= source->flags & UCOL_FORCE_HAN_IMPLICIT; @@ -3954,7 +3954,7 @@ uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE, // The total size for our collation key is half of endIndex, rounded up. int32_t size = (endIndex+1)/2; if(!ensureCEsCapacity(source, size)) { - return UCOL_NULLORDER; + return (uint32_t)UCOL_NULLORDER; } *(source->CEpos++) = (((numTempBuf[0] << 8) | numTempBuf[1]) << UCOL_PRIMARYORDERSHIFT) | //Primary weight (UCOL_BYTE_COMMON << UCOL_SECONDARYORDERSHIFT) | // Secondary weight @@ -6060,7 +6060,7 @@ saveState: // If we are doing French, we need to store whether we have just finished the French level if(level == UCOL_PSK_SECONDARY && doingFrench) { - state[1] |= (((state[0] == 0) & UCOL_PSK_BYTE_COUNT_OR_FRENCH_DONE_MASK) << UCOL_PSK_BYTE_COUNT_OR_FRENCH_DONE_SHIFT); + state[1] |= (((int32_t)(state[0] == 0) & UCOL_PSK_BYTE_COUNT_OR_FRENCH_DONE_MASK) << UCOL_PSK_BYTE_COUNT_OR_FRENCH_DONE_SHIFT); } else { state[1] |= ((byteCountOrFrenchDone & UCOL_PSK_BYTE_COUNT_OR_FRENCH_DONE_MASK) << UCOL_PSK_BYTE_COUNT_OR_FRENCH_DONE_SHIFT); } diff --git a/icu4c/source/i18n/ucol_res.cpp b/icu4c/source/i18n/ucol_res.cpp index 2f730469561..f1d0235c511 100644 --- a/icu4c/source/i18n/ucol_res.cpp +++ b/icu4c/source/i18n/ucol_res.cpp @@ -453,6 +453,8 @@ ucol_openRulesForImport( const UChar *rules, } result->hasRealData = TRUE; result->freeImageOnClose = TRUE; + } else { + goto cleanup; } } else { /* no rules, but no error either */ // must be only options diff --git a/icu4c/source/i18n/ucurr.cpp b/icu4c/source/i18n/ucurr.cpp index 707aa480a95..b86f8e288c6 100644 --- a/icu4c/source/i18n/ucurr.cpp +++ b/icu4c/source/i18n/ucurr.cpp @@ -223,8 +223,8 @@ idForLocale(const char* locale, char* countryAndVariant, int capacity, UErrorCod uloc_getCountry(locale, countryAndVariant, capacity, ec); uloc_getVariant(locale, variant, sizeof(variant), ec); if (variant[0] != 0) { - variantType = (0 == uprv_strcmp(variant, VAR_EURO)) - | ((0 == uprv_strcmp(variant, VAR_PRE_EURO)) << 1); + variantType = (uint32_t)(0 == uprv_strcmp(variant, VAR_EURO)) + | ((uint32_t)(0 == uprv_strcmp(variant, VAR_PRE_EURO)) << 1); if (variantType) { uprv_strcat(countryAndVariant, VAR_DELIM_STR); diff --git a/icu4c/source/i18n/unicode/msgfmt.h b/icu4c/source/i18n/unicode/msgfmt.h index 7c5cb0ddff4..60ba1538574 100644 --- a/icu4c/source/i18n/unicode/msgfmt.h +++ b/icu4c/source/i18n/unicode/msgfmt.h @@ -1073,10 +1073,17 @@ private: public: virtual UBool operator==(const Format&) const; virtual Format* clone() const; + virtual UnicodeString& format(const Formattable& obj, + UnicodeString& appendTo, + UErrorCode& status) const; virtual UnicodeString& format(const Formattable&, UnicodeString& appendTo, FieldPosition&, UErrorCode& status) const; + virtual UnicodeString& format(const Formattable& obj, + UnicodeString& appendTo, + FieldPositionIterator* posIter, + UErrorCode& status) const; virtual void parseObject(const UnicodeString&, Formattable&, ParsePosition&) const; diff --git a/icu4c/source/io/locbund.cpp b/icu4c/source/io/locbund.cpp index b2dfa1b74d4..8486f996e02 100644 --- a/icu4c/source/io/locbund.cpp +++ b/icu4c/source/io/locbund.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1998-2011, International Business Machines +* Copyright (C) 1998-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -29,7 +29,6 @@ #include "unicode/ustring.h" #include "unicode/uloc.h" -static UBool isFormatsInitialized = FALSE; static UNumberFormat *gPosixNumberFormat[ULOCALEBUNDLE_NUMBERFORMAT_COUNT]; U_CDECL_BEGIN @@ -39,7 +38,6 @@ static UBool U_CALLCONV locbund_cleanup(void) { unum_close(gPosixNumberFormat[style]); gPosixNumberFormat[style] = NULL; } - isFormatsInitialized = FALSE; return TRUE; } U_CDECL_END diff --git a/icu4c/source/layout/LookupProcessor.cpp b/icu4c/source/layout/LookupProcessor.cpp index 04295852193..4f9d97c58d1 100644 --- a/icu4c/source/layout/LookupProcessor.cpp +++ b/icu4c/source/layout/LookupProcessor.cpp @@ -1,6 +1,6 @@ /* * - * (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved + * (C) Copyright IBM Corp. 1998-2012 - All Rights Reserved * */ @@ -199,6 +199,11 @@ LookupProcessor::LookupProcessor(const char *baseAddress, featureReferences += SWAPW(featureTable->lookupCount); } + if (!featureTable) { + success = LE_INTERNAL_ERROR; + return; + } + if (requiredFeatureIndex != 0xFFFF) { requiredFeatureTable = featureListTable->getFeatureTable(requiredFeatureIndex, &requiredFeatureTag); featureReferences += SWAPW(featureTable->lookupCount); diff --git a/icu4c/source/tools/ctestfw/ctest.c b/icu4c/source/tools/ctestfw/ctest.c index 474e75423e9..6e79261f904 100644 --- a/icu4c/source/tools/ctestfw/ctest.c +++ b/icu4c/source/tools/ctestfw/ctest.c @@ -1182,7 +1182,7 @@ setTestOption ( int32_t testOption, int32_t value) { REPEAT_TESTS = value; break; case ICU_TRACE_OPTION: - ICU_TRACE = value; + ICU_TRACE = (UTraceLevel)value; break; default : break; diff --git a/icu4c/source/tools/gencnval/gencnval.c b/icu4c/source/tools/gencnval/gencnval.c index 0f0a915887b..12718cd7bee 100644 --- a/icu4c/source/tools/gencnval/gencnval.c +++ b/icu4c/source/tools/gencnval/gencnval.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1999-2011, International Business Machines +* Copyright (C) 1999-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -644,7 +644,6 @@ addToKnownAliases(const char *alias) { static uint16_t addAlias(const char *alias, uint16_t standard, uint16_t converter, UBool defaultName) { uint32_t idx, idx2; - UBool dupFound = FALSE; UBool startEmptyWithoutDefault = FALSE; AliasList *aliasList; @@ -713,7 +712,6 @@ addAlias(const char *alias, uint16_t standard, uint16_t converter, UBool default GET_ALIAS_STR(converters[converter].converter), GET_ALIAS_STR(converters[idx].converter)); } - dupFound = TRUE; break; } } diff --git a/icu4c/source/tools/genrb/parse.cpp b/icu4c/source/tools/genrb/parse.cpp index b9e393c2881..f5a5fd779ae 100644 --- a/icu4c/source/tools/genrb/parse.cpp +++ b/icu4c/source/tools/genrb/parse.cpp @@ -73,7 +73,7 @@ const char *tokenNames[TOK_TOKEN_COUNT] = }; /* Just to store "TRUE" */ -static const UChar trueValue[] = {0x0054, 0x0052, 0x0055, 0x0045, 0x0000}; +//static const UChar trueValue[] = {0x0054, 0x0052, 0x0055, 0x0045, 0x0000}; typedef struct { struct Lookahead lookahead[MAX_LOOKAHEAD + 1]; @@ -283,7 +283,6 @@ parseUCARules(ParseState* state, char *tag, uint32_t startline, const struct USt char filename[256] = { '\0' }; char cs[128] = { '\0' }; uint32_t line; - int len=0; UBool quoted = FALSE; UCHARBUF *ucbuf=NULL; UChar32 c = 0; @@ -363,7 +362,7 @@ parseUCARules(ParseState* state, char *tag, uint32_t startline, const struct USt * append at the end of the loop */ while(c != ENDCOMMAND) { - U_APPEND_CHAR32(c, target,len); + U_APPEND_CHAR32_ONLY(c, target); c = ucbuf_getc(ucbuf, status); } } @@ -396,7 +395,7 @@ parseUCARules(ParseState* state, char *tag, uint32_t startline, const struct USt /* Append UChar * after dissembling if c > 0xffff*/ if (c != (UChar32)U_EOF) { - U_APPEND_CHAR32(c, target,len); + U_APPEND_CHAR32_ONLY(c, target); } else { diff --git a/icu4c/source/tools/genrb/ustr.h b/icu4c/source/tools/genrb/ustr.h index b2d597256bd..05a446ea0e5 100644 --- a/icu4c/source/tools/genrb/ustr.h +++ b/icu4c/source/tools/genrb/ustr.h @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1998-2011, International Business Machines +* Copyright (C) 1998-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -35,6 +35,19 @@ } \ } +#define U_APPEND_CHAR32_ONLY(c,target) { \ + if (c <= 0xffff) \ + { \ + *(target)++ = (UChar) c; \ + } \ + else \ + { \ + target[0] = U16_LEAD(c); \ + target[1] = U16_TRAIL(c); \ + target +=2; \ + } \ +} + /* A C representation of a string "object" (to avoid realloc all the time) */ struct UString { UChar *fChars; diff --git a/icu4c/source/tools/genrb/wrtjava.c b/icu4c/source/tools/genrb/wrtjava.c index ff6f63b030c..6239569d85e 100644 --- a/icu4c/source/tools/genrb/wrtjava.c +++ b/icu4c/source/tools/genrb/wrtjava.c @@ -82,7 +82,7 @@ static int tabCount = 3; static FileStream* out=NULL; static struct SRBRoot* srBundle ; -static const char* outDir = NULL; +/*static const char* outDir = NULL;*/ static const char* bName=NULL; static const char* pName=NULL; @@ -621,7 +621,7 @@ bundle_write_java(struct SRBRoot *bundle, const char *outputDir,const char* outp char className[256]={'\0'}; /*char constructor[1000] = { 0 };*/ /*UBool j1 =FALSE;*/ - outDir = outputDir; + /*outDir = outputDir;*/ start = TRUE; /* Reset the start indictor*/ diff --git a/icu4c/source/tools/makeconv/genmbcs.cpp b/icu4c/source/tools/makeconv/genmbcs.cpp index 5c4c911b377..556d8139419 100644 --- a/icu4c/source/tools/makeconv/genmbcs.cpp +++ b/icu4c/source/tools/makeconv/genmbcs.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2000-2011, International Business Machines +* Copyright (C) 2000-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -399,7 +399,7 @@ MBCSAddToUnicode(MBCSData *mbcsData, offset+=MBCS_ENTRY_TRANSITION_OFFSET(entry); } else { if(iucm->states.maxCharLength; @@ -1097,7 +1097,7 @@ transformEUC(MBCSData *mbcsData) { /* modify outputType and adjust stage3Top */ mbcsData->ucm->states.outputType=(int8_t)(MBCS_OUTPUT_3_EUC+oldLength-3); - mbcsData->stage3Top=new3Top=(old3Top*(oldLength-1))/oldLength; + mbcsData->stage3Top=(old3Top*(oldLength-1))/oldLength; /* * EUC-encode all byte sequences; diff --git a/icu4c/source/tools/makeconv/makeconv.c b/icu4c/source/tools/makeconv/makeconv.c index 09cd9c8bb78..424c9622511 100644 --- a/icu4c/source/tools/makeconv/makeconv.c +++ b/icu4c/source/tools/makeconv/makeconv.c @@ -1,7 +1,7 @@ /* ******************************************************************************** * - * Copyright (C) 1998-2011, International Business Machines + * Copyright (C) 1998-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************** @@ -245,7 +245,7 @@ int main(int argc, char* argv[]) } if(options[OPT_VERSION].doesOccur) { - printf("makeconv version %hu.%hu, ICU tool to read .ucm codepage mapping files and write .cnv files\n", + printf("makeconv version %u.%u, ICU tool to read .ucm codepage mapping files and write .cnv files\n", dataInfo.formatVersion[0], dataInfo.formatVersion[1]); printf("%s\n", U_COPYRIGHT_STRING); exit(0); @@ -293,7 +293,7 @@ int main(int argc, char* argv[]) arg = getLongPathname(*argv); /* Check for potential buffer overflow */ - if(strlen(arg) > UCNV_MAX_FULL_FILE_NAME_LENGTH) + if(strlen(arg) >= UCNV_MAX_FULL_FILE_NAME_LENGTH) { fprintf(stderr, "%s\n", u_errorName(U_BUFFER_OVERFLOW_ERROR)); return U_BUFFER_OVERFLOW_ERROR; diff --git a/icu4c/source/tools/pkgdata/pkgdata.cpp b/icu4c/source/tools/pkgdata/pkgdata.cpp index 0ec63db42cc..44c1a388d6b 100644 --- a/icu4c/source/tools/pkgdata/pkgdata.cpp +++ b/icu4c/source/tools/pkgdata/pkgdata.cpp @@ -1117,13 +1117,17 @@ static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, c } #ifndef U_WINDOWS_WITH_MSVC char buffer[SMALL_BUFFER_MAX_SIZE] = ""; + int32_t bufferLength = 0; FileStream *f = T_FileStream_open(fileListName, "r"); if (f != NULL) { for(;;) { if (T_FileStream_readLine(f, buffer, SMALL_BUFFER_MAX_SIZE) != NULL) { + bufferLength = uprv_strlen(buffer); /* Remove new line character. */ - buffer[uprv_strlen(buffer)-1] = 0; + if (bufferLength > 0) { + buffer[bufferLength-1] = 0; + } sprintf(cmd, "%s %s%s%s %s%s%s", pkgDataFlags[INSTALL_CMD], @@ -2011,6 +2015,7 @@ static void loadLists(UPKGOptions *o, UErrorCode *status) option->doesOccur = TRUE; return 0; -#endif +#else return -1; +#endif } diff --git a/icu4c/source/tools/toolutil/pkg_genc.c b/icu4c/source/tools/toolutil/pkg_genc.c index e0e91bdefea..dc87188a22c 100644 --- a/icu4c/source/tools/toolutil/pkg_genc.c +++ b/icu4c/source/tools/toolutil/pkg_genc.c @@ -1012,7 +1012,7 @@ writeObjectCode(const char *filename, const char *destdir, const char *optEntryP /* deal with options, files and the entry point name */ getArchitecture(&cpu, &bits, &makeBigEndian, optMatchArch); - printf("genccode: --match-arch cpu=%hu bits=%hu big-endian=%hu\n", cpu, bits, makeBigEndian); + printf("genccode: --match-arch cpu=%hu bits=%hu big-endian=%d\n", cpu, bits, makeBigEndian); #if U_PLATFORM_HAS_WIN32_API if(cpu==IMAGE_FILE_MACHINE_I386) { entryOffset=1; diff --git a/icu4c/source/tools/toolutil/pkg_gencmn.c b/icu4c/source/tools/toolutil/pkg_gencmn.c index ced82138d2e..25f36088a0f 100644 --- a/icu4c/source/tools/toolutil/pkg_gencmn.c +++ b/icu4c/source/tools/toolutil/pkg_gencmn.c @@ -203,9 +203,7 @@ createCommonDataFile(const char *destDir, const char *name, const char *entrypoi addFile(getLongPathname(line), name, source, sourceTOC, verbose); } - if (linePtr) { - uprv_free(linePtr); - } + uprv_free(linePtr); if(in!=T_FileStream_stdin()) { T_FileStream_close(in); diff --git a/icu4c/source/tools/toolutil/ppucd.cpp b/icu4c/source/tools/toolutil/ppucd.cpp index c2a1b77d4b7..f1c711c8e87 100644 --- a/icu4c/source/tools/toolutil/ppucd.cpp +++ b/icu4c/source/tools/toolutil/ppucd.cpp @@ -71,7 +71,7 @@ PreparsedUCD::PreparsedUCD(const char *filename, UErrorCode &errorCode) } if(file==NULL) { perror("error opening preparsed UCD"); - fprintf(stderr, "error opening preparsed UCD file %s\n", filename); + fprintf(stderr, "error opening preparsed UCD file %s\n", filename ? filename : "\"no file name given\""); errorCode=U_FILE_ACCESS_ERROR; return; } @@ -327,6 +327,11 @@ PreparsedUCD::parseProperty(UniProps &props, const char *field, UnicodeSet &newV "for non-binary property on line %ld\n", field, (long)lineNumber); errorCode=U_PARSE_ERROR; + } else if (prop < UCHAR_INT_START) { + fprintf(stderr, + "error in preparsed UCD: prop value is invalid: '%d' for line %ld\n", + prop, (long)lineNumber); + errorCode=U_PARSE_ERROR; } else if(propgetPropertyValueEnum(prop, v); if(value==UCHAR_INVALID_CODE && prop==UCHAR_CANONICAL_COMBINING_CLASS) { diff --git a/icu4c/source/tools/toolutil/swapimpl.cpp b/icu4c/source/tools/toolutil/swapimpl.cpp index 90c1eb41e05..5b67b0fd524 100644 --- a/icu4c/source/tools/toolutil/swapimpl.cpp +++ b/icu4c/source/tools/toolutil/swapimpl.cpp @@ -653,7 +653,7 @@ test_swap(const UDataSwapper *ds, /* udata_swapDataHeader checks the arguments */ headerSize=udata_swapDataHeader(ds, inData, length, outData, pErrorCode); if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { - udata_printError(ds, "test_swap(): data header swap failed %s\n", u_errorName(*pErrorCode)); + udata_printError(ds, "test_swap(): data header swap failed %s\n", pErrorCode != NULL ? u_errorName(*pErrorCode) : "pErrorCode is NULL"); return 0; } diff --git a/icu4c/source/tools/toolutil/ucmstate.c b/icu4c/source/tools/toolutil/ucmstate.c index 5d8c8777356..ee07a4ca772 100644 --- a/icu4c/source/tools/toolutil/ucmstate.c +++ b/icu4c/source/tools/toolutil/ucmstate.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2003-2011, International Business Machines +* Copyright (C) 2003-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -1028,7 +1028,7 @@ ucm_countChars(UCMStates *states, } if(offset!=0) { - fprintf(stderr, "ucm error: byte sequence too short, ends in non-final state %hu\n", state); + fprintf(stderr, "ucm error: byte sequence too short, ends in non-final state %u\n", state); return -1; } diff --git a/icu4c/source/tools/toolutil/uparse.c b/icu4c/source/tools/toolutil/uparse.c index 3d098cbfac8..5878597ad35 100644 --- a/icu4c/source/tools/toolutil/uparse.c +++ b/icu4c/source/tools/toolutil/uparse.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2000-2011, International Business Machines +* Copyright (C) 2000-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -245,6 +245,7 @@ u_parseString(const char *s, } if(s==NULL || destCapacity<0 || (destCapacity>0 && dest==NULL)) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; + return 0; } if(pFirst!=NULL) { -- 2.40.0