]> granicus.if.org Git - icu/commitdiff
ICU-8578 Apply patch to fix some compiler warnings and related issues
authorMichael Ow <mow@svn.icu-project.org>
Fri, 10 Jun 2011 18:56:08 +0000 (18:56 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Fri, 10 Jun 2011 18:56:08 +0000 (18:56 +0000)
X-SVN-Rev: 30205

45 files changed:
icu4c/source/common/common.vcxproj
icu4c/source/common/icuplug.c
icu4c/source/common/locdispnames.cpp
icu4c/source/common/locmap.c
icu4c/source/common/uloc_tag.c
icu4c/source/common/unicode/umachine.h
icu4c/source/common/uniset_props.cpp
icu4c/source/common/unorm.cpp
icu4c/source/common/unormcmp.cpp
icu4c/source/i18n/alphaindex.cpp
icu4c/source/i18n/i18n.vcxproj
icu4c/source/i18n/msgfmt.cpp
icu4c/source/i18n/plurrule.cpp
icu4c/source/i18n/unicode/msgfmt.h
icu4c/source/i18n/unicode/plurfmt.h
icu4c/source/i18n/uspoof_impl.cpp
icu4c/source/icudefs.mk.in
icu4c/source/samples/ucnv/convsamp.cpp
icu4c/source/test/cintltst/bocu1tst.c
icu4c/source/test/cintltst/ccaltst.c
icu4c/source/test/cintltst/ccapitst.c
icu4c/source/test/cintltst/cintltst.vcxproj
icu4c/source/test/cintltst/cloctst.c
icu4c/source/test/cintltst/cmsccoll.c
icu4c/source/test/cintltst/nucnvtst.c
icu4c/source/test/cintltst/putiltst.c
icu4c/source/test/cintltst/reapits.c
icu4c/source/test/cintltst/sprpdata.c
icu4c/source/test/cintltst/usrchtst.c
icu4c/source/test/intltest/calregts.cpp
icu4c/source/test/intltest/caltest.cpp
icu4c/source/test/intltest/fldset.cpp
icu4c/source/test/intltest/intltest.vcxproj
icu4c/source/test/intltest/numrgts.cpp
icu4c/source/test/intltest/plurults.cpp
icu4c/source/test/intltest/rbbitst.cpp
icu4c/source/test/intltest/regextst.cpp
icu4c/source/test/intltest/srchtest.cpp
icu4c/source/test/intltest/tmsgfmt.cpp
icu4c/source/test/intltest/utxttest.cpp
icu4c/source/test/iotest/filetst.c
icu4c/source/test/iotest/iotest.vcxproj
icu4c/source/test/perf/collationperf/collperf.cpp
icu4c/source/tools/dumpce/dumpce.cpp
icu4c/source/tools/gencfu/gencfu.cpp

index cc2c3c23eaab6f90939e0a28bf17adadfe463280..20f1cefd75d991725aa41650dae3126648698c20 100644 (file)
@@ -86,7 +86,7 @@
       <TypeLibraryName>.\..\..\lib\icuuc.tlb</TypeLibraryName>\r
     </Midl>\r
     <ClCompile>\r
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
     </Midl>\r
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;RBBI_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;RBBI_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
       <TypeLibraryName>.\..\..\lib64\icuuc.tlb</TypeLibraryName>\r
     </Midl>\r
     <ClCompile>\r
-      <PreprocessorDefinitions>WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
     </Midl>\r
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
-      <PreprocessorDefinitions>WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;RBBI_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;RBBI_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
@@ -1744,7 +1744,7 @@ copy "%(FullPath)"  ..\..\include\unicode\%(FileName).h</Command>
       <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)"  unicode\%(FileName).h\r
 copy "%(FullPath)"  ..\..\include\unicode\%(FileName).h</Command>\r
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">unicode\%(Filename).h;..\..\include\unicode\%(Filename).h;%(Outputs)</Outputs>\r
-            <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)"  unicode\%(FileName).h\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)"  unicode\%(FileName).h\r
 copy "%(FullPath)"  ..\..\include\unicode\%(FileName).h</Command>\r
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">unicode\%(Filename).h;..\..\include\unicode\%(Filename).h;%(Outputs)</Outputs>\r
       <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)"  unicode\%(FileName).h\r
index f5a4a66f39370bd424cd555089b914bd2fcabf97..5040be0526d5c214cf96644845f58bb21d104648 100644 (file)
@@ -809,6 +809,7 @@ uplug_init(UErrorCode *status) {
           }
         }
       }
