/*
*******************************************************************************
-* Copyright (C) 1997-2010, International Business Machines Corporation and
+* Copyright (C) 1997-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
// Use the string if we found it
if (U_SUCCESS(status) && brkfname) {
uprv_strncpy(actualLocale,
- ures_getLocale(brkName, &status),
+ ures_getLocaleInternal(brkName, &status),
sizeof(actualLocale)/sizeof(actualLocale[0]));
UChar* extStart=u_strchr(brkfname, 0x002e);
<ClCompile Include="ubidi_props.c" />\r
<ClCompile Include="ubidiln.c" />\r
<ClCompile Include="ubidiwrt.c" />\r
- <ClCompile Include="ushape.c" />\r
+ <ClCompile Include="ushape.cpp" />\r
<ClCompile Include="brkeng.cpp" />\r
<ClCompile Include="brkiter.cpp" />\r
<ClCompile Include="dictbe.cpp" />\r
<ClCompile Include="ulist.c" />\r
<ClCompile Include="ustack.cpp" />\r
<ClCompile Include="ustrenum.cpp" />\r
- <ClCompile Include="utrie.c" />\r
+ <ClCompile Include="utrie.cpp" />\r
<ClCompile Include="utrie2.cpp" />\r
- <ClCompile Include="utrie2_builder.c" />\r
+ <ClCompile Include="utrie2_builder.cpp" />\r
<ClCompile Include="uvector.cpp" />\r
<ClCompile Include="uvectr32.cpp" />\r
<ClCompile Include="uvectr64.cpp" />\r
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DisableLanguageExtensions>\r
</ClCompile>\r
<ClCompile Include="mutex.cpp" />\r
- <ClCompile Include="putil.c">\r
+ <ClCompile Include="putil.cpp">\r
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableLanguageExtensions>\r
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</DisableLanguageExtensions>\r
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</DisableLanguageExtensions>\r
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DisableLanguageExtensions>\r
</ClCompile>\r
<ClCompile Include="ucnv.c" />\r
- <ClCompile Include="ucnv2022.c" />\r
- <ClCompile Include="ucnv_bld.c" />\r
+ <ClCompile Include="ucnv2022.cpp" />\r
+ <ClCompile Include="ucnv_bld.cpp" />\r
<ClCompile Include="ucnv_cb.c" />\r
<ClCompile Include="ucnv_cnv.c" />\r
<ClCompile Include="ucnv_ct.c" />\r
<ClCompile Include="ucnv_err.c" />\r
- <ClCompile Include="ucnv_ext.c" />\r
- <ClCompile Include="ucnv_io.c" />\r
+ <ClCompile Include="ucnv_ext.cpp" />\r
+ <ClCompile Include="ucnv_io.cpp" />\r
<ClCompile Include="ucnv_lmb.c" />\r
<ClCompile Include="ucnv_set.c" />\r
<ClCompile Include="ucnv_u16.c" />\r
<ClCompile Include="ucnv_u32.c" />\r
<ClCompile Include="ucnv_u7.c" />\r
<ClCompile Include="ucnv_u8.c" />\r
- <ClCompile Include="ucnvbocu.c" />\r
+ <ClCompile Include="ucnvbocu.cpp" />\r
<ClCompile Include="ucnvdisp.c" />\r
<ClCompile Include="ucnvhz.c" />\r
<ClCompile Include="ucnvisci.c" />\r
<ClCompile Include="ustrfmt.c" />\r
<ClCompile Include="util.cpp" />\r
<ClCompile Include="util_props.cpp" />\r
- <ClCompile Include="punycode.c" />\r
+ <ClCompile Include="punycode.cpp" />\r
<ClCompile Include="uidna.cpp" />\r
<ClCompile Include="uts46.cpp" />\r
<ClCompile Include="locavailable.cpp" />\r
<ClCompile Include="resbund.cpp" />\r
<ClCompile Include="resbund_cnv.cpp" />\r
<ClCompile Include="ucat.c" />\r
- <ClCompile Include="uloc.c" />\r
+ <ClCompile Include="uloc.cpp" />\r
<ClCompile Include="uloc_tag.c" />\r
<ClCompile Include="ures_cnv.c" />\r
- <ClCompile Include="uresbund.c" />\r
+ <ClCompile Include="uresbund.cpp" />\r
<ClCompile Include="uresdata.c" />\r
<ClCompile Include="caniter.cpp" />\r
<ClCompile Include="filterednormalizer2.cpp" />\r
<ClCompile Include="patternprops.cpp" />\r
<ClCompile Include="propname.cpp" />\r
<ClCompile Include="ruleiter.cpp" />\r
- <ClCompile Include="ucase.c" />\r
+ <ClCompile Include="ucase.cpp" />\r
<ClCompile Include="uchar.c" />\r
- <ClCompile Include="unames.c" />\r
+ <ClCompile Include="unames.cpp" />\r
<ClCompile Include="unifilt.cpp" />\r
<ClCompile Include="unifunct.cpp" />\r
<ClCompile Include="uniset.cpp" />\r
<ClCompile Include="schriter.cpp" />\r
<ClCompile Include="stringpiece.cpp" />\r
<ClCompile Include="stringtriebuilder.cpp" />\r
- <ClCompile Include="ucasemap.c" />\r
+ <ClCompile Include="ucasemap.cpp" />\r
<ClCompile Include="ucharstrie.cpp" />\r
<ClCompile Include="ucharstriebuilder.cpp" />\r
<ClCompile Include="ucharstrieiterator.cpp" />\r
<ClCompile Include="unistr_cnv.cpp" />\r
<ClCompile Include="unistr_props.cpp" />\r
<ClCompile Include="ustr_cnv.c" />\r
- <ClCompile Include="ustr_wcs.c" />\r
- <ClCompile Include="ustrcase.c" />\r
- <ClCompile Include="ustring.c" />\r
- <ClCompile Include="ustrtrns.c" />\r
+ <ClCompile Include="ustr_wcs.cpp" />\r
+ <ClCompile Include="ustrcase.cpp" />\r
+ <ClCompile Include="ustring.cpp" />\r
+ <ClCompile Include="ustrtrns.cpp" />\r
<ClCompile Include="utext.cpp" />\r
<ClCompile Include="utf_impl.c" />\r
</ItemGroup>\r
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
<ImportGroup Label="ExtensionTargets">\r
</ImportGroup>\r
-</Project>
+</Project>\r
<ClCompile Include="ubidiwrt.c">\r
<Filter>bidi</Filter>\r
</ClCompile>\r
- <ClCompile Include="ushape.c">\r
+ <ClCompile Include="ushape.cpp">\r
<Filter>bidi</Filter>\r
</ClCompile>\r
<ClCompile Include="brkeng.cpp">\r
<ClCompile Include="ustrenum.cpp">\r
<Filter>collections</Filter>\r
</ClCompile>\r
- <ClCompile Include="utrie.c">\r
+ <ClCompile Include="utrie.cpp">\r
<Filter>collections</Filter>\r
</ClCompile>\r
<ClCompile Include="utrie2.cpp">\r
<Filter>collections</Filter>\r
</ClCompile>\r
- <ClCompile Include="utrie2_builder.c">\r
+ <ClCompile Include="utrie2_builder.cpp">\r
<Filter>collections</Filter>\r
</ClCompile>\r
<ClCompile Include="uvector.cpp">\r
<ClCompile Include="mutex.cpp">\r
<Filter>configuration</Filter>\r
</ClCompile>\r
- <ClCompile Include="putil.c">\r
+ <ClCompile Include="putil.cpp">\r
<Filter>configuration</Filter>\r
</ClCompile>\r
<ClCompile Include="umath.c">\r
<ClCompile Include="ucnv.c">\r
<Filter>conversion</Filter>\r
</ClCompile>\r
- <ClCompile Include="ucnv2022.c">\r
+ <ClCompile Include="ucnv2022.cpp">\r
<Filter>conversion</Filter>\r
</ClCompile>\r
- <ClCompile Include="ucnv_bld.c">\r
+ <ClCompile Include="ucnv_bld.cpp">\r
<Filter>conversion</Filter>\r
</ClCompile>\r
<ClCompile Include="ucnv_cb.c">\r
<ClCompile Include="ucnv_err.c">\r
<Filter>conversion</Filter>\r
</ClCompile>\r
- <ClCompile Include="ucnv_ext.c">\r
+ <ClCompile Include="ucnv_ext.cpp">\r
<Filter>conversion</Filter>\r
</ClCompile>\r
- <ClCompile Include="ucnv_io.c">\r
+ <ClCompile Include="ucnv_io.cpp">\r
<Filter>conversion</Filter>\r
</ClCompile>\r
<ClCompile Include="ucnv_lmb.c">\r
<ClCompile Include="ucnv_u8.c">\r
<Filter>conversion</Filter>\r
</ClCompile>\r
- <ClCompile Include="ucnvbocu.c">\r
+ <ClCompile Include="ucnvbocu.cpp">\r
<Filter>conversion</Filter>\r
</ClCompile>\r
<ClCompile Include="ucnvdisp.c">\r
<ClCompile Include="util_props.cpp">\r
<Filter>formatting</Filter>\r
</ClCompile>\r
- <ClCompile Include="punycode.c">\r
+ <ClCompile Include="punycode.cpp">\r
<Filter>idna</Filter>\r
</ClCompile>\r
<ClCompile Include="uidna.cpp">\r
<ClCompile Include="ucat.c">\r
<Filter>locales & resources</Filter>\r
</ClCompile>\r
- <ClCompile Include="uloc.c">\r
+ <ClCompile Include="uloc.cpp">\r
<Filter>locales & resources</Filter>\r
</ClCompile>\r
<ClCompile Include="uloc_tag.c">\r
<ClCompile Include="ures_cnv.c">\r
<Filter>locales & resources</Filter>\r
</ClCompile>\r
- <ClCompile Include="uresbund.c">\r
+ <ClCompile Include="uresbund.cpp">\r
<Filter>locales & resources</Filter>\r
</ClCompile>\r
<ClCompile Include="uresdata.c">\r
<ClCompile Include="ruleiter.cpp">\r
<Filter>properties & sets</Filter>\r
</ClCompile>\r
- <ClCompile Include="ucase.c">\r
+ <ClCompile Include="ucase.cpp">\r
<Filter>properties & sets</Filter>\r
</ClCompile>\r
<ClCompile Include="uchar.c">\r
<Filter>properties & sets</Filter>\r
</ClCompile>\r
- <ClCompile Include="unames.c">\r
+ <ClCompile Include="unames.cpp">\r
<Filter>properties & sets</Filter>\r
</ClCompile>\r
<ClCompile Include="unifilt.cpp">\r
<ClCompile Include="stringpiece.cpp">\r
<Filter>strings</Filter>\r
</ClCompile>\r
- <ClCompile Include="ucasemap.c">\r
+ <ClCompile Include="ucasemap.cpp">\r
<Filter>strings</Filter>\r
</ClCompile>\r
<ClCompile Include="uchriter.cpp">\r
<ClCompile Include="ustr_cnv.c">\r
<Filter>strings</Filter>\r
</ClCompile>\r
- <ClCompile Include="ustr_wcs.c">\r
+ <ClCompile Include="ustr_wcs.cpp">\r
<Filter>strings</Filter>\r
</ClCompile>\r
- <ClCompile Include="ustrcase.c">\r
+ <ClCompile Include="ustrcase.cpp">\r
<Filter>strings</Filter>\r
</ClCompile>\r
- <ClCompile Include="ustring.c">\r
+ <ClCompile Include="ustring.cpp">\r
<Filter>strings</Filter>\r
</ClCompile>\r
- <ClCompile Include="ustrtrns.c">\r
+ <ClCompile Include="ustrtrns.cpp">\r
<Filter>strings</Filter>\r
</ClCompile>\r
<ClCompile Include="utext.cpp">\r
/*
**********************************************************************
- * Copyright (C) 1997-2010, International Business Machines
+ * Copyright (C) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
/*
*******************************************************************************
*
-* Copyright (C) 2002-2010, International Business Machines
+* Copyright (C) 2002-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
-* file name: punycode.c
+* file name: punycode.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
* range 0 to BASE-1. The lowercase form is used unless the uppercase flag is
* nonzero, in which case the uppercase form is used.
*/
-static U_INLINE char
+static inline char
digitToBasic(int32_t digit, UBool uppercase) {
/* 0..25 map to ASCII a..z or A..Z */
/* 26..35 map to ASCII 0..9 */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
-static U_INLINE char
+static inline char
asciiCaseMap(char b, UBool uppercase) {
if(uppercase) {
if(_SMALL_A<=b && b<=_SMALL_Z) {
#include "icucfg.h"
#endif
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
/* Define the extension for data files, again... */
#define DATA_TYPE "dat"
#ifdef DEBUG_TZNAME
fprintf(stderr, "TZ=%s std=%s dst=%s daylight=%d offset=%d\n", getenv("TZ"), stdID, dstID, daylightType, offset);
#endif
- for (idx = 0; idx < (int32_t)sizeof(OFFSET_ZONE_MAPPINGS)/sizeof(OFFSET_ZONE_MAPPINGS[0]); idx++)
+ for (idx = 0; idx < LENGTHOF(OFFSET_ZONE_MAPPINGS); idx++)
{
if (offset == OFFSET_ZONE_MAPPINGS[idx].offsetSeconds
&& daylightType == OFFSET_ZONE_MAPPINGS[idx].daylightType
if ((p = uprv_strchr(posixID, '.')) != NULL) {
/* assume new locale can't be larger than old one? */
- correctedPOSIXLocale = uprv_malloc(uprv_strlen(posixID)+1);
+ correctedPOSIXLocale = reinterpret_cast<char *>(uprv_malloc(uprv_strlen(posixID)+1));
/* Exit on memory allocation error. */
if (correctedPOSIXLocale == NULL) {
return NULL;
/* Note that we scan the *uncorrected* ID. */
if ((p = uprv_strrchr(posixID, '@')) != NULL) {
if (correctedPOSIXLocale == NULL) {
- correctedPOSIXLocale = uprv_malloc(uprv_strlen(posixID)+1);
+ correctedPOSIXLocale = reinterpret_cast<char *>(uprv_malloc(uprv_strlen(posixID)+1));
/* Exit on memory allocation error. */
if (correctedPOSIXLocale == NULL) {
return NULL;
localeBuf[localeCapacity-1] = 0; /* ensure NULL termination */
name = uprv_strncpy(buffer, name+1, buffCapacity);
buffer[buffCapacity-1] = 0; /* ensure NULL termination */
- if ((variant = (uprv_strchr(name, '@'))) != NULL) {
+ if ((variant = const_cast<char *>(uprv_strchr(name, '@'))) != NULL) {
*variant = 0;
}
name = remapPlatformDependentCodepage(localeBuf, name);
/*
**********************************************************************
-* Copyright (C) 1997-2010, International Business Machines
+* Copyright (C) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
/*
*******************************************************************************
*
-* Copyright (C) 2004-2010, International Business Machines
+* Copyright (C) 2004-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
-* file name: ucase.c
+* file name: ucase.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
/* set of property starts for UnicodeSet ------------------------------------ */
static UBool U_CALLCONV
-_enumPropertyStartsRange(const void *context, UChar32 start, UChar32 end, uint32_t value) {
+_enumPropertyStartsRange(const void *context, UChar32 start, UChar32 /*end*/, uint32_t /*value*/) {
/* add the start code point to the USet */
const USetAdder *sa=(const USetAdder *)context;
sa->add(sa->set, start);
* compare s, which has a length, with t, which has a maximum length or is NUL-terminated
* must be length>0 and max>0 and length<=max
*/
-static U_INLINE int32_t
+static inline int32_t
strcmpMax(const UChar *s, int32_t length, const UChar *t, int32_t max) {
int32_t c1, c2;
}
/** @return UCASE_NO_DOT, UCASE_SOFT_DOTTED, UCASE_ABOVE, UCASE_OTHER_ACCENT */
-static U_INLINE int32_t
+static inline int32_t
getDotType(const UCaseProps *csp, UChar32 c) {
uint16_t props=UTRIE2_GET16(&csp->trie, c);
if(!PROPS_HAS_EXCEPTION(props)) {
/*
*******************************************************************************
*
-* Copyright (C) 2004-2010, International Business Machines
+* Copyright (C) 2004-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
};
typedef struct UCaseContext UCaseContext;
+#define UCASECONTEXT_INITIALIZER { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+
enum {
/**
* For string case mappings, a single character (a code point) is mapped
/*
*******************************************************************************
*
-* Copyright (C) 2005-2010, International Business Machines
+* Copyright (C) 2005-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
-* file name: ucasemap.c
+* file name: ucasemap.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
}
U_CAPI void U_EXPORT2
-ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode) {
+ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode * /*pErrorCode*/) {
csm->options=options;
}
}
U_CAPI void U_EXPORT2
-ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode *pErrorCode) {
+ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode * /*pErrorCode*/) {
ubrk_close(csm->iter);
csm->iter=iterToAdopt;
}
/* TODO(markus): Move to a new, separate utf8case.c file. */
/* append a full case mapping result, see UCASE_MAX_STRING_LENGTH */
-static U_INLINE int32_t
+static inline int32_t
appendResult(uint8_t *dest, int32_t destIndex, int32_t destCapacity,
int32_t result, const UChar *s) {
UChar32 c;
destLength=utf8_foldCase(csm->csp, dest, destCapacity, src, srcLength,
csm->options, pErrorCode);
} else {
- UCaseContext csc={ NULL };
+ UCaseContext csc=UCASECONTEXT_INITIALIZER;
csc.p=(void *)src;
csc.limit=srcLength;
/*
**********************************************************************
-* Copyright (C) 2000-2010, International Business Machines
+* Copyright (C) 2000-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
-* file name: ucnv2022.c
+* file name: ucnv2022.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
T_UConverter_toUnicode_ISO_2022_OFFSETS_LOGIC(UConverterToUnicodeArgs* args, UErrorCode* err);
#endif
+namespace {
+
/*const UConverterSharedData _ISO2022Data;*/
-static const UConverterSharedData _ISO2022JPData;
-static const UConverterSharedData _ISO2022KRData;
-static const UConverterSharedData _ISO2022CNData;
+extern const UConverterSharedData _ISO2022JPData;
+extern const UConverterSharedData _ISO2022KRData;
+extern const UConverterSharedData _ISO2022CNData;
+
+} // namespace
/*************** Converter implementations ******************/
/* The purpose of this function is to get around gcc compiler warnings. */
-static U_INLINE void
+static inline void
fromUWriteUInt8(UConverter *cnv,
const char *bytes, int32_t length,
uint8_t **target, const char *targetLimit,
}
-static U_INLINE void
-setInitialStateToUnicodeKR(UConverter* converter, UConverterDataISO2022 *myConverterData){
+static inline void
+setInitialStateToUnicodeKR(UConverter* /*converter*/, UConverterDataISO2022 *myConverterData){
if(myConverterData->version == 1) {
UConverter *cnv = myConverterData->currentConverter;
}
}
-static U_INLINE void
+static inline void
setInitialStateFromUnicodeKR(UConverter* converter,UConverterDataISO2022 *myConverterData){
/* in ISO-2022-KR the designator sequence appears only once
* in a file so we append it only once
cnv->extraInfo = uprv_malloc (sizeof (UConverterDataISO2022));
if(cnv->extraInfo != NULL) {
UConverterNamePieces stackPieces;
- UConverterLoadArgs stackArgs={ (int32_t)sizeof(UConverterLoadArgs) };
+ UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
UConverterDataISO2022 *myConverterData=(UConverterDataISO2022 *) cnv->extraInfo;
uint32_t version;
*to determine the longest possible convertible
*data stream
*/
-static U_INLINE const char*
+static inline const char*
getEndOfBuffer_2022(const char** source,
const char* sourceLimit,
- UBool flush){
+ UBool /*flush*/){
const char* mySource = *source;
* any future change in _MBCSFromUChar32() function should be reflected here.
* @return number of bytes in *value; negative number if fallback; 0 if no mapping
*/
-static U_INLINE int32_t
+static inline int32_t
MBCS_FROM_UCHAR32_ISO2022(UConverterSharedData* sharedData,
UChar32 c,
uint32_t* value,
* @param retval pointer to output byte
* @return 1 roundtrip byte 0 no mapping -1 fallback byte
*/
-static U_INLINE int32_t
+static inline int32_t
MBCS_SINGLE_FROM_UCHAR32(UConverterSharedData* sharedData,
UChar32 c,
uint32_t* retval,
* to move it to the ISO 2022 range 21..7E.
* Return 0 if out of range.
*/
-static U_INLINE uint32_t
+static inline uint32_t
_2022FromGR94DBCS(uint32_t value) {
if( (uint16_t)(value - 0xa1a1) <= (0xfefe - 0xa1a1) &&
(uint8_t)(value - 0xa1) <= (0xfe - 0xa1)
* 2 byte value that is in the range A1..FE for each byte. Otherwise it returns the 2022 code point
* unchanged.
*/
-static U_INLINE uint32_t
+static inline uint32_t
_2022ToGR94DBCS(uint32_t value) {
uint32_t returnValue = value + 0x8080;
if( (uint16_t)(returnValue - 0xa1a1) <= (0xfefe - 0xa1a1) &&
*/
/* Map 00..7F to Unicode according to JIS X 0201. */
-static U_INLINE uint32_t
+static inline uint32_t
jisx201ToU(uint32_t value) {
if(value < 0x5c) {
return value;
}
/* Map Unicode to 00..7F according to JIS X 0201. Return U+FFFE if unmappable. */
-static U_INLINE uint32_t
+static inline uint32_t
jisx201FromU(uint32_t value) {
if(value<=0x7f) {
if(value!=0x5c && value!=0x7e) {
* to JIS X 0208, and convert it to a pair of 21..7E bytes.
* Return 0 if the byte pair is out of range.
*/
-static U_INLINE uint32_t
+static inline uint32_t
_2022FromSJIS(uint32_t value) {
uint8_t trail;
* Some invalid byte values already turn into equally invalid Shift-JIS
* byte values and need not be tested explicitly.
*/
-static U_INLINE void
+static inline void
_2022ToSJIS(uint8_t c1, uint8_t c2, char bytes[2]) {
if(c1&1) {
++c1;
_ISO2022getName,
_ISO_2022_WriteSub,
_ISO_2022_SafeClone,
- _ISO_2022_GetUnicodeSet
+ _ISO_2022_GetUnicodeSet,
+
+ NULL,
+ NULL
};
static const UConverterStaticData _ISO2022StaticData={
sizeof(UConverterStaticData),
&_ISO2022StaticData,
FALSE,
&_ISO2022Impl,
- 0
+ 0, UCNV_MBCS_TABLE_INITIALIZER
};
/*************JP****************/
_ISO2022getName,
_ISO_2022_WriteSub,
_ISO_2022_SafeClone,
- _ISO_2022_GetUnicodeSet
+ _ISO_2022_GetUnicodeSet,
+
+ NULL,
+ NULL
};
static const UConverterStaticData _ISO2022JPStaticData={
sizeof(UConverterStaticData),
0,
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } /* reserved */
};
-static const UConverterSharedData _ISO2022JPData={
+
+namespace {
+
+const UConverterSharedData _ISO2022JPData={
sizeof(UConverterSharedData),
~((uint32_t) 0),
NULL,
&_ISO2022JPStaticData,
FALSE,
&_ISO2022JPImpl,
- 0
+ 0, UCNV_MBCS_TABLE_INITIALIZER
};
+} // namespace
+
/************* KR ***************/
static const UConverterImpl _ISO2022KRImpl={
UCNV_ISO_2022,
_ISO2022getName,
_ISO_2022_WriteSub,
_ISO_2022_SafeClone,
- _ISO_2022_GetUnicodeSet
+ _ISO_2022_GetUnicodeSet,
+
+ NULL,
+ NULL
};
static const UConverterStaticData _ISO2022KRStaticData={
sizeof(UConverterStaticData),
0,
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } /* reserved */
};
-static const UConverterSharedData _ISO2022KRData={
+
+namespace {
+
+const UConverterSharedData _ISO2022KRData={
sizeof(UConverterSharedData),
~((uint32_t) 0),
NULL,
&_ISO2022KRStaticData,
FALSE,
&_ISO2022KRImpl,
- 0
+ 0, UCNV_MBCS_TABLE_INITIALIZER
};
+} // namespace
+
/*************** CN ***************/
static const UConverterImpl _ISO2022CNImpl={
_ISO2022getName,
_ISO_2022_WriteSub,
_ISO_2022_SafeClone,
- _ISO_2022_GetUnicodeSet
+ _ISO_2022_GetUnicodeSet,
+
+ NULL,
+ NULL
};
static const UConverterStaticData _ISO2022CNStaticData={
sizeof(UConverterStaticData),
0,
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } /* reserved */
};
-static const UConverterSharedData _ISO2022CNData={
+
+namespace {
+
+const UConverterSharedData _ISO2022CNData={
sizeof(UConverterSharedData),
~((uint32_t) 0),
NULL,
&_ISO2022CNStaticData,
FALSE,
&_ISO2022CNImpl,
- 0
+ 0, UCNV_MBCS_TABLE_INITIALIZER
};
-
+} // namespace
#endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */
/*
********************************************************************
* COPYRIGHT:
- * Copyright (c) 1996-2010, International Business Machines Corporation and
+ * Copyright (c) 1996-2011, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************
*
- * uconv_bld.c:
+ * uconv_bld.cpp:
*
* Defines functions that are used in the creation/initialization/deletion
* of converters and related structures.
}
static UBool U_CALLCONV
-isCnvAcceptable(void *context,
- const char *type, const char *name,
+isCnvAcceptable(void * /*context*/,
+ const char * /*type*/, const char * /*name*/,
const UDataInfo *pInfo) {
return (UBool)(
pInfo->size>=20 &&
* It must be sharedData->referenceCounter != ~0
* and this function must be called inside umtx_lock(&cnvCacheMutex).
*/
-void
+U_CAPI void
ucnv_unload(UConverterSharedData *sharedData) {
if(sharedData != NULL) {
if (sharedData->referenceCounter > 0) {
}
}
-void
+U_CFUNC void
ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData)
{
/*
in multithreaded applications because the value never changes.
Don't check referenceCounter for any other value.
*/
- if(sharedData != NULL && sharedData->referenceCounter != ~0) {
+ if(sharedData != NULL && sharedData->referenceCounter != (uint32_t)~0) {
umtx_lock(&cnvCacheMutex);
ucnv_unload(sharedData);
umtx_unlock(&cnvCacheMutex);
}
}
-void
+U_CFUNC void
ucnv_incrementRefCount(UConverterSharedData *sharedData)
{
/*
in multithreaded applications because the value never changes.
Don't check referenceCounter for any other value.
*/
- if(sharedData != NULL && sharedData->referenceCounter != ~0) {
+ if(sharedData != NULL && sharedData->referenceCounter != (uint32_t)~0) {
umtx_lock(&cnvCacheMutex);
sharedData->referenceCounter++;
umtx_unlock(&cnvCacheMutex);
* -Call dataConverter initializer (Data=TRUE, Cached=TRUE)
* -Call AlgorithmicConverter initializer (Data=FALSE, Cached=TRUE)
*/
-UConverterSharedData *
+U_CFUNC UConverterSharedData *
ucnv_loadSharedData(const char *converterName,
UConverterNamePieces *pPieces,
UConverterLoadArgs *pArgs,
return mySharedConverterData;
}
-UConverter *
+U_CAPI UConverter *
ucnv_createConverter(UConverter *myUConverter, const char *converterName, UErrorCode * err)
{
UConverterNamePieces stackPieces;
- UConverterLoadArgs stackArgs={ (int32_t)sizeof(UConverterLoadArgs) };
+ UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
UConverterSharedData *mySharedConverterData;
UTRACE_ENTRY_OC(UTRACE_UCNV_OPEN);
ucnv_canCreateConverter(const char *converterName, UErrorCode *err) {
UConverter myUConverter;
UConverterNamePieces stackPieces;
- UConverterLoadArgs stackArgs={ (int32_t)sizeof(UConverterLoadArgs) };
+ UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
UConverterSharedData *mySharedConverterData;
UTRACE_ENTRY_OC(UTRACE_UCNV_OPEN);
UErrorCode *err) {
UConverter *cnv;
const UConverterSharedData *sharedData;
- UConverterLoadArgs stackArgs={ (int32_t)sizeof(UConverterLoadArgs) };
+ UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
UTRACE_ENTRY_OC(UTRACE_UCNV_OPEN_ALGORITHMIC);
UTRACE_DATA1(UTRACE_OPEN_CLOSE, "open algorithmic converter type %d", (int32_t)type);
in multithreaded applications because the value never changes.
Don't check referenceCounter for any other value.
*/
- if(sharedData == NULL || sharedData->referenceCounter != ~0) {
+ if(sharedData == NULL || sharedData->referenceCounter != (uint32_t)~0) {
/* not a valid type, or not an algorithmic converter */
*err = U_ILLEGAL_ARGUMENT_ERROR;
UTRACE_EXIT_STATUS(U_ILLEGAL_ARGUMENT_ERROR);
return cnv;
}
-UConverter*
+U_CFUNC UConverter*
ucnv_createConverterFromPackage(const char *packageName, const char *converterName, UErrorCode * err)
{
UConverter *myUConverter;
UConverterSharedData *mySharedConverterData;
UConverterNamePieces stackPieces;
- UConverterLoadArgs stackArgs={ (int32_t)sizeof(UConverterLoadArgs) };
+ UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
UTRACE_ENTRY_OC(UTRACE_UCNV_OPEN_PACKAGE);
}
-UConverter*
+U_CFUNC UConverter*
ucnv_createConverterFromSharedData(UConverter *myUConverter,
UConverterSharedData *mySharedConverterData,
UConverterLoadArgs *pArgs,
Since the name is a returned via ucnv_getDefaultName without copying,
you shouldn't be modifying or deleting the string from a separate thread.
*/
-static U_INLINE void
+static inline void
internalSetName(const char *name, UErrorCode *status) {
UConverterNamePieces stackPieces;
- UConverterLoadArgs stackArgs={ (int32_t)sizeof(UConverterLoadArgs) };
+ UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
int32_t length=(int32_t)(uprv_strlen(name));
UBool containsOption = (UBool)(uprv_strchr(name, UCNV_OPTION_SEP_CHAR) != NULL);
const UConverterSharedData *algorithmicSharedData;
staticDataSize=ds->readUInt32(inStaticData->structSize);
} else {
length-=headerSize;
- if( length<sizeof(UConverterStaticData) ||
+ if( length<(int32_t)sizeof(UConverterStaticData) ||
(uint32_t)length<(staticDataSize=ds->readUInt32(inStaticData->structSize))
) {
udata_printError(ds, "ucnv_swap(): too few bytes (%d after header) for an ICU .cnv conversion table\n",
inMBCSHeader=(const _MBCSHeader *)inBytes;
outMBCSHeader=(_MBCSHeader *)outBytes;
- if(0<=length && length<sizeof(_MBCSHeader)) {
+ if(0<=length && length<(int32_t)sizeof(_MBCSHeader)) {
udata_printError(ds, "ucnv_swap(): too few bytes (%d after headers) for an ICU MBCS .cnv conversion table\n",
length);
*pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR;
/*
**********************************************************************
-* Copyright (C) 1999-2009 International Business Machines
+* Copyright (C) 1999-2011 International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
* Load a non-algorithmic converter.
* If pkg==NULL, then this function must be called inside umtx_lock(&cnvCacheMutex).
*/
-UConverterSharedData *
+U_CAPI UConverterSharedData *
ucnv_load(UConverterLoadArgs *pArgs, UErrorCode *err);
/**
* It must be sharedData->referenceCounter != ~0
* and this function must be called inside umtx_lock(&cnvCacheMutex).
*/
-void
+U_CAPI void
ucnv_unload(UConverterSharedData *sharedData);
/**
/*
**********************************************************************
-* Copyright (C) 1999-2010, International Business Machines
+* Copyright (C) 1999-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
const char *pkg, *name, *locale;
} UConverterLoadArgs;
+#define UCNV_LOAD_ARGS_INITIALIZER \
+ { (int32_t)sizeof(UConverterLoadArgs), 0, FALSE, FALSE, 0, 0, NULL, NULL, NULL }
+
typedef void (*UConverterLoad) (UConverterSharedData *sharedData,
UConverterLoadArgs *pArgs,
const uint8_t *raw, UErrorCode *pErrorCode);
/*
******************************************************************************
*
-* Copyright (C) 2003-2009, International Business Machines
+* Copyright (C) 2003-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
-* file name: ucnv_ext.c
+* file name: ucnv_ext.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
/*
* @return lookup value for the byte, if found; else 0
*/
-static U_INLINE uint32_t
+static inline uint32_t
ucnv_extFindToU(const uint32_t *toUSection, int32_t length, uint8_t byte) {
uint32_t word0, word;
int32_t i, start, limit;
const char *pre, int32_t preLength,
const char *src, int32_t srcLength,
uint32_t *pMatchValue,
- UBool useFallback, UBool flush) {
+ UBool /*useFallback*/, UBool flush) {
const uint32_t *toUTable, *toUSection;
uint32_t value, matchValue;
return matchLength;
}
-static U_INLINE void
+static inline void
ucnv_extWriteToU(UConverter *cnv, const int32_t *cx,
uint32_t value,
UChar **target, const UChar *targetLimit,
/*
* @return index of the UChar, if found; else <0
*/
-static U_INLINE int32_t
+static inline int32_t
ucnv_extFindFromU(const UChar *fromUSection, int32_t length, UChar u) {
int32_t i, start, limit;
/*
* @param value fromUnicode mapping table value; ignores roundtrip and reserved bits
*/
-static U_INLINE void
+static inline void
ucnv_extWriteFromU(UConverter *cnv, const int32_t *cx,
uint32_t value,
char **target, const char *targetLimit,
/*
**********************************************************************
-* Copyright (C) 1999-2009, International Business Machines
+* Copyright (C) 1999-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
* @param err The error code
* @return the newly created converter
*/
-UConverter *ucnv_createConverter (UConverter *myUConverter, const char *converterName, UErrorCode * err);
+U_CAPI UConverter *
+ucnv_createConverter(UConverter *myUConverter, const char *converterName, UErrorCode * err);
/*
* Open a purely algorithmic converter, specified by a type constant.
* unload mySharedConverterData, except via ucnv_close(return value)
* if this function is successful.
*/
-UConverter*
+U_CFUNC UConverter *
ucnv_createConverterFromSharedData(UConverter *myUConverter,
UConverterSharedData *mySharedConverterData,
UConverterLoadArgs *pArgs,
UErrorCode *err);
-UConverter* ucnv_createConverterFromPackage(const char *packageName, const char *converterName,
- UErrorCode *err);
+U_CFUNC UConverter *
+ucnv_createConverterFromPackage(const char *packageName, const char *converterName, UErrorCode *err);
/**
* Load a converter but do not create a UConverter object.
* - pieces!=NULL && args!=NULL
* @internal
*/
-UConverterSharedData *
+U_CFUNC UConverterSharedData *
ucnv_loadSharedData(const char *converterName,
UConverterNamePieces *pieces,
UConverterLoadArgs *pArgs,
* This may unload the shared data in a thread safe manner.
* This will only unload the data if no other converters are sharing it.
*/
-void
+U_CFUNC void
ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData);
/**
* This is a thread safe way to increment the reference count.
*/
-void
+U_CFUNC void
ucnv_incrementRefCount(UConverterSharedData *sharedData);
/**
/*
******************************************************************************
*
-* Copyright (C) 1999-2008, International Business Machines
+* Copyright (C) 1999-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
*
*
-* ucnv_io.c:
+* ucnv_io.cpp:
* initializes global variables and defines functions pertaining to converter
* name resolution aspect of the conversion code.
*
#define GET_NORMALIZED_STRING(idx) (const char *)(gMainTable.normalizedStringTable + (idx))
static UBool U_CALLCONV
-isAcceptable(void *context,
- const char *type, const char *name,
+isAcceptable(void * /*context*/,
+ const char * /*type*/, const char * /*name*/,
const UDataInfo *pInfo) {
return (UBool)(
pInfo->size>=20 &&
return TRUE;
}
-static U_INLINE UBool
+static inline UBool
isAlias(const char *alias, UErrorCode *pErrorCode) {
if(alias==NULL) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
* search for an alias
* return the converter number index for gConverterList
*/
-static U_INLINE uint32_t
+static inline uint32_t
findConverter(const char *alias, UBool *containsOption, UErrorCode *pErrorCode) {
uint32_t mid, start, limit;
uint32_t lastMid;
* Is this alias in this list?
* alias and listOffset should be non-NULL.
*/
-static U_INLINE UBool
+static inline UBool
isAliasInList(const char *alias, uint32_t listOffset) {
if (listOffset) {
uint32_t currAlias;
}
static int32_t U_CALLCONV
-ucnv_io_countStandardAliases(UEnumeration *enumerator, UErrorCode *pErrorCode) {
+ucnv_io_countStandardAliases(UEnumeration *enumerator, UErrorCode * /*pErrorCode*/) {
int32_t value = 0;
UAliasContext *myContext = (UAliasContext *)(enumerator->context);
uint32_t listOffset = myContext->listOffset;
static const char* U_CALLCONV
ucnv_io_nextStandardAliases(UEnumeration *enumerator,
int32_t* resultLength,
- UErrorCode *pErrorCode)
+ UErrorCode * /*pErrorCode*/)
{
UAliasContext *myContext = (UAliasContext *)(enumerator->context);
uint32_t listOffset = myContext->listOffset;
}
static void U_CALLCONV
-ucnv_io_resetStandardAliases(UEnumeration *enumerator, UErrorCode *pErrorCode) {
+ucnv_io_resetStandardAliases(UEnumeration *enumerator, UErrorCode * /*pErrorCode*/) {
((UAliasContext *)(enumerator->context))->listIdx = 0;
}
if (listOffset < gMainTable.taggedAliasListsSize) {
UAliasContext *myContext;
- myEnum = uprv_malloc(sizeof(UEnumeration));
+ myEnum = reinterpret_cast<UEnumeration *>(uprv_malloc(sizeof(UEnumeration)));
if (myEnum == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
uprv_memcpy(myEnum, &gEnumAliases, sizeof(UEnumeration));
- myContext = uprv_malloc(sizeof(UAliasContext));
+ myContext = reinterpret_cast<UAliasContext *>(uprv_malloc(sizeof(UAliasContext)));
if (myContext == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
uprv_free(myEnum);
}
static int32_t U_CALLCONV
-ucnv_io_countAllConverters(UEnumeration *enumerator, UErrorCode *pErrorCode) {
+ucnv_io_countAllConverters(UEnumeration * /*enumerator*/, UErrorCode * /*pErrorCode*/) {
return gMainTable.converterListSize;
}
static const char* U_CALLCONV
ucnv_io_nextAllConverters(UEnumeration *enumerator,
int32_t* resultLength,
- UErrorCode *pErrorCode)
+ UErrorCode * /*pErrorCode*/)
{
uint16_t *myContext = (uint16_t *)(enumerator->context);
}
static void U_CALLCONV
-ucnv_io_resetAllConverters(UEnumeration *enumerator, UErrorCode *pErrorCode) {
+ucnv_io_resetAllConverters(UEnumeration *enumerator, UErrorCode * /*pErrorCode*/) {
*((uint16_t *)(enumerator->context)) = 0;
}
if (haveAliasData(pErrorCode)) {
uint16_t *myContext;
- myEnum = uprv_malloc(sizeof(UEnumeration));
+ myEnum = reinterpret_cast<UEnumeration *>(uprv_malloc(sizeof(UEnumeration)));
if (myEnum == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
uprv_memcpy(myEnum, &gEnumAllConverters, sizeof(UEnumeration));
- myContext = uprv_malloc(sizeof(uint16_t));
+ myContext = reinterpret_cast<uint16_t *>(uprv_malloc(sizeof(uint16_t)));
if (myContext == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
uprv_free(myEnum);
/*
******************************************************************************
*
-* Copyright (C) 2002-2005, International Business Machines
+* Copyright (C) 2002-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
-* file name: ucnvbocu.c
+* file name: ucnvbocu.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
* @param c current code point, 0x3040..0xd7a3 (rest handled by macro below)
* @return "previous code point" state value
*/
-static U_INLINE int32_t
+static inline int32_t
bocu1Prev(int32_t c) {
/* compute new prev */
if(/* 0x3040<=c && */ c<=0x309f) {
* BOCU1_MIN<=b<BOCU1_START_NEG_2 or BOCU1_START_POS_2<=b<BOCU1_MAX_LEAD
* @return (diff<<2)|count
*/
-static U_INLINE int32_t
+static inline int32_t
decodeBocu1LeadByte(int32_t b) {
int32_t diff, count;
*
* @see decodeBocu1
*/
-static U_INLINE int32_t
+static inline int32_t
decodeBocu1TrailByte(int32_t count, int32_t b) {
if(b<=0x20) {
/* skip some C0 controls and make the trail byte range contiguous */
NULL,
NULL,
NULL,
- ucnv_getCompleteUnicodeSet
+ ucnv_getCompleteUnicodeSet,
+
+ NULL,
+ NULL
};
static const UConverterStaticData _Bocu1StaticData={
const UConverterSharedData _Bocu1Data={
sizeof(UConverterSharedData), ~((uint32_t)0),
NULL, NULL, &_Bocu1StaticData, FALSE, &_Bocu1Impl,
- 0
+ 0,
+ UCNV_MBCS_TABLE_INITIALIZER
};
#endif
/*
******************************************************************************
*
-* Copyright (C) 2000-2007, International Business Machines
+* Copyright (C) 2000-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
const int32_t *extIndexes;
} UConverterMBCSTable;
+#define UCNV_MBCS_TABLE_INITIALIZER { \
+ /* toUnicode */ \
+ 0, 0, 0, \
+ 0, \
+ \
+ NULL, \
+ NULL, \
+ NULL, \
+ NULL, \
+ \
+ /* fromUnicode */ \
+ NULL, \
+ NULL, \
+ { 0 }, \
+ NULL, \
+ NULL, \
+ 0, \
+ 0, 0, \
+ FALSE, \
+ 0, \
+ \
+ /* roundtrips */ \
+ 0, \
+ \
+ /* reconstituted data that was omitted from the .cnv file */ \
+ NULL, \
+ \
+ /* converter name for swaplfnl */ \
+ NULL, \
+ \
+ /* extension data */ \
+ NULL, \
+ NULL \
+}
+
enum {
MBCS_OPT_LENGTH_MASK=0x3f,
MBCS_OPT_NO_FROM_U=0x40,
uint32_t fullStage2Length; /* number of 32-bit units */
} _MBCSHeader;
+#define UCNV_MBCS_HEADER_INITIALIZER { { 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+
/*
* This is a simple version of _MBCSGetNextUChar() that is used
* by other converter implementations.
} KeywordStruct;
static int32_t U_CALLCONV
-compareKeywordStructs(const void *context, const void *left, const void *right) {
+compareKeywordStructs(const void * /*context*/, const void *left, const void *right) {
const char* leftString = ((const KeywordStruct *)left)->keyword;
const char* rightString = ((const KeywordStruct *)right)->keyword;
return uprv_strcmp(leftString, rightString);
}
/* count the length of src while copying it to dest; return strlen(src) */
-static U_INLINE int32_t
+static inline int32_t
_copyCount(char *dest, int32_t destCapacity, const char *src) {
const char *anchor;
char c;
}
static int32_t U_CALLCONV
-uloc_kw_countKeywords(UEnumeration *en, UErrorCode *status) {
+uloc_kw_countKeywords(UEnumeration *en, UErrorCode * /*status*/) {
char *kw = ((UKeywordsContext *)en->context)->keywords;
int32_t result = 0;
while(*kw) {
static const char* U_CALLCONV
uloc_kw_nextKeyword(UEnumeration* en,
int32_t* resultLength,
- UErrorCode* status) {
+ UErrorCode* /*status*/) {
const char* result = ((UKeywordsContext *)en->context)->current;
int32_t len = 0;
if(*result) {
static void U_CALLCONV
uloc_kw_resetKeywords(UEnumeration* en,
- UErrorCode* status) {
+ UErrorCode* /*status*/) {
((UKeywordsContext *)en->context)->current = ((UKeywordsContext *)en->context)->keywords;
}
return NULL;
}
uprv_memcpy(result, &gKeywordsEnum, sizeof(UEnumeration));
- myContext = uprv_malloc(sizeof(UKeywordsContext));
+ myContext = reinterpret_cast<UKeywordsContext *>(uprv_malloc(sizeof(UKeywordsContext)));
if (myContext == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
uprv_free(result);
/* if we are doing a full canonicalization, then put results in
localeBuffer, if necessary; otherwise send them to result. */
if (/*OPTION_SET(options, _ULOC_CANONICALIZE) &&*/
- (result == NULL || resultCapacity < sizeof(localeBuffer))) {
+ (result == NULL || resultCapacity < (int32_t)sizeof(localeBuffer))) {
name = localeBuffer;
- nameCapacity = sizeof(localeBuffer);
+ nameCapacity = (int32_t)sizeof(localeBuffer);
} else {
name = result;
nameCapacity = resultCapacity;
} _acceptLangItem;
static int32_t U_CALLCONV
-uloc_acceptLanguageCompare(const void *context, const void *a, const void *b)
+uloc_acceptLanguageCompare(const void * /*context*/, const void *a, const void *b)
{
const _acceptLangItem *aa = (const _acceptLangItem*)a;
const _acceptLangItem *bb = (const _acceptLangItem*)b;
}
if(n>=jSize) {
if(j==smallBuffer) { /* overflowed the small buffer. */
- j = uprv_malloc(sizeof(j[0])*(jSize*2));
+ j = reinterpret_cast<_acceptLangItem *>(uprv_malloc(sizeof(j[0])*(jSize*2)));
if(j!=NULL) {
uprv_memcpy(j,smallBuffer,sizeof(j[0])*jSize);
}
fprintf(stderr,"malloced at size %d\n", jSize);
#endif
} else {
- j = uprv_realloc(j, sizeof(j[0])*jSize*2);
+ j = reinterpret_cast<_acceptLangItem *>(uprv_realloc(j, sizeof(j[0])*jSize*2));
#if defined(ULOC_DEBUG)
fprintf(stderr,"re-alloced at size %d\n", jSize);
#endif
}
return -1;
}
- strs = uprv_malloc((size_t)(sizeof(strs[0])*n));
+ strs = reinterpret_cast<char **>(uprv_malloc((size_t)(sizeof(strs[0])*n)));
/* Check for null pointer */
if (strs == NULL) {
uprv_free(j); /* Free to avoid memory leak */
if(U_FAILURE(*status)) {
return -1;
}
- fallbackList = uprv_malloc((size_t)(sizeof(fallbackList[0])*acceptListCount));
+ fallbackList = reinterpret_cast<char **>(uprv_malloc((size_t)(sizeof(fallbackList[0])*acceptListCount)));
if(fallbackList==NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return -1;
/*
******************************************************************************
*
-* Copyright (C) 1999-2009, International Business Machines
+* Copyright (C) 1999-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
/* prototypes ------------------------------------------------------------- */
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
static const char DATA_NAME[] = "unames";
static const char DATA_TYPE[] = "icu";
#define GROUP_SHIFT 5
-#define LINES_PER_GROUP (1UL<<GROUP_SHIFT)
+#define LINES_PER_GROUP (1L<<GROUP_SHIFT)
#define GROUP_MASK (LINES_PER_GROUP-1)
/*
}
static UBool U_CALLCONV
-isAcceptable(void *context,
- const char *type, const char *name,
+isAcceptable(void * /*context*/,
+ const char * /*type*/, const char * /*name*/,
const UDataInfo *pInfo) {
return (UBool)(
pInfo->size>=20 &&
}
/* set hex digits, used in various names, and <>-, used in extended names */
- for(i=0; i<sizeof(extChars)-1; ++i) {
+ for(i=0; i<(int32_t)sizeof(extChars)-1; ++i) {
SET_ADD(gNameSet, extChars[i]);
}
/*
******************************************************************************
*
-* Copyright (C) 1997-2006, International Business Machines
+* Copyright (C) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
#define U_IMPORT
/*===========================================================================*/
-/* Code alignment and C function inlining */
+/* Code alignment */
/*===========================================================================*/
-#ifndef U_INLINE
-# ifdef __cplusplus
-# define U_INLINE inline
-# else
-# define U_INLINE __inline
-# endif
-#endif
-
#if defined(_MSC_VER) && defined(_M_IX86)
#define U_ALIGN_CODE(val) __asm align val
#else
/** @} */
/*===========================================================================*/
-/** @{ Symbol import-export control */
+/** @{ Symbol import-export control */
/*===========================================================================*/
#ifdef U_STATIC_IMPLEMENTATION
/** @} */
/*===========================================================================*/
-/** @{ Code alignment and C function inlining */
+/** @{ Code alignment */
/*===========================================================================*/
-#ifndef U_INLINE
-# ifdef __cplusplus
-# define U_INLINE inline
-# else
-# define U_INLINE __inline
-# endif
-#endif
-
#if defined(_MSC_VER) && defined(_M_IX86) && !defined(_MANAGED)
#define U_ALIGN_CODE(val) __asm align val
#else
/** @} */
/*===========================================================================*/
-/** @{ Programs used by ICU code */
+/** @{ Programs used by ICU code */
/*===========================================================================*/
#ifndef U_MAKE
typedef int32_t UChar32;
/*==========================================================================*/
-/* U_INLINE and U_ALIGN_CODE Set default values if these are not already */
+/* U_ALIGN_CODE Set default values if these are not already */
/* defined. Definitions normally are in */
/* platform.h or the corresponding file for */
/* the OS in use. */
#endif /* U_HIDE_INTERNAL_API */
-/**
- * \def U_INLINE
- * This is used to request inlining of a function, on platforms and languages which support it.
- * @internal
- */
-
-#ifndef U_INLINE
-# ifdef XP_CPLUSPLUS
-# define U_INLINE inline
-# else
-# define U_INLINE
-# endif
-#endif
-
#include "unicode/urename.h"
#endif
if(capacity < len) {
capacity = len;
}
- if(capacity <= sizeof(stackAlias)) {
- capacity = sizeof(stackAlias);
+ if(capacity <= (int32_t)sizeof(stackAlias)) {
+ capacity = (int32_t)sizeof(stackAlias);
chAlias = stackAlias;
} else {
chAlias = (char *)uprv_malloc(capacity);
}
static int32_t U_CALLCONV
-ures_loc_countLocales(UEnumeration *en, UErrorCode *status) {
+ures_loc_countLocales(UEnumeration *en, UErrorCode * /*status*/) {
ULocalesContext *ctx = (ULocalesContext *)en->context;
return ures_getSize(&ctx->installed);
}
static void U_CALLCONV
ures_loc_resetLocales(UEnumeration* en,
- UErrorCode* status) {
+ UErrorCode* /*status*/) {
UResourceBundle *res = &((ULocalesContext *)en->context)->installed;
ures_resetIterator(res);
}
UResourceBundle *idx = NULL;
UEnumeration *en = NULL;
ULocalesContext *myContext = NULL;
-
+
if(U_FAILURE(*status)) {
return NULL;
}
- myContext = uprv_malloc(sizeof(ULocalesContext));
+ myContext = reinterpret_cast<ULocalesContext *>(uprv_malloc(sizeof(ULocalesContext)));
en = (UEnumeration *)uprv_malloc(sizeof(UEnumeration));
if(!en || !myContext) {
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
uprv_memcpy(en, &gLocalesEnum, sizeof(UEnumeration));
-
+
ures_initStackObject(&myContext->installed);
ures_initStackObject(&myContext->curr);
idx = ures_openDirect(path, INDEX_LOCALE_NAME, status);
/*
*******************************************************************************
*
-* Copyright (C) 2002-2010, International Business Machines
+* Copyright (C) 2002-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
-* file name: uset.c
+* file name: uset.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
// ---
// #define USET_GROW_DELTA 20
//
-// static U_INLINE int32_t
+// static int32_t
// findChar(const UChar32* array, int32_t length, UChar32 c) {
// int32_t i;
//
* Corporation and others. All Rights Reserved.
*
******************************************************************************
- * file name: ushape.c
+ * file name: ushape.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
#include "ustr_imp.h"
#include "ubidi_props.h"
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
#if UTF_SIZE<16
/*
* This implementation assumes that the internal encoding is UTF-16
* U_SHAPE_TEXT_DIRECTION_LOGICAL
*/
static void
-invertBuffer(UChar *buffer,int32_t size,uint32_t options,int32_t lowlimit,int32_t highlimit) {
+invertBuffer(UChar *buffer, int32_t size, uint32_t /*options*/, int32_t lowlimit, int32_t highlimit) {
UChar temp;
int32_t i=0,j=0;
for(i=lowlimit,j=size-highlimit-1;i<j;i++,j--) {
* later it'll be converted into the 0xFExx LamAlefs
* in the shaping function.
*/
-static U_INLINE UChar
+static inline UChar
changeLamAlef(UChar ch) {
switch(ch) {
case 0x0622 :
* at each end of the logical buffer
*/
static void
-countSpaces(UChar *dest,int32_t size,uint32_t options,int32_t *spacesCountl,int32_t *spacesCountr) {
+countSpaces(UChar *dest, int32_t size, uint32_t /*options*/, int32_t *spacesCountl, int32_t *spacesCountr) {
int32_t i = 0;
int32_t countl = 0,countr = 0;
while(dest[i] == SPACE_CHAR) {
*Name : isTashkeelChar
*Function : Returns 1 for Tashkeel characters in 06 range else return 0
*/
-static U_INLINE int32_t
+static inline int32_t
isTashkeelChar(UChar ch) {
return (int32_t)( ch>=0x064B && ch<= 0x0652 );
}
*Name : isTashkeelCharFE
*Function : Returns 1 for Tashkeel characters in FE range else return 0
*/
-static U_INLINE int32_t
+static inline int32_t
isTashkeelCharFE(UChar ch) {
return (int32_t)( ch>=0xFE70 && ch<= 0xFE7F );
}
*Name : isAlefChar
*Function : Returns 1 for Alef characters else return 0
*/
-static U_INLINE int32_t
+static inline int32_t
isAlefChar(UChar ch) {
return (int32_t)( (ch==0x0622)||(ch==0x0623)||(ch==0x0625)||(ch==0x0627) );
}
*Name : isLamAlefChar
*Function : Returns 1 for LamAlef characters else return 0
*/
-static U_INLINE int32_t
+static inline int32_t
isLamAlefChar(UChar ch) {
return (int32_t)((ch>=0xFEF5)&&(ch<=0xFEFC) );
}
*Function : returns 1 if the character matches one of the tail characters (0xfe73 or 0x200b) otherwise returns 0
*/
-static U_INLINE int32_t
+static inline int32_t
isTailChar(UChar ch) {
if(ch == OLD_TAIL_CHAR || ch == NEW_TAIL_CHAR){
return 1;
* in the FE range otherwise returns 0
*/
-static U_INLINE int32_t
+static inline int32_t
isSeenTailFamilyChar(UChar ch) {
if(ch >= 0xfeb1 && ch < 0xfebf){
return tailFamilyIsolatedFinal [ch - 0xFEB1];
* 06 range otherwise returns 0
*/
-static U_INLINE int32_t
+static inline int32_t
isSeenFamilyChar(UChar ch){
if(ch >= 0x633 && ch <= 0x636){
return 1;
*Function : returns 1 if the character is a Alef Maksoura Final or isolated
* otherwise returns 0
*/
-static U_INLINE int32_t
+static inline int32_t
isAlefMaksouraChar(UChar ch) {
return (int32_t)( (ch == 0xFEEF) || ( ch == 0xFEF0) || (ch == 0x0649));
}
* Function : returns 1 if the character is a yehHamza isolated or yehhamza
* final is found otherwise returns 0
*/
-static U_INLINE int32_t
+static inline int32_t
isYehHamzaChar(UChar ch) {
if((ch==0xFE89)||(ch==0xFE8A)){
return 1;
* Tashkeel with shadda on tatweel (FC range)return 2 otherwise
* returns 0
*/
-static U_INLINE int32_t
+static inline int32_t
isTashkeelOnTatweelChar(UChar ch){
if(ch >= 0xfe70 && ch <= 0xfe7f && ch != NEW_TAIL_CHAR && ch != 0xFE75 && ch != SHADDA_TATWEEL_CHAR)
{
* with shadda is in the isolated form (i.e. Unicode FC range)
* returns 2 otherwise returns 0
*/
-static U_INLINE int32_t
+static inline int32_t
isIsolatedTashkeelChar(UChar ch){
if(ch >= 0xfe70 && ch <= 0xfe7f && ch != NEW_TAIL_CHAR && ch != 0xFE75){
return (1 - tashkeelMedial [ch - 0xFE70]);
*/
static int32_t
handleTashkeelWithTatweel(UChar *dest, int32_t sourceLength,
- int32_t destSize,uint32_t options,
- UErrorCode *pErrorCode) {
+ int32_t /*destSize*/, uint32_t /*options*/,
+ UErrorCode * /*pErrorCode*/) {
int i;
for(i = 0; i < sourceLength; i++){
if((isTashkeelOnTatweelChar(dest[i]) == 1)){
}
/* Start of Arabic letter shaping part */
- if(outputSize<=sizeof(buffer)/U_SIZEOF_UCHAR) {
- outputSize=sizeof(buffer)/U_SIZEOF_UCHAR;
+ if(outputSize<=LENGTHOF(buffer)) {
+ outputSize=LENGTHOF(buffer);
tempbuffer=buffer;
} else {
tempbuffer = (UChar *)uprv_malloc(outputSize*U_SIZEOF_UCHAR);
typedef struct UCaseMap UCaseMap;
#endif
+#if UCONFIG_NO_BREAK_ITERATION
+# define UCASEMAP_INITIALIZER { NULL, { 0 }, 0, 0 }
+#else
+# define UCASEMAP_INITIALIZER { NULL, NULL, { 0 }, 0, 0 }
+#endif
+
enum {
TO_LOWER,
TO_UPPER,
/*
*******************************************************************************
*
-* Copyright (C) 2001-2010, International Business Machines
+* Copyright (C) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
-* file name: ustr_wcs.c
+* file name: ustr_wcs.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
#define _BUFFER_CAPACITY_MULTIPLIER 2
#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
-static U_INLINE UBool
+static inline UBool
u_growAnyBufferFromStatic(void *context,
void **pBuffer, int32_t *pCapacity, int32_t reqCapacity,
int32_t length, int32_t size) {
/*
*******************************************************************************
*
-* Copyright (C) 2001-2010, International Business Machines
+* Copyright (C) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
-* file name: ustrcase.c
+* file name: ustrcase.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
#include "ucase.h"
#include "ustr_imp.h"
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
/* string casing ------------------------------------------------------------ */
/* append a full case mapping result, see UCASE_MAX_STRING_LENGTH */
-static U_INLINE int32_t
+static inline int32_t
appendResult(UChar *dest, int32_t destIndex, int32_t destCapacity,
int32_t result, const UChar *s) {
UChar32 c;
}
static void
-setTempCaseMapLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode) {
+setTempCaseMapLocale(UCaseMap *csm, const char *locale, UErrorCode * /*pErrorCode*/) {
/*
* We could call ucasemap_setLocale(), but here we really only care about
* the initial language subtag, we need not return the real string via
* Set parameters on an empty UCaseMap, for UCaseMap-less API functions.
* Do this fast because it is called with every function call.
*/
-static U_INLINE void
+static inline void
setTempCaseMap(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode) {
if(csm->csp==NULL) {
csm->csp=ucase_getSingleton();
const UChar *src, int32_t srcLength,
const char *locale,
UErrorCode *pErrorCode) {
- UCaseMap csm={ NULL };
- UCaseContext csc={ NULL };
+ UCaseMap csm=UCASEMAP_INITIALIZER;
+ UCaseContext csc=UCASECONTEXT_INITIALIZER;
csm.csp=csp;
setTempCaseMap(&csm, locale, pErrorCode);
const UChar *src, int32_t srcLength,
const char *locale,
UErrorCode *pErrorCode) {
- UCaseMap csm={ NULL };
- UCaseContext csc={ NULL };
+ UCaseMap csm=UCASEMAP_INITIALIZER;
+ UCaseContext csc=UCASECONTEXT_INITIALIZER;
csm.csp=csp;
setTempCaseMap(&csm, locale, pErrorCode);
UBreakIterator *titleIter,
const char *locale, uint32_t options,
UErrorCode *pErrorCode) {
- UCaseMap csm={ NULL };
- UCaseContext csc={ NULL };
+ UCaseMap csm=UCASEMAP_INITIALIZER;
+ UCaseContext csc=UCASECONTEXT_INITIALIZER;
int32_t length;
csm.csp=csp;
(dest>=src && dest<(src+srcLength)))
) {
/* overlap: provide a temporary destination buffer and later copy the result */
- if(destCapacity<=(sizeof(buffer)/U_SIZEOF_UCHAR)) {
+ if(destCapacity<=LENGTHOF(buffer)) {
/* the stack buffer is large enough */
temp=buffer;
} else {
destLength=ustr_foldCase(csm->csp, temp, destCapacity, src, srcLength,
csm->options, pErrorCode);
} else {
- UCaseContext csc={ NULL };
+ UCaseContext csc=UCASECONTEXT_INITIALIZER;
csc.p=(void *)src;
csc.limit=srcLength;
const UChar *src, int32_t srcLength,
const char *locale,
UErrorCode *pErrorCode) {
- UCaseMap csm={ NULL };
+ UCaseMap csm=UCASEMAP_INITIALIZER;
setTempCaseMap(&csm, locale, pErrorCode);
return caseMap(&csm,
dest, destCapacity,
const UChar *src, int32_t srcLength,
const char *locale,
UErrorCode *pErrorCode) {
- UCaseMap csm={ NULL };
+ UCaseMap csm=UCASEMAP_INITIALIZER;
setTempCaseMap(&csm, locale, pErrorCode);
return caseMap(&csm,
dest, destCapacity,
UBreakIterator *titleIter,
const char *locale,
UErrorCode *pErrorCode) {
- UCaseMap csm={ NULL };
+ UCaseMap csm=UCASEMAP_INITIALIZER;
int32_t length;
csm.iter=titleIter;
const UChar *src, int32_t srcLength,
uint32_t options,
UErrorCode *pErrorCode) {
- UCaseMap csm={ NULL };
+ UCaseMap csm=UCASEMAP_INITIALIZER;
csm.csp=ucase_getSingleton();
csm.options=options;
return caseMap(&csm,
/*
******************************************************************************
*
-* Copyright (C) 1998-2010, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
*
-* File ustring.h
+* File ustring.cpp
*
* Modification History:
*
* All pointers refer to the same buffer.
* The limit pointer may be NULL, all others must be real pointers.
*/
-static U_INLINE UBool
+static inline UBool
isMatchAtCPBoundary(const UChar *start, const UChar *match, const UChar *matchLimit, const UChar *limit) {
if(U16_IS_TRAIL(*match) && start!=match && U16_IS_LEAD(*(match-1))) {
/* the leading edge of the match is in the middle of a surrogate pair */
/*
******************************************************************************
*
-* Copyright (C) 2001-2010, International Business Machines
+* Copyright (C) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
*
-* File ustrtrns.c
+* File ustrtrns.cpp
*
* Modification History:
*
return dest;
}
-static U_INLINE uint8_t *
+static inline uint8_t *
_appendUTF8(uint8_t *pDest, UChar32 c) {
/* it is 0<=c<=0x10ffff and not a surrogate if called by a validating function */
if((c)<=0x7f) {
/*
******************************************************************************
*
-* Copyright (C) 2001-2009, International Business Machines
+* Copyright (C) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
-* file name: utrie.c
+* file name: utrie.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
#undef ABS
#define ABS(x) ((x)>=0 ? (x) : -(x))
-static U_INLINE UBool
+static inline UBool
equal_uint32(const uint32_t *s, const uint32_t *t, int32_t length) {
while(length>0 && *s==*t) {
++s;
}
/* enough data for a trie header? */
- if(length<sizeof(UTrieHeader)) {
+ if(length<(int32_t)sizeof(UTrieHeader)) {
*pErrorCode=U_INVALID_FORMAT_ERROR;
return -1;
}
/* default UTrieEnumValue() returns the input value itself */
static uint32_t U_CALLCONV
-enumSameValue(const void *context, uint32_t value) {
+enumSameValue(const void * /*context*/, uint32_t value) {
return value;
}
/*
******************************************************************************
*
-* Copyright (C) 2001-2010, International Business Machines
+* Copyright (C) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
}
}
-static U_INLINE int32_t
+static inline int32_t
u8Index(const UTrie2 *trie, UChar32 c, int32_t i) {
int32_t idx=
_UTRIE2_INDEX_FROM_CP(
/*
******************************************************************************
*
-* Copyright (C) 2001-2010, International Business Machines
+* Copyright (C) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
-* file name: utrie2_builder.c
+* file name: utrie2_builder.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
return context.trie;
}
-static U_INLINE UBool
+static inline UBool
isInNullBlock(UNewTrie2 *trie, UChar32 c, UBool forLSCP) {
int32_t i2, block;
trie->firstFreeBlock=block;
}
-static U_INLINE UBool
+static inline UBool
isWritableBlock(UNewTrie2 *trie, int32_t block) {
return (UBool)(block!=trie->dataNullOffset && 1==trie->map[block>>UTRIE2_SHIFT_2]);
}
-static U_INLINE void
+static inline void
setIndex2Entry(UNewTrie2 *trie, int32_t i2, int32_t block) {
int32_t oldBlock;
++trie->map[block>>UTRIE2_SHIFT_2]; /* increment first, in case block==oldBlock! */
/* compaction --------------------------------------------------------------- */
-static U_INLINE UBool
+static inline UBool
equal_int32(const int32_t *s, const int32_t *t, int32_t length) {
while(length>0 && *s==*t) {
++s;
return (UBool)(length==0);
}
-static U_INLINE UBool
+static inline UBool
equal_uint32(const uint32_t *s, const uint32_t *t, int32_t length) {
while(length>0 && *s==*t) {
++s;
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
-* file name: ucol_wgt.c
+* file name: ucol_wgt.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
/* helper functions for CE weights */
-static U_INLINE int32_t
+static inline int32_t
lengthOfWeight(uint32_t weight) {
if((weight&0xffffff)==0) {
return 1;
}
}
-static U_INLINE uint32_t
+static inline uint32_t
getWeightTrail(uint32_t weight, int32_t length) {
return (uint32_t)(weight>>(8*(4-length)))&0xff;
}
-static U_INLINE uint32_t
+static inline uint32_t
setWeightTrail(uint32_t weight, int32_t length, uint32_t trail) {
length=8*(4-length);
return (uint32_t)((weight&(0xffffff00<<length))|(trail<<length));
}
-static U_INLINE uint32_t
+static inline uint32_t
getWeightByte(uint32_t weight, int32_t idx) {
return getWeightTrail(weight, idx); /* same calculation */
}
-static U_INLINE uint32_t
+static inline uint32_t
setWeightByte(uint32_t weight, int32_t idx, uint32_t byte) {
uint32_t mask; /* 0xffffffff except a 00 "hole" for the index-th byte */
return (uint32_t)((weight&mask)|(byte<<idx));
}
-static U_INLINE uint32_t
+static inline uint32_t
truncateWeight(uint32_t weight, int32_t length) {
return (uint32_t)(weight&(0xffffffff<<(8*(4-length))));
}
-static U_INLINE uint32_t
+static inline uint32_t
incWeightTrail(uint32_t weight, int32_t length) {
return (uint32_t)(weight+(1UL<<(8*(4-length))));
}
-static U_INLINE uint32_t
+static inline uint32_t
decWeightTrail(uint32_t weight, int32_t length) {
return (uint32_t)(weight-(1UL<<(8*(4-length))));
}
-static U_INLINE uint32_t
+static inline uint32_t
incWeight(uint32_t weight, int32_t length, uint32_t maxByte) {
uint32_t byte;
}
}
-static U_INLINE int32_t
+static inline int32_t
lengthenRange(WeightRange *range, uint32_t maxByte, uint32_t countBytes) {
int32_t length;
* possible ranges of weights between the two limits, excluding them
* for weights with up to 4 bytes there are up to 2*4-1=7 ranges
*/
-static U_INLINE int32_t
+static inline int32_t
getWeightRanges(uint32_t lowerLimit, uint32_t upperLimit,
uint32_t maxByte, uint32_t countBytes,
WeightRange ranges[7]) {
</Link>\r
</ItemDefinitionGroup>\r
<ItemGroup>\r
- <ClCompile Include="locbund.c" />\r
+ <ClCompile Include="locbund.cpp" />\r
<ClCompile Include="sprintf.c" />\r
<ClCompile Include="sscanf.c" />\r
<ClCompile Include="ucln_io.c">\r
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
<ImportGroup Label="ExtensionTargets">\r
</ImportGroup>\r
-</Project>
+</Project>\r
</Filter>\r
</ItemGroup>\r
<ItemGroup>\r
- <ClCompile Include="locbund.c">\r
+ <ClCompile Include="locbund.cpp">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="sprintf.c">\r
/*
*******************************************************************************
*
-* Copyright (C) 1998-2007, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*
-* File locbund.c
+* File locbund.cpp
*
* Modification History:
*
U_CDECL_END
-static U_INLINE UNumberFormat * copyInvariantFormatter(ULocaleBundle *result, UNumberFormatStyle style) {
+static inline UNumberFormat * copyInvariantFormatter(ULocaleBundle *result, UNumberFormatStyle style) {
if (result->fNumberFormat[style-1] == NULL) {
UErrorCode status = U_ZERO_ERROR;
UBool needsInit;
return result->fNumberFormat[style-1];
}
-ULocaleBundle*
+U_CAPI ULocaleBundle *
u_locbund_init(ULocaleBundle *result, const char *loc)
{
int32_t len;
return result;
}
-/*ULocaleBundle*
+/*U_CAPI ULocaleBundle *
u_locbund_new(const char *loc)
{
ULocaleBundle *result = (ULocaleBundle*) uprv_malloc(sizeof(ULocaleBundle));
return u_locbund_init(result, loc);
}
-ULocaleBundle*
+U_CAPI ULocaleBundle *
u_locbund_clone(const ULocaleBundle *bundle)
{
ULocaleBundle *result = (ULocaleBundle*)uprv_malloc(sizeof(ULocaleBundle));
return result;
}*/
-void
+U_CAPI void
u_locbund_close(ULocaleBundle *bundle)
{
int32_t styleIdx;
/* uprv_free(bundle);*/
}
-UNumberFormat*
+U_CAPI UNumberFormat *
u_locbund_getNumberFormat(ULocaleBundle *bundle, UNumberFormatStyle style)
{
UNumberFormat *formatAlias = NULL;
/*
*******************************************************************************
*
-* Copyright (C) 1998-2006s, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* @param loc The locale of the ULocaleBundle.
* @return A pointer to a ULocaleBundle, or 0 if <TT>loc</TT> was invalid.
*/
-ULocaleBundle*
+U_CAPI ULocaleBundle *
u_locbund_init(ULocaleBundle *result, const char *loc);
/**
* @param loc The locale of the ULocaleBundle.
* @return A pointer to a ULocaleBundle, or 0 if <TT>loc</TT> was invalid.
*/
-/*ULocaleBundle*
+/*U_CAPI ULocaleBundle *
u_locbund_new(const char *loc);*/
/**
* @param bundle The ULocaleBundle to clone.
* @return A new ULocaleBundle.
*/
-/*ULocaleBundle*
+/*U_CAPI ULocaleBundle *
u_locbund_clone(const ULocaleBundle *bundle);*/
/**
* Delete the specified ULocaleBundle, freeing all associated memory.
* @param bundle The ULocaleBundle to delete
*/
-void
+U_CAPI void
u_locbund_close(ULocaleBundle *bundle);
/**
* @param bundle The ULocaleBundle to use
* @return A pointer to the NumberFormat used for number formatting and parsing.
*/
-UNumberFormat*
+U_CAPI UNumberFormat *
u_locbund_getNumberFormat(ULocaleBundle *bundle, UNumberFormatStyle style);
#endif /* #if !UCONFIG_NO_FORMATTING */
/*
******************************************************************************
*
-* Copyright (C) 2002-2010, International Business Machines
+* Copyright (C) 2002-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
* @param c current code point, 0..0x10ffff
* @return "previous code point" state value
*/
-static U_INLINE int32_t
+static int32_t
bocu1Prev(int32_t c) {
/* compute new prev */
if(0x3040<=c && c<=0x309f) {
return sLength;
}
-static U_INLINE char
+static char
hexDigit(uint8_t digit) {
return digit<=9 ? (char)('0'+digit) : (char)('a'-10+digit);
}
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2011, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*****************************************************************************
/* Test that ucnv_compareNames() matches names according to spec. ----------- */
-static U_INLINE int
+static int
sign(int n) {
if(n==0) {
return 0;
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2011, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
CASE(2, testPositiveInfinity)
CASE(3, testNegativeInfinity)
CASE(4, testZero)
- CASE(5, testU_INLINE)
// CASE(, testIEEEremainder)
default: name = ""; break; //needed to end loop
logln("WARNING: NaN != 10.0 returned FALSE, should be TRUE");
}
}
-
-U_INLINE int32_t inlineTriple(int32_t x) {
- return 3*x;
-}
-
-// "code" coverage test for Jitterbug 4515 RFE: in C++, use U_INLINE=inline
-void
-PUtilTest::testU_INLINE() {
- if(inlineTriple(2)!=6 || inlineTriple(-55)!=-165) {
- errln("inlineTriple() failed");
- }
-}
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2011, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
void testPositiveInfinity(void);
void testNegativeInfinity(void);
void testZero(void);
- void testU_INLINE();
// subtests of testNaN
void testIsNaN(void);
/*
************************************************************************
-* Copyright (c) 1997-2010, International Business Machines
+* Copyright (c) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
************************************************************************
*/
*
* @param timer A pointer to UTimer struct to recieve the current time
*/
-static U_INLINE void U_EXPORT2
+static inline void U_EXPORT2
utimer_getTime(UTimer* timer){
uprv_initFrequency(timer);
uprv_start(timer);
* @param timer2 A pointer to UTimer struct to be used as end time
* @return Time in seconds
*/
-static U_INLINE double U_EXPORT2
+static inline double U_EXPORT2
utimer_getDeltaSeconds(UTimer* timer1, UTimer* timer2){
if(uprv_compareFrequency(timer1,timer2)){
return uprv_delta(timer1,timer2);
* @param timer A pointer to UTimer struct to be used as starting time
* @return Time elapsed in seconds
*/
-static U_INLINE double U_EXPORT2
+static inline double U_EXPORT2
utimer_getElapsedSeconds(UTimer* timer){
UTimer temp;
utimer_getTime(&temp);
* @param param Parameters to be passed to the fn
* @return the time elapsed in seconds
*/
-static U_INLINE double U_EXPORT2
+static inline double U_EXPORT2
utimer_loopUntilDone(double thresholdTimeVal,
int32_t* loopCount,
FuntionToBeTimed fn,
/*
*******************************************************************************
*
-* Copyright (C) 1998-2004, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
#include "cstring.h"
#include "errmsg.h"
-void error(uint32_t linenumber, const char *msg, ...)
+U_CFUNC void error(uint32_t linenumber, const char *msg, ...)
{
va_list va;
static UBool gShowWarning = TRUE;
-void setShowWarning(UBool val)
+U_CFUNC void setShowWarning(UBool val)
{
gShowWarning = val;
}
-UBool getShowWarning(){
+U_CFUNC UBool getShowWarning(){
return gShowWarning;
}
static UBool gStrict =FALSE;
-UBool isStrict(){
+U_CFUNC UBool isStrict(){
return gStrict;
}
-void setStrict(UBool val){
+U_CFUNC void setStrict(UBool val){
gStrict = val;
}
static UBool gVerbose =FALSE;
-UBool isVerbose(){
+U_CFUNC UBool isVerbose(){
return gVerbose;
}
-void setVerbose(UBool val){
+U_CFUNC void setVerbose(UBool val){
gVerbose = val;
}
-void warning(uint32_t linenumber, const char *msg, ...)
+U_CFUNC void warning(uint32_t linenumber, const char *msg, ...)
{
if (gShowWarning)
{
va_end(va);
}
}
-
/*
*******************************************************************************
*
-* Copyright (C) 1998-1999, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
extern const char *gCurrentFileName;
-void error (uint32_t linenumber, const char *msg, ...);
-void warning (uint32_t linenumber, const char *msg, ...);
-
+U_CFUNC void error(uint32_t linenumber, const char *msg, ...);
+U_CFUNC void warning(uint32_t linenumber, const char *msg, ...);
/* Show warnings? */
U_CFUNC void setShowWarning(UBool val);
<ItemGroup>\r
<ClCompile Include="errmsg.c" />\r
<ClCompile Include="genrb.c" />\r
- <ClCompile Include="parse.c" />\r
+ <ClCompile Include="parse.cpp" />\r
<ClCompile Include="prscmnts.cpp" />\r
<ClCompile Include="rbutil.c" />\r
<ClCompile Include="read.c" />\r
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
<ImportGroup Label="ExtensionTargets">\r
</ImportGroup>\r
-</Project>
+</Project>\r
<ClCompile Include="genrb.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="parse.c">\r
+ <ClCompile Include="parse.cpp">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="prscmnts.cpp">\r
*
*******************************************************************************
*
-* File parse.c
+* File parse.cpp
*
* Modification History:
*
return NULL;
}
- result = uprv_malloc(count+1);
+ result = reinterpret_cast<char *>(uprv_malloc(count+1));
if (result == NULL)
{
}
static struct SResource *
-parseUCARules(ParseState* state, char *tag, uint32_t startline, const struct UString* comment, UErrorCode *status)
+parseUCARules(ParseState* state, char *tag, uint32_t startline, const struct UString* /*comment*/, UErrorCode *status)
{
struct SResource *result = NULL;
struct UString *tokenValue;
{
c = unescape(ucbuf, status);
- if (c == U_ERR)
+ if (c == (UChar32)U_ERR)
{
uprv_free(pTarget);
T_FileStream_close(file);
}
/* Append UChar * after dissembling if c > 0xffff*/
- if (c != U_EOF)
+ if (c != (UChar32)U_EOF)
{
U_APPEND_CHAR32(c, target,len);
}
}
static struct SResource *
-parseTransliterator(ParseState* state, char *tag, uint32_t startline, const struct UString* comment, UErrorCode *status)
+parseTransliterator(ParseState* state, char *tag, uint32_t startline, const struct UString* /*comment*/, UErrorCode *status)
{
struct SResource *result = NULL;
struct UString *tokenValue;
uint8_t *data = NULL;
UCollator *coll = NULL;
int32_t reorderCodes[USCRIPT_CODE_LIMIT + (UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_FIRST)];
- uint32_t reorderCodeCount;
+ int32_t reorderCodeCount;
int32_t reorderCodeIndex;
UParseError parseError;
struct SResource *collationBin = bin_open(state->bundle, "%%CollationBin", len, data, NULL, NULL, status);
table_add(result, collationBin, line, status);
uprv_free(data);
-
+
reorderCodeCount = ucol_getReorderCodes(
coll, reorderCodes, USCRIPT_CODE_LIMIT + (UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_FIRST), &intStatus);
if (U_SUCCESS(intStatus) && reorderCodeCount > 0) {
count = (uint32_t)uprv_strlen(string);
if (count > 0){
if((count % 2)==0){
- value = uprv_malloc(sizeof(uint8_t) * count);
+ value = reinterpret_cast<uint8_t *>(uprv_malloc(sizeof(uint8_t) * count));
if (value == NULL)
{
gOmitCollationRules = omitCollationRules;
}
-static U_INLINE UBool isTable(enum EResourceType type) {
+static inline UBool isTable(enum EResourceType type) {
return (UBool)(type==RT_TABLE || type==RT_TABLE_NO_FALLBACK);
}
/* Search for normal types */
result=RT_UNKNOWN;
- while (++result < RT_RESERVED) {
+ while ((result=(EResourceType)(result+1)) < RT_RESERVED) {
if (u_strcmp(tokenValue->fChars, gResourceTypes[result].nameUChars) == 0) {
break;
}
/*
*******************************************************************************
*
-* Copyright (C) 1998-2009, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
static UBool isWhitespace (UChar32 c);
static UBool isNewline (UChar32 c);
-void resetLineNumber() {
+U_CFUNC void resetLineNumber() {
lineCount = 1;
}
never return eString twice in a row; instead, multiple adjacent
string tokens will be merged into one, with no intervening
space. */
-enum ETokenType getNextToken(UCHARBUF* buf,
- struct UString *token,
- uint32_t *linenumber, /* out: linenumber of token */
- struct UString *comment,
- UErrorCode *status) {
+U_CFUNC enum ETokenType
+getNextToken(UCHARBUF* buf,
+ struct UString *token,
+ uint32_t *linenumber, /* out: linenumber of token */
+ struct UString *comment,
+ UErrorCode *status) {
enum ETokenType result;
UChar32 c;
}
}
-UChar32 unescape(UCHARBUF *buf,
- UErrorCode *status) {
+U_CFUNC UChar32 unescape(UCHARBUF *buf, UErrorCode *status) {
if (U_FAILURE(*status)) {
return U_EOF;
}
/*
*******************************************************************************
*
-* Copyright (C) 1998-2003, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
TOK_TOKEN_COUNT /* Number of "real" token types */
};
-UChar32 unescape(UCHARBUF *buf, UErrorCode *status);
+U_CFUNC UChar32 unescape(UCHARBUF *buf, UErrorCode *status);
-void resetLineNumber(void);
+U_CFUNC void resetLineNumber(void);
-enum ETokenType getNextToken(UCHARBUF *buf,
- struct UString *token,
- uint32_t *linenumber, /* out: linenumber of token */
- struct UString *comment,
- UErrorCode *status);
+U_CFUNC enum ETokenType
+getNextToken(UCHARBUF *buf,
+ struct UString *token,
+ uint32_t *linenumber, /* out: linenumber of token */
+ struct UString *comment,
+ UErrorCode *status);
#endif
/*
*******************************************************************************
*
-* Copyright (C) 1998-2008, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
/* Macros */
#define ALLOCATION(minSize) (minSize < 0x80 ? 0x80 : (2 * minSize + 0x80) & ~(0x80 - 1))
-void
+U_CFUNC void
ustr_init(struct UString *s)
{
s->fChars = 0;
s->fLength = s->fCapacity = 0;
}
-void
+U_CFUNC void
ustr_initChars(struct UString *s, const char* source, int32_t length, UErrorCode *status)
{
int i = 0;
}
}
-void
+U_CFUNC void
ustr_deinit(struct UString *s)
{
if (s) {
}
}
-void
+U_CFUNC void
ustr_cpy(struct UString *dst,
const struct UString *src,
UErrorCode *status)
dst->fChars[dst->fLength] = 0x0000;
}
-void
+U_CFUNC void
ustr_setlen(struct UString *s,
int32_t len,
UErrorCode *status)
s->fChars[len] = 0x0000;
}
-void
+U_CFUNC void
ustr_cat(struct UString *dst,
const struct UString *src,
UErrorCode *status)
ustr_ncat(dst, src, src->fLength, status);
}
-void
+U_CFUNC void
ustr_ncat(struct UString *dst,
const struct UString *src,
int32_t n,
dst->fChars[dst->fLength] = 0x0000;
}
-void
+U_CFUNC void
ustr_ucat(struct UString *dst,
UChar c,
UErrorCode *status)
dst->fLength += 1;
dst->fChars[dst->fLength] = 0x0000;
}
-void
+U_CFUNC void
ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status){
if(c > 0x10FFFF){
*status = U_ILLEGAL_CHAR_FOUND;
ustr_ucat(dst, (UChar) c, status);
}
}
-void
+U_CFUNC void
ustr_uscat(struct UString *dst,
const UChar* src,int len,
UErrorCode *status)
/*
*******************************************************************************
*
-* Copyright (C) 1998-2003, International Business Machines
+* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
int32_t fCapacity;
};
-void ustr_init(struct UString *s);
+U_CFUNC void ustr_init(struct UString *s);
-void
+U_CFUNC void
ustr_initChars(struct UString *s, const char* source, int32_t length, UErrorCode *status);
-void ustr_deinit(struct UString *s);
+U_CFUNC void ustr_deinit(struct UString *s);
-void ustr_setlen(struct UString *s, int32_t len, UErrorCode *status);
+U_CFUNC void ustr_setlen(struct UString *s, int32_t len, UErrorCode *status);
-void ustr_cpy(struct UString *dst, const struct UString *src,
- UErrorCode *status);
+U_CFUNC void ustr_cpy(struct UString *dst, const struct UString *src,
+ UErrorCode *status);
-void ustr_cat(struct UString *dst, const struct UString *src,
- UErrorCode *status);
+U_CFUNC void ustr_cat(struct UString *dst, const struct UString *src,
+ UErrorCode *status);
-void ustr_ncat(struct UString *dst, const struct UString *src,
- int32_t n, UErrorCode *status);
+U_CFUNC void ustr_ncat(struct UString *dst, const struct UString *src,
+ int32_t n, UErrorCode *status);
-void ustr_ucat(struct UString *dst, UChar c, UErrorCode *status);
-void ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status);
-void ustr_uscat(struct UString *dst, const UChar* src,int len,UErrorCode *status);
+U_CFUNC void ustr_ucat(struct UString *dst, UChar c, UErrorCode *status);
+U_CFUNC void ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status);
+U_CFUNC void ustr_uscat(struct UString *dst, const UChar* src,int len,UErrorCode *status);
#endif
/*
*******************************************************************************
*
-* Copyright (C) 2000-2010, International Business Machines
+* Copyright (C) 2000-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
-* file name: genmbcs.c
+* file name: genmbcs.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
/* helper ------------------------------------------------------------------- */
-static U_INLINE char
+static inline char
hexDigit(uint8_t digit) {
return digit<=9 ? (char)('0'+digit) : (char)('a'-10+digit);
}
-static U_INLINE char *
+static inline char *
printBytes(char *buffer, const uint8_t *bytes, int32_t length) {
char *s=buffer;
while(length>0) {
static UBool
MBCSSingleAddFromUnicode(MBCSData *mbcsData,
- const uint8_t *bytes, int32_t length,
+ const uint8_t *bytes, int32_t /*length*/,
UChar32 c,
int8_t flag) {
uint16_t *stage3, *p;
}
static void
-MBCSPostprocess(MBCSData *mbcsData, const UConverterStaticData *staticData) {
+MBCSPostprocess(MBCSData *mbcsData, const UConverterStaticData * /*staticData*/) {
UCMStates *states;
int32_t maxCharLength, stage3Width;
int32_t i, stage1Top;
uint32_t headerLength;
- _MBCSHeader header={ { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0 };
+ _MBCSHeader header=UCNV_MBCS_HEADER_INITIALIZER;
stage2Length=mbcsData->stage2Top;
if(mbcsData->omitFromU) {
</ItemDefinitionGroup>\r
<ItemGroup>\r
<ClCompile Include="gencnvex.c" />\r
- <ClCompile Include="genmbcs.c" />\r
+ <ClCompile Include="genmbcs.cpp" />\r
<ClCompile Include="makeconv.c" />\r
<ClCompile Include="ucnvstat.c" />\r
</ItemGroup>\r
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
<ImportGroup Label="ExtensionTargets">\r
</ImportGroup>\r
-</Project>
+</Project>\r
<ClCompile Include="gencnvex.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="genmbcs.c">\r
+ <ClCompile Include="genmbcs.cpp">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="makeconv.c">\r