diff --git a/icu4c/source/common/common.vcxproj b/icu4c/source/common/common.vcxproj
index cc2c3c23eaa..20f1cefd75d 100644
--- a/icu4c/source/common/common.vcxproj
+++ b/icu4c/source/common/common.vcxproj
@@ -86,7 +86,7 @@
.\..\..\lib\icuuc.tlb
- WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;%(PreprocessorDefinitions)
true
MultiThreadedDLL
true
@@ -125,7 +125,7 @@
Disabled
- WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;RBBI_DEBUG;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;RBBI_DEBUG;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
true
@@ -165,7 +165,7 @@
.\..\..\lib64\icuuc.tlb
- WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;%(PreprocessorDefinitions)
true
MultiThreadedDLL
true
@@ -202,7 +202,7 @@
Disabled
- WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;RBBI_DEBUG;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_COMMON_IMPLEMENTATION;RBBI_DEBUG;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
true
@@ -1744,7 +1744,7 @@ copy "%(FullPath)" ..\..\include\unicode\%(FileName).h
copy "%(FullPath)" unicode\%(FileName).h
copy "%(FullPath)" ..\..\include\unicode\%(FileName).h
unicode\%(Filename).h;..\..\include\unicode\%(Filename).h;%(Outputs)
- copy "%(FullPath)" unicode\%(FileName).h
+ copy "%(FullPath)" unicode\%(FileName).h
copy "%(FullPath)" ..\..\include\unicode\%(FileName).h
unicode\%(Filename).h;..\..\include\unicode\%(Filename).h;%(Outputs)
copy "%(FullPath)" unicode\%(FileName).h
diff --git a/icu4c/source/common/icuplug.c b/icu4c/source/common/icuplug.c
index f5a4a66f393..5040be0526d 100644
--- a/icu4c/source/common/icuplug.c
+++ b/icu4c/source/common/icuplug.c
@@ -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));
diff --git a/icu4c/source/common/locdispnames.cpp b/icu4c/source/common/locdispnames.cpp
index cc6340c29da..9b5230d0b9d 100644
--- a/icu4c/source/common/locdispnames.cpp
+++ b/icu4c/source/common/locdispnames.cpp
@@ -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) {
diff --git a/icu4c/source/common/locmap.c b/icu4c/source/common/locmap.c
index 0855e913e86..dc06318ca3d 100644
--- a/icu4c/source/common/locmap.c
+++ b/icu4c/source/common/locmap.c
@@ -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;
diff --git a/icu4c/source/common/uloc_tag.c b/icu4c/source/common/uloc_tag.c
index 6d01df09e0c..6289e8f6bc1 100644
--- a/icu4c/source/common/uloc_tag.c
+++ b/icu4c/source/common/uloc_tag.c
@@ -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 */
diff --git a/icu4c/source/common/unicode/umachine.h b/icu4c/source/common/unicode/umachine.h
index 1ff91a3574f..a587883fb3c 100644
--- a/icu4c/source/common/unicode/umachine.h
+++ b/icu4c/source/common/unicode/umachine.h
@@ -111,6 +111,7 @@
# define U_CDECL_END
#endif
+#ifndef U_ATTRIBUTE_DEPRECATED
/**
* \def U_ATTRIBUTE_DEPRECATED
* This is used for GCC specific attributes
@@ -128,6 +129,8 @@
#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*/
diff --git a/icu4c/source/common/uniset_props.cpp b/icu4c/source/common/uniset_props.cpp
index c4e46657f78..30c65f470e3 100644
--- a/icu4c/source/common/uniset_props.cpp
+++ b/icu4c/source/common/uniset_props.cpp
@@ -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);
diff --git a/icu4c/source/common/unorm.cpp b/icu4c/source/common/unorm.cpp
index 8b685ea600f..d31682183ee 100644
--- a/icu4c/source/common/unorm.cpp
+++ b/icu4c/source/common/unorm.cpp
@@ -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
diff --git a/icu4c/source/common/unormcmp.cpp b/icu4c/source/common/unormcmp.cpp
index 83fbc58ecf9..f53f8660af6 100644
--- a/icu4c/source/common/unormcmp.cpp
+++ b/icu4c/source/common/unormcmp.cpp
@@ -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;
diff --git a/icu4c/source/i18n/alphaindex.cpp b/icu4c/source/i18n/alphaindex.cpp
index f8d5ffc3db4..a4bb522a69b 100644
--- a/icu4c/source/i18n/alphaindex.cpp
+++ b/icu4c/source/i18n/alphaindex.cpp
@@ -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 {
diff --git a/icu4c/source/i18n/i18n.vcxproj b/icu4c/source/i18n/i18n.vcxproj
index d660201ba72..c83f0240627 100644
--- a/icu4c/source/i18n/i18n.vcxproj
+++ b/icu4c/source/i18n/i18n.vcxproj
@@ -87,7 +87,7 @@
..\..\include;..\common;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)
true
MultiThreadedDLL
true
@@ -129,7 +129,7 @@
Disabled
..\..\include;..\common;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
true
@@ -172,7 +172,7 @@
..\..\include;..\common;%(AdditionalIncludeDirectories)
- WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)
true
MultiThreadedDLL
true
@@ -212,7 +212,7 @@
Disabled
..\..\include;..\common;%(AdditionalIncludeDirectories)
- WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;U_I18N_IMPLEMENTATION;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
true
@@ -1524,4 +1524,4 @@
-
+
\ No newline at end of file
diff --git a/icu4c/source/i18n/msgfmt.cpp b/icu4c/source/i18n/msgfmt.cpp
index 4ed4526ada8..212a809cdd8 100644
--- a/icu4c/source/i18n/msgfmt.cpp
+++ b/icu4c/source/i18n/msgfmt.cpp
@@ -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) :
diff --git a/icu4c/source/i18n/plurrule.cpp b/icu4c/source/i18n/plurrule.cpp
index 3b8c114f47e..3fcbfa5cbce 100644
--- a/icu4c/source/i18n/plurrule.cpp
+++ b/icu4c/source/i18n/plurrule.cpp
@@ -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;
diff --git a/icu4c/source/i18n/unicode/msgfmt.h b/icu4c/source/i18n/unicode/msgfmt.h
index 5c5ebddd0db..b2fc2b2b6a4 100644
--- a/icu4c/source/i18n/unicode/msgfmt.h
+++ b/icu4c/source/i18n/unicode/msgfmt.h
@@ -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);
diff --git a/icu4c/source/i18n/unicode/plurfmt.h b/icu4c/source/i18n/unicode/plurfmt.h
index 63939223eca..cc1a426a57c 100644
--- a/icu4c/source/i18n/unicode/plurfmt.h
+++ b/icu4c/source/i18n/unicode/plurfmt.h
@@ -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.
diff --git a/icu4c/source/i18n/uspoof_impl.cpp b/icu4c/source/i18n/uspoof_impl.cpp
index d4be252c71d..e43072273d5 100644
--- a/icu4c/source/i18n/uspoof_impl.cpp
+++ b/icu4c/source/i18n/uspoof_impl.cpp
@@ -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("");
}
diff --git a/icu4c/source/icudefs.mk.in b/icu4c/source/icudefs.mk.in
index a6923e32fac..316ba53a4eb 100644
--- a/icu4c/source/icudefs.mk.in
+++ b/icu4c/source/icudefs.mk.in
@@ -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
diff --git a/icu4c/source/samples/ucnv/convsamp.cpp b/icu4c/source/samples/ucnv/convsamp.cpp
index 506a1b6448b..93cd4d2a867 100644
--- a/icu4c/source/samples/ucnv/convsamp.cpp
+++ b/icu4c/source/samples/ucnv/convsamp.cpp
@@ -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++;
diff --git a/icu4c/source/test/cintltst/bocu1tst.c b/icu4c/source/test/cintltst/bocu1tst.c
index 41647ffb41d..47b29e209dc 100644
--- a/icu4c/source/test/cintltst/bocu1tst.c
+++ b/icu4c/source/test/cintltst/bocu1tst.c
@@ -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);
diff --git a/icu4c/source/test/cintltst/ccaltst.c b/icu4c/source/test/cintltst/ccaltst.c
index f0ae5b175af..64109871e83 100644
--- a/icu4c/source/test/cintltst/ccaltst.c
+++ b/icu4c/source/test/cintltst/ccaltst.c
@@ -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:
diff --git a/icu4c/source/test/cintltst/ccapitst.c b/icu4c/source/test/cintltst/ccapitst.c
index 85f503cbd52..7191ecaf774 100644
--- a/icu4c/source/test/cintltst/ccapitst.c
+++ b/icu4c/source/test/cintltst/ccapitst.c
@@ -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);
diff --git a/icu4c/source/test/cintltst/cintltst.vcxproj b/icu4c/source/test/cintltst/cintltst.vcxproj
index d4754f0b8de..234e24a8892 100644
--- a/icu4c/source/test/cintltst/cintltst.vcxproj
+++ b/icu4c/source/test/cintltst/cintltst.vcxproj
@@ -84,7 +84,7 @@
Disabled
..\..\..\include;..\..\tools\ctestfw;..\..\common;..\..\i18n;..\..\tools\toolutil;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
true
@@ -122,7 +122,7 @@
..\..\..\include;..\..\tools\ctestfw;..\..\common;..\..\i18n;..\..\tools\toolutil;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
true
MultiThreaded
true
@@ -160,7 +160,7 @@
Disabled
..\..\..\include;..\..\tools\ctestfw;..\..\common;..\..\i18n;..\..\tools\toolutil;%(AdditionalIncludeDirectories)
- WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
true
@@ -197,7 +197,7 @@
..\..\..\include;..\..\tools\ctestfw;..\..\common;..\..\i18n;..\..\tools\toolutil;%(AdditionalIncludeDirectories)
- WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
true
MultiThreaded
true
@@ -376,4 +376,4 @@
-
+
\ No newline at end of file
diff --git a/icu4c/source/test/cintltst/cloctst.c b/icu4c/source/test/cintltst/cloctst.c
index 55af3c43c48..01c4effd980 100644
--- a/icu4c/source/test/cintltst/cloctst.c
+++ b/icu4c/source/test/cintltst/cloctst.c
@@ -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;jescapeLimit1) {
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
Disabled
..\..\..\include;..\..\common;..\..\i18n;..\..\tools\toolutil;..\..\tools\ctestfw;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
true
@@ -125,7 +125,7 @@
Disabled
..\..\..\include;..\..\common;..\..\i18n;..\..\tools\toolutil;..\..\tools\ctestfw;%(AdditionalIncludeDirectories)
- WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebug
true
@@ -161,7 +161,7 @@
..\..\..\include;..\..\common;..\..\i18n;..\..\tools\toolutil;..\..\tools\ctestfw;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
true
MultiThreaded
true
@@ -196,7 +196,7 @@
..\..\..\include;..\..\common;..\..\i18n;..\..\tools\toolutil;..\..\tools\ctestfw;%(AdditionalIncludeDirectories)
- WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
true
MultiThreaded
true
@@ -533,4 +533,4 @@
-
+
\ No newline at end of file
diff --git a/icu4c/source/test/intltest/numrgts.cpp b/icu4c/source/test/intltest/numrgts.cpp
index 8189cb079fa..110e2e7cbd7 100644
--- a/icu4c/source/test/intltest/numrgts.cpp
+++ b/icu4c/source/test/intltest/numrgts.cpp
@@ -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;
diff --git a/icu4c/source/test/intltest/plurults.cpp b/icu4c/source/test/intltest/plurults.cpp
index a05637aef20..bf7eb66efbe 100644
--- a/icu4c/source/test/intltest/plurults.cpp
+++ b/icu4c/source/test/intltest/plurults.cpp
@@ -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!");
}
diff --git a/icu4c/source/test/intltest/rbbitst.cpp b/icu4c/source/test/intltest/rbbitst.cpp
index 73f3443c018..880455c9fcd 100644
--- a/icu4c/source/test/intltest/rbbitst.cpp
+++ b/icu4c/source/test/intltest/rbbitst.cpp
@@ -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;
};
diff --git a/icu4c/source/test/intltest/regextst.cpp b/icu4c/source/test/intltest/regextst.cpp
index e3e43f8fe4a..e9cd536ec92 100644
--- a/icu4c/source/test/intltest/regextst.cpp
+++ b/icu4c/source/test/intltest/regextst.cpp
@@ -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;
};
diff --git a/icu4c/source/test/intltest/srchtest.cpp b/icu4c/source/test/intltest/srchtest.cpp
index 94afbc06c08..a748ac70746 100644
--- a/icu4c/source/test/intltest/srchtest.cpp
+++ b/icu4c/source/test/intltest/srchtest.cpp
@@ -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()
diff --git a/icu4c/source/test/intltest/tmsgfmt.cpp b/icu4c/source/test/intltest/tmsgfmt.cpp
index 6072cd496e8..e32f2759507 100644
--- a/icu4c/source/test/intltest/tmsgfmt.cpp
+++ b/icu4c/source/test/intltest/tmsgfmt.cpp
@@ -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;
diff --git a/icu4c/source/test/intltest/utxttest.cpp b/icu4c/source/test/intltest/utxttest.cpp
index 5dd812778fa..2482bb4ad2e 100644
--- a/icu4c/source/test/intltest/utxttest.cpp
+++ b/icu4c/source/test/intltest/utxttest.cpp
@@ -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);
diff --git a/icu4c/source/test/iotest/filetst.c b/icu4c/source/test/iotest/filetst.c
index c0ddd5ed281..fc104eb5485 100644
--- a/icu4c/source/test/iotest/filetst.c
+++ b/icu4c/source/test/iotest/filetst.c
@@ -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
Disabled
..\..\..\include;..\..\tools\ctestfw;..\..\common;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
true
@@ -124,7 +124,7 @@
..\..\..\include;..\..\tools\ctestfw;..\..\common;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
true
MultiThreadedDLL
true
@@ -162,7 +162,7 @@
Disabled
..\..\..\include;..\..\tools\ctestfw;..\..\common;%(AdditionalIncludeDirectories)
- WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
true
@@ -198,7 +198,7 @@
..\..\..\include;..\..\tools\ctestfw;..\..\common;%(AdditionalIncludeDirectories)
- WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ U_ATTRIBUTE_DEPRECATED=;WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
true
MultiThreadedDLL
true
@@ -259,4 +259,4 @@
-
+
\ No newline at end of file
diff --git a/icu4c/source/test/perf/collationperf/collperf.cpp b/icu4c/source/test/perf/collationperf/collperf.cpp
index 7bcf2e840d5..9149bfc5801 100644
--- a/icu4c/source/test/perf/collationperf/collperf.cpp
+++ b/icu4c/source/test/perf/collationperf/collperf.cpp
@@ -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;
diff --git a/icu4c/source/tools/dumpce/dumpce.cpp b/icu4c/source/tools/dumpce/dumpce.cpp
index 47792faafd5..236e3799942 100644
--- a/icu4c/source/tools/dumpce/dumpce.cpp
+++ b/icu4c/source/tools/dumpce/dumpce.cpp
@@ -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);
+ 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");
+ 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;
+ UnicodeSetIterator* usetiter = new UnicodeSetIterator(*uniset);
- while (usetiter -> next()) {
- if (usetiter -> isString()) {
- UnicodeString strItem = usetiter -> getString();
+ int32_t count = 0;
- 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;
- }
+ while (usetiter -> next()) {
+ if (usetiter -> isString()) {
+ UnicodeString strItem = usetiter -> getString();
- count++;
- }
+ 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;
+ }
- return count;
+ 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);
diff --git a/icu4c/source/tools/gencfu/gencfu.cpp b/icu4c/source/tools/gencfu/gencfu.cpp
index b50d6cbb684..79a11f9fc0c 100644
--- a/icu4c/source/tools/gencfu/gencfu.cpp
+++ b/icu4c/source/tools/gencfu/gencfu.cpp
@@ -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);