+      fclose(f);
     } else {
 #if UPLUG_TRACE
       DBG((stderr, "Can't open plugin file %s\n", plugin_file));
index cc6340c29dabf01e1a6968a5f01c4531d6a2b946..9b5230d0b9d6ba121cc12d7d07a48f097f6d725a 100644 (file)
@@ -535,7 +535,7 @@ uloc_getDisplayName(const char *locale,
         int32_t langPos=0; /* position in output of language substitution */
         int32_t restLen=0; /* length of 'everything else' substitution */
         int32_t restPos=0; /* position in output of 'everything else' substitution */
-        UEnumeration* kenum; /* keyword enumeration */
+        UEnumeration* kenum = NULL; /* keyword enumeration */
 
         /* prefix of pattern, extremely likely to be empty */
         if(sub0Pos) {
index 0855e913e863756aea8f5a98a162ad9db7ec3f33..dc06318ca3d7e2520d91100fa433e58ead699a93 100644 (file)
@@ -957,7 +957,7 @@ uprv_convertToPosix(uint32_t hostid, UErrorCode* status)
 
     ret = GetLocaleInfoA(hostid, LOCALE_SNAME, (LPSTR)gPosixFromLCID, sizeof(gPosixFromLCID));
     if (ret > 1) {
-        FIX_LOCALE_ID_TAG_SEPARATOR(gPosixFromLCID, ret, localeIndex)
+        FIX_LOCALE_ID_TAG_SEPARATOR(gPosixFromLCID, (uint32_t)ret, localeIndex)
         FIX_LANGUAGE_ID_TAG(gPosixFromLCID, ret)
 
         return gPosixFromLCID;
index 6d01df09e0c0dce80d4f0459e3a71d1867d329a5..6289e8f6bc18335a4e4ba334a3632967d4271b13 100644 (file)
@@ -1464,6 +1464,7 @@ _appendKeywordsToLanguageTag(const char* localeID, char* appendAt, int32_t capac
             ext = uprv_malloc(sizeof(ExtensionListEntry));
             if (ext == NULL) {
                 *status = U_MEMORY_ALLOCATION_ERROR;
+                goto cleanup;
             }
             ext->key = POSIX_KEY;
             ext->value = POSIX_VALUE;
@@ -1531,6 +1532,7 @@ _appendKeywordsToLanguageTag(const char* localeID, char* appendAt, int32_t capac
                 }
             } while (attr != NULL || ext != NULL);
         }
+cleanup:
         /* clean up */
         ext = firstExt;
         while (ext != NULL) {
@@ -2047,13 +2049,13 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
 
     /* create a ULanguageTag */
     t = (ULanguageTag*)uprv_malloc(sizeof(ULanguageTag));
-    _initializeULanguageTag(t);
-    t->buf = tagBuf;
     if (t == NULL) {
         uprv_free(tagBuf);
         *status = U_MEMORY_ALLOCATION_ERROR;
         return NULL;
     }
+    _initializeULanguageTag(t);
+    t->buf = tagBuf;
 
     if (tagLen < MINLEN) {
         /* the input tag is too short - return empty ULanguageTag */
index 1ff91a3574fb58683c1435076c45e1120b1c915d..a587883fb3cdb4384fa1dc5e782281c84a4bfc46 100644 (file)
 #   define U_CDECL_END
 #endif
 
+#ifndef U_ATTRIBUTE_DEPRECATED
 /**
  * \def U_ATTRIBUTE_DEPRECATED
  *  This is used for GCC specific attributes
 #else
 #    define U_ATTRIBUTE_DEPRECATED
 #endif
+#endif
+
 /** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
 #define U_CAPI U_CFUNC U_EXPORT
 /** This is used to declare a function as a stable public ICU C API*/
index c4e46657f78611251a8428d597431da337da8411..30c65f470e3224de5a80aba74ccd94b748eb6a1f 100644 (file)
@@ -115,6 +115,7 @@ private:
         UnicodeSet *set=new UnicodeSet(pattern, errorCode);
         if(set==NULL) {
             errorCode=U_MEMORY_ALLOCATION_ERROR;
+            return NULL;
         }
         set->freeze();
         ucln_common_registerCleanup(UCLN_COMMON_USET, uset_cleanup);
@@ -191,8 +192,8 @@ const UnicodeSet* UnicodeSet::getInclusions(int32_t src, UErrorCode &status) {
             NULL, // don't need remove()
             NULL // don't need removeRange()
         };
-        incl->ensureCapacity(DEFAULT_INCLUSION_CAPACITY, status);
         if (incl != NULL) {
+            incl->ensureCapacity(DEFAULT_INCLUSION_CAPACITY, status);
             switch(src) {
             case UPROPS_SRC_CHAR:
                 uchar_addPropertyStarts(&sa, &status);
index 8b685ea600f7aa7c709329d19fef1c69aeba03bb..d31682183ee063d895ece389e8bea4827c6b27ac 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ******************************************************************************
-* Copyright (c) 1996-2010, International Business Machines
+* Copyright (c) 1996-2011, International Business Machines
 * Corporation and others. All Rights Reserved.
 ******************************************************************************
 * File unorm.cpp
@@ -126,13 +126,16 @@ unorm_iterate(UCharIterator *src, UBool forward,
     } else {
         uni32=NULL;  // unused
     }
+
+    if(U_FAILURE(*pErrorCode)) {
+        return 0;
+    }
+
     FilteredNormalizer2 fn2(*n2, *uni32);
     if(options&UNORM_UNICODE_3_2) {
         n2=&fn2;
     }
-    if(U_FAILURE(*pErrorCode)) {
-        return 0;
-    }
+    
     if( destCapacity<0 || (dest==NULL && destCapacity>0) ||
         src==NULL
     ) {
@@ -227,13 +230,16 @@ unorm_concatenate(const UChar *left, int32_t leftLength,
     } else {
         uni32=NULL;  // unused
     }
+
+    if(U_FAILURE(*pErrorCode)) {
+        return 0;
+    }
+
     FilteredNormalizer2 fn2(*n2, *uni32);
     if(options&UNORM_UNICODE_3_2) {
         n2=&fn2;
     }
-    if(U_FAILURE(*pErrorCode)) {
-        return 0;
-    }
+    
     if( destCapacity<0 || (dest==NULL && destCapacity>0) ||
         left==NULL || leftLength<-1 ||
         right==NULL || rightLength<-1
index 83fbc58ecf9d6d5395f8cf1aa3959fcfa29df22b..f53f8660af6256d9163330c98ef1563b85645152 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2001-2010, International Business Machines
+*   Copyright (C) 2001-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -591,6 +591,9 @@ unorm_compare(const UChar *s1, int32_t length1,
         } else {
             uni32=NULL;  // unused
         }
+        if(U_FAILURE(*pErrorCode)) {
+            return 0;
+        }
         FilteredNormalizer2 fn2(*n2, *uni32);
         if(normOptions&UNORM_UNICODE_3_2) {
             n2=&fn2;
index f8d5ffc3db4143f5426eaa2961aeb510c650e8cf..a4bb522a69b61f02acf33f7b833405be8cf79449 100644 (file)
@@ -867,10 +867,11 @@ UVector *AlphabeticIndex::firstStringsInScript(UErrorCode &status) {
         return NULL;
     }
     UVector *dest = new UVector(status);
-    dest->setDeleter(uprv_deleteUObject);
     if (dest == NULL && U_SUCCESS(status)) {
         status = U_MEMORY_ALLOCATION_ERROR;
+        return NULL;
     }
+    dest->setDeleter(uprv_deleteUObject);
     const UChar *src  = HACK_FIRST_CHARS_IN_SCRIPTS;
     const UChar *limit = src + sizeof(HACK_FIRST_CHARS_IN_SCRIPTS) / sizeof(HACK_FIRST_CHARS_IN_SCRIPTS[0]);
     do {
index d660201ba7257976be28bb4d464239eec13f4115..c83f024062718e4752c30e9429c610c7564e3808 100644 (file)
@@ -87,7 +87,7 @@
     </Midl>\r
     <ClCompile>\r
       <AdditionalIncludeDirectories>..\..\include;..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
       <AdditionalIncludeDirectories>..\..\include;..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
     </Midl>\r
     <ClCompile>\r
       <AdditionalIncludeDirectories>..\..\include;..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
       <AdditionalIncludeDirectories>..\..\include;..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
-</Project>\r
+</Project>
\ No newline at end of file
index 4ed4526ada8f967b4dde07c07331f9beebbe74d5..212a809cdd8575928c0a8dc3d4d912f0c6efe26b 100644 (file)
@@ -548,7 +548,7 @@ void MessageFormat::setArgStartFormat(int32_t argStart,
 }
 
 
-bool MessageFormat::argNameMatches(int32_t partIndex, const UnicodeString& argName, int32_t argNumber) {
+UBool MessageFormat::argNameMatches(int32_t partIndex, const UnicodeString& argName, int32_t argNumber) {
     const MessagePattern::Part& part = msgPattern.getPart(partIndex);
     return part.getType() == UMSGPAT_PART_TYPE_ARG_NAME ?
         msgPattern.partSubstringMatches(part, argName) :
index 3b8c114f47e7956ae16a4a97db404e81938b9d2e..3fcbfa5cbce4372b8539b1fd9f824fac4c87c658 100644 (file)
@@ -206,7 +206,7 @@ PluralRules::getKeywords(UErrorCode& status) const {
 
 double
 PluralRules::getUniqueKeywordValue(const UnicodeString& keyword) {
-  double val;
+  double val = 0.0;
   UErrorCode status = U_ZERO_ERROR;
   int32_t count = getSamplesInternal(keyword, &val, 1, FALSE, status);
   return count == 1 ? val : UPLRULES_NO_UNIQUE_VALUE;
index 5c5ebddd0dbcad452b22132d271999411ff544ae..b2fc2b2b6a46f8c5a1d6ff0d33dc49e06e013a5c 100644 (file)
@@ -991,7 +991,7 @@ private:
 
     int32_t nextTopLevelArgStart(int32_t partIndex) const;
 
-    bool argNameMatches(int32_t partIndex, const UnicodeString& argName, int32_t argNumber);
+    UBool argNameMatches(int32_t partIndex, const UnicodeString& argName, int32_t argNumber);
 
     void cacheExplicitFormats(UErrorCode& status);
 
index 63939223eca6a1d5e3694246e2f3fe56cfa9f6e3..cc1a426a57c08e9fb2c00617af4d2183391a4a67 100644 (file)
@@ -484,7 +484,7 @@ public:
      /**
       * @internal 
       */
-    class  PluralSelector : public UMemory {
+    class U_I18N_API PluralSelector : public UMemory {
       public:
         /**
          * Given a number, returns the appropriate PluralFormat keyword.
index d4be252c71d3bb5f4c1b8d8e3476088deaac77b5..e43072273d53f99c706642df3afe5a364ddaaabe 100644 (file)
@@ -27,7 +27,7 @@ U_NAMESPACE_BEGIN
 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SpoofImpl)
 
 SpoofImpl::SpoofImpl(SpoofData *data, UErrorCode &status) :
-    fMagic(0), fSpoofData(NULL), fAllowedCharsSet(NULL) , fAllowedLocales(NULL) {
+    fMagic(0), fSpoofData(NULL), fAllowedCharsSet(NULL) , fAllowedLocales(uprv_strdup("")) {
     if (U_FAILURE(status)) {
         return;
     }
@@ -35,12 +35,12 @@ SpoofImpl::SpoofImpl(SpoofData *data, UErrorCode &status) :
     fSpoofData = data;
     fChecks = USPOOF_ALL_CHECKS;
     UnicodeSet *allowedCharsSet = new UnicodeSet(0, 0x10ffff);
-    if (allowedCharsSet == NULL) {
+    if (allowedCharsSet == NULL || fAllowedLocales == NULL) {
         status = U_MEMORY_ALLOCATION_ERROR;
+        return;
     }
     allowedCharsSet->freeze();
     fAllowedCharsSet = allowedCharsSet;
-    fAllowedLocales  = uprv_strdup("");
 }
 
 
index a6923e32fac3eb1be38ecd4a4a9eca758ac53f66..316ba53a4eb6b0118e096ac252caffab95bb7496 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Yves Arrouye.
 #
-# Copyright (C) 2000-2010, International Business Machines Corporation and others.
+# Copyright (C) 2000-2011, International Business Machines Corporation and others.
 # All Rights Reserved.
 
 #
@@ -124,7 +124,8 @@ UCLN_NO_AUTO_CLEANUP = @UCLN_NO_AUTO_CLEANUP@
 # DEFS is for common macro definitions.
 # configure prevents user defined DEFS, and configure's DEFS is not needed
 # So we ignore the DEFS that comes from configure
-DEFS =
+# U_ATTRIBUTE_DEPRECATED is defined to hide warnings about deprecated API warnings.
+DEFS = -DU_ATTRIBUTE_DEPRECATED=
 # CFLAGS is for C only flags
 CFLAGS = @CFLAGS@
 # CXXFLAGS is for C++ only flags
index 506a1b6448b65e48a76044d32149a04232cf9d5f..93cd4d2a867daf955c1481a021a09a58276a926f 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
 *
-*   Copyright (C) 2000-2010, International Business Machines
+*   Copyright (C) 2000-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ***************************************************************************
@@ -397,7 +397,6 @@ UErrorCode convsample_06()
   char inBuf[BUFFERSIZE];
   const char *source;
   const char *sourceLimit;
-  UChar *uBuf;
   int32_t uBufSize = 0;
   UConverter *conv;
   UErrorCode status = U_ZERO_ERROR;
@@ -438,8 +437,6 @@ UErrorCode convsample_06()
   uBufSize = (BUFFERSIZE/ucnv_getMinCharSize(conv));
   printf("input bytes %d / min chars %d = %d UChars\n",
          BUFFERSIZE, ucnv_getMinCharSize(conv), uBufSize);
-  uBuf = (UChar*)malloc(uBufSize * sizeof(UChar));
-  assert(uBuf!=NULL);
 
   // grab another buffer's worth
   while((!feof(f)) && 
@@ -473,6 +470,9 @@ UErrorCode convsample_06()
       if(p>charCount)
       {
         fprintf(stderr, "U+%06X: oh.., we only handle BMP characters so far.. redesign!\n", p);
+        free(info);
+        fclose(f);
+        ucnv_close(conv);
         return U_UNSUPPORTED_ERROR;
       }
       info[p].frequency++;
index 41647ffb41d393519b6c864f66fa8c7ef235c760..47b29e209dcee589f53c7e960b60eef6da04b237 100644 (file)
@@ -895,35 +895,35 @@ roundtripBOCU1(UConverter *bocu1, int32_t number, const UChar *text, int32_t len
     bocu1ICULength=ucnv_fromUChars(bocu1, bocu1ICU, DEFAULT_BUFFER_SIZE, text, length, &errorCode);
     if(U_FAILURE(errorCode)) {
         log_err("ucnv_fromUChars(BOCU-1, text(%d)[%d]) failed: %s\n", number, length, u_errorName(errorCode));
-        return;
+        goto cleanup; 
     }
 
     if(bocu1RefLength!=bocu1ICULength || 0!=uprv_memcmp(bocu1Ref, bocu1ICU, bocu1RefLength)) {
         log_err("Unicode(%d)[%d] -> BOCU-1: reference[%d]!=ICU[%d]\n", number, length, bocu1RefLength, bocu1ICULength);
-        return;
+        goto cleanup;
     }
 
     /* BOCU-1 -> Unicode */
     roundtripRefLength=readString((uint8_t *)bocu1Ref, bocu1RefLength, roundtripRef);
     if(roundtripRefLength<0) {
-        free(roundtripICU);
-        return; /* readString() found an error and reported it */
+        goto cleanup; /* readString() found an error and reported it */
     }
 
     roundtripICULength=ucnv_toUChars(bocu1, roundtripICU, DEFAULT_BUFFER_SIZE, bocu1ICU, bocu1ICULength, &errorCode);
     if(U_FAILURE(errorCode)) {
         log_err("ucnv_toUChars(BOCU-1, text(%d)[%d]) failed: %s\n", number, length, u_errorName(errorCode));
-        return;
+        goto cleanup;
     }
 
     if(length!=roundtripRefLength || 0!=u_memcmp(text, roundtripRef, length)) {
         log_err("BOCU-1 -> Unicode: original(%d)[%d]!=reference[%d]\n", number, length, roundtripRefLength);
-        return;
+        goto cleanup;
     }
     if(roundtripRefLength!=roundtripICULength || 0!=u_memcmp(roundtripRef, roundtripICU, roundtripRefLength)) {
         log_err("BOCU-1 -> Unicode: reference(%d)[%d]!=ICU[%d]\n", number, roundtripRefLength, roundtripICULength);
-        return;
+        goto cleanup;
     }
+cleanup:
     free(roundtripRef);
     free(roundtripICU);
     free(bocu1Ref);
index f0ae5b175af54199957b6c8440fa68baf32706c0..64109871e832f5ea302da7da32c488b4f49b647a 100644 (file)
@@ -127,7 +127,7 @@ static void TestCalendar()
     
     /*Test ucal_openTimeZones, ucal_openCountryTimeZones and ucal_openTimeZoneIDEnumeration */
     for (j=0; j<6; ++j) {
-        const char *api;
+        const char *api = "?";
         const int32_t offsetMinus5 = -5*60*60*1000;
         switch (j) {
         case 0:
index 85f503cbd52a060ede2619ac3dec99f5e41489db..7191ecaf774a8087cb17d65cc81c067c1dc421fe 100644 (file)
@@ -594,8 +594,8 @@ static void TestConvert()
         if (!myConverter || U_FAILURE(err))   
         {
             log_data_err("Error creating the ibm-949 converter - %s \n", u_errorName(err));
-
-            return;
+            fclose(ucs_file_name);
+            break;
         }
 
         /*testing for ucnv_getName()  */
@@ -885,7 +885,8 @@ static void TestConvert()
         if (BOM!=0xFEFF && BOM!=0xFFFE) 
         {
             log_err("File Missing BOM...Bailing!\n");
-            return;
+            fclose(ucs_file_in);
+            break;
         }
 
 
@@ -2478,11 +2479,13 @@ static const char *const badUTF8[]={
     "\xff"
 };
 
+#define ARG_CHAR_ARR_SIZE 8
+
 /* get some character that can be converted and convert it */
 static UBool getTestChar(UConverter *cnv, const char *converterName,
                          char charUTF8[4], int32_t *pCharUTF8Length,
-                         char char0[8], int32_t *pChar0Length,
-                         char char1[8], int32_t *pChar1Length) {
+                         char char0[ARG_CHAR_ARR_SIZE], int32_t *pChar0Length,
+                         char char1[ARG_CHAR_ARR_SIZE], int32_t *pChar1Length) {
     UChar utf16[U16_MAX_LENGTH];
     int32_t utf16Length;
 
@@ -2507,7 +2510,7 @@ static UBool getTestChar(UConverter *cnv, const char *converterName,
     utf16Source=utf16;
     target=char0;
     ucnv_fromUnicode(cnv,
-                     &target, char0+sizeof(char0),
+                     &target, char0+ARG_CHAR_ARR_SIZE,
                      &utf16Source, utf16+utf16Length,
                      NULL, FALSE, &errorCode);
     *pChar0Length=(int32_t)(target-char0);
@@ -2515,7 +2518,7 @@ static UBool getTestChar(UConverter *cnv, const char *converterName,
     utf16Source=utf16;
     target=char1;
     ucnv_fromUnicode(cnv,
-                     &target, char1+sizeof(char1),
+                     &target, char1+ARG_CHAR_ARR_SIZE,
                      &utf16Source, utf16+utf16Length,
                      NULL, FALSE, &errorCode);
     *pChar1Length=(int32_t)(target-char1);
index d4754f0b8de4fdd4098292c3ba39f6944e15a6af..234e24a8892bbf6aac90e27b4571f1f46268be3d 100644 (file)
@@ -84,7 +84,7 @@
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\tools\ctestfw;..\..\common;..\..\i18n;..\..\tools\toolutil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
     </Midl>\r
     <ClCompile>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\tools\ctestfw;..\..\common;..\..\i18n;..\..\tools\toolutil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\tools\ctestfw;..\..\common;..\..\i18n;..\..\tools\toolutil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
     </Midl>\r
     <ClCompile>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\tools\ctestfw;..\..\common;..\..\i18n;..\..\tools\toolutil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
-</Project>
+</Project>
\ No newline at end of file
index 55af3c43c48ebf00ee3181d1be9bd17f14627969..01c4effd9804d431c10e9fff3abd589441f7d66b 100644 (file)
@@ -561,28 +561,27 @@ static void TestSimpleResourceInfo() {
     cleanUpDataTable();
 }
 
-/* obviously, on non-ascii platforms this is useless, but it's test/debug code */
 /* if len < 0, we convert until we hit UChar 0x0000, which is not output. will add trailing null
  * if there's room but won't be included in result.  result < 0 indicates an error.
  * Returns the number of chars written (not those that would be written if there's enough room.*/
 static int32_t UCharsToEscapedAscii(const UChar* utext, int32_t len, char* resultChars, int32_t buflen) {
-#if U_CHARSET_FAMILY != U_ASCII_FAMILY
-    return -1;
-#else
-    static const UChar ESCAPE_MAP[] = {
-        /*a*/ 0x61, 0x07,
-        /*b*/ 0x62, 0x08,
-        /*e*/ 0x65, 0x1b,
-        /*f*/ 0x66, 0x0c,
-        /*n*/ 0x6E, 0x0a,
-        /*r*/ 0x72, 0x0d,
-        /*t*/ 0x74, 0x09,
-        /*v*/ 0x76, 0x0b
+    static const struct {
+        char escapedChar;
+        UChar sourceVal;
+    } ESCAPE_MAP[] = {
+        /*a*/ {'a', 0x07},
+        /*b*/ {'b', 0x08},
+        /*e*/ {'e', 0x1b},
+        /*f*/ {'f', 0x0c},
+        /*n*/ {'n', 0x0a},
+        /*r*/ {'r', 0x0d},
+        /*t*/ {'t', 0x09},
+        /*v*/ {'v', 0x0b}
     };
     static const int32_t ESCAPE_MAP_LENGTH = sizeof(ESCAPE_MAP)/sizeof(ESCAPE_MAP[0]);
     static const char HEX_DIGITS[] = {
-        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-        0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66
+        '0', '1', '2', '3', '4', '5', '6', '7',
+        '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
     };
     int32_t i, j;
     int32_t resultLen = 0;
@@ -601,21 +600,19 @@ static int32_t UCharsToEscapedAscii(const UChar* utext, int32_t len, char* resul
             break;
         }
         if(uc<0x20) {
-            for(j=0;j<ESCAPE_MAP_LENGTH;j+=2) {
-                if(uc==ESCAPE_MAP[j+1]) {
-                    break;
-                }
+            for(j=0;j<ESCAPE_MAP_LENGTH && uc!=ESCAPE_MAP[j].sourceVal;j++) {
             }
             if(j<ESCAPE_MAP_LENGTH) {
                 if(resultLen>escapeLimit1) {
                     break;
                 }
                 resultChars[resultLen++]='\\';
-                resultChars[resultLen++]=ESCAPE_MAP[j];
+                resultChars[resultLen++]=ESCAPE_MAP[j].escapedChar;
                 continue;
             }
         } else if(uc<0x7f) {
-            resultChars[resultLen++] = uc;
+            u_austrncpy(resultChars + resultLen, &uc, 1);
+            resultLen++;
             continue;
         }
 
@@ -637,7 +634,6 @@ static int32_t UCharsToEscapedAscii(const UChar* utext, int32_t len, char* resul
     }
 
     return resultLen;
-#endif
 }
 
 /*
@@ -747,7 +743,7 @@ static void TestDisplayNames()
                         locale, displayLocale, preflightLen, expectedLen);
             } else if(u_strncmp(result, expected, len)) {
                 int32_t cap=len*6+1;  /* worst case + space for trailing null */
-                char* resultChars=malloc(cap);
+                char* resultChars=(char*)malloc(cap);
                 int32_t resultCharsLen=UCharsToEscapedAscii(result, len, resultChars, cap);
                 if(resultCharsLen<0 || resultCharsLen<cap-1) {
                     log_err("uloc_getDisplayName(%s, %s...) mismatch", locale, displayLocale);
index 743c68d6c265f343877485ac902fb6335e955d0e..f66755d549d497cacb4d8a2a7f7fcf17cb607935 100644 (file)
@@ -1671,7 +1671,7 @@ static void TestComposeDecompose(void) {
         log_err("Set was zero. Missing data?\n");
         return;
     }
-    t = malloc(charsToTestSize * sizeof(tester *));
+    t = (tester **)malloc(charsToTestSize * sizeof(tester *));
     t[0] = (tester *)malloc(sizeof(tester));
     log_verbose("Testing UCA extensively for %d characters\n", charsToTestSize);
 
@@ -5920,7 +5920,7 @@ static void TestNonLeadBytesDuringCollationReordering(void)
 
     UChar testString[] = { 0x03b1, 0x03b2, 0x03b3 };
     
-    int i;
+    uint32_t i;
 
 
     log_verbose("Testing non-lead bytes in a sort key with and without reordering\n");
@@ -6208,7 +6208,7 @@ static int compareUScriptCodes(const void * a, const void * b)
   return ( *(int32_t*)a - *(int32_t*)b );
 }
 
-static void TestEquivalentReorderingScripts() {
+static void TestEquivalentReorderingScripts(void) {
     UErrorCode status = U_ZERO_ERROR;
     int32_t equivalentScripts[50];
     int32_t equivalentScriptsLength;
@@ -6282,7 +6282,7 @@ static void TestEquivalentReorderingScripts() {
     }
 }
 
-static void TestReorderingAcrossCloning() 
+static void TestReorderingAcrossCloning(void
 {
     UErrorCode status = U_ZERO_ERROR;
     UCollator  *myCollation;
@@ -6348,7 +6348,7 @@ static void TestReorderingAcrossCloning()
  */
 static void doTestOneReorderingAPITestCase(const OneTestCase testCases[], uint32_t testCasesLen, const int32_t reorderTokens[], int32_t reorderTokensLen)
 {
-    int testCaseNum;
+    uint32_t testCaseNum;
     UErrorCode status = U_ZERO_ERROR;
     UCollator  *myCollation;
 
@@ -6477,7 +6477,7 @@ static void TestHaniReorder(void)
     doTestOneReorderingAPITestCase(privateUseCharacterStrings, LEN(privateUseCharacterStrings), apiRules, LEN(apiRules));
 }
 
-static void TestMultipleReorder()
+static void TestMultipleReorder(void)
 {
     const char* strRules[] = {
         "[reorder Grek Zzzz DIGIT Latn Hani]"
index 24f241a43e828e895ddc53580fecfac905441166..3265f4a92a2dec2a5aff4f151422a6655fe1e3b2 100644 (file)
@@ -5579,12 +5579,12 @@ TestIsFixedWidth() {
     for (i = 0; i < LENGTHOF(notFixedWidth); i++) {
         cnv = ucnv_open(notFixedWidth[i], &status);
         if (cnv == NULL || U_FAILURE(status)) {
-            log_data_err("Error open converter: %s - %s \n", fixedWidth[i], u_errorName(status));
+            log_data_err("Error open converter: %s - %s \n", notFixedWidth[i], u_errorName(status));
             continue;
         }
 
         if (ucnv_isFixedWidth(cnv, &status)) {
-            log_err("%s is NOT a fixedWidth converter but returned TRUE.\n", fixedWidth[i]);
+            log_err("%s is NOT a fixedWidth converter but returned TRUE.\n", notFixedWidth[i]);
         }
         ucnv_close(cnv);
     }
index 84a519501cf2bd2fb7cf32e9406aca690da80257..beb4a6d512a8e68a4e4081949f43bd45f3ff4e50 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1998-2010, International Business Machines Corporation and
+ * Copyright (c) 1998-2011, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /*
@@ -185,7 +185,7 @@ static void TestPUtilAPI(void){
     }
 }
 
-static void TestVersion()
+static void TestVersion(void)
 {
     UVersionInfo versionArray = {0x01, 0x00, 0x02, 0x02};
     UVersionInfo versionArray2 = {0x01, 0x00, 0x02, 0x02};
@@ -288,7 +288,7 @@ static void TestVersion()
     }
 }
 
-static void TestCompareVersions()
+static void TestCompareVersions(void)
 {
    /* use a 1d array to be palatable to java */
    const char *testCases[] = {
index 197752546b46ed82db1277647f9b301a4703a518..2bc91eb7390c90d4a2f4fc2b7d0370349ffb703c 100644 (file)
@@ -1757,7 +1757,7 @@ static void TestUTextAPI(void) {
             nativeIndex = utext_getNativeIndex(actual);
             /*  Following returns U_INDEX_OUTOFBOUNDS_ERROR... looks like a bug in ucstrFuncs UTextFuncs [utext.cpp]  */
             /*  len16 = utext_extract(actual, nativeIndex, nativeIndex + group_len, NULL, 0, &shallowStatus);  */
-            len16 = group_len;
+            len16 = (int32_t)group_len;
             
             groupChars = (UChar *)malloc(sizeof(UChar)*(len16+1));
             utext_extract(actual, nativeIndex, nativeIndex + group_len, groupChars, len16+1, &shallowStatus);
index a96251cb34d98df3800d97d65a034f9e52ef547d..ff2f9bd8cb73ea4eab94727b3cc72e4e5112a143 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003-2008, International Business Machines
+ *   Copyright (C) 2003-2011, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
@@ -285,7 +285,6 @@ doStringPrepTest(const char* binFileName, const char* txtFileName, int32_t optio
     relativepath = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
 #endif
 
-    filename = (char*) malloc(strlen(srcdatapath)+strlen(relativepath)+strlen(txtFileName)+10 );
     profile = usprep_open(testdatapath, binFileName, errorCode);
 
     if(*errorCode == U_FILE_ACCESS_ERROR) {
@@ -295,6 +294,7 @@ doStringPrepTest(const char* binFileName, const char* txtFileName, int32_t optio
         log_err("Failed to load %s data file. Error: %s \n", binFileName, u_errorName(*errorCode));
         return;
     }
+    filename = (char*) malloc(strlen(srcdatapath)+strlen(relativepath)+strlen(txtFileName)+10 );
     /* open and load the txt file */
     strcpy(filename,srcdatapath);
     strcat(filename,relativepath);
index e98e46150fbf5efd11de4a90529745ab16459f54..8c88fe2fbbfb1fd9edc7c607e3c0d3c90a60c073 100644 (file)
@@ -2893,7 +2893,7 @@ exit:
 }
 
 
-static void TestPCEBuffer_100df() {
+static void TestPCEBuffer_100df(void) {
   UChar search[] =
     { 0x0020, 0x0020, 0x00df, 0x0020, 0x0041, 0x00df, 0x0020, 0x0061, 0x00df, 0x0020, 0x00c5, 0x00df, 0x0020, 0x212b, 0x00df, 0x0020, 0x0041, 0x030a, 0x00df, 0x0020, 0x00e5, 0x00df, 0x0020, 0x0061, 0x02da, 0x00df, 0x0020, 0x0061, 0x030a, 0x00df, 0x0020, 0xd8fa, 0xdeae, 0x00df, 0x0020, 0x2027, 0x00df }; /* 38 cp, 9 of them unpaired surrogates */
   UChar source[] = 
@@ -2904,7 +2904,7 @@ static void TestPCEBuffer_100df() {
  }
 
 
-static void TestPCEBuffer_2surr() {
+static void TestPCEBuffer_2surr(void) {
   UChar search[] =
     { 0x0020, 0x0020, 0xdfff, 0x0020, 0x0041, 0xdfff, 0x0020, 0x0061, 0xdfff, 0x0020, 0x00c5, 0xdfff, 0x0020, 0x212b, 0xdfff, 0x0020, 0x0041, 0x030a, 0xdfff, 0x0020, 0x00e5, 0xdfff, 0x0020, 0x0061, 0x02da, 0xdfff, 0x0020, 0x0061, 0x030a, 0xdfff, 0x0020, 0xd8fa, 0xdeae, 0xdfff, 0x0020, 0x2027, 0xdfff }; /* 38 cp, 9 of them unpaired surrogates */
   UChar source[] = 
index 0c3ad2b606b0828e962f8729b2cc29d906dcac36..bc97a5514400d665af6f62c449f6eee6a1321729 100644 (file)
@@ -775,7 +775,8 @@ void CalendarRegressionTest::test4092362() {
 
     logln( UnicodeString(" Cal1 = ") + cal1->getTime(status) ); 
     logln( UnicodeString(" Cal1 time in ms = ") + cal1->get(UCAL_MILLISECOND,status) ); 
-    for( int32_t k = 0; k < 100 ; k++ ); 
+    for (int32_t k = 0; k < 100 ; k++)
+        ;
 
     GregorianCalendar *cal2 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); 
     /*cal2.set( Calendar::YEAR, 1997 ); 
index 616a09bca5bf2f59b8c8c3d97bf5bbd5aa9761ea..d57fc386168406f189a763bff07cdf84a06f6001 100644 (file)
@@ -2175,7 +2175,7 @@ void CalendarTest::Test1624() {
 
 void CalendarTest::TestTimeStamp() {
     UErrorCode status = U_ZERO_ERROR;
-    UDate start, time;
+    UDate start = 0.0, time;
     Calendar *cal;
 
     // Create a new Gregorian Calendar.
index b289ad60169308d5818588b3d02a85f68af85a7c..fcea3e072485115cc0d5d5a3be09c5d1a73c378b 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ************************************************************************
-* Copyright (c) 2007-2008, International Business Machines
+* Copyright (c) 2007-2011, International Business Machines
 * Corporation and others.  All Rights Reserved.
 ************************************************************************
 */
@@ -119,6 +119,8 @@ int32_t FieldsSet::parseFrom(const UnicodeString& str, const
             u_UCharsToChars(u, ch, len);
             ch[len] = 0; /* include terminating \0 */
             it_errln(UnicodeString("Parse Failed: Field ") + UnicodeString(ch) + UnicodeString(", err ") + UnicodeString(u_errorName(status)));
+            delete[] kv;
+            delete[] dest;
             return -1;
         }
 
@@ -132,6 +134,8 @@ int32_t FieldsSet::parseFrom(const UnicodeString& str, const
                 u_UCharsToChars(u, ch, len);
                 ch[len] = 0; /* include terminating \0 */
                 it_errln(UnicodeString("Parse Failed: Value ") + UnicodeString(ch) + UnicodeString(", err ") + UnicodeString(u_errorName(status)));
+                delete[] kv;
+                delete[] dest;
                 return -1;
             }
 
index 9a0a88d3c02074936a6fbdb9d7586a98dfe920ae..52ada6a373e1e68bdef21ad933abd0c94f47958f 100644 (file)
@@ -85,7 +85,7 @@
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\common;..\..\i18n;..\..\tools\toolutil;..\..\tools\ctestfw;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\common;..\..\i18n;..\..\tools\toolutil;..\..\tools\ctestfw;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
     </Midl>\r
     <ClCompile>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\common;..\..\i18n;..\..\tools\toolutil;..\..\tools\ctestfw;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
       <DisableLanguageExtensions>true</DisableLanguageExtensions>\r
     </Midl>\r
     <ClCompile>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\common;..\..\i18n;..\..\tools\toolutil;..\..\tools\ctestfw;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
       <DisableLanguageExtensions>true</DisableLanguageExtensions>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
-</Project>\r
+</Project>
\ No newline at end of file
index 8189cb079fa900eaeca0cdf3da2a4c501b1ca838..110e2e7cbd701d079b8ab3bc882685b38680c405 100644 (file)
@@ -712,8 +712,8 @@ void NumberFormatRegressionTest::Test4090504 (void)
             df->setMaximumFractionDigits(i);
             //sb = new StringBuffer("");
             fp.setField(0);
-            logln("  getMaximumFractionDigits() = " + i);
-            logln("  formated: " + df->format(d, sb, fp));
+            logln(UnicodeString("  getMaximumFractionDigits() = ") + i);
+            logln(UnicodeString("  formated: ") + df->format(d, sb, fp));
         }
     /*} catch (Exception foo) {
         errln("Bug 4090504 regression test failed. Message : " + foo.getMessage());
@@ -1994,12 +1994,12 @@ void NumberFormatRegressionTest::Test4147295(void)
         int minIntDig = sdf->getMinimumIntegerDigits();
         if (minIntDig != 0) {
             errln("Test failed");
-            errln(" Minimum integer digits : " + minIntDig);
+            errln(UnicodeString(" Minimum integer digits : ") + minIntDig);
             UnicodeString temp;
-            errln(" new pattern: " + sdf->toPattern(temp));
+            errln(UnicodeString(" new pattern: ") + sdf->toPattern(temp));
         } else {
             logln("Test passed");
-            logln(" Minimum integer digits : " + minIntDig);
+            logln(UnicodeString(" Minimum integer digits : ") + minIntDig);
         }
     }
     delete sdf;
index a05637aef205492e70ff69ca91e96e5ce6e573ee..bf7eb66efbe4519a3cad902acb1d2c1c54337388 100644 (file)
@@ -104,7 +104,11 @@ void PluralRulesTest::testAPI(/*char *par*/)
 
     // ======= Test clone, assignment operator && == operator.
     PluralRules *dupRule = defRule.clone();
-    if (dupRule!=NULL) {
+    if (dupRule==NULL) {
+        errln("ERROR: clone plural rules test failed!");
+        delete test;
+        return;
+    } else {
         if ( *dupRule != defRule ) {
             errln("ERROR:  clone plural rules test failed!");
         }
index 73f3443c01859ede901a684d5a902c015d2e9be3..880455c9fcd75d22f20bcb863df6fd8fc282c77c 100644 (file)
@@ -2146,7 +2146,7 @@ cleanUpAndReturn:
     ucnv_close(conv);
     if (U_FAILURE(status)) {
         errln("ucnv_toUChars: ICU Error \"%s\"\n", u_errorName(status));
-        delete retPtr;
+        delete []retPtr;
         retPtr = 0;
         ulen   = 0;
     };
index e3e43f8fe4abb30020c39100467a8f494a1c00b0..e9cd536ec928a60cf85078aca6144d76c8ec779e 100644 (file)
@@ -3173,7 +3173,7 @@ static UBool utextOffsetToNative(UText *utext, int32_t unistrOffset, int32_t& na
             break;
         }
     }
-    nativeIndex = UTEXT_GETNATIVEINDEX(utext);
+    nativeIndex = (int32_t)UTEXT_GETNATIVEINDEX(utext);
     return couldFind;
 }
 
@@ -3784,7 +3784,7 @@ cleanUpAndReturn:
     ucnv_close(conv);
     if (U_FAILURE(status)) {
         errln("ucnv_toUChars: ICU Error \"%s\"\n", u_errorName(status));
-        delete retPtr;
+        delete []retPtr;
         retPtr = 0;
         ulen   = 0;
     };
index 94afbc06c08863291f619f0833ef98750851b88f..a748ac707465a30a1b540022caa56b0a569c4005 100644 (file)
@@ -1074,9 +1074,7 @@ void StringSearchTest::TestCollator()
     if (U_FAILURE(status)) {
         errln("Error opening rule based collator %s", u_errorName(status));
         delete strsrch;
-        if (tailored != NULL) {
-            delete tailored;
-        }
+        delete tailored;
         return;
     }
 
@@ -1084,16 +1082,12 @@ void StringSearchTest::TestCollator()
     if (U_FAILURE(status) || (*strsrch->getCollator()) != (*tailored)) {
         errln("Error setting rule based collator");
         delete strsrch;
-        if (tailored != NULL) {
-            delete tailored;
-        }
+        delete tailored;
     }
     strsrch->reset();
     if (!assertEqualWithStringSearch(strsrch, &COLLATOR[1])) {
         delete strsrch;
-        if (tailored != NULL) {
-            delete tailored;
-        }
+        delete tailored;
         return;
     }
         
@@ -1102,17 +1096,13 @@ void StringSearchTest::TestCollator()
     if (U_FAILURE(status) || (*strsrch->getCollator()) != (*m_en_us_)) {
         errln("Error setting rule based collator");
         delete strsrch;
-        if (tailored != NULL) {
-            delete tailored;
-        }
+        delete tailored;
     }
     if (!assertEqualWithStringSearch(strsrch, &COLLATOR[0])) {
        errln("Error searching collator test");
     }
     delete strsrch;
-    if (tailored != NULL) {
-        delete tailored;
-    }
+    delete tailored;
 }
 
 void StringSearchTest::TestPattern()
index 6072cd496e81ac28708c60bd85875837cf7435ad..e32f27595077823d9f5272b4542b9872794adf9e 100644 (file)
@@ -1410,26 +1410,41 @@ static void _testCopyConstructor2()
     const Formattable fargs( d, Formattable::kIsDate );
 
     MessageFormat* fmt1 = new MessageFormat( formatStr, status );
-    MessageFormat* fmt2 = new MessageFormat( *fmt1 );
-    MessageFormat* fmt3;
-    MessageFormat* fmt4;
+    MessageFormat* fmt2 = NULL;
+    MessageFormat* fmt3 = NULL;
+    MessageFormat* fmt4 = NULL;
 
-    if (fmt1 == NULL) it_err("testCopyConstructor2: (fmt1 != NULL)");
+    if (fmt1 == NULL) {
+        it_err("testCopyConstructor2: (fmt1 != NULL)");
+        goto cleanup;
+    }
 
+    fmt2 = new MessageFormat( *fmt1 );
     result = fmt1->format( &fargs, 1, resultStr, fp, status );
 
-    if (fmt2 == NULL) it_err("testCopyConstructor2: (fmt2 != NULL)");
+    if (fmt2 == NULL) {
+        it_err("testCopyConstructor2: (fmt2 != NULL)");
+        goto cleanup;
+    }
 
     fmt3 = (MessageFormat*) fmt1->clone();
     fmt4 = (MessageFormat*) fmt2->clone();
 
-    if (fmt3 == NULL) it_err("testCopyConstructor2: (fmt3 != NULL)");
-    if (fmt4 == NULL) it_err("testCopyConstructor2: (fmt4 != NULL)");
+    if (fmt3 == NULL) {
+        it_err("testCopyConstructor2: (fmt3 != NULL)");
+        goto cleanup;
+    }
+    if (fmt4 == NULL) {
+        it_err("testCopyConstructor2: (fmt4 != NULL)");
+        goto cleanup;
+    }
 
     result = fmt1->format( &fargs, 1, resultStr, fp, status );
     result = fmt2->format( &fargs, 1, resultStr, fp, status );
     result = fmt3->format( &fargs, 1, resultStr, fp, status );
     result = fmt4->format( &fargs, 1, resultStr, fp, status );
+
+cleanup:
     delete fmt1;
     delete fmt2;
     delete fmt3;
index 5dd812778faa450d01ab260a3644418706111b10..2482bb4ad2ee2eee121d361d87d2671b4a79442a 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 2005-2010, International Business Machines Corporation and
+ * Copyright (c) 2005-2011, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /************************************************************************
@@ -1910,7 +1910,7 @@ void UTextTest::Ticket6847() {
     utext_setNativeIndex(ut, 0);
     int32_t count = 0;
     UChar32 c = 0;
-    int32_t nativeIndex = UTEXT_GETNATIVEINDEX(ut);
+    int64_t nativeIndex = UTEXT_GETNATIVEINDEX(ut);
     TEST_ASSERT(nativeIndex == 0);
     while ((c = utext_next32(ut)) != U_SENTINEL) {
         TEST_ASSERT(c == 0x41);
index c0ddd5ed2812f89f4f3642eef5d5a38315204085..fc104eb548589e470f7faefd57f82a60cf6eb2da 100644 (file)
@@ -920,7 +920,7 @@ static void TestCodepageFlush(void) {
   UFILE *myFile = u_fopen(STANDARD_TEST_FILE, "wb", "en_US_POSIX", enc);
   FILE *myCFile;
   int shift = 0;
-  int i;
+  int32_t i;
 
   if (myFile == NULL) {
     log_err("Can't write test file %s\n", STANDARD_TEST_FILE);
@@ -946,7 +946,7 @@ static void TestCodepageFlush(void) {
     }
 
     /* check if shift in and out */
-    for(i=0;i<inLen;i++) {
+    for(i=0;i<(int32_t)inLen;i++) {
       if(inBuf[i]==0x0E) {  /* SO */
         shift= 1;
       } else if(inBuf[i]==0x0F) { /* SI */
index aa7239595d5bf9d0bc890f245a25e11adf2d7764..8566f0e44bf0dee85dc727accc0e16f1b140c10c 100644 (file)
@@ -86,7 +86,7 @@
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\tools\ctestfw;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
     </Midl>\r
     <ClCompile>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\tools\ctestfw;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
       <DisableLanguageExtensions>true</DisableLanguageExtensions>\r
     <ClCompile>\r
       <Optimization>Disabled</Optimization>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\tools\ctestfw;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
       <BufferSecurityCheck>true</BufferSecurityCheck>\r
     </Midl>\r
     <ClCompile>\r
       <AdditionalIncludeDirectories>..\..\..\include;..\..\tools\ctestfw;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <StringPooling>true</StringPooling>\r
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
       <DisableLanguageExtensions>true</DisableLanguageExtensions>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
-</Project>
+</Project>
\ No newline at end of file
index 7bcf2e840d541557f8a47abc2ed7ce57fd808bf7..9149bfc5801a1075aa31b4487efada21d2671ea1 100644 (file)
@@ -1377,6 +1377,7 @@ UCollator *openRulesCollator() {
 
     int  bufLen = 10000;
     UChar *buf = (UChar *)malloc(bufLen * sizeof(UChar));
+    UChar *tmp;
     int i = 0;
 
     for(;;) {
@@ -1389,8 +1390,13 @@ UCollator *openRulesCollator() {
         }
         i++;
         if (i >= bufLen) {
+            tmp = buf;
             bufLen += 10000;
             buf = (UChar *)realloc(buf, bufLen);
+            if (buf == NULL) {
+                free(tmp);
+                return 0;
+            }
         }
     }
     buf[i] = 0;
index 47792faafd51745250b4e8b23fa70d74e0d0c9b1..236e3799942133900b79ff669138b5acf3af47eb 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (C) 2001-2005 IBM, Inc.   All Rights Reserved.
+ * Copyright (C) 2001-2011 IBM, Inc.   All Rights Reserved.
  *
  ********************************************************************/
 /********************************************************************************
@@ -572,7 +572,7 @@ CLOSETAILOR :
     }
 
     if (options[7].doesOccur) {
-        char inputfilename[128];
+        char inputfilename[128] = "";
         // rules are to be used
         if (options[5].doesOccur) {
             strcpy(inputfilename, options[5].value);
@@ -955,75 +955,74 @@ inline UBool checkInScripts(UScriptCode script[], int scriptcount,
 * Add by Richard
 */
 int getScriptElementsFromExemplars(ScriptElement scriptelem[], const char* locale) {
-       UErrorCode error = U_ZERO_ERROR;
-    UChar32    codepoint = 0;
+    UErrorCode error = U_ZERO_ERROR;
+    UChar32 codepoint = 0;
 
-       UResourceBundle* ures = ures_open(NULL, locale, &error);
-       if (U_FAILURE(error)) {
-               fprintf(stdout, "Can not find resource bundle for locale: %s\n", locale);
+    UResourceBundle* ures = ures_open(NULL, locale, &error);
+    if (U_FAILURE(error)) {
+        fprintf(stdout, "Can not find resource bundle for locale: %s\n", locale);
         return -1;
-       }
-       int32_t length;
-       const UChar* exemplarChars = ures_getStringByKey(ures, "ExemplarCharacters", &length, &error);
-       
-       if (U_FAILURE(error)) {
-               fprintf(stdout, "Can not find ExemplarCharacters in resource bundle\n");
+    }
+    int32_t length;
+    const UChar* exemplarChars = ures_getStringByKey(ures, "ExemplarCharacters", &length, &error);
+
+    if (U_FAILURE(error)) {
+        fprintf(stdout, "Can not find ExemplarCharacters in resource bundle\n");
         return -1;
-       }
+    }
 
-       UChar* upperChars = new UChar[length*2];
-       if (upperChars == 0) {
-               fprintf(stdout, "Memory error\n");
+    UChar* upperChars = new UChar[length * 2];
+    if (upperChars == 0) {
+        fprintf(stdout, "Memory error\n");
         return -1;
-       }
+    }
 
-       int32_t destLength = u_strToUpper(upperChars, length*2, exemplarChars, -1, locale, &error);
-       if (U_FAILURE(error)) {
-               fprintf(stdout, "Error when u_strToUpper() \n");
+    int32_t destLength = u_strToUpper(upperChars, length * 2, exemplarChars, -1, locale, &error);
+    if (U_FAILURE(error)) {
+        fprintf(stdout, "Error when u_strToUpper() \n");
         return -1;
-       }
-
-       UChar* pattern = new UChar[length + destLength + 10];
-       UChar left[2] = {0x005b, 0x0};
-       UChar right[2] = {0x005d, 0x0};
-       pattern = u_strcpy(pattern, left);
-       pattern = u_strcat(pattern, exemplarChars);
-       pattern = u_strcat(pattern, upperChars);
-       pattern = u_strcat(pattern, right);
-
-       UnicodeSet * uniset = new UnicodeSet(UnicodeString(pattern), error);
-       if (U_FAILURE(error)) {
-               fprintf(stdout, "Can not open USet \n");
+    }
+
+    UChar* pattern = new UChar[length + destLength + 10];
+    UChar left[2] = {0x005b, 0x0};
+    UChar right[2] = {0x005d, 0x0};
+    pattern = u_strcpy(pattern, left);
+    pattern = u_strcat(pattern, exemplarChars);
+    pattern = u_strcat(pattern, upperChars);
+    pattern = u_strcat(pattern, right);
+
+    UnicodeSet * uniset = new UnicodeSet(UnicodeString(pattern), error);
+    if (U_FAILURE(error)) {
+        fprintf(stdout, "Can not open USet \n");
         return -1;
-       }
-       
-       UnicodeSetIterator* usetiter = new UnicodeSetIterator(*uniset);
-
-       int32_t count = 0;
-
-       while (usetiter -> next()) {
-               if (usetiter -> isString()) {
-                       UnicodeString strItem = usetiter -> getString();
-
-                       scriptelem[count].count = 0;
-                       for (int i = 0; i < strItem.length(); i++) {
-                               codepoint = strItem.char32At(i);
-                               UTF16_APPEND_CHAR_UNSAFE(scriptelem[count].ch, 
-                                                                               scriptelem[count].count, codepoint);
-                               scriptelem[count].tailored = FALSE;
-                       }
-               } else {
-                       codepoint = usetiter -> getCodepoint();
-                       scriptelem[count].count = 0;
-                       UTF16_APPEND_CHAR_UNSAFE(scriptelem[count].ch, 
-                                                    scriptelem[count].count, codepoint);
-                       scriptelem[count].tailored = FALSE;
-               }
-
-               count++;
-       }
-
-       return count;
+    }
+
+    UnicodeSetIterator* usetiter = new UnicodeSetIterator(*uniset);
+
+    int32_t count = 0;
+
+    while (usetiter -> next()) {
+        if (usetiter -> isString()) {
+            UnicodeString strItem = usetiter -> getString();
+
+            scriptelem[count].count = 0;
+            for (int i = 0; i < strItem.length(); i++) {
+                codepoint = strItem.char32At(i);
+                UTF16_APPEND_CHAR_UNSAFE(scriptelem[count].ch, scriptelem[count].count, codepoint);
+                scriptelem[count].tailored = FALSE;
+            }
+        } else {
+            codepoint = usetiter -> getCodepoint();
+            scriptelem[count].count = 0;
+            UTF16_APPEND_CHAR_UNSAFE(scriptelem[count].ch, scriptelem[count].count, codepoint);
+            scriptelem[count].tailored = FALSE;
+        }
+
+        count++;
+    }
+    delete []pattern;
+
+    return count;
 }
 
 /**
@@ -1483,7 +1482,7 @@ void serializeScripts() {
         if (U_FAILURE(error)) {
             fprintf(stdout, "Collator creation failed:");
             fprintf(stdout, u_errorName(error));
-            return;
+            break;
         }
         if ((error != U_USING_FALLBACK_WARNING && // not tailored
             error != U_USING_DEFAULT_WARNING) ||
@@ -1493,7 +1492,7 @@ void serializeScripts() {
             if (U_FAILURE(error)) {
                fprintf(stdout, "Collator attribute setting failed:");
                fprintf(stdout, u_errorName(error));
-               return;
+               break;
             }
 
             UScriptCode scriptcode[32];
@@ -1501,7 +1500,7 @@ void serializeScripts() {
                                                    &error);
             if (U_FAILURE(error)) {
                 fprintf(stdout, "Error getting lcale scripts\n");
-                return;
+                break;
             }
 
             strcat(filename, locale);
@@ -1509,14 +1508,14 @@ void serializeScripts() {
             OUTPUT_ = fopen(filename, "w");
             if (OUTPUT_ == NULL) {
                 fprintf(stdout, "Cannot open file:%s\n", filename);
-                return;
+                break;
             }
             outputHTMLHeader(locale, scriptcode, scriptcount);
-                       fprintf(stdout, "%s\n", locale);
-                       
+            fprintf(stdout, "%s\n", locale);
+
             if(options[12].doesOccur) {
               // use whole scripts
-                         serializeScripts(scriptcode, scriptcount); 
+                serializeScripts(scriptcode, scriptcount);
             } else {
               // use exemplar chars
               serializeScripts(scriptcode, scriptcount, locale);
index b50d6cbb684ecfaff110ca85be6331deb0ecda4c..79a11f9fc0c6a010248a43645a6e237eefa6c2d2 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 2009-2010, International Business Machines
+*   Copyright (C) 2009-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *
@@ -313,7 +313,8 @@ int  main(int argc, char **argv) {
     fseek(file, 0, SEEK_SET);
     result = new char[fileSize+10];
     if (result==NULL) {
-        return result;
+        fclose(file);
+        return NULL;
     }
 
     long t = fread(result, 1, fileSize, file);