зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1824744
- Part 2: Update in-tree ICU to 73. r=platform-i18n-reviewers,gregtatum
Depends on D176263 Differential Revision: https://phabricator.services.mozilla.com/D176264
This commit is contained in:
Родитель
a1ca2d701e
Коммит
9f5d869662
|
@ -40,6 +40,7 @@ sources = [
|
|||
'/intl/icu/source/common/lsr.cpp',
|
||||
'/intl/icu/source/common/lstmbe.cpp',
|
||||
'/intl/icu/source/common/messagepattern.cpp',
|
||||
'/intl/icu/source/common/mlbe.cpp',
|
||||
'/intl/icu/source/common/normalizer2.cpp',
|
||||
'/intl/icu/source/common/normalizer2impl.cpp',
|
||||
'/intl/icu/source/common/normlzr.cpp',
|
||||
|
|
Двоичные данные
config/external/icu/data/icudt72l.dat → config/external/icu/data/icudt73l.dat
поставляемый
Двоичные данные
config/external/icu/data/icudt72l.dat → config/external/icu/data/icudt73l.dat
поставляемый
Двоичный файл не отображается.
|
@ -70,6 +70,7 @@ sources = [
|
|||
'/intl/icu/source/i18n/hebrwcal.cpp',
|
||||
'/intl/icu/source/i18n/indiancal.cpp',
|
||||
'/intl/icu/source/i18n/islamcal.cpp',
|
||||
'/intl/icu/source/i18n/iso8601cal.cpp',
|
||||
'/intl/icu/source/i18n/japancal.cpp',
|
||||
'/intl/icu/source/i18n/listformatter.cpp',
|
||||
'/intl/icu/source/i18n/measfmt.cpp',
|
||||
|
@ -102,6 +103,7 @@ sources = [
|
|||
'/intl/icu/source/i18n/number_patternstring.cpp',
|
||||
'/intl/icu/source/i18n/number_rounding.cpp',
|
||||
'/intl/icu/source/i18n/number_scientific.cpp',
|
||||
'/intl/icu/source/i18n/number_simple.cpp',
|
||||
'/intl/icu/source/i18n/number_skeletons.cpp',
|
||||
'/intl/icu/source/i18n/number_symbolswrapper.cpp',
|
||||
'/intl/icu/source/i18n/number_usageprefs.cpp',
|
||||
|
@ -267,6 +269,7 @@ EXPORTS.unicode += [
|
|||
'/intl/icu/source/i18n/unicode/fieldpos.h',
|
||||
'/intl/icu/source/i18n/unicode/fmtable.h',
|
||||
'/intl/icu/source/i18n/unicode/format.h',
|
||||
'/intl/icu/source/i18n/unicode/formattednumber.h',
|
||||
'/intl/icu/source/i18n/unicode/formattedvalue.h',
|
||||
'/intl/icu/source/i18n/unicode/fpositer.h',
|
||||
'/intl/icu/source/i18n/unicode/gender.h',
|
||||
|
@ -291,6 +294,7 @@ EXPORTS.unicode += [
|
|||
'/intl/icu/source/i18n/unicode/scientificnumberformatter.h',
|
||||
'/intl/icu/source/i18n/unicode/search.h',
|
||||
'/intl/icu/source/i18n/unicode/selfmt.h',
|
||||
'/intl/icu/source/i18n/unicode/simplenumberformatter.h',
|
||||
'/intl/icu/source/i18n/unicode/simpletz.h',
|
||||
'/intl/icu/source/i18n/unicode/smpdtfmt.h',
|
||||
'/intl/icu/source/i18n/unicode/sortkey.h',
|
||||
|
@ -315,6 +319,7 @@ EXPORTS.unicode += [
|
|||
'/intl/icu/source/i18n/unicode/udisplayoptions.h',
|
||||
'/intl/icu/source/i18n/unicode/ufieldpositer.h',
|
||||
'/intl/icu/source/i18n/unicode/uformattable.h',
|
||||
'/intl/icu/source/i18n/unicode/uformattednumber.h',
|
||||
'/intl/icu/source/i18n/unicode/uformattedvalue.h',
|
||||
'/intl/icu/source/i18n/unicode/ugender.h',
|
||||
'/intl/icu/source/i18n/unicode/ulistformatter.h',
|
||||
|
@ -323,6 +328,7 @@ EXPORTS.unicode += [
|
|||
'/intl/icu/source/i18n/unicode/unirepl.h',
|
||||
'/intl/icu/source/i18n/unicode/unum.h',
|
||||
'/intl/icu/source/i18n/unicode/unumberformatter.h',
|
||||
'/intl/icu/source/i18n/unicode/unumberoptions.h',
|
||||
'/intl/icu/source/i18n/unicode/unumberrangeformatter.h',
|
||||
'/intl/icu/source/i18n/unicode/unumsys.h',
|
||||
'/intl/icu/source/i18n/unicode/upluralrules.h',
|
||||
|
@ -330,6 +336,7 @@ EXPORTS.unicode += [
|
|||
'/intl/icu/source/i18n/unicode/uregion.h',
|
||||
'/intl/icu/source/i18n/unicode/ureldatefmt.h',
|
||||
'/intl/icu/source/i18n/unicode/usearch.h',
|
||||
'/intl/icu/source/i18n/unicode/usimplenumberformatter.h',
|
||||
'/intl/icu/source/i18n/unicode/uspoof.h',
|
||||
'/intl/icu/source/i18n/unicode/utmscale.h',
|
||||
'/intl/icu/source/i18n/unicode/utrans.h',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
commit ff3514f257ea10afe7e710e9f946f68d256704b1
|
||||
commit 5861e1fd52f1d7673eee38bc3c965aa18b336062
|
||||
Author: Peter Edberg <pedberg@unicode.org>
|
||||
Date: Thu Oct 13 13:44:35 2022 -0700
|
||||
Date: Tue Apr 11 10:32:35 2023 -0700
|
||||
|
||||
ICU-21958 integrate CLDR release-42-beta5 to ICU main for 72
|
||||
ICU-22221 update cldr-icu instructions, and ICU tag for integration
|
||||
|
|
|
@ -2085,8 +2085,7 @@ PREDEFINED = U_EXPORT2= \
|
|||
U_IN_DOXYGEN=1 \
|
||||
U_CHAR16_IS_TYPEDEF=0 \
|
||||
U_CPLUSPLUS_VERSION=11 \
|
||||
U_WCHAR_IS_UTF16 \
|
||||
U_FINAL=final
|
||||
U_WCHAR_IS_UTF16
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||
# tag can be used to specify a list of macro names that should be expanded. The
|
||||
|
|
|
@ -77,6 +77,7 @@ x86_64-*-cygwin)
|
|||
*-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
|
||||
*-*-os400*) icu_cv_host_frag=mh-os400 ;;
|
||||
*-apple-rhapsody*) icu_cv_host_frag=mh-darwin ;;
|
||||
powerpc*-apple-darwin*) icu_cv_host_frag=mh-darwin-ppc ;;
|
||||
*-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
|
||||
*-*-beos) icu_cv_host_frag=mh-beos ;;
|
||||
*-*-haiku) icu_cv_host_frag=mh-haiku ;;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.16.1 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -67,7 +67,7 @@ AS_VAR_POPDEF([CACHEVAR])dnl
|
|||
])dnl AX_CHECK_COMPILE_FLAGS
|
||||
|
||||
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
dnl serial 11 (pkg-config-0.29)
|
||||
dnl serial 11 (pkg-config-0.29.1)
|
||||
dnl
|
||||
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
||||
|
@ -109,7 +109,7 @@ dnl
|
|||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29])
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.1])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
|
@ -154,7 +154,7 @@ dnl Check to see whether a particular set of modules exists. Similar to
|
|||
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
|
||||
dnl
|
||||
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
dnl only at the first occurrence in configure.ac, so if the first place
|
||||
dnl only at the first occurence in configure.ac, so if the first place
|
||||
dnl it's called might be skipped (such as if it is within an "if", you
|
||||
dnl have to call PKG_CHECK_EXISTS manually
|
||||
AC_DEFUN([PKG_CHECK_EXISTS],
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!-- This file is used to set the ICU Major Version number, which is used as a suffix on various file names in other Visual Studio projects. -->
|
||||
<PropertyGroup>
|
||||
<IcuMajorVersion>72</IcuMajorVersion>
|
||||
<IcuMajorVersion>73</IcuMajorVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
@ -342,6 +342,7 @@ cc_library(
|
|||
"dictionarydata.cpp",
|
||||
"filteredbrk.cpp",
|
||||
"lstmbe.cpp",
|
||||
"mlbe.cpp",
|
||||
"rbbi.cpp",
|
||||
"rbbi_cache.cpp",
|
||||
"rbbidata.cpp",
|
||||
|
|
|
@ -25,23 +25,23 @@ Appendable::~Appendable() {}
|
|||
UBool
|
||||
Appendable::appendCodePoint(UChar32 c) {
|
||||
if(c<=0xffff) {
|
||||
return appendCodeUnit((UChar)c);
|
||||
return appendCodeUnit((char16_t)c);
|
||||
} else {
|
||||
return appendCodeUnit(U16_LEAD(c)) && appendCodeUnit(U16_TRAIL(c));
|
||||
}
|
||||
}
|
||||
|
||||
UBool
|
||||
Appendable::appendString(const UChar *s, int32_t length) {
|
||||
Appendable::appendString(const char16_t *s, int32_t length) {
|
||||
if(length<0) {
|
||||
UChar c;
|
||||
char16_t c;
|
||||
while((c=*s++)!=0) {
|
||||
if(!appendCodeUnit(c)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if(length>0) {
|
||||
const UChar *limit=s+length;
|
||||
const char16_t *limit=s+length;
|
||||
do {
|
||||
if(!appendCodeUnit(*s++)) {
|
||||
return false;
|
||||
|
@ -56,14 +56,14 @@ Appendable::reserveAppendCapacity(int32_t /*appendCapacity*/) {
|
|||
return true;
|
||||
}
|
||||
|
||||
UChar *
|
||||
char16_t *
|
||||
Appendable::getAppendBuffer(int32_t minCapacity,
|
||||
int32_t /*desiredCapacityHint*/,
|
||||
UChar *scratch, int32_t scratchCapacity,
|
||||
char16_t *scratch, int32_t scratchCapacity,
|
||||
int32_t *resultCapacity) {
|
||||
if(minCapacity<1 || scratchCapacity<minCapacity) {
|
||||
*resultCapacity=0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
*resultCapacity=scratchCapacity;
|
||||
return scratch;
|
||||
|
|
|
@ -319,9 +319,9 @@ BMPSet::contains(UChar32 c) const {
|
|||
* Check for sufficient length for trail unit for each surrogate pair.
|
||||
* Handle single surrogates as surrogate code points as usual in ICU.
|
||||
*/
|
||||
const UChar *
|
||||
BMPSet::span(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const {
|
||||
UChar c, c2;
|
||||
const char16_t *
|
||||
BMPSet::span(const char16_t *s, const char16_t *limit, USetSpanCondition spanCondition) const {
|
||||
char16_t c, c2;
|
||||
|
||||
if(spanCondition) {
|
||||
// span
|
||||
|
@ -408,9 +408,9 @@ BMPSet::span(const UChar *s, const UChar *limit, USetSpanCondition spanCondition
|
|||
}
|
||||
|
||||
/* Symmetrical with span(). */
|
||||
const UChar *
|
||||
BMPSet::spanBack(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const {
|
||||
UChar c, c2;
|
||||
const char16_t *
|
||||
BMPSet::spanBack(const char16_t *s, const char16_t *limit, USetSpanCondition spanCondition) const {
|
||||
char16_t c, c2;
|
||||
|
||||
if(spanCondition) {
|
||||
// span
|
||||
|
|
|
@ -48,14 +48,14 @@ public:
|
|||
* It must be s<limit and spanCondition==0 or 1.
|
||||
* @return The string pointer which limits the span.
|
||||
*/
|
||||
const UChar *span(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const;
|
||||
const char16_t *span(const char16_t *s, const char16_t *limit, USetSpanCondition spanCondition) const;
|
||||
|
||||
/*
|
||||
* Span the trailing substring for which each character c has spanCondition==contains(c).
|
||||
* It must be s<limit and spanCondition==0 or 1.
|
||||
* @return The string pointer which starts the span.
|
||||
*/
|
||||
const UChar *spanBack(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const;
|
||||
const char16_t *spanBack(const char16_t *s, const char16_t *limit, USetSpanCondition spanCondition) const;
|
||||
|
||||
/*
|
||||
* Span the initial substring for which each character c has spanCondition==contains(c).
|
||||
|
|
|
@ -130,7 +130,7 @@ U_NAMESPACE_BEGIN
|
|||
|
||||
const LanguageBreakEngine *
|
||||
ICULanguageBreakFactory::getEngineFor(UChar32 c) {
|
||||
const LanguageBreakEngine *lbe = NULL;
|
||||
const LanguageBreakEngine *lbe = nullptr;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
static UMutex gBreakEngineMutex;
|
||||
|
@ -147,7 +147,7 @@ ICULanguageBreakFactory::getEngineFor(UChar32 c) {
|
|||
int32_t i = fEngines->size();
|
||||
while (--i >= 0) {
|
||||
lbe = (const LanguageBreakEngine *)(fEngines->elementAt(i));
|
||||
if (lbe != NULL && lbe->handles(c)) {
|
||||
if (lbe != nullptr && lbe->handles(c)) {
|
||||
return lbe;
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ ICULanguageBreakFactory::loadEngineFor(UChar32 c) {
|
|||
}
|
||||
status = U_ZERO_ERROR; // fallback to dictionary based
|
||||
DictionaryMatcher *m = loadDictionaryMatcherFor(code);
|
||||
if (m != NULL) {
|
||||
if (m != nullptr) {
|
||||
switch(code) {
|
||||
case USCRIPT_THAI:
|
||||
engine = new ThaiBreakEngine(m, status);
|
||||
|
@ -230,17 +230,17 @@ ICULanguageBreakFactory::loadEngineFor(UChar32 c) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (engine == NULL) {
|
||||
if (engine == nullptr) {
|
||||
delete m;
|
||||
}
|
||||
else if (U_FAILURE(status)) {
|
||||
delete engine;
|
||||
engine = NULL;
|
||||
engine = nullptr;
|
||||
}
|
||||
return engine;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DictionaryMatcher *
|
||||
|
@ -250,16 +250,16 @@ ICULanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script) {
|
|||
UResourceBundle *b = ures_open(U_ICUDATA_BRKITR, "", &status);
|
||||
b = ures_getByKeyWithFallback(b, "dictionaries", b, &status);
|
||||
int32_t dictnlength = 0;
|
||||
const UChar *dictfname =
|
||||
const char16_t *dictfname =
|
||||
ures_getStringByKeyWithFallback(b, uscript_getShortName(script), &dictnlength, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
ures_close(b);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
CharString dictnbuf;
|
||||
CharString ext;
|
||||
const UChar *extStart = u_memrchr(dictfname, 0x002e, dictnlength); // last dot
|
||||
if (extStart != NULL) {
|
||||
const char16_t *extStart = u_memrchr(dictfname, 0x002e, dictnlength); // last dot
|
||||
if (extStart != nullptr) {
|
||||
int32_t len = (int32_t)(extStart - dictfname);
|
||||
ext.appendInvariantChars(UnicodeString(false, extStart + 1, dictnlength - len - 1), status);
|
||||
dictnlength = len;
|
||||
|
@ -274,29 +274,29 @@ ICULanguageBreakFactory::loadDictionaryMatcherFor(UScriptCode script) {
|
|||
const int32_t *indexes = (const int32_t *)data;
|
||||
const int32_t offset = indexes[DictionaryData::IX_STRING_TRIE_OFFSET];
|
||||
const int32_t trieType = indexes[DictionaryData::IX_TRIE_TYPE] & DictionaryData::TRIE_TYPE_MASK;
|
||||
DictionaryMatcher *m = NULL;
|
||||
DictionaryMatcher *m = nullptr;
|
||||
if (trieType == DictionaryData::TRIE_TYPE_BYTES) {
|
||||
const int32_t transform = indexes[DictionaryData::IX_TRANSFORM];
|
||||
const char *characters = (const char *)(data + offset);
|
||||
m = new BytesDictionaryMatcher(characters, transform, file);
|
||||
}
|
||||
else if (trieType == DictionaryData::TRIE_TYPE_UCHARS) {
|
||||
const UChar *characters = (const UChar *)(data + offset);
|
||||
const char16_t *characters = (const char16_t *)(data + offset);
|
||||
m = new UCharsDictionaryMatcher(characters, file);
|
||||
}
|
||||
if (m == NULL) {
|
||||
if (m == nullptr) {
|
||||
// no matcher exists to take ownership - either we are an invalid
|
||||
// type or memory allocation failed
|
||||
udata_close(file);
|
||||
}
|
||||
return m;
|
||||
} else if (dictfname != NULL) {
|
||||
} else if (dictfname != nullptr) {
|
||||
// we don't have a dictionary matcher.
|
||||
// returning NULL here will cause us to fail to find a dictionary break engine, as expected
|
||||
// returning nullptr here will cause us to fail to find a dictionary break engine, as expected
|
||||
status = U_ZERO_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
|
@ -266,7 +266,7 @@ protected:
|
|||
* <p>Create a DictionaryMatcher for the specified script and break type.</p>
|
||||
* @param script An ISO 15924 script code that identifies the dictionary to be
|
||||
* created.
|
||||
* @return A DictionaryMatcher with the desired characteristics, or NULL.
|
||||
* @return A DictionaryMatcher with the desired characteristics, or nullptr.
|
||||
*/
|
||||
virtual DictionaryMatcher *loadDictionaryMatcherFor(UScriptCode script);
|
||||
};
|
||||
|
|
|
@ -60,15 +60,15 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, UErrorCode &st
|
|||
char ext[4]={'\0'};
|
||||
CharString actualLocale;
|
||||
int32_t size;
|
||||
const UChar* brkfname = NULL;
|
||||
const char16_t* brkfname = nullptr;
|
||||
UResourceBundle brkRulesStack;
|
||||
UResourceBundle brkNameStack;
|
||||
UResourceBundle *brkRules = &brkRulesStack;
|
||||
UResourceBundle *brkName = &brkNameStack;
|
||||
RuleBasedBreakIterator *result = NULL;
|
||||
RuleBasedBreakIterator *result = nullptr;
|
||||
|
||||
if (U_FAILURE(status))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
ures_initStackObject(brkRules);
|
||||
ures_initStackObject(brkName);
|
||||
|
@ -95,9 +95,9 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, UErrorCode &st
|
|||
if (U_SUCCESS(status) && brkfname) {
|
||||
actualLocale.append(ures_getLocaleInternal(brkName, &status), -1, status);
|
||||
|
||||
UChar* extStart=u_strchr(brkfname, 0x002e);
|
||||
char16_t* extStart=u_strchr(brkfname, 0x002e);
|
||||
int len = 0;
|
||||
if(extStart!=NULL){
|
||||
if (extStart != nullptr){
|
||||
len = (int)(extStart-brkfname);
|
||||
u_UCharsToChars(extStart+1, ext, sizeof(ext)); // nul terminates the buff
|
||||
u_UCharsToChars(brkfname, fnbuff, len);
|
||||
|
@ -112,14 +112,14 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, UErrorCode &st
|
|||
UDataMemory* file = udata_open(U_ICUDATA_BRKITR, ext, fnbuff, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
ures_close(b);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Create a RuleBasedBreakIterator
|
||||
result = new RuleBasedBreakIterator(file, uprv_strstr(type, "phrase") != NULL, status);
|
||||
result = new RuleBasedBreakIterator(file, uprv_strstr(type, "phrase") != nullptr, status);
|
||||
|
||||
// If there is a result, set the valid locale and actual locale, and the kind
|
||||
if (U_SUCCESS(status) && result != NULL) {
|
||||
if (U_SUCCESS(status) && result != nullptr) {
|
||||
U_LOCALE_BASED(locBased, *(BreakIterator*)result);
|
||||
locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status),
|
||||
actualLocale.data());
|
||||
|
@ -127,12 +127,12 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, UErrorCode &st
|
|||
|
||||
ures_close(b);
|
||||
|
||||
if (U_FAILURE(status) && result != NULL) { // Sometimes redundant check, but simple
|
||||
if (U_FAILURE(status) && result != nullptr) { // Sometimes redundant check, but simple
|
||||
delete result;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (result == NULL) {
|
||||
if (result == nullptr) {
|
||||
udata_close(file);
|
||||
if (U_SUCCESS(status)) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
|
@ -260,7 +260,7 @@ public:
|
|||
}
|
||||
|
||||
virtual UObject* handleDefault(const ICUServiceKey& key, UnicodeString* /*actualID*/, UErrorCode& status) const override {
|
||||
LocaleKey& lkey = (LocaleKey&)key;
|
||||
LocaleKey& lkey = static_cast<LocaleKey&>(const_cast<ICUServiceKey&>(key));
|
||||
int32_t kind = lkey.kind();
|
||||
Locale loc;
|
||||
lkey.currentLocale(loc);
|
||||
|
@ -280,7 +280,7 @@ ICUBreakIteratorService::~ICUBreakIteratorService() {}
|
|||
U_NAMESPACE_END
|
||||
|
||||
static icu::UInitOnce gInitOnceBrkiter {};
|
||||
static icu::ICULocaleService* gService = NULL;
|
||||
static icu::ICULocaleService* gService = nullptr;
|
||||
|
||||
|
||||
|
||||
|
@ -288,11 +288,11 @@ static icu::ICULocaleService* gService = NULL;
|
|||
* Release all static memory held by breakiterator.
|
||||
*/
|
||||
U_CDECL_BEGIN
|
||||
static UBool U_CALLCONV breakiterator_cleanup(void) {
|
||||
static UBool U_CALLCONV breakiterator_cleanup() {
|
||||
#if !UCONFIG_NO_SERVICE
|
||||
if (gService) {
|
||||
delete gService;
|
||||
gService = NULL;
|
||||
gService = nullptr;
|
||||
}
|
||||
gInitOnceBrkiter.reset();
|
||||
#endif
|
||||
|
@ -302,13 +302,13 @@ U_CDECL_END
|
|||
U_NAMESPACE_BEGIN
|
||||
|
||||
static void U_CALLCONV
|
||||
initService(void) {
|
||||
initService() {
|
||||
gService = new ICUBreakIteratorService();
|
||||
ucln_common_registerCleanup(UCLN_COMMON_BREAKITERATOR, breakiterator_cleanup);
|
||||
}
|
||||
|
||||
static ICULocaleService*
|
||||
getService(void)
|
||||
getService()
|
||||
{
|
||||
umtx_initOnce(gInitOnceBrkiter, &initService);
|
||||
return gService;
|
||||
|
@ -318,9 +318,9 @@ getService(void)
|
|||
// -------------------------------------
|
||||
|
||||
static inline UBool
|
||||
hasService(void)
|
||||
hasService()
|
||||
{
|
||||
return !gInitOnceBrkiter.isReset() && getService() != NULL;
|
||||
return !gInitOnceBrkiter.isReset() && getService() != nullptr;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
@ -329,9 +329,9 @@ URegistryKey U_EXPORT2
|
|||
BreakIterator::registerInstance(BreakIterator* toAdopt, const Locale& locale, UBreakIteratorType kind, UErrorCode& status)
|
||||
{
|
||||
ICULocaleService *service = getService();
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return service->registerInstance(toAdopt, locale, kind, status);
|
||||
}
|
||||
|
@ -353,11 +353,11 @@ BreakIterator::unregister(URegistryKey key, UErrorCode& status)
|
|||
// -------------------------------------
|
||||
|
||||
StringEnumeration* U_EXPORT2
|
||||
BreakIterator::getAvailableLocales(void)
|
||||
BreakIterator::getAvailableLocales()
|
||||
{
|
||||
ICULocaleService *service = getService();
|
||||
if (service == NULL) {
|
||||
return NULL;
|
||||
if (service == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return service->getAvailableLocales();
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ BreakIterator*
|
|||
BreakIterator::createInstance(const Locale& loc, int32_t kind, UErrorCode& status)
|
||||
{
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if !UCONFIG_NO_SERVICE
|
||||
|
@ -386,7 +386,7 @@ BreakIterator::createInstance(const Locale& loc, int32_t kind, UErrorCode& statu
|
|||
// handleDefault calls), so we don't touch it. YES, A COMMENT
|
||||
// THIS LONG is a sign of bad code -- so the action item is to
|
||||
// revisit this in ICU 3.0 and clean it up/fix it/remove it.
|
||||
if (U_SUCCESS(status) && (result != NULL) && *actualLoc.getName() != 0) {
|
||||
if (U_SUCCESS(status) && (result != nullptr) && *actualLoc.getName() != 0) {
|
||||
U_LOCALE_BASED(locBased, *result);
|
||||
locBased.setLocaleIDs(actualLoc.getName(), actualLoc.getName());
|
||||
}
|
||||
|
@ -407,10 +407,10 @@ BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
|
|||
{
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BreakIterator *result = NULL;
|
||||
BreakIterator *result = nullptr;
|
||||
switch (kind) {
|
||||
case UBRK_CHARACTER:
|
||||
{
|
||||
|
@ -439,8 +439,8 @@ BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
|
|||
uprv_strcat(lb_lw, "_");
|
||||
uprv_strcat(lb_lw, value.data());
|
||||
}
|
||||
// lw=phrase is only supported in Japanese.
|
||||
if (uprv_strcmp(loc.getLanguage(), "ja") == 0) {
|
||||
// lw=phrase is only supported in Japanese and Korean
|
||||
if (uprv_strcmp(loc.getLanguage(), "ja") == 0 || uprv_strcmp(loc.getLanguage(), "ko") == 0) {
|
||||
value.clear();
|
||||
loc.getKeywordValue("lw", valueSink, kvStatus);
|
||||
if (U_SUCCESS(kvStatus) && value == "phrase") {
|
||||
|
@ -485,7 +485,7 @@ BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
|
|||
}
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -20,7 +20,7 @@ char* ByteSink::GetAppendBuffer(int32_t min_capacity,
|
|||
int32_t* result_capacity) {
|
||||
if (min_capacity < 1 || scratch_capacity < min_capacity) {
|
||||
*result_capacity = 0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
*result_capacity = scratch_capacity;
|
||||
return scratch;
|
||||
|
@ -70,7 +70,7 @@ char* CheckedArrayByteSink::GetAppendBuffer(int32_t min_capacity,
|
|||
int32_t* result_capacity) {
|
||||
if (min_capacity < 1 || scratch_capacity < min_capacity) {
|
||||
*result_capacity = 0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
int32_t available = capacity_ - size_;
|
||||
if (available >= min_capacity) {
|
||||
|
|
|
@ -68,7 +68,7 @@ BytesTrie::jumpByDelta(const uint8_t *pos) {
|
|||
UStringTrieResult
|
||||
BytesTrie::current() const {
|
||||
const uint8_t *pos=pos_;
|
||||
if(pos==NULL) {
|
||||
if(pos==nullptr) {
|
||||
return USTRINGTRIE_NO_MATCH;
|
||||
} else {
|
||||
int32_t node;
|
||||
|
@ -182,7 +182,7 @@ BytesTrie::nextImpl(const uint8_t *pos, int32_t inByte) {
|
|||
UStringTrieResult
|
||||
BytesTrie::next(int32_t inByte) {
|
||||
const uint8_t *pos=pos_;
|
||||
if(pos==NULL) {
|
||||
if(pos==nullptr) {
|
||||
return USTRINGTRIE_NO_MATCH;
|
||||
}
|
||||
if(inByte<0) {
|
||||
|
@ -212,7 +212,7 @@ BytesTrie::next(const char *s, int32_t sLength) {
|
|||
return current();
|
||||
}
|
||||
const uint8_t *pos=pos_;
|
||||
if(pos==NULL) {
|
||||
if(pos==nullptr) {
|
||||
return USTRINGTRIE_NO_MATCH;
|
||||
}
|
||||
int32_t length=remainingMatchLength_; // Actual remaining match length minus 1.
|
||||
|
@ -317,8 +317,8 @@ BytesTrie::findUniqueValueFromBranch(const uint8_t *pos, int32_t length,
|
|||
UBool haveUniqueValue, int32_t &uniqueValue) {
|
||||
while(length>kMaxBranchLinearSubNodeLength) {
|
||||
++pos; // ignore the comparison byte
|
||||
if(NULL==findUniqueValueFromBranch(jumpByDelta(pos), length>>1, haveUniqueValue, uniqueValue)) {
|
||||
return NULL;
|
||||
if(nullptr==findUniqueValueFromBranch(jumpByDelta(pos), length>>1, haveUniqueValue, uniqueValue)) {
|
||||
return nullptr;
|
||||
}
|
||||
length=length-(length>>1);
|
||||
pos=skipDelta(pos);
|
||||
|
@ -333,7 +333,7 @@ BytesTrie::findUniqueValueFromBranch(const uint8_t *pos, int32_t length,
|
|||
if(isFinal) {
|
||||
if(haveUniqueValue) {
|
||||
if(value!=uniqueValue) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
uniqueValue=value;
|
||||
|
@ -341,7 +341,7 @@ BytesTrie::findUniqueValueFromBranch(const uint8_t *pos, int32_t length,
|
|||
}
|
||||
} else {
|
||||
if(!findUniqueValue(pos+value, haveUniqueValue, uniqueValue)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
haveUniqueValue=true;
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ BytesTrie::findUniqueValue(const uint8_t *pos, UBool haveUniqueValue, int32_t &u
|
|||
node=*pos++;
|
||||
}
|
||||
pos=findUniqueValueFromBranch(pos, node+1, haveUniqueValue, uniqueValue);
|
||||
if(pos==NULL) {
|
||||
if(pos==nullptr) {
|
||||
return false;
|
||||
}
|
||||
haveUniqueValue=true;
|
||||
|
@ -387,7 +387,7 @@ BytesTrie::findUniqueValue(const uint8_t *pos, UBool haveUniqueValue, int32_t &u
|
|||
int32_t
|
||||
BytesTrie::getNextBytes(ByteSink &out) const {
|
||||
const uint8_t *pos=pos_;
|
||||
if(pos==NULL) {
|
||||
if(pos==nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if(remainingMatchLength_>=0) {
|
||||
|
|
|
@ -127,13 +127,13 @@ BytesTrieElement::compareStringTo(const BytesTrieElement &other, const CharStrin
|
|||
}
|
||||
|
||||
BytesTrieBuilder::BytesTrieBuilder(UErrorCode &errorCode)
|
||||
: strings(NULL), elements(NULL), elementsCapacity(0), elementsLength(0),
|
||||
bytes(NULL), bytesCapacity(0), bytesLength(0) {
|
||||
: strings(nullptr), elements(nullptr), elementsCapacity(0), elementsLength(0),
|
||||
bytes(nullptr), bytesCapacity(0), bytesLength(0) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
strings=new CharString();
|
||||
if(strings==NULL) {
|
||||
if(strings==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ BytesTrieBuilder::add(StringPiece s, int32_t value, UErrorCode &errorCode) {
|
|||
newCapacity=4*elementsCapacity;
|
||||
}
|
||||
BytesTrieElement *newElements=new BytesTrieElement[newCapacity];
|
||||
if(newElements==NULL) {
|
||||
if(newElements==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return *this; // error instead of dereferencing null
|
||||
}
|
||||
|
@ -192,13 +192,13 @@ U_CDECL_END
|
|||
BytesTrie *
|
||||
BytesTrieBuilder::build(UStringTrieBuildOption buildOption, UErrorCode &errorCode) {
|
||||
buildBytes(buildOption, errorCode);
|
||||
BytesTrie *newTrie=NULL;
|
||||
BytesTrie *newTrie=nullptr;
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
newTrie=new BytesTrie(bytes, bytes+(bytesCapacity-bytesLength));
|
||||
if(newTrie==NULL) {
|
||||
if(newTrie==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
} else {
|
||||
bytes=NULL; // The new trie now owns the array.
|
||||
bytes=nullptr; // The new trie now owns the array.
|
||||
bytesCapacity=0;
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ BytesTrieBuilder::buildBytes(UStringTrieBuildOption buildOption, UErrorCode &err
|
|||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
if(bytes!=NULL && bytesLength>0) {
|
||||
if(bytes!=nullptr && bytesLength>0) {
|
||||
// Already built.
|
||||
return;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ BytesTrieBuilder::buildBytes(UStringTrieBuildOption buildOption, UErrorCode &err
|
|||
if(bytesCapacity<capacity) {
|
||||
uprv_free(bytes);
|
||||
bytes=static_cast<char *>(uprv_malloc(capacity));
|
||||
if(bytes==NULL) {
|
||||
if(bytes==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
bytesCapacity=0;
|
||||
return;
|
||||
|
@ -264,7 +264,7 @@ BytesTrieBuilder::buildBytes(UStringTrieBuildOption buildOption, UErrorCode &err
|
|||
bytesCapacity=capacity;
|
||||
}
|
||||
StringTrieBuilder::build(buildOption, elementsLength, errorCode);
|
||||
if(bytes==NULL) {
|
||||
if(bytes==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ BytesTrieBuilder::getElementStringLength(int32_t i) const {
|
|||
return elements[i].getStringLength(*strings);
|
||||
}
|
||||
|
||||
UChar
|
||||
char16_t
|
||||
BytesTrieBuilder::getElementUnit(int32_t i, int32_t byteIndex) const {
|
||||
return (uint8_t)elements[i].charAt(byteIndex, *strings);
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ BytesTrieBuilder::skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t
|
|||
}
|
||||
|
||||
int32_t
|
||||
BytesTrieBuilder::indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, UChar byte) const {
|
||||
BytesTrieBuilder::indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, char16_t byte) const {
|
||||
char b=(char)byte;
|
||||
while(b==elements[i].charAt(byteIndex, *strings)) {
|
||||
++i;
|
||||
|
@ -351,13 +351,13 @@ BytesTrieBuilder::BTLinearMatchNode::operator==(const Node &other) const {
|
|||
if(!LinearMatchNode::operator==(other)) {
|
||||
return false;
|
||||
}
|
||||
const BTLinearMatchNode &o=(const BTLinearMatchNode &)other;
|
||||
const BTLinearMatchNode &o=static_cast<const BTLinearMatchNode &>(other);
|
||||
return 0==uprv_memcmp(s, o.s, length);
|
||||
}
|
||||
|
||||
void
|
||||
BytesTrieBuilder::BTLinearMatchNode::write(StringTrieBuilder &builder) {
|
||||
BytesTrieBuilder &b=(BytesTrieBuilder &)builder;
|
||||
BytesTrieBuilder &b=static_cast<BytesTrieBuilder &>(builder);
|
||||
next->write(builder);
|
||||
b.write(s, length);
|
||||
offset=b.write(b.getMinLinearMatch()+length-1);
|
||||
|
@ -374,7 +374,7 @@ BytesTrieBuilder::createLinearMatchNode(int32_t i, int32_t byteIndex, int32_t le
|
|||
|
||||
UBool
|
||||
BytesTrieBuilder::ensureCapacity(int32_t length) {
|
||||
if(bytes==NULL) {
|
||||
if(bytes==nullptr) {
|
||||
return false; // previous memory allocation had failed
|
||||
}
|
||||
if(length>bytesCapacity) {
|
||||
|
@ -383,10 +383,10 @@ BytesTrieBuilder::ensureCapacity(int32_t length) {
|
|||
newCapacity*=2;
|
||||
} while(newCapacity<=length);
|
||||
char *newBytes=static_cast<char *>(uprv_malloc(newCapacity));
|
||||
if(newBytes==NULL) {
|
||||
if(newBytes==nullptr) {
|
||||
// unable to allocate memory
|
||||
uprv_free(bytes);
|
||||
bytes=NULL;
|
||||
bytes=nullptr;
|
||||
bytesCapacity=0;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ BytesTrie::Iterator::Iterator(const void *trieBytes, int32_t maxStringLength,
|
|||
: bytes_(static_cast<const uint8_t *>(trieBytes)),
|
||||
pos_(bytes_), initialPos_(bytes_),
|
||||
remainingMatchLength_(-1), initialRemainingMatchLength_(-1),
|
||||
str_(NULL), maxLength_(maxStringLength), value_(0), stack_(NULL) {
|
||||
str_(nullptr), maxLength_(maxStringLength), value_(0), stack_(nullptr) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ BytesTrie::Iterator::Iterator(const void *trieBytes, int32_t maxStringLength,
|
|||
// cost is minimal.
|
||||
str_=new CharString();
|
||||
stack_=new UVector32(errorCode);
|
||||
if(U_SUCCESS(errorCode) && (str_==NULL || stack_==NULL)) {
|
||||
if(U_SUCCESS(errorCode) && (str_==nullptr || stack_==nullptr)) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ BytesTrie::Iterator::Iterator(const BytesTrie &trie, int32_t maxStringLength,
|
|||
: bytes_(trie.bytes_), pos_(trie.pos_), initialPos_(trie.pos_),
|
||||
remainingMatchLength_(trie.remainingMatchLength_),
|
||||
initialRemainingMatchLength_(trie.remainingMatchLength_),
|
||||
str_(NULL), maxLength_(maxStringLength), value_(0), stack_(NULL) {
|
||||
str_(nullptr), maxLength_(maxStringLength), value_(0), stack_(nullptr) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ BytesTrie::Iterator::Iterator(const BytesTrie &trie, int32_t maxStringLength,
|
|||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
if(str_==NULL || stack_==NULL) {
|
||||
if(str_==nullptr || stack_==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ BytesTrie::Iterator::reset() {
|
|||
}
|
||||
|
||||
UBool
|
||||
BytesTrie::Iterator::hasNext() const { return pos_!=NULL || !stack_->isEmpty(); }
|
||||
BytesTrie::Iterator::hasNext() const { return pos_!=nullptr || !stack_->isEmpty(); }
|
||||
|
||||
UBool
|
||||
BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
||||
|
@ -104,7 +104,7 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
|||
return false;
|
||||
}
|
||||
const uint8_t *pos=pos_;
|
||||
if(pos==NULL) {
|
||||
if(pos==nullptr) {
|
||||
if(stack_->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
|||
length=(int32_t)((uint32_t)length>>16);
|
||||
if(length>1) {
|
||||
pos=branchNext(pos, length, errorCode);
|
||||
if(pos==NULL) {
|
||||
if(pos==nullptr) {
|
||||
return true; // Reached a final value.
|
||||
}
|
||||
} else {
|
||||
|
@ -137,7 +137,7 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
|||
UBool isFinal=(UBool)(node&kValueIsFinal);
|
||||
value_=readValue(pos, node>>1);
|
||||
if(isFinal || (maxLength_>0 && str_->length()==maxLength_)) {
|
||||
pos_=NULL;
|
||||
pos_=nullptr;
|
||||
} else {
|
||||
pos_=skipValue(pos, node);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
|||
node=*pos++;
|
||||
}
|
||||
pos=branchNext(pos, node+1, errorCode);
|
||||
if(pos==NULL) {
|
||||
if(pos==nullptr) {
|
||||
return true; // Reached a final value.
|
||||
}
|
||||
} else {
|
||||
|
@ -170,12 +170,12 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
|||
|
||||
StringPiece
|
||||
BytesTrie::Iterator::getString() const {
|
||||
return str_ == NULL ? StringPiece() : str_->toStringPiece();
|
||||
return str_ == nullptr ? StringPiece() : str_->toStringPiece();
|
||||
}
|
||||
|
||||
UBool
|
||||
BytesTrie::Iterator::truncateAndStop() {
|
||||
pos_=NULL;
|
||||
pos_=nullptr;
|
||||
value_=-1; // no real value for str
|
||||
return true;
|
||||
}
|
||||
|
@ -203,9 +203,9 @@ BytesTrie::Iterator::branchNext(const uint8_t *pos, int32_t length, UErrorCode &
|
|||
stack_->addElement(((length-1)<<16)|str_->length(), errorCode);
|
||||
str_->append((char)trieByte, errorCode);
|
||||
if(isFinal) {
|
||||
pos_=NULL;
|
||||
pos_=nullptr;
|
||||
value_=value;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
return pos+value;
|
||||
}
|
||||
|
|
|
@ -68,10 +68,10 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CanonicalIterator)
|
|||
*@param source string to get results for
|
||||
*/
|
||||
CanonicalIterator::CanonicalIterator(const UnicodeString &sourceStr, UErrorCode &status) :
|
||||
pieces(NULL),
|
||||
pieces(nullptr),
|
||||
pieces_length(0),
|
||||
pieces_lengths(NULL),
|
||||
current(NULL),
|
||||
pieces_lengths(nullptr),
|
||||
current(nullptr),
|
||||
current_length(0),
|
||||
nfd(*Normalizer2::getNFDInstance(status)),
|
||||
nfcImpl(*Normalizer2Factory::getNFCImpl(status))
|
||||
|
@ -87,23 +87,23 @@ CanonicalIterator::~CanonicalIterator() {
|
|||
|
||||
void CanonicalIterator::cleanPieces() {
|
||||
int32_t i = 0;
|
||||
if(pieces != NULL) {
|
||||
if(pieces != nullptr) {
|
||||
for(i = 0; i < pieces_length; i++) {
|
||||
if(pieces[i] != NULL) {
|
||||
if(pieces[i] != nullptr) {
|
||||
delete[] pieces[i];
|
||||
}
|
||||
}
|
||||
uprv_free(pieces);
|
||||
pieces = NULL;
|
||||
pieces = nullptr;
|
||||
pieces_length = 0;
|
||||
}
|
||||
if(pieces_lengths != NULL) {
|
||||
if(pieces_lengths != nullptr) {
|
||||
uprv_free(pieces_lengths);
|
||||
pieces_lengths = NULL;
|
||||
pieces_lengths = nullptr;
|
||||
}
|
||||
if(current != NULL) {
|
||||
if(current != nullptr) {
|
||||
uprv_free(current);
|
||||
current = NULL;
|
||||
current = nullptr;
|
||||
current_length = 0;
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
|
|||
UChar32 cp = 0;
|
||||
int32_t start = 0;
|
||||
int32_t i = 0;
|
||||
UnicodeString *list = NULL;
|
||||
UnicodeString *list = nullptr;
|
||||
|
||||
nfd.normalize(newSource, source, status);
|
||||
if(U_FAILURE(status)) {
|
||||
|
@ -187,7 +187,7 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
|
|||
pieces_length = 1;
|
||||
current = (int32_t*)uprv_malloc(1 * sizeof(int32_t));
|
||||
current_length = 1;
|
||||
if (pieces == NULL || pieces_lengths == NULL || current == NULL) {
|
||||
if (pieces == nullptr || pieces_lengths == nullptr || current == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto CleanPartialInitialization;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
|
|||
pieces_lengths = (int32_t*)uprv_malloc(list_length * sizeof(int32_t));
|
||||
current = (int32_t*)uprv_malloc(list_length * sizeof(int32_t));
|
||||
current_length = list_length;
|
||||
if (pieces == NULL || pieces_lengths == NULL || current == NULL) {
|
||||
if (pieces == nullptr || pieces_lengths == nullptr || current == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto CleanPartialInitialization;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
|
|||
return;
|
||||
// Common section to cleanup all local variables and reset object variables.
|
||||
CleanPartialInitialization:
|
||||
if (list != NULL) {
|
||||
if (list != nullptr) {
|
||||
delete[] list;
|
||||
}
|
||||
cleanPieces();
|
||||
|
@ -276,7 +276,7 @@ void U_EXPORT2 CanonicalIterator::permute(UnicodeString &source, UBool skipZeros
|
|||
// we check for length < 2 to keep from counting code points all the time
|
||||
if (source.length() <= 2 && source.countChar32() <= 1) {
|
||||
UnicodeString *toPut = new UnicodeString(source);
|
||||
/* test for NULL */
|
||||
/* test for nullptr */
|
||||
if (toPut == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
|
@ -295,7 +295,7 @@ void U_EXPORT2 CanonicalIterator::permute(UnicodeString &source, UBool skipZeros
|
|||
|
||||
for (i = 0; i < source.length(); i += U16_LENGTH(cp)) {
|
||||
cp = source.char32At(i);
|
||||
const UHashElement *ne = NULL;
|
||||
const UHashElement *ne = nullptr;
|
||||
int32_t el = UHASH_FIRST;
|
||||
UnicodeString subPermuteString = source;
|
||||
|
||||
|
@ -321,11 +321,11 @@ void U_EXPORT2 CanonicalIterator::permute(UnicodeString &source, UBool skipZeros
|
|||
|
||||
// prefix this character to all of them
|
||||
ne = subpermute.nextElement(el);
|
||||
while (ne != NULL) {
|
||||
while (ne != nullptr) {
|
||||
UnicodeString *permRes = (UnicodeString *)(ne->value.pointer);
|
||||
UnicodeString *chStr = new UnicodeString(cp);
|
||||
//test for NULL
|
||||
if (chStr == NULL) {
|
||||
//test for nullptr
|
||||
if (chStr == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
|||
permutations.setValueDeleter(uprv_deleteUObject);
|
||||
basic.setValueDeleter(uprv_deleteUObject);
|
||||
|
||||
UChar USeg[256];
|
||||
char16_t USeg[256];
|
||||
int32_t segLen = segment.extract(USeg, 256, status);
|
||||
getEquivalents2(&basic, USeg, segLen, status);
|
||||
|
||||
|
@ -360,23 +360,23 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
|||
// add only the ones that are canonically equivalent
|
||||
// TODO: optimize by not permuting any class zero.
|
||||
|
||||
const UHashElement *ne = NULL;
|
||||
const UHashElement *ne = nullptr;
|
||||
int32_t el = UHASH_FIRST;
|
||||
//Iterator it = basic.iterator();
|
||||
ne = basic.nextElement(el);
|
||||
//while (it.hasNext())
|
||||
while (ne != NULL) {
|
||||
while (ne != nullptr) {
|
||||
//String item = (String) it.next();
|
||||
UnicodeString item = *((UnicodeString *)(ne->value.pointer));
|
||||
|
||||
permutations.removeAll();
|
||||
permute(item, CANITER_SKIP_ZEROES, &permutations, status);
|
||||
const UHashElement *ne2 = NULL;
|
||||
const UHashElement *ne2 = nullptr;
|
||||
int32_t el2 = UHASH_FIRST;
|
||||
//Iterator it2 = permutations.iterator();
|
||||
ne2 = permutations.nextElement(el2);
|
||||
//while (it2.hasNext())
|
||||
while (ne2 != NULL) {
|
||||
while (ne2 != nullptr) {
|
||||
//String possible = (String) it2.next();
|
||||
//UnicodeString *possible = new UnicodeString(*((UnicodeString *)(ne2->value.pointer)));
|
||||
UnicodeString possible(*((UnicodeString *)(ne2->value.pointer)));
|
||||
|
@ -403,24 +403,24 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
|||
}
|
||||
// convert into a String[] to clean up storage
|
||||
//String[] finalResult = new String[result.size()];
|
||||
UnicodeString *finalResult = NULL;
|
||||
UnicodeString *finalResult = nullptr;
|
||||
int32_t resultCount;
|
||||
if((resultCount = result.count()) != 0) {
|
||||
finalResult = new UnicodeString[resultCount];
|
||||
if (finalResult == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
//result.toArray(finalResult);
|
||||
result_len = 0;
|
||||
el = UHASH_FIRST;
|
||||
ne = result.nextElement(el);
|
||||
while(ne != NULL) {
|
||||
while(ne != nullptr) {
|
||||
finalResult[result_len++] = *((UnicodeString *)(ne->value.pointer));
|
||||
ne = result.nextElement(el);
|
||||
}
|
||||
|
@ -429,10 +429,10 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
|||
return finalResult;
|
||||
}
|
||||
|
||||
Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UChar *segment, int32_t segLen, UErrorCode &status) {
|
||||
Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const char16_t *segment, int32_t segLen, UErrorCode &status) {
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//if (PROGRESS) printf("Adding: %s\n", UToS(Tr(segment)));
|
||||
|
@ -457,7 +457,7 @@ Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UCh
|
|||
UChar32 cp2 = iter.getCodepoint();
|
||||
Hashtable remainder(status);
|
||||
remainder.setValueDeleter(uprv_deleteUObject);
|
||||
if (extract(&remainder, cp2, segment, segLen, i, status) == NULL) {
|
||||
if (extract(&remainder, cp2, segment, segLen, i, status) == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -467,13 +467,13 @@ Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UCh
|
|||
|
||||
int32_t el = UHASH_FIRST;
|
||||
const UHashElement *ne = remainder.nextElement(el);
|
||||
while (ne != NULL) {
|
||||
while (ne != nullptr) {
|
||||
UnicodeString item = *((UnicodeString *)(ne->value.pointer));
|
||||
UnicodeString *toAdd = new UnicodeString(prefix);
|
||||
/* test for NULL */
|
||||
/* test for nullptr */
|
||||
if (toAdd == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
*toAdd += item;
|
||||
fillinResult->put(*toAdd, toAdd, status);
|
||||
|
@ -487,7 +487,7 @@ Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UCh
|
|||
|
||||
/* Test for buffer overflows */
|
||||
if(U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return fillinResult;
|
||||
}
|
||||
|
@ -497,13 +497,13 @@ Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UCh
|
|||
* (with canonical rearrangement!)
|
||||
* If so, take the remainder, and return the equivalents
|
||||
*/
|
||||
Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
|
||||
Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, const char16_t *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
|
||||
//Hashtable *CanonicalIterator::extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
|
||||
//if (PROGRESS) printf(" extract: %s, ", UToS(Tr(UnicodeString(comp))));
|
||||
//if (PROGRESS) printf("%s, %i\n", UToS(Tr(segment)), segmentPos);
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UnicodeString temp(comp);
|
||||
|
@ -511,13 +511,13 @@ Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, con
|
|||
UnicodeString decompString;
|
||||
nfd.normalize(temp, decompString, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (decompString.isBogus()) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
const UChar *decomp=decompString.getBuffer();
|
||||
const char16_t *decomp=decompString.getBuffer();
|
||||
int32_t decompLen=decompString.length();
|
||||
|
||||
// See if it matches the start of segment (at segmentPos)
|
||||
|
@ -561,7 +561,7 @@ Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, con
|
|||
}
|
||||
}
|
||||
if (!ok)
|
||||
return NULL; // we failed, characters left over
|
||||
return nullptr; // we failed, characters left over
|
||||
|
||||
//if (PROGRESS) printf("Matches\n");
|
||||
|
||||
|
@ -575,7 +575,7 @@ Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, con
|
|||
UnicodeString trial;
|
||||
nfd.normalize(temp, trial, status);
|
||||
if(U_FAILURE(status) || trial.compare(segment+segmentPos, segLen - segmentPos) != 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return getEquivalents2(fillinResult, temp.getBuffer()+inputLen, temp.length()-inputLen, status);
|
||||
|
|
|
@ -67,7 +67,7 @@ _set_addRange(USet *set, UChar32 start, UChar32 end) {
|
|||
}
|
||||
|
||||
void U_CALLCONV
|
||||
_set_addString(USet *set, const UChar *str, int32_t length) {
|
||||
_set_addString(USet *set, const char16_t *str, int32_t length) {
|
||||
((UnicodeSet *)set)->add(icu::UnicodeString((UBool)(length<0), str, length));
|
||||
}
|
||||
|
||||
|
@ -377,22 +377,30 @@ UCPMap *makeMap(UProperty property, UErrorCode &errorCode) {
|
|||
|
||||
} // namespace
|
||||
|
||||
U_NAMESPACE_USE
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
U_CAPI const USet * U_EXPORT2
|
||||
u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) { return nullptr; }
|
||||
const UnicodeSet *CharacterProperties::getBinaryPropertySet(UProperty property, UErrorCode &errorCode) {
|
||||
if (U_FAILURE(errorCode)) { return nullptr; }
|
||||
if (property < 0 || UCHAR_BINARY_LIMIT <= property) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
Mutex m(&cpMutex);
|
||||
UnicodeSet *set = sets[property];
|
||||
if (set == nullptr) {
|
||||
sets[property] = set = makeSet(property, *pErrorCode);
|
||||
sets[property] = set = makeSet(property, errorCode);
|
||||
}
|
||||
if (U_FAILURE(*pErrorCode)) { return nullptr; }
|
||||
return set->toUSet();
|
||||
return set;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
U_NAMESPACE_USE
|
||||
|
||||
U_CAPI const USet * U_EXPORT2
|
||||
u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode) {
|
||||
const UnicodeSet *set = CharacterProperties::getBinaryPropertySet(property, *pErrorCode);
|
||||
return U_SUCCESS(*pErrorCode) ? set->toUSet() : nullptr;
|
||||
}
|
||||
|
||||
U_CAPI const UCPMap * U_EXPORT2
|
||||
|
|
|
@ -85,14 +85,14 @@ CharacterIterator::operator=(const CharacterIterator &that) {
|
|||
|
||||
// implementing first[32]PostInc() directly in a subclass should be faster
|
||||
// but these implementations make subclassing a little easier
|
||||
UChar
|
||||
CharacterIterator::firstPostInc(void) {
|
||||
char16_t
|
||||
CharacterIterator::firstPostInc() {
|
||||
setToStart();
|
||||
return nextPostInc();
|
||||
}
|
||||
|
||||
UChar32
|
||||
CharacterIterator::first32PostInc(void) {
|
||||
CharacterIterator::first32PostInc() {
|
||||
setToStart();
|
||||
return next32PostInc();
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
CharString::CharString(CharString&& src) U_NOEXCEPT
|
||||
CharString::CharString(CharString&& src) noexcept
|
||||
: buffer(std::move(src.buffer)), len(src.len) {
|
||||
src.len = 0; // not strictly necessary because we make no guarantees on the source string
|
||||
}
|
||||
|
||||
CharString& CharString::operator=(CharString&& src) U_NOEXCEPT {
|
||||
CharString& CharString::operator=(CharString&& src) noexcept {
|
||||
buffer = std::move(src.buffer);
|
||||
len = src.len;
|
||||
src.len = 0; // not strictly necessary because we make no guarantees on the source string
|
||||
|
@ -113,7 +113,7 @@ CharString &CharString::append(const char *s, int32_t sLength, UErrorCode &error
|
|||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
if(sLength<-1 || (s==NULL && sLength!=0)) {
|
||||
if(sLength<-1 || (s==nullptr && sLength!=0)) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return *this;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ char *CharString::getAppendBuffer(int32_t minCapacity,
|
|||
UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
resultCapacity=0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
int32_t appendCapacity=buffer.getCapacity()-len-1; // -1 for NUL
|
||||
if(appendCapacity>=minCapacity) {
|
||||
|
@ -193,14 +193,14 @@ char *CharString::getAppendBuffer(int32_t minCapacity,
|
|||
return buffer.getAlias()+len;
|
||||
}
|
||||
resultCapacity=0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CharString &CharString::appendInvariantChars(const UnicodeString &s, UErrorCode &errorCode) {
|
||||
return appendInvariantChars(s.getBuffer(), s.length(), errorCode);
|
||||
}
|
||||
|
||||
CharString &CharString::appendInvariantChars(const UChar* uchars, int32_t ucharsLen, UErrorCode &errorCode) {
|
||||
CharString &CharString::appendInvariantChars(const char16_t* uchars, int32_t ucharsLen, UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
|
@ -226,8 +226,8 @@ UBool CharString::ensureCapacity(int32_t capacity,
|
|||
if(desiredCapacityHint==0) {
|
||||
desiredCapacityHint=capacity+buffer.getCapacity();
|
||||
}
|
||||
if( (desiredCapacityHint<=capacity || buffer.resize(desiredCapacityHint, len+1)==NULL) &&
|
||||
buffer.resize(capacity, len+1)==NULL
|
||||
if( (desiredCapacityHint<=capacity || buffer.resize(desiredCapacityHint, len+1)==nullptr) &&
|
||||
buffer.resize(capacity, len+1)==nullptr
|
||||
) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
|
|
|
@ -59,13 +59,13 @@ public:
|
|||
* Move constructor; might leave src in an undefined state.
|
||||
* This string will have the same contents and state that the source string had.
|
||||
*/
|
||||
CharString(CharString &&src) U_NOEXCEPT;
|
||||
CharString(CharString &&src) noexcept;
|
||||
/**
|
||||
* Move assignment operator; might leave src in an undefined state.
|
||||
* This string will have the same contents and state that the source string had.
|
||||
* The behavior is undefined if *this and src are the same object.
|
||||
*/
|
||||
CharString &operator=(CharString &&src) U_NOEXCEPT;
|
||||
CharString &operator=(CharString &&src) noexcept;
|
||||
|
||||
/**
|
||||
* Replaces this string's contents with the other string's contents.
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
UErrorCode &errorCode);
|
||||
|
||||
CharString &appendInvariantChars(const UnicodeString &s, UErrorCode &errorCode);
|
||||
CharString &appendInvariantChars(const UChar* uchars, int32_t ucharsLen, UErrorCode& errorCode);
|
||||
CharString &appendInvariantChars(const char16_t* uchars, int32_t ucharsLen, UErrorCode& errorCode);
|
||||
|
||||
/**
|
||||
* Appends a filename/path part, e.g., a directory name.
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
map = uhash_openSize(uhash_hashChars, uhash_compareChars, uhash_compareChars,
|
||||
size, &errorCode);
|
||||
}
|
||||
CharStringMap(CharStringMap &&other) U_NOEXCEPT : map(other.map) {
|
||||
CharStringMap(CharStringMap &&other) noexcept : map(other.map) {
|
||||
other.map = nullptr;
|
||||
}
|
||||
CharStringMap(const CharStringMap &other) = delete;
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
uhash_close(map);
|
||||
}
|
||||
|
||||
CharStringMap &operator=(CharStringMap &&other) U_NOEXCEPT {
|
||||
CharStringMap &operator=(CharStringMap &&other) noexcept {
|
||||
map = other.map;
|
||||
other.map = nullptr;
|
||||
return *this;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* If you have a need to replace ICU allocation, this is the
|
||||
* place to do it.
|
||||
*
|
||||
* Note that uprv_malloc(0) returns a non-NULL pointer, and
|
||||
* that a subsequent free of that pointer value is a NOP.
|
||||
* Note that uprv_malloc(0) returns a non-nullptr pointer,
|
||||
* and that a subsequent free of that pointer value is a NOP.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
@ -103,7 +103,7 @@ uprv_free(void *buffer) {
|
|||
|
||||
U_CAPI void * U_EXPORT2
|
||||
uprv_calloc(size_t num, size_t size) {
|
||||
void *mem = NULL;
|
||||
void *mem = nullptr;
|
||||
size *= num;
|
||||
mem = uprv_malloc(size);
|
||||
if (mem) {
|
||||
|
@ -118,7 +118,7 @@ u_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMem
|
|||
if (U_FAILURE(*status)) {
|
||||
return;
|
||||
}
|
||||
if (a==NULL || r==NULL || f==NULL) {
|
||||
if (a==nullptr || r==nullptr || f==nullptr) {
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -129,10 +129,10 @@ u_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMem
|
|||
}
|
||||
|
||||
|
||||
U_CFUNC UBool cmemory_cleanup(void) {
|
||||
pContext = NULL;
|
||||
pAlloc = NULL;
|
||||
pRealloc = NULL;
|
||||
pFree = NULL;
|
||||
U_CFUNC UBool cmemory_cleanup() {
|
||||
pContext = nullptr;
|
||||
pAlloc = nullptr;
|
||||
pRealloc = nullptr;
|
||||
pFree = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -192,13 +192,13 @@ public:
|
|||
* Constructor takes ownership.
|
||||
* @param p simple pointer to an array of T items that is adopted
|
||||
*/
|
||||
explicit LocalMemory(T *p=NULL) : LocalPointerBase<T>(p) {}
|
||||
explicit LocalMemory(T *p=nullptr) : LocalPointerBase<T>(p) {}
|
||||
/**
|
||||
* Move constructor, leaves src with isNull().
|
||||
* @param src source smart pointer
|
||||
*/
|
||||
LocalMemory(LocalMemory<T> &&src) U_NOEXCEPT : LocalPointerBase<T>(src.ptr) {
|
||||
src.ptr=NULL;
|
||||
LocalMemory(LocalMemory<T> &&src) noexcept : LocalPointerBase<T>(src.ptr) {
|
||||
src.ptr=nullptr;
|
||||
}
|
||||
/**
|
||||
* Destructor deletes the memory it owns.
|
||||
|
@ -212,17 +212,17 @@ public:
|
|||
* @param src source smart pointer
|
||||
* @return *this
|
||||
*/
|
||||
LocalMemory<T> &operator=(LocalMemory<T> &&src) U_NOEXCEPT {
|
||||
LocalMemory<T> &operator=(LocalMemory<T> &&src) noexcept {
|
||||
uprv_free(LocalPointerBase<T>::ptr);
|
||||
LocalPointerBase<T>::ptr=src.ptr;
|
||||
src.ptr=NULL;
|
||||
src.ptr=nullptr;
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* Swap pointers.
|
||||
* @param other other smart pointer
|
||||
*/
|
||||
void swap(LocalMemory<T> &other) U_NOEXCEPT {
|
||||
void swap(LocalMemory<T> &other) noexcept {
|
||||
T *temp=LocalPointerBase<T>::ptr;
|
||||
LocalPointerBase<T>::ptr=other.ptr;
|
||||
other.ptr=temp;
|
||||
|
@ -232,7 +232,7 @@ public:
|
|||
* @param p1 will get p2's pointer
|
||||
* @param p2 will get p1's pointer
|
||||
*/
|
||||
friend inline void swap(LocalMemory<T> &p1, LocalMemory<T> &p2) U_NOEXCEPT {
|
||||
friend inline void swap(LocalMemory<T> &p1, LocalMemory<T> &p2) noexcept {
|
||||
p1.swap(p2);
|
||||
}
|
||||
/**
|
||||
|
@ -248,21 +248,21 @@ public:
|
|||
* Deletes the array it owns, allocates a new one and reset its bytes to 0.
|
||||
* Returns the new array pointer.
|
||||
* If the allocation fails, then the current array is unchanged and
|
||||
* this method returns NULL.
|
||||
* this method returns nullptr.
|
||||
* @param newCapacity must be >0
|
||||
* @return the allocated array pointer, or NULL if the allocation failed
|
||||
* @return the allocated array pointer, or nullptr if the allocation failed
|
||||
*/
|
||||
inline T *allocateInsteadAndReset(int32_t newCapacity=1);
|
||||
/**
|
||||
* Deletes the array it owns and allocates a new one, copying length T items.
|
||||
* Returns the new array pointer.
|
||||
* If the allocation fails, then the current array is unchanged and
|
||||
* this method returns NULL.
|
||||
* this method returns nullptr.
|
||||
* @param newCapacity must be >0
|
||||
* @param length number of T items to be copied from the old array to the new one;
|
||||
* must be no more than the capacity of the old array,
|
||||
* which the caller must track because the LocalMemory does not track it
|
||||
* @return the allocated array pointer, or NULL if the allocation failed
|
||||
* @return the allocated array pointer, or nullptr if the allocation failed
|
||||
*/
|
||||
inline T *allocateInsteadAndCopy(int32_t newCapacity=1, int32_t length=0);
|
||||
/**
|
||||
|
@ -278,14 +278,14 @@ template<typename T>
|
|||
inline T *LocalMemory<T>::allocateInsteadAndReset(int32_t newCapacity) {
|
||||
if(newCapacity>0) {
|
||||
T *p=(T *)uprv_malloc(newCapacity*sizeof(T));
|
||||
if(p!=NULL) {
|
||||
if(p!=nullptr) {
|
||||
uprv_memset(p, 0, newCapacity*sizeof(T));
|
||||
uprv_free(LocalPointerBase<T>::ptr);
|
||||
LocalPointerBase<T>::ptr=p;
|
||||
}
|
||||
return p;
|
||||
} else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ template<typename T>
|
|||
inline T *LocalMemory<T>::allocateInsteadAndCopy(int32_t newCapacity, int32_t length) {
|
||||
if(newCapacity>0) {
|
||||
T *p=(T *)uprv_malloc(newCapacity*sizeof(T));
|
||||
if(p!=NULL) {
|
||||
if(p!=nullptr) {
|
||||
if(length>0) {
|
||||
if(length>newCapacity) {
|
||||
length=newCapacity;
|
||||
|
@ -306,7 +306,7 @@ inline T *LocalMemory<T>::allocateInsteadAndCopy(int32_t newCapacity, int32_t le
|
|||
}
|
||||
return p;
|
||||
} else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,10 +332,10 @@ template<typename T, int32_t stackCapacity>
|
|||
class MaybeStackArray {
|
||||
public:
|
||||
// No heap allocation. Use only on the stack.
|
||||
static void* U_EXPORT2 operator new(size_t) U_NOEXCEPT = delete;
|
||||
static void* U_EXPORT2 operator new[](size_t) U_NOEXCEPT = delete;
|
||||
static void* U_EXPORT2 operator new(size_t) noexcept = delete;
|
||||
static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
|
||||
#if U_HAVE_PLACEMENT_NEW
|
||||
static void* U_EXPORT2 operator new(size_t, void*) U_NOEXCEPT = delete;
|
||||
static void* U_EXPORT2 operator new(size_t, void*) noexcept = delete;
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -364,11 +364,11 @@ public:
|
|||
/**
|
||||
* Move constructor: transfers ownership or copies the stack array.
|
||||
*/
|
||||
MaybeStackArray(MaybeStackArray<T, stackCapacity> &&src) U_NOEXCEPT;
|
||||
MaybeStackArray(MaybeStackArray<T, stackCapacity> &&src) noexcept;
|
||||
/**
|
||||
* Move assignment: transfers ownership or copies the stack array.
|
||||
*/
|
||||
MaybeStackArray<T, stackCapacity> &operator=(MaybeStackArray<T, stackCapacity> &&src) U_NOEXCEPT;
|
||||
MaybeStackArray<T, stackCapacity> &operator=(MaybeStackArray<T, stackCapacity> &&src) noexcept;
|
||||
/**
|
||||
* Returns the array capacity (number of T items).
|
||||
* @return array capacity
|
||||
|
@ -403,11 +403,11 @@ public:
|
|||
/**
|
||||
* Deletes the array (if owned) and aliases another one, no transfer of ownership.
|
||||
* If the arguments are illegal, then the current array is unchanged.
|
||||
* @param otherArray must not be NULL
|
||||
* @param otherArray must not be nullptr
|
||||
* @param otherCapacity must be >0
|
||||
*/
|
||||
void aliasInstead(T *otherArray, int32_t otherCapacity) {
|
||||
if(otherArray!=NULL && otherCapacity>0) {
|
||||
if(otherArray!=nullptr && otherCapacity>0) {
|
||||
releaseArray();
|
||||
ptr=otherArray;
|
||||
capacity=otherCapacity;
|
||||
|
@ -418,17 +418,17 @@ public:
|
|||
* Deletes the array (if owned) and allocates a new one, copying length T items.
|
||||
* Returns the new array pointer.
|
||||
* If the allocation fails, then the current array is unchanged and
|
||||
* this method returns NULL.
|
||||
* this method returns nullptr.
|
||||
* @param newCapacity can be less than or greater than the current capacity;
|
||||
* must be >0
|
||||
* @param length number of T items to be copied from the old array to the new one
|
||||
* @return the allocated array pointer, or NULL if the allocation failed
|
||||
* @return the allocated array pointer, or nullptr if the allocation failed
|
||||
*/
|
||||
inline T *resize(int32_t newCapacity, int32_t length=0);
|
||||
/**
|
||||
* Gives up ownership of the array if owned, or else clones it,
|
||||
* copying length T items; resets itself to the internal stack array.
|
||||
* Returns NULL if the allocation failed.
|
||||
* Returns nullptr if the allocation failed.
|
||||
* @param length number of T items to copy when cloning,
|
||||
* and capacity of the clone when cloning
|
||||
* @param resultCapacity will be set to the returned array's capacity (output-only)
|
||||
|
@ -443,7 +443,7 @@ protected:
|
|||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
if (this->resize(src.capacity, 0) == NULL) {
|
||||
if (this->resize(src.capacity, 0) == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ private:
|
|||
|
||||
template<typename T, int32_t stackCapacity>
|
||||
icu::MaybeStackArray<T, stackCapacity>::MaybeStackArray(
|
||||
MaybeStackArray <T, stackCapacity>&& src) U_NOEXCEPT
|
||||
MaybeStackArray <T, stackCapacity>&& src) noexcept
|
||||
: ptr(src.ptr), capacity(src.capacity), needToRelease(src.needToRelease) {
|
||||
if (src.ptr == src.stackArray) {
|
||||
ptr = stackArray;
|
||||
|
@ -487,7 +487,7 @@ icu::MaybeStackArray<T, stackCapacity>::MaybeStackArray(
|
|||
|
||||
template<typename T, int32_t stackCapacity>
|
||||
inline MaybeStackArray <T, stackCapacity>&
|
||||
MaybeStackArray<T, stackCapacity>::operator=(MaybeStackArray <T, stackCapacity>&& src) U_NOEXCEPT {
|
||||
MaybeStackArray<T, stackCapacity>::operator=(MaybeStackArray <T, stackCapacity>&& src) noexcept {
|
||||
releaseArray(); // in case this instance had its own memory allocated
|
||||
capacity = src.capacity;
|
||||
needToRelease = src.needToRelease;
|
||||
|
@ -508,7 +508,7 @@ inline T *MaybeStackArray<T, stackCapacity>::resize(int32_t newCapacity, int32_t
|
|||
::fprintf(::stderr, "MaybeStackArray (resize) alloc %d * %lu\n", newCapacity, sizeof(T));
|
||||
#endif
|
||||
T *p=(T *)uprv_malloc(newCapacity*sizeof(T));
|
||||
if(p!=NULL) {
|
||||
if(p!=nullptr) {
|
||||
if(length>0) {
|
||||
if(length>capacity) {
|
||||
length=capacity;
|
||||
|
@ -525,7 +525,7 @@ inline T *MaybeStackArray<T, stackCapacity>::resize(int32_t newCapacity, int32_t
|
|||
}
|
||||
return p;
|
||||
} else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,7 +535,7 @@ inline T *MaybeStackArray<T, stackCapacity>::orphanOrClone(int32_t length, int32
|
|||
if(needToRelease) {
|
||||
p=ptr;
|
||||
} else if(length<=0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
if(length>capacity) {
|
||||
length=capacity;
|
||||
|
@ -544,8 +544,8 @@ inline T *MaybeStackArray<T, stackCapacity>::orphanOrClone(int32_t length, int32
|
|||
#if U_DEBUG && defined(UPRV_MALLOC_COUNT)
|
||||
::fprintf(::stderr,"MaybeStacArray (orphan) alloc %d * %lu\n", length,sizeof(T));
|
||||
#endif
|
||||
if(p==NULL) {
|
||||
return NULL;
|
||||
if(p==nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
uprv_memcpy(p, ptr, (size_t)length*sizeof(T));
|
||||
}
|
||||
|
@ -568,10 +568,10 @@ template<typename H, typename T, int32_t stackCapacity>
|
|||
class MaybeStackHeaderAndArray {
|
||||
public:
|
||||
// No heap allocation. Use only on the stack.
|
||||
static void* U_EXPORT2 operator new(size_t) U_NOEXCEPT = delete;
|
||||
static void* U_EXPORT2 operator new[](size_t) U_NOEXCEPT = delete;
|
||||
static void* U_EXPORT2 operator new(size_t) noexcept = delete;
|
||||
static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
|
||||
#if U_HAVE_PLACEMENT_NEW
|
||||
static void* U_EXPORT2 operator new(size_t, void*) U_NOEXCEPT = delete;
|
||||
static void* U_EXPORT2 operator new(size_t, void*) noexcept = delete;
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -618,11 +618,11 @@ public:
|
|||
/**
|
||||
* Deletes the memory block (if owned) and aliases another one, no transfer of ownership.
|
||||
* If the arguments are illegal, then the current memory is unchanged.
|
||||
* @param otherArray must not be NULL
|
||||
* @param otherArray must not be nullptr
|
||||
* @param otherCapacity must be >0
|
||||
*/
|
||||
void aliasInstead(H *otherMemory, int32_t otherCapacity) {
|
||||
if(otherMemory!=NULL && otherCapacity>0) {
|
||||
if(otherMemory!=nullptr && otherCapacity>0) {
|
||||
releaseMemory();
|
||||
ptr=otherMemory;
|
||||
capacity=otherCapacity;
|
||||
|
@ -634,17 +634,17 @@ public:
|
|||
* copying the header and length T array items.
|
||||
* Returns the new header pointer.
|
||||
* If the allocation fails, then the current memory is unchanged and
|
||||
* this method returns NULL.
|
||||
* this method returns nullptr.
|
||||
* @param newCapacity can be less than or greater than the current capacity;
|
||||
* must be >0
|
||||
* @param length number of T items to be copied from the old array to the new one
|
||||
* @return the allocated pointer, or NULL if the allocation failed
|
||||
* @return the allocated pointer, or nullptr if the allocation failed
|
||||
*/
|
||||
inline H *resize(int32_t newCapacity, int32_t length=0);
|
||||
/**
|
||||
* Gives up ownership of the memory if owned, or else clones it,
|
||||
* copying the header and length T array items; resets itself to the internal memory.
|
||||
* Returns NULL if the allocation failed.
|
||||
* Returns nullptr if the allocation failed.
|
||||
* @param length number of T items to copy when cloning,
|
||||
* and array capacity of the clone when cloning
|
||||
* @param resultCapacity will be set to the returned array's capacity (output-only)
|
||||
|
@ -680,7 +680,7 @@ inline H *MaybeStackHeaderAndArray<H, T, stackCapacity>::resize(int32_t newCapac
|
|||
::fprintf(::stderr,"MaybeStackHeaderAndArray alloc %d + %d * %ul\n", sizeof(H),newCapacity,sizeof(T));
|
||||
#endif
|
||||
H *p=(H *)uprv_malloc(sizeof(H)+newCapacity*sizeof(T));
|
||||
if(p!=NULL) {
|
||||
if(p!=nullptr) {
|
||||
if(length<0) {
|
||||
length=0;
|
||||
} else if(length>0) {
|
||||
|
@ -699,7 +699,7 @@ inline H *MaybeStackHeaderAndArray<H, T, stackCapacity>::resize(int32_t newCapac
|
|||
}
|
||||
return p;
|
||||
} else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,8 +719,8 @@ inline H *MaybeStackHeaderAndArray<H, T, stackCapacity>::orphanOrClone(int32_t l
|
|||
::fprintf(::stderr,"MaybeStackHeaderAndArray (orphan) alloc %ul + %d * %lu\n", sizeof(H),length,sizeof(T));
|
||||
#endif
|
||||
p=(H *)uprv_malloc(sizeof(H)+length*sizeof(T));
|
||||
if(p==NULL) {
|
||||
return NULL;
|
||||
if(p==nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
uprv_memcpy(p, ptr, sizeof(H)+(size_t)length*sizeof(T));
|
||||
}
|
||||
|
@ -768,12 +768,12 @@ public:
|
|||
MemoryPool(const MemoryPool&) = delete;
|
||||
MemoryPool& operator=(const MemoryPool&) = delete;
|
||||
|
||||
MemoryPool(MemoryPool&& other) U_NOEXCEPT : fCount(other.fCount),
|
||||
MemoryPool(MemoryPool&& other) noexcept : fCount(other.fCount),
|
||||
fPool(std::move(other.fPool)) {
|
||||
other.fCount = 0;
|
||||
}
|
||||
|
||||
MemoryPool& operator=(MemoryPool&& other) U_NOEXCEPT {
|
||||
MemoryPool& operator=(MemoryPool&& other) noexcept {
|
||||
// Since `this` may contain instances that need to be deleted, we can't
|
||||
// just throw them away and replace them with `other`. The normal way of
|
||||
// dealing with this in C++ is to swap `this` and `other`, rather than
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
<ClCompile Include="brkiter.cpp" />
|
||||
<ClCompile Include="dictbe.cpp" />
|
||||
<ClCompile Include="lstmbe.cpp" />
|
||||
<ClCompile Include="mlbe.cpp" />
|
||||
<ClCompile Include="pluralmap.cpp" />
|
||||
<ClCompile Include="rbbi.cpp" />
|
||||
<ClCompile Include="rbbidata.cpp" />
|
||||
|
@ -282,6 +283,7 @@
|
|||
<ClInclude Include="brkeng.h" />
|
||||
<ClInclude Include="dictbe.h" />
|
||||
<ClInclude Include="lstmbe.h" />
|
||||
<ClInclude Include="mlbe.h" />
|
||||
<ClInclude Include="rbbidata.h" />
|
||||
<ClInclude Include="rbbinode.h" />
|
||||
<ClInclude Include="rbbirb.h" />
|
||||
|
|
|
@ -76,6 +76,9 @@
|
|||
<ClCompile Include="lstmbe.cpp">
|
||||
<Filter>break iteration</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mlbe.cpp">
|
||||
<Filter>break iteration</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rbbi.cpp">
|
||||
<Filter>break iteration</Filter>
|
||||
</ClCompile>
|
||||
|
@ -660,6 +663,9 @@
|
|||
<ClInclude Include="lstmbe.h">
|
||||
<Filter>break iteration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="mlbe.h">
|
||||
<Filter>break iteration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rbbidata.h">
|
||||
<Filter>break iteration</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -222,6 +222,7 @@
|
|||
<ClCompile Include="brkiter.cpp" />
|
||||
<ClCompile Include="dictbe.cpp" />
|
||||
<ClCompile Include="lstmbe.cpp" />
|
||||
<ClCompile Include="mlbe.cpp" />
|
||||
<ClCompile Include="pluralmap.cpp" />
|
||||
<ClCompile Include="rbbi.cpp" />
|
||||
<ClCompile Include="rbbidata.cpp" />
|
||||
|
@ -417,6 +418,7 @@
|
|||
<ClInclude Include="brkeng.h" />
|
||||
<ClInclude Include="dictbe.h" />
|
||||
<ClInclude Include="lstmbe.h" />
|
||||
<ClInclude Include="mlbe.h" />
|
||||
<ClInclude Include="rbbidata.h" />
|
||||
<ClInclude Include="rbbinode.h" />
|
||||
<ClInclude Include="rbbirb.h" />
|
||||
|
|
|
@ -62,8 +62,8 @@ inline void uprv_arrayCopy(const int32_t* src, int32_t srcStart,
|
|||
|
||||
static
|
||||
inline void
|
||||
uprv_arrayCopy(const UChar *src, int32_t srcStart,
|
||||
UChar *dst, int32_t dstStart, int32_t count)
|
||||
uprv_arrayCopy(const char16_t *src, int32_t srcStart,
|
||||
char16_t *dst, int32_t dstStart, int32_t count)
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); }
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ U_NAMESPACE_BEGIN
|
|||
CStr::CStr(const UnicodeString &in) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
#if !UCONFIG_NO_CONVERSION || U_CHARSET_IS_UTF8
|
||||
int32_t length = in.extract(0, in.length(), static_cast<char *>(NULL), static_cast<uint32_t>(0));
|
||||
int32_t length = in.extract(0, in.length(), static_cast<char *>(nullptr), static_cast<uint32_t>(0));
|
||||
int32_t resultCapacity = 0;
|
||||
char *buf = s.getAppendBuffer(length, length, resultCapacity, status);
|
||||
if (U_SUCCESS(status)) {
|
||||
|
|
|
@ -189,7 +189,7 @@ T_CString_integerToString(char* buffer, int32_t v, int32_t radix)
|
|||
/*
|
||||
* Takes a int64_t and fills in a char* string with that number "radix"-based.
|
||||
* Writes at most 21: chars ("-9223372036854775807" plus NUL).
|
||||
* Returns the length of the string, not including the terminating NULL.
|
||||
* Returns the length of the string, not including the terminating NUL.
|
||||
*/
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
T_CString_int64ToString(char* buffer, int64_t v, uint32_t radix)
|
||||
|
@ -233,16 +233,16 @@ T_CString_stringToInteger(const char *integerString, int32_t radix)
|
|||
|
||||
U_CAPI int U_EXPORT2
|
||||
uprv_stricmp(const char *str1, const char *str2) {
|
||||
if(str1==NULL) {
|
||||
if(str2==NULL) {
|
||||
if(str1==nullptr) {
|
||||
if(str2==nullptr) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if(str2==NULL) {
|
||||
} else if(str2==nullptr) {
|
||||
return 1;
|
||||
} else {
|
||||
/* compare non-NULL strings lexically with lowercase */
|
||||
/* compare non-nullptr strings lexically with lowercase */
|
||||
int rc;
|
||||
unsigned char c1, c2;
|
||||
|
||||
|
@ -272,16 +272,16 @@ uprv_stricmp(const char *str1, const char *str2) {
|
|||
|
||||
U_CAPI int U_EXPORT2
|
||||
uprv_strnicmp(const char *str1, const char *str2, uint32_t n) {
|
||||
if(str1==NULL) {
|
||||
if(str2==NULL) {
|
||||
if(str1==nullptr) {
|
||||
if(str2==nullptr) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if(str2==NULL) {
|
||||
} else if(str2==nullptr) {
|
||||
return 1;
|
||||
} else {
|
||||
/* compare non-NULL strings lexically with lowercase */
|
||||
/* compare non-nullptr strings lexically with lowercase */
|
||||
int rc;
|
||||
unsigned char c1, c2;
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ int32_t PossibleWord::candidates( UText *text, DictionaryMatcher *dict, int32_t
|
|||
int32_t start = (int32_t)utext_getNativeIndex(text);
|
||||
if (start != offset) {
|
||||
offset = start;
|
||||
count = dict->matches(text, rangeEnd-start, UPRV_LENGTHOF(cuLengths), cuLengths, cpLengths, NULL, &prefix);
|
||||
count = dict->matches(text, rangeEnd-start, UPRV_LENGTHOF(cuLengths), cuLengths, cpLengths, nullptr, &prefix);
|
||||
// Dictionary leaves text after longest prefix, not longest word. Back up.
|
||||
if (count <= 0) {
|
||||
utext_setNativeIndex(text, start);
|
||||
|
@ -1054,9 +1054,10 @@ foundBest:
|
|||
*/
|
||||
static const uint32_t kuint32max = 0xFFFFFFFF;
|
||||
CjkBreakEngine::CjkBreakEngine(DictionaryMatcher *adoptDictionary, LanguageType type, UErrorCode &status)
|
||||
: DictionaryBreakEngine(), fDictionary(adoptDictionary) {
|
||||
: DictionaryBreakEngine(), fDictionary(adoptDictionary), isCj(false) {
|
||||
UTRACE_ENTRY(UTRACE_UBRK_CREATE_BREAK_ENGINE);
|
||||
UTRACE_DATA1(UTRACE_INFO, "dictbe=%s", "Hani");
|
||||
fMlBreakEngine = nullptr;
|
||||
nfkcNorm2 = Normalizer2::getNFKCInstance(status);
|
||||
// Korean dictionary only includes Hangul syllables
|
||||
fHangulWordSet.applyPattern(UnicodeString(u"[\\uac00-\\ud7a3]"), status);
|
||||
|
@ -1073,11 +1074,20 @@ CjkBreakEngine::CjkBreakEngine(DictionaryMatcher *adoptDictionary, LanguageType
|
|||
if (U_SUCCESS(status)) {
|
||||
setCharacters(fHangulWordSet);
|
||||
}
|
||||
} else { //Chinese and Japanese
|
||||
} else { // Chinese and Japanese
|
||||
UnicodeSet cjSet(UnicodeString(u"[[:Han:][:Hiragana:][:Katakana:]\\u30fc\\uff70\\uff9e\\uff9f]"), status);
|
||||
isCj = true;
|
||||
if (U_SUCCESS(status)) {
|
||||
setCharacters(cjSet);
|
||||
#if UCONFIG_USE_ML_PHRASE_BREAKING
|
||||
fMlBreakEngine = new MlBreakEngine(fDigitOrOpenPunctuationOrAlphabetSet,
|
||||
fClosePunctuationSet, status);
|
||||
if (fMlBreakEngine == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
#else
|
||||
initJapanesePhraseParameter(status);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
UTRACE_EXIT_STATUS(status);
|
||||
|
@ -1085,6 +1095,7 @@ CjkBreakEngine::CjkBreakEngine(DictionaryMatcher *adoptDictionary, LanguageType
|
|||
|
||||
CjkBreakEngine::~CjkBreakEngine(){
|
||||
delete fDictionary;
|
||||
delete fMlBreakEngine;
|
||||
}
|
||||
|
||||
// The katakanaCost values below are based on the length frequencies of all
|
||||
|
@ -1135,7 +1146,7 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText,
|
|||
UnicodeString inString;
|
||||
|
||||
// inputMap[inStringIndex] = corresponding native index from UText inText.
|
||||
// If NULL then mapping is 1:1
|
||||
// If nullptr then mapping is 1:1
|
||||
LocalPointer<UVector32> inputMap;
|
||||
|
||||
// if UText has the input string as one contiguous UTF-16 chunk
|
||||
|
@ -1251,7 +1262,15 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if UCONFIG_USE_ML_PHRASE_BREAKING
|
||||
// PhraseBreaking is supported in ja and ko; MlBreakEngine only supports ja.
|
||||
if (isPhraseBreaking && isCj) {
|
||||
return fMlBreakEngine->divideUpRange(inText, rangeStart, rangeEnd, foundBreaks, inString,
|
||||
inputMap, status);
|
||||
}
|
||||
#endif
|
||||
|
||||
// bestSnlp[i] is the snlp of the best segmentation of the first i
|
||||
// code points in the range to be matched.
|
||||
UVector32 bestSnlp(numCodePts + 1, status);
|
||||
|
@ -1292,9 +1311,9 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText,
|
|||
int32_t count;
|
||||
utext_setNativeIndex(&fu, ix);
|
||||
count = fDictionary->matches(&fu, maxWordSize, numCodePts,
|
||||
NULL, lengths.getBuffer(), values.getBuffer(), NULL);
|
||||
nullptr, lengths.getBuffer(), values.getBuffer(), nullptr);
|
||||
// Note: lengths is filled with code point lengths
|
||||
// The NULL parameter is the ignored code unit lengths.
|
||||
// The nullptr parameter is the ignored code unit lengths.
|
||||
|
||||
// if there are no single character matches found in the dictionary
|
||||
// starting with this character, treat character as a 1-character word
|
||||
|
|
|
@ -16,11 +16,13 @@
|
|||
|
||||
#include "brkeng.h"
|
||||
#include "hash.h"
|
||||
#include "mlbe.h"
|
||||
#include "uvectr32.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class DictionaryMatcher;
|
||||
class MlBreakEngine;
|
||||
class Normalizer2;
|
||||
|
||||
/*******************************************************************
|
||||
|
@ -374,6 +376,8 @@ class CjkBreakEngine : public DictionaryBreakEngine {
|
|||
|
||||
DictionaryMatcher *fDictionary;
|
||||
const Normalizer2 *nfkcNorm2;
|
||||
MlBreakEngine *fMlBreakEngine;
|
||||
bool isCj;
|
||||
|
||||
private:
|
||||
// Load Japanese extensions.
|
||||
|
|
|
@ -57,13 +57,13 @@ int32_t UCharsDictionaryMatcher::matches(UText *text, int32_t maxLength, int32_t
|
|||
codePointsMatched += 1;
|
||||
if (USTRINGTRIE_HAS_VALUE(result)) {
|
||||
if (wordCount < limit) {
|
||||
if (values != NULL) {
|
||||
if (values != nullptr) {
|
||||
values[wordCount] = uct.getValue();
|
||||
}
|
||||
if (lengths != NULL) {
|
||||
if (lengths != nullptr) {
|
||||
lengths[wordCount] = lengthMatched;
|
||||
}
|
||||
if (cpLengths != NULL) {
|
||||
if (cpLengths != nullptr) {
|
||||
cpLengths[wordCount] = codePointsMatched;
|
||||
}
|
||||
++wordCount;
|
||||
|
@ -80,7 +80,7 @@ int32_t UCharsDictionaryMatcher::matches(UText *text, int32_t maxLength, int32_t
|
|||
}
|
||||
}
|
||||
|
||||
if (prefix != NULL) {
|
||||
if (prefix != nullptr) {
|
||||
*prefix = codePointsMatched;
|
||||
}
|
||||
return wordCount;
|
||||
|
@ -124,13 +124,13 @@ int32_t BytesDictionaryMatcher::matches(UText *text, int32_t maxLength, int32_t
|
|||
codePointsMatched += 1;
|
||||
if (USTRINGTRIE_HAS_VALUE(result)) {
|
||||
if (wordCount < limit) {
|
||||
if (values != NULL) {
|
||||
if (values != nullptr) {
|
||||
values[wordCount] = bt.getValue();
|
||||
}
|
||||
if (lengths != NULL) {
|
||||
if (lengths != nullptr) {
|
||||
lengths[wordCount] = lengthMatched;
|
||||
}
|
||||
if (cpLengths != NULL) {
|
||||
if (cpLengths != nullptr) {
|
||||
cpLengths[wordCount] = codePointsMatched;
|
||||
}
|
||||
++wordCount;
|
||||
|
@ -147,7 +147,7 @@ int32_t BytesDictionaryMatcher::matches(UText *text, int32_t maxLength, int32_t
|
|||
}
|
||||
}
|
||||
|
||||
if (prefix != NULL) {
|
||||
if (prefix != nullptr) {
|
||||
*prefix = codePointsMatched;
|
||||
}
|
||||
return wordCount;
|
||||
|
@ -170,7 +170,7 @@ udict_swap(const UDataSwapper *ds, const void *inData, int32_t length,
|
|||
int32_t i, offset, size;
|
||||
|
||||
headerSize = udata_swapDataHeader(ds, inData, length, outData, pErrorCode);
|
||||
if (pErrorCode == NULL || U_FAILURE(*pErrorCode)) return 0;
|
||||
if (pErrorCode == nullptr || U_FAILURE(*pErrorCode)) return 0;
|
||||
pInfo = (const UDataInfo *)((const char *)inData + 4);
|
||||
if (!(pInfo->dataFormat[0] == 0x44 &&
|
||||
pInfo->dataFormat[1] == 0x69 &&
|
||||
|
@ -184,7 +184,7 @@ udict_swap(const UDataSwapper *ds, const void *inData, int32_t length,
|
|||
}
|
||||
|
||||
inBytes = (const uint8_t *)inData + headerSize;
|
||||
outBytes = (uint8_t *)outData + headerSize;
|
||||
outBytes = (outData == nullptr) ? nullptr : (uint8_t *)outData + headerSize;
|
||||
|
||||
inIndexes = (const int32_t *)inBytes;
|
||||
if (length >= 0) {
|
||||
|
|
|
@ -79,15 +79,15 @@ public:
|
|||
* matching words to be found.
|
||||
* @param lengths output array, filled with the lengths of the matches, in order,
|
||||
* from shortest to longest. Lengths are in native indexing units
|
||||
* of the UText. May be NULL.
|
||||
* of the UText. May be nullptr.
|
||||
* @param cpLengths output array, filled with the lengths of the matches, in order,
|
||||
* from shortest to longest. Lengths are the number of Unicode code points.
|
||||
* May be NULL.
|
||||
* May be nullptr.
|
||||
* @param values Output array, filled with the values associated with the words found.
|
||||
* May be NULL.
|
||||
* May be nullptr.
|
||||
* @param prefix Output parameter, the code point length of the prefix match, even if that
|
||||
* prefix didn't lead to a complete word. Will always be >= the cpLength
|
||||
* of the longest complete word matched. May be NULL.
|
||||
* of the longest complete word matched. May be nullptr.
|
||||
* @return Number of matching words found.
|
||||
*/
|
||||
virtual int32_t matches(UText *text, int32_t maxLength, int32_t limit,
|
||||
|
@ -103,14 +103,14 @@ class U_COMMON_API UCharsDictionaryMatcher : public DictionaryMatcher {
|
|||
public:
|
||||
// constructs a new UCharsDictionaryMatcher.
|
||||
// The UDataMemory * will be closed on this object's destruction.
|
||||
UCharsDictionaryMatcher(const UChar *c, UDataMemory *f) : characters(c), file(f) { }
|
||||
UCharsDictionaryMatcher(const char16_t *c, UDataMemory *f) : characters(c), file(f) { }
|
||||
virtual ~UCharsDictionaryMatcher();
|
||||
virtual int32_t matches(UText *text, int32_t maxLength, int32_t limit,
|
||||
int32_t *lengths, int32_t *cpLengths, int32_t *values,
|
||||
int32_t *prefix) const override;
|
||||
virtual int32_t getType() const override;
|
||||
private:
|
||||
const UChar *characters;
|
||||
const char16_t *characters;
|
||||
UDataMemory *file;
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ const int32_t LENGTH_IN_2TRAIL = 62;
|
|||
|
||||
} // namespace
|
||||
|
||||
void Edits::releaseArray() U_NOEXCEPT {
|
||||
void Edits::releaseArray() noexcept {
|
||||
if (array != stackArray) {
|
||||
uprv_free(array);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ Edits &Edits::copyArray(const Edits &other) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
Edits &Edits::moveArray(Edits &src) U_NOEXCEPT {
|
||||
Edits &Edits::moveArray(Edits &src) noexcept {
|
||||
if (U_FAILURE(errorCode_)) {
|
||||
length = delta = numChanges = 0;
|
||||
return *this;
|
||||
|
@ -94,7 +94,7 @@ Edits &Edits::operator=(const Edits &other) {
|
|||
return copyArray(other);
|
||||
}
|
||||
|
||||
Edits &Edits::operator=(Edits &&src) U_NOEXCEPT {
|
||||
Edits &Edits::operator=(Edits &&src) noexcept {
|
||||
length = src.length;
|
||||
delta = src.delta;
|
||||
numChanges = src.numChanges;
|
||||
|
@ -106,7 +106,7 @@ Edits::~Edits() {
|
|||
releaseArray();
|
||||
}
|
||||
|
||||
void Edits::reset() U_NOEXCEPT {
|
||||
void Edits::reset() noexcept {
|
||||
length = delta = numChanges = 0;
|
||||
errorCode_ = U_ZERO_ERROR;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ UBool Edits::growArray() {
|
|||
return false;
|
||||
}
|
||||
uint16_t *newArray = (uint16_t *)uprv_malloc((size_t)newCapacity * 2);
|
||||
if (newArray == NULL) {
|
||||
if (newArray == nullptr) {
|
||||
errorCode_ = U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ void U_CALLCONV initSingleton(UErrorCode &errorCode) {
|
|||
// TODO: turn this into a shared helper function
|
||||
// Requires the major version to match, and then requires at least the minor version.
|
||||
UBool udata_isAcceptableMajorMinor(
|
||||
const UDataInfo &info, const UChar *dataFormat, uint8_t major, uint8_t minor) {
|
||||
const UDataInfo &info, const char16_t *dataFormat, uint8_t major, uint8_t minor) {
|
||||
return
|
||||
info.size >= 20 &&
|
||||
info.isBigEndian == U_IS_BIG_ENDIAN &&
|
||||
|
@ -104,7 +104,7 @@ EmojiProps::load(UErrorCode &errorCode) {
|
|||
offset = inIndexes[i];
|
||||
nextOffset = inIndexes[i + 1];
|
||||
// Set/leave nullptr if there is no UCharsTrie.
|
||||
const UChar *p = nextOffset > offset ? (const UChar *)(inBytes + offset) : nullptr;
|
||||
const char16_t *p = nextOffset > offset ? (const char16_t *)(inBytes + offset) : nullptr;
|
||||
stringTries[getStringTrieIndex(i)] = p;
|
||||
}
|
||||
}
|
||||
|
@ -160,14 +160,14 @@ EmojiProps::hasBinaryPropertyImpl(UChar32 c, UProperty which) const {
|
|||
}
|
||||
|
||||
UBool
|
||||
EmojiProps::hasBinaryProperty(const UChar *s, int32_t length, UProperty which) {
|
||||
EmojiProps::hasBinaryProperty(const char16_t *s, int32_t length, UProperty which) {
|
||||
UErrorCode errorCode = U_ZERO_ERROR;
|
||||
const EmojiProps *ep = getSingleton(errorCode);
|
||||
return U_SUCCESS(errorCode) && ep->hasBinaryPropertyImpl(s, length, which);
|
||||
}
|
||||
|
||||
UBool
|
||||
EmojiProps::hasBinaryPropertyImpl(const UChar *s, int32_t length, UProperty which) const {
|
||||
EmojiProps::hasBinaryPropertyImpl(const char16_t *s, int32_t length, UProperty which) const {
|
||||
if (s == nullptr && length != 0) { return false; }
|
||||
if (length <= 0 && (length == 0 || *s == 0)) { return false; } // empty string
|
||||
// The caller should have delegated single code points to hasBinaryProperty(c, which).
|
||||
|
@ -181,7 +181,7 @@ EmojiProps::hasBinaryPropertyImpl(const UChar *s, int32_t length, UProperty whic
|
|||
lastProp = UCHAR_RGI_EMOJI_ZWJ_SEQUENCE;
|
||||
}
|
||||
for (int32_t prop = firstProp; prop <= lastProp; ++prop) {
|
||||
const UChar *trieUChars = stringTries[prop - UCHAR_BASIC_EMOJI];
|
||||
const char16_t *trieUChars = stringTries[prop - UCHAR_BASIC_EMOJI];
|
||||
if (trieUChars != nullptr) {
|
||||
UCharsTrie trie(trieUChars);
|
||||
UStringTrieResult result = trie.next(s, length);
|
||||
|
@ -206,7 +206,7 @@ EmojiProps::addStrings(const USetAdder *sa, UProperty which, UErrorCode &errorCo
|
|||
lastProp = UCHAR_RGI_EMOJI_ZWJ_SEQUENCE;
|
||||
}
|
||||
for (int32_t prop = firstProp; prop <= lastProp; ++prop) {
|
||||
const UChar *trieUChars = stringTries[prop - UCHAR_BASIC_EMOJI];
|
||||
const char16_t *trieUChars = stringTries[prop - UCHAR_BASIC_EMOJI];
|
||||
if (trieUChars != nullptr) {
|
||||
UCharsTrie::Iterator iter(trieUChars, 0, errorCode);
|
||||
while (iter.next(errorCode)) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
static const EmojiProps *getSingleton(UErrorCode &errorCode);
|
||||
static UBool hasBinaryProperty(UChar32 c, UProperty which);
|
||||
static UBool hasBinaryProperty(const UChar *s, int32_t length, UProperty which);
|
||||
static UBool hasBinaryProperty(const char16_t *s, int32_t length, UProperty which);
|
||||
|
||||
void addPropertyStarts(const USetAdder *sa, UErrorCode &errorCode) const;
|
||||
void addStrings(const USetAdder *sa, UProperty which, UErrorCode &errorCode) const;
|
||||
|
@ -78,11 +78,11 @@ private:
|
|||
|
||||
void load(UErrorCode &errorCode);
|
||||
UBool hasBinaryPropertyImpl(UChar32 c, UProperty which) const;
|
||||
UBool hasBinaryPropertyImpl(const UChar *s, int32_t length, UProperty which) const;
|
||||
UBool hasBinaryPropertyImpl(const char16_t *s, int32_t length, UProperty which) const;
|
||||
|
||||
UDataMemory *memory = nullptr;
|
||||
UCPTrie *cpTrie = nullptr;
|
||||
const UChar *stringTries[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
|
||||
const char16_t *stringTries[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
|
@ -35,7 +35,7 @@ static void _fb_trace(const char *m, const UnicodeString *s, UBool b, int32_t d,
|
|||
if(s) {
|
||||
s->extract(0,s->length(),buf,2048);
|
||||
} else {
|
||||
strcpy(buf,"NULL");
|
||||
strcpy(buf,"nullptr");
|
||||
}
|
||||
fprintf(stderr,"%s:%d: %s. s='%s'(%p), b=%c, d=%d\n",
|
||||
f, l, m, buf, (const void*)s, b?'T':'F',(int)d);
|
||||
|
@ -102,7 +102,7 @@ class UStringSet : public UVector {
|
|||
inline UBool add(const UnicodeString& str, UErrorCode &status) {
|
||||
if(U_FAILURE(status)) return false;
|
||||
UnicodeString *t = new UnicodeString(str);
|
||||
if(t==NULL) {
|
||||
if(t==nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR; return false;
|
||||
}
|
||||
return adopt(t, status);
|
||||
|
@ -130,7 +130,7 @@ static const int32_t kPARTIAL = (1<<0); //< partial - need to run through forwar
|
|||
static const int32_t kMATCH = (1<<1); //< exact match - skip this one.
|
||||
static const int32_t kSuppressInReverse = (1<<0);
|
||||
static const int32_t kAddToForward = (1<<1);
|
||||
static const UChar kFULLSTOP = 0x002E; // '.'
|
||||
static const char16_t kFULLSTOP = 0x002E; // '.'
|
||||
|
||||
/**
|
||||
* Shared data for SimpleFilteredSentenceBreakIterator
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
return clone();
|
||||
}
|
||||
virtual SimpleFilteredSentenceBreakIterator* clone() const override { return new SimpleFilteredSentenceBreakIterator(*this); }
|
||||
virtual UClassID getDynamicClassID(void) const override { return NULL; }
|
||||
virtual UClassID getDynamicClassID() const override { return nullptr; }
|
||||
virtual bool operator==(const BreakIterator& o) const override { if(this==&o) return true; return false; }
|
||||
|
||||
/* -- text modifying -- */
|
||||
|
@ -202,20 +202,20 @@ public:
|
|||
|
||||
/* -- other functions that are just delegated -- */
|
||||
virtual UText *getUText(UText *fillIn, UErrorCode &status) const override { return fDelegate->getUText(fillIn,status); }
|
||||
virtual CharacterIterator& getText(void) const override { return fDelegate->getText(); }
|
||||
virtual CharacterIterator& getText() const override { return fDelegate->getText(); }
|
||||
|
||||
/* -- ITERATION -- */
|
||||
virtual int32_t first(void) override;
|
||||
virtual int32_t first() override;
|
||||
virtual int32_t preceding(int32_t offset) override;
|
||||
virtual int32_t previous(void) override;
|
||||
virtual int32_t previous() override;
|
||||
virtual UBool isBoundary(int32_t offset) override;
|
||||
virtual int32_t current(void) const override { return fDelegate->current(); } // we keep the delegate current, so this should be correct.
|
||||
virtual int32_t current() const override { return fDelegate->current(); } // we keep the delegate current, so this should be correct.
|
||||
|
||||
virtual int32_t next(void) override;
|
||||
virtual int32_t next() override;
|
||||
|
||||
virtual int32_t next(int32_t n) override;
|
||||
virtual int32_t following(int32_t offset) override;
|
||||
virtual int32_t last(void) override;
|
||||
virtual int32_t last() override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -289,11 +289,11 @@ SimpleFilteredSentenceBreakIterator::breakExceptionAt(int32_t n) {
|
|||
// Assume a space is following the '.' (so we handle the case: "Mr. /Brown")
|
||||
if(utext_previous32(fText.getAlias())==u' ') { // TODO: skip a class of chars here??
|
||||
// TODO only do this the 1st time?
|
||||
//if(debug2) u_printf("skipping prev: |%C| \n", (UChar)uch);
|
||||
//if(debug2) u_printf("skipping prev: |%C| \n", (char16_t)uch);
|
||||
} else {
|
||||
//if(debug2) u_printf("not skipping prev: |%C| \n", (UChar)uch);
|
||||
//if(debug2) u_printf("not skipping prev: |%C| \n", (char16_t)uch);
|
||||
utext_next32(fText.getAlias());
|
||||
//if(debug2) u_printf(" -> : |%C| \n", (UChar)uch);
|
||||
//if(debug2) u_printf(" -> : |%C| \n", (char16_t)uch);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -309,20 +309,20 @@ SimpleFilteredSentenceBreakIterator::breakExceptionAt(int32_t n) {
|
|||
if(!USTRINGTRIE_HAS_NEXT(r)) {
|
||||
break;
|
||||
}
|
||||
//if(debug2) u_printf("rev< /%C/ cont?%d @%d\n", (UChar)uch, r, utext_getNativeIndex(fText.getAlias()));
|
||||
//if(debug2) u_printf("rev< /%C/ cont?%d @%d\n", (char16_t)uch, r, utext_getNativeIndex(fText.getAlias()));
|
||||
}
|
||||
}
|
||||
|
||||
//if(bestValue >= 0) {
|
||||
//if(debug2) u_printf("rev<+/%C/+end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (UChar)uch, r, bestPosn, bestValue);
|
||||
//if(debug2) u_printf("rev<+/%C/+end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (char16_t)uch, r, bestPosn, bestValue);
|
||||
//}
|
||||
|
||||
if(bestPosn>=0) {
|
||||
//if(debug2) u_printf("rev< /%C/ end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (UChar)uch, r, bestPosn, bestValue);
|
||||
//if(debug2) u_printf("rev< /%C/ end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (char16_t)uch, r, bestPosn, bestValue);
|
||||
|
||||
//if(USTRINGTRIE_MATCHES(r)) { // matched - so, now what?
|
||||
//int32_t bestValue = iter.getValue();
|
||||
////if(debug2) u_printf("rev< /%C/ matched, skip..%d bestValue=%d\n", (UChar)uch, r, bestValue);
|
||||
////if(debug2) u_printf("rev< /%C/ matched, skip..%d bestValue=%d\n", (char16_t)uch, r, bestValue);
|
||||
|
||||
if(bestValue == kMATCH) { // exact match!
|
||||
//if(debug2) u_printf(" exact backward match\n");
|
||||
|
@ -340,15 +340,15 @@ SimpleFilteredSentenceBreakIterator::breakExceptionAt(int32_t n) {
|
|||
UChar32 uch;
|
||||
while((uch=utext_next32(fText.getAlias()))!=U_SENTINEL &&
|
||||
USTRINGTRIE_HAS_NEXT(rfwd=iter.nextForCodePoint(uch))) {
|
||||
//if(debug2) u_printf("fwd> /%C/ cont?%d @%d\n", (UChar)uch, rfwd, utext_getNativeIndex(fText.getAlias()));
|
||||
//if(debug2) u_printf("fwd> /%C/ cont?%d @%d\n", (char16_t)uch, rfwd, utext_getNativeIndex(fText.getAlias()));
|
||||
}
|
||||
if(USTRINGTRIE_MATCHES(rfwd)) {
|
||||
//if(debug2) u_printf("fwd> /%C/ == forward match!\n", (UChar)uch);
|
||||
//if(debug2) u_printf("fwd> /%C/ == forward match!\n", (char16_t)uch);
|
||||
// only full matches here, nothing to check
|
||||
// skip the next:
|
||||
return kExceptionHere;
|
||||
} else {
|
||||
//if(debug2) u_printf("fwd> /%C/ no match.\n", (UChar)uch);
|
||||
//if(debug2) u_printf("fwd> /%C/ no match.\n", (char16_t)uch);
|
||||
// no match (no exception) -return the 'underlying' break
|
||||
return kNoExceptionHere;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ SimpleFilteredSentenceBreakIterator::breakExceptionAt(int32_t n) {
|
|||
return kNoExceptionHere; // internal error and/or no forwards trie
|
||||
}
|
||||
} else {
|
||||
//if(debug2) u_printf("rev< /%C/ .. no match..%d\n", (UChar)uch, r); // no best match
|
||||
//if(debug2) u_printf("rev< /%C/ .. no match..%d\n", (char16_t)uch, r); // no best match
|
||||
return kNoExceptionHere; // No match - so exit. Not an exception.
|
||||
}
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ SimpleFilteredSentenceBreakIterator::next() {
|
|||
}
|
||||
|
||||
int32_t
|
||||
SimpleFilteredSentenceBreakIterator::first(void) {
|
||||
SimpleFilteredSentenceBreakIterator::first() {
|
||||
// Don't suppress a break opportunity at the beginning of text.
|
||||
return fDelegate->first();
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ SimpleFilteredSentenceBreakIterator::preceding(int32_t offset) {
|
|||
}
|
||||
|
||||
int32_t
|
||||
SimpleFilteredSentenceBreakIterator::previous(void) {
|
||||
SimpleFilteredSentenceBreakIterator::previous() {
|
||||
return internalPrev(fDelegate->previous());
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ SimpleFilteredSentenceBreakIterator::following(int32_t offset) {
|
|||
}
|
||||
|
||||
int32_t
|
||||
SimpleFilteredSentenceBreakIterator::last(void) {
|
||||
SimpleFilteredSentenceBreakIterator::last() {
|
||||
// Don't suppress a break opportunity at the end of text.
|
||||
return fDelegate->last();
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(const Loc
|
|||
#endif
|
||||
return; // leaves the builder empty, if you try to use it.
|
||||
}
|
||||
LocalUResourceBundlePointer exceptions(ures_getByKeyWithFallback(b.getAlias(), "exceptions", NULL, &subStatus));
|
||||
LocalUResourceBundlePointer exceptions(ures_getByKeyWithFallback(b.getAlias(), "exceptions", nullptr, &subStatus));
|
||||
if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) {
|
||||
status = subStatus; // copy the failing status
|
||||
#if FB_DEBUG
|
||||
|
@ -524,7 +524,7 @@ SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(const Loc
|
|||
#endif
|
||||
return; // leaves the builder empty, if you try to use it.
|
||||
}
|
||||
LocalUResourceBundlePointer breaks(ures_getByKeyWithFallback(exceptions.getAlias(), "SentenceBreak", NULL, &subStatus));
|
||||
LocalUResourceBundlePointer breaks(ures_getByKeyWithFallback(exceptions.getAlias(), "SentenceBreak", nullptr, &subStatus));
|
||||
|
||||
#if FB_DEBUG
|
||||
{
|
||||
|
@ -590,7 +590,7 @@ SimpleFilteredBreakIteratorBuilder::build(BreakIterator* adoptBreakIterator, UEr
|
|||
LocalPointer<UCharsTrieBuilder> builder(new UCharsTrieBuilder(status), status);
|
||||
LocalPointer<UCharsTrieBuilder> builder2(new UCharsTrieBuilder(status), status);
|
||||
if(U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t revCount = 0;
|
||||
|
@ -620,7 +620,7 @@ SimpleFilteredBreakIteratorBuilder::build(BreakIterator* adoptBreakIterator, UEr
|
|||
} else {
|
||||
FB_TRACE("build",abbr,false,i);
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
partials[n] = 0; // default: not partial
|
||||
n++;
|
||||
|
@ -682,21 +682,21 @@ SimpleFilteredBreakIteratorBuilder::build(BreakIterator* adoptBreakIterator, UEr
|
|||
////if(debug2) u_printf("SUPPRESS- not Added(%d): /%S/ status=%s\n",partials[i], ustrs[i].getTerminatedBuffer(), u_errorName(status));
|
||||
}
|
||||
}
|
||||
FB_TRACE("AbbrCount",NULL,false, subCount);
|
||||
FB_TRACE("AbbrCount",nullptr,false, subCount);
|
||||
|
||||
if(revCount>0) {
|
||||
backwardsTrie.adoptInstead(builder->build(USTRINGTRIE_BUILD_FAST, status));
|
||||
if(U_FAILURE(status)) {
|
||||
FB_TRACE(u_errorName(status),NULL,false, -1);
|
||||
return NULL;
|
||||
FB_TRACE(u_errorName(status),nullptr,false, -1);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if(fwdCount>0) {
|
||||
forwardsPartialTrie.adoptInstead(builder2->build(USTRINGTRIE_BUILD_FAST, status));
|
||||
if(U_FAILURE(status)) {
|
||||
FB_TRACE(u_errorName(status),NULL,false, -1);
|
||||
return NULL;
|
||||
FB_TRACE(u_errorName(status),nullptr,false, -1);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -714,9 +714,9 @@ FilteredBreakIteratorBuilder::~FilteredBreakIteratorBuilder() {
|
|||
|
||||
FilteredBreakIteratorBuilder *
|
||||
FilteredBreakIteratorBuilder::createInstance(const Locale& where, UErrorCode& status) {
|
||||
if(U_FAILURE(status)) return NULL;
|
||||
if(U_FAILURE(status)) return nullptr;
|
||||
LocalPointer<FilteredBreakIteratorBuilder> ret(new SimpleFilteredBreakIteratorBuilder(where, status), status);
|
||||
return (U_SUCCESS(status))? ret.orphan(): NULL;
|
||||
return (U_SUCCESS(status))? ret.orphan(): nullptr;
|
||||
}
|
||||
|
||||
FilteredBreakIteratorBuilder *
|
||||
|
@ -726,9 +726,9 @@ FilteredBreakIteratorBuilder::createInstance(UErrorCode &status) {
|
|||
|
||||
FilteredBreakIteratorBuilder *
|
||||
FilteredBreakIteratorBuilder::createEmptyInstance(UErrorCode& status) {
|
||||
if(U_FAILURE(status)) return NULL;
|
||||
if(U_FAILURE(status)) return nullptr;
|
||||
LocalPointer<FilteredBreakIteratorBuilder> ret(new SimpleFilteredBreakIteratorBuilder(status), status);
|
||||
return (U_SUCCESS(status))? ret.orphan(): NULL;
|
||||
return (U_SUCCESS(status))? ret.orphan(): nullptr;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
|
@ -346,15 +346,15 @@ U_NAMESPACE_USE
|
|||
U_CAPI UNormalizer2 * U_EXPORT2
|
||||
unorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if(filterSet==NULL) {
|
||||
if(filterSet==nullptr) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Normalizer2 *fn2=new FilteredNormalizer2(*(Normalizer2 *)norm2,
|
||||
*UnicodeSet::fromUSet(filterSet));
|
||||
if(fn2==NULL) {
|
||||
if(fn2==nullptr) {
|
||||
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
return (UNormalizer2 *)fn2;
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
|
||||
inline int32_t removei(const UnicodeString& key);
|
||||
|
||||
inline void removeAll(void);
|
||||
inline void removeAll();
|
||||
|
||||
inline UBool containsKey(const UnicodeString& key) const;
|
||||
|
||||
|
@ -159,7 +159,7 @@ inline Hashtable::Hashtable(UBool ignoreKeyCase, UErrorCode& status)
|
|||
: uhash_hashUnicodeString,
|
||||
ignoreKeyCase ? uhash_compareCaselessUnicodeString
|
||||
: uhash_compareUnicodeString,
|
||||
NULL,
|
||||
nullptr,
|
||||
status);
|
||||
}
|
||||
|
||||
|
@ -170,25 +170,25 @@ inline Hashtable::Hashtable(UBool ignoreKeyCase, int32_t size, UErrorCode& statu
|
|||
: uhash_hashUnicodeString,
|
||||
ignoreKeyCase ? uhash_compareCaselessUnicodeString
|
||||
: uhash_compareUnicodeString,
|
||||
NULL, size,
|
||||
nullptr, size,
|
||||
status);
|
||||
}
|
||||
|
||||
inline Hashtable::Hashtable(UErrorCode& status)
|
||||
: hash(0)
|
||||
{
|
||||
init(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, status);
|
||||
init(uhash_hashUnicodeString, uhash_compareUnicodeString, nullptr, status);
|
||||
}
|
||||
|
||||
inline Hashtable::Hashtable()
|
||||
: hash(0)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
init(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, status);
|
||||
init(uhash_hashUnicodeString, uhash_compareUnicodeString, nullptr, status);
|
||||
}
|
||||
|
||||
inline Hashtable::~Hashtable() {
|
||||
if (hash != NULL) {
|
||||
if (hash != nullptr) {
|
||||
uhash_close(hash);
|
||||
}
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ inline const UHashElement* Hashtable::nextElement(int32_t& pos) const {
|
|||
return uhash_nextElement(hash, &pos);
|
||||
}
|
||||
|
||||
inline void Hashtable::removeAll(void) {
|
||||
inline void Hashtable::removeAll() {
|
||||
uhash_removeAll(hash);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
#include "uresimp.h" /* for ures_getVersionByKey */
|
||||
|
||||
U_CAPI void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status) {
|
||||
UResourceBundle *icudatares = NULL;
|
||||
UResourceBundle *icudatares = nullptr;
|
||||
|
||||
if (U_FAILURE(*status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataVersionFillin != NULL) {
|
||||
icudatares = ures_openDirect(NULL, U_ICU_VERSION_BUNDLE , status);
|
||||
if (dataVersionFillin != nullptr) {
|
||||
icudatares = ures_openDirect(nullptr, U_ICU_VERSION_BUNDLE , status);
|
||||
if (U_SUCCESS(*status)) {
|
||||
ures_getVersionByKey(icudatares, U_ICU_DATA_KEY, dataVersionFillin, status);
|
||||
}
|
||||
|
|
|
@ -52,9 +52,9 @@ struct UPlugData {
|
|||
UPlugEntrypoint *entrypoint; /**< plugin entrypoint */
|
||||
uint32_t structSize; /**< initialized to the size of this structure */
|
||||
uint32_t token; /**< must be U_PLUG_TOKEN */
|
||||
void *lib; /**< plugin library, or NULL */
|
||||
void *lib; /**< plugin library, or nullptr */
|
||||
char libName[UPLUG_NAME_MAX]; /**< library name */
|
||||
char sym[UPLUG_NAME_MAX]; /**< plugin symbol, or NULL */
|
||||
char sym[UPLUG_NAME_MAX]; /**< plugin symbol, or nullptr */
|
||||
char config[UPLUG_NAME_MAX]; /**< configuration data */
|
||||
void *context; /**< user context data */
|
||||
char name[UPLUG_NAME_MAX]; /**< name of plugin */
|
||||
|
@ -148,9 +148,9 @@ static int32_t searchForLibrary(void *lib) {
|
|||
U_CAPI char * U_EXPORT2
|
||||
uplug_findLibrary(void *lib, UErrorCode *status) {
|
||||
int32_t libEnt;
|
||||
char *ret = NULL;
|
||||
char *ret = nullptr;
|
||||
if(U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
libEnt = searchForLibrary(lib);
|
||||
if(libEnt!=-1) {
|
||||
|
@ -164,9 +164,9 @@ uplug_findLibrary(void *lib, UErrorCode *status) {
|
|||
U_CAPI void * U_EXPORT2
|
||||
uplug_openLibrary(const char *libName, UErrorCode *status) {
|
||||
int32_t libEntry = -1;
|
||||
void *lib = NULL;
|
||||
void *lib = nullptr;
|
||||
|
||||
if(U_FAILURE(*status)) return NULL;
|
||||
if(U_FAILURE(*status)) return nullptr;
|
||||
|
||||
libEntry = searchForLibraryName(libName);
|
||||
if(libEntry == -1) {
|
||||
|
@ -177,7 +177,7 @@ uplug_openLibrary(const char *libName, UErrorCode *status) {
|
|||
#if UPLUG_TRACE
|
||||
DBG((stderr, "uplug_openLibrary() - out of library slots (max %d)\n", libraryMax));
|
||||
#endif
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
/* Some operating systems don't want
|
||||
DL operations from multiple threads. */
|
||||
|
@ -186,9 +186,9 @@ uplug_openLibrary(const char *libName, UErrorCode *status) {
|
|||
DBG((stderr, "uplug_openLibrary(%s,%s) libEntry %d, lib %p\n", libName, u_errorName(*status), libEntry, lib));
|
||||
#endif
|
||||
|
||||
if(libraryList[libEntry].lib == NULL || U_FAILURE(*status)) {
|
||||
if(libraryList[libEntry].lib == nullptr || U_FAILURE(*status)) {
|
||||
/* cleanup. */
|
||||
libraryList[libEntry].lib = NULL; /* failure with open */
|
||||
libraryList[libEntry].lib = nullptr; /* failure with open */
|
||||
libraryList[libEntry].name[0] = 0;
|
||||
#if UPLUG_TRACE
|
||||
DBG((stderr, "uplug_openLibrary(%s,%s) libEntry %d, lib %p\n", libName, u_errorName(*status), libEntry, lib));
|
||||
|
@ -252,14 +252,14 @@ static int32_t uplug_pluginNumber(UPlugData* d) {
|
|||
|
||||
U_CAPI UPlugData * U_EXPORT2
|
||||
uplug_nextPlug(UPlugData *prior) {
|
||||
if(prior==NULL) {
|
||||
if(prior==nullptr) {
|
||||
return pluginList;
|
||||
} else {
|
||||
UPlugData *nextPlug = &prior[1];
|
||||
UPlugData *pastPlug = &pluginList[pluginCount];
|
||||
|
||||
if(nextPlug>=pastPlug) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
return nextPlug;
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ uplug_nextPlug(UPlugData *prior) {
|
|||
*/
|
||||
static void uplug_callPlug(UPlugData *plug, UPlugReason reason, UErrorCode *status) {
|
||||
UPlugTokenReturn token;
|
||||
if(plug==NULL||U_FAILURE(*status)) {
|
||||
if(plug==nullptr||U_FAILURE(*status)) {
|
||||
return;
|
||||
}
|
||||
token = (*(plug->entrypoint))(plug, reason, status);
|
||||
|
@ -330,15 +330,15 @@ static void uplug_loadPlug(UPlugData *plug, UErrorCode *status) {
|
|||
|
||||
static UPlugData *uplug_allocateEmptyPlug(UErrorCode *status)
|
||||
{
|
||||
UPlugData *plug = NULL;
|
||||
UPlugData *plug = nullptr;
|
||||
|
||||
if(U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(pluginCount == UPLUG_PLUGIN_INITIAL_COUNT) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
plug = &pluginList[pluginCount++];
|
||||
|
@ -353,8 +353,8 @@ static UPlugData *uplug_allocateEmptyPlug(UErrorCode *status)
|
|||
plug->libName[0] = 0;
|
||||
plug->config[0]=0;
|
||||
plug->sym[0]=0;
|
||||
plug->lib=NULL;
|
||||
plug->entrypoint=NULL;
|
||||
plug->lib=nullptr;
|
||||
plug->entrypoint=nullptr;
|
||||
|
||||
|
||||
return plug;
|
||||
|
@ -364,16 +364,16 @@ static UPlugData *uplug_allocatePlug(UPlugEntrypoint *entrypoint, const char *co
|
|||
UErrorCode *status) {
|
||||
UPlugData *plug = uplug_allocateEmptyPlug(status);
|
||||
if(U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(config!=NULL) {
|
||||
if(config!=nullptr) {
|
||||
uprv_strncpy(plug->config, config, UPLUG_NAME_MAX);
|
||||
} else {
|
||||
plug->config[0] = 0;
|
||||
}
|
||||
|
||||
if(symName!=NULL) {
|
||||
if(symName!=nullptr) {
|
||||
uprv_strncpy(plug->sym, symName, UPLUG_NAME_MAX);
|
||||
} else {
|
||||
plug->sym[0] = 0;
|
||||
|
@ -393,7 +393,7 @@ static void uplug_deallocatePlug(UPlugData *plug, UErrorCode *status) {
|
|||
uplug_closeLibrary(plug->lib, &subStatus);
|
||||
#endif
|
||||
}
|
||||
plug->lib = NULL;
|
||||
plug->lib = nullptr;
|
||||
if(U_SUCCESS(*status) && U_FAILURE(subStatus)) {
|
||||
*status = subStatus;
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ static void uplug_deallocatePlug(UPlugData *plug, UErrorCode *status) {
|
|||
}
|
||||
|
||||
static void uplug_doUnloadPlug(UPlugData *plugToRemove, UErrorCode *status) {
|
||||
if(plugToRemove != NULL) {
|
||||
if(plugToRemove != nullptr) {
|
||||
uplug_unloadPlug(plugToRemove, status);
|
||||
uplug_deallocatePlug(plugToRemove, status);
|
||||
}
|
||||
|
@ -418,14 +418,14 @@ static void uplug_doUnloadPlug(UPlugData *plugToRemove, UErrorCode *status) {
|
|||
|
||||
U_CAPI void U_EXPORT2
|
||||
uplug_removePlug(UPlugData *plug, UErrorCode *status) {
|
||||
UPlugData *cursor = NULL;
|
||||
UPlugData *plugToRemove = NULL;
|
||||
UPlugData *cursor = nullptr;
|
||||
UPlugData *plugToRemove = nullptr;
|
||||
if(U_FAILURE(*status)) return;
|
||||
|
||||
for(cursor=pluginList;cursor!=NULL;) {
|
||||
for(cursor=pluginList;cursor!=nullptr;) {
|
||||
if(cursor==plug) {
|
||||
plugToRemove = plug;
|
||||
cursor=NULL;
|
||||
cursor=nullptr;
|
||||
} else {
|
||||
cursor = uplug_nextPlug(cursor);
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ uplug_getLibraryName(UPlugData *data, UErrorCode *status) {
|
|||
#if U_ENABLE_DYLOAD
|
||||
return uplug_findLibrary(data->lib, status);
|
||||
#else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ uplug_getConfiguration(UPlugData *data) {
|
|||
U_CAPI UPlugData* U_EXPORT2
|
||||
uplug_getPlugInternal(int32_t n) {
|
||||
if(n <0 || n >= pluginCount) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
return &(pluginList[n]);
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ uplug_getPlugLoadStatus(UPlugData *plug) {
|
|||
*/
|
||||
static UPlugData* uplug_initPlugFromEntrypointAndLibrary(UPlugEntrypoint *entrypoint, const char *config, void *lib, const char *sym,
|
||||
UErrorCode *status) {
|
||||
UPlugData *plug = NULL;
|
||||
UPlugData *plug = nullptr;
|
||||
|
||||
plug = uplug_allocatePlug(entrypoint, config, lib, sym, status);
|
||||
|
||||
|
@ -538,13 +538,13 @@ static UPlugData* uplug_initPlugFromEntrypointAndLibrary(UPlugEntrypoint *entryp
|
|||
return plug;
|
||||
} else {
|
||||
uplug_deallocatePlug(plug, status);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
U_CAPI UPlugData* U_EXPORT2
|
||||
uplug_loadPlugFromEntrypoint(UPlugEntrypoint *entrypoint, const char *config, UErrorCode *status) {
|
||||
UPlugData* plug = uplug_initPlugFromEntrypointAndLibrary(entrypoint, config, NULL, NULL, status);
|
||||
UPlugData* plug = uplug_initPlugFromEntrypointAndLibrary(entrypoint, config, nullptr, nullptr, status);
|
||||
uplug_loadPlug(plug, status);
|
||||
return plug;
|
||||
}
|
||||
|
@ -555,25 +555,25 @@ static UPlugData*
|
|||
uplug_initErrorPlug(const char *libName, const char *sym, const char *config, const char *nameOrError, UErrorCode loadStatus, UErrorCode *status)
|
||||
{
|
||||
UPlugData *plug = uplug_allocateEmptyPlug(status);
|
||||
if(U_FAILURE(*status)) return NULL;
|
||||
if(U_FAILURE(*status)) return nullptr;
|
||||
|
||||
plug->pluginStatus = loadStatus;
|
||||
plug->awaitingLoad = false; /* Won't load. */
|
||||
plug->dontUnload = true; /* cannot unload. */
|
||||
|
||||
if(sym!=NULL) {
|
||||
if(sym!=nullptr) {
|
||||
uprv_strncpy(plug->sym, sym, UPLUG_NAME_MAX);
|
||||
}
|
||||
|
||||
if(libName!=NULL) {
|
||||
if(libName!=nullptr) {
|
||||
uprv_strncpy(plug->libName, libName, UPLUG_NAME_MAX);
|
||||
}
|
||||
|
||||
if(nameOrError!=NULL) {
|
||||
if(nameOrError!=nullptr) {
|
||||
uprv_strncpy(plug->name, nameOrError, UPLUG_NAME_MAX);
|
||||
}
|
||||
|
||||
if(config!=NULL) {
|
||||
if(config!=nullptr) {
|
||||
uprv_strncpy(plug->config, config, UPLUG_NAME_MAX);
|
||||
}
|
||||
|
||||
|
@ -585,39 +585,39 @@ uplug_initErrorPlug(const char *libName, const char *sym, const char *config, co
|
|||
*/
|
||||
static UPlugData*
|
||||
uplug_initPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status) {
|
||||
void *lib = NULL;
|
||||
UPlugData *plug = NULL;
|
||||
if(U_FAILURE(*status)) { return NULL; }
|
||||
void *lib = nullptr;
|
||||
UPlugData *plug = nullptr;
|
||||
if(U_FAILURE(*status)) { return nullptr; }
|
||||
lib = uplug_openLibrary(libName, status);
|
||||
if(lib!=NULL && U_SUCCESS(*status)) {
|
||||
UPlugEntrypoint *entrypoint = NULL;
|
||||
if(lib!=nullptr && U_SUCCESS(*status)) {
|
||||
UPlugEntrypoint *entrypoint = nullptr;
|
||||
entrypoint = (UPlugEntrypoint*)uprv_dlsym_func(lib, sym, status);
|
||||
|
||||
if(entrypoint!=NULL&&U_SUCCESS(*status)) {
|
||||
if(entrypoint!=nullptr&&U_SUCCESS(*status)) {
|
||||
plug = uplug_initPlugFromEntrypointAndLibrary(entrypoint, config, lib, sym, status);
|
||||
if(plug!=NULL&&U_SUCCESS(*status)) {
|
||||
if(plug!=nullptr&&U_SUCCESS(*status)) {
|
||||
plug->lib = lib; /* plug takes ownership of library */
|
||||
lib = NULL; /* library is now owned by plugin. */
|
||||
lib = nullptr; /* library is now owned by plugin. */
|
||||
}
|
||||
} else {
|
||||
UErrorCode subStatus = U_ZERO_ERROR;
|
||||
plug = uplug_initErrorPlug(libName,sym,config,"ERROR: Could not load entrypoint",(lib==NULL)?U_MISSING_RESOURCE_ERROR:*status,&subStatus);
|
||||
plug = uplug_initErrorPlug(libName,sym,config,"ERROR: Could not load entrypoint",(lib==nullptr)?U_MISSING_RESOURCE_ERROR:*status,&subStatus);
|
||||
}
|
||||
if(lib!=NULL) { /* still need to close the lib */
|
||||
if(lib!=nullptr) { /* still need to close the lib */
|
||||
UErrorCode subStatus = U_ZERO_ERROR;
|
||||
uplug_closeLibrary(lib, &subStatus); /* don't care here */
|
||||
}
|
||||
} else {
|
||||
UErrorCode subStatus = U_ZERO_ERROR;
|
||||
plug = uplug_initErrorPlug(libName,sym,config,"ERROR: could not load library",(lib==NULL)?U_MISSING_RESOURCE_ERROR:*status,&subStatus);
|
||||
plug = uplug_initErrorPlug(libName,sym,config,"ERROR: could not load library",(lib==nullptr)?U_MISSING_RESOURCE_ERROR:*status,&subStatus);
|
||||
}
|
||||
return plug;
|
||||
}
|
||||
|
||||
U_CAPI UPlugData* U_EXPORT2
|
||||
uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status) {
|
||||
UPlugData *plug = NULL;
|
||||
if(U_FAILURE(*status)) { return NULL; }
|
||||
UPlugData *plug = nullptr;
|
||||
if(U_FAILURE(*status)) { return nullptr; }
|
||||
plug = uplug_initPlugFromLibrary(libName, sym, config, status);
|
||||
uplug_loadPlug(plug, status);
|
||||
|
||||
|
@ -632,7 +632,7 @@ U_CAPI UPlugLevel U_EXPORT2 uplug_getCurrentLevel() {
|
|||
return gCurrentLevel;
|
||||
}
|
||||
|
||||
static UBool U_CALLCONV uplug_cleanup(void)
|
||||
static UBool U_CALLCONV uplug_cleanup()
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
|
@ -712,7 +712,7 @@ uplug_getPluginFile() {
|
|||
#if U_ENABLE_DYLOAD && !UCONFIG_NO_FILE_IO
|
||||
return plugin_file;
|
||||
#else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -728,7 +728,7 @@ uplug_init(UErrorCode *status) {
|
|||
const char *env = getenv("ICU_PLUGINS");
|
||||
|
||||
if(U_FAILURE(*status)) return;
|
||||
if(env != NULL) {
|
||||
if(env != nullptr) {
|
||||
plugin_dir.append(env, -1, *status);
|
||||
}
|
||||
if(U_FAILURE(*status)) return;
|
||||
|
@ -791,7 +791,7 @@ uplug_init(UErrorCode *status) {
|
|||
#ifdef __MVS__
|
||||
if (iscics()) /* 12 Nov 2011 JAM */
|
||||
{
|
||||
f = NULL;
|
||||
f = nullptr;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -799,9 +799,9 @@ uplug_init(UErrorCode *status) {
|
|||
f = fopen(pluginFile.data(), "r");
|
||||
}
|
||||
|
||||
if(f != NULL) {
|
||||
if(f != nullptr) {
|
||||
char linebuf[1024];
|
||||
char *p, *libName=NULL, *symName=NULL, *config=NULL;
|
||||
char *p, *libName=nullptr, *symName=nullptr, *config=nullptr;
|
||||
int32_t line = 0;
|
||||
|
||||
|
||||
|
@ -843,7 +843,7 @@ uplug_init(UErrorCode *status) {
|
|||
}
|
||||
|
||||
/* chop whitespace at the end of the config */
|
||||
if(config!=NULL&&*config!=0) {
|
||||
if(config!=nullptr&&*config!=0) {
|
||||
p = config+strlen(config);
|
||||
while(p>config&&isspace((int)*(--p))) {
|
||||
*p=0;
|
||||
|
|
|
@ -33,7 +33,7 @@ U_NAMESPACE_BEGIN
|
|||
|
||||
class LoadedNormalizer2Impl : public Normalizer2Impl {
|
||||
public:
|
||||
LoadedNormalizer2Impl() : memory(NULL), ownedTrie(NULL) {}
|
||||
LoadedNormalizer2Impl() : memory(nullptr), ownedTrie(nullptr) {}
|
||||
virtual ~LoadedNormalizer2Impl();
|
||||
|
||||
void load(const char *packageName, const char *name, UErrorCode &errorCode);
|
||||
|
@ -93,7 +93,7 @@ LoadedNormalizer2Impl::load(const char *packageName, const char *name, UErrorCod
|
|||
int32_t offset=inIndexes[IX_NORM_TRIE_OFFSET];
|
||||
int32_t nextOffset=inIndexes[IX_EXTRA_DATA_OFFSET];
|
||||
ownedTrie=ucptrie_openFromBinary(UCPTRIE_TYPE_FAST, UCPTRIE_VALUE_BITS_16,
|
||||
inBytes+offset, nextOffset-offset, NULL,
|
||||
inBytes+offset, nextOffset-offset, nullptr,
|
||||
&errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
|
@ -117,12 +117,12 @@ Norm2AllModes::createInstance(const char *packageName,
|
|||
const char *name,
|
||||
UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
LoadedNormalizer2Impl *impl=new LoadedNormalizer2Impl;
|
||||
if(impl==NULL) {
|
||||
if(impl==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
impl->load(packageName, name, errorCode);
|
||||
return createInstance(impl, errorCode);
|
||||
|
@ -143,19 +143,19 @@ static icu::UInitOnce nfkcInitOnce {};
|
|||
static Norm2AllModes *nfkc_cfSingleton;
|
||||
static icu::UInitOnce nfkc_cfInitOnce {};
|
||||
|
||||
static UHashtable *cache=NULL;
|
||||
static UHashtable *cache=nullptr;
|
||||
|
||||
// UInitOnce singleton initialization function
|
||||
static void U_CALLCONV initSingletons(const char *what, UErrorCode &errorCode) {
|
||||
#if !NORM2_HARDCODE_NFC_DATA
|
||||
if (uprv_strcmp(what, "nfc") == 0) {
|
||||
nfcSingleton = Norm2AllModes::createInstance(NULL, "nfc", errorCode);
|
||||
nfcSingleton = Norm2AllModes::createInstance(nullptr, "nfc", errorCode);
|
||||
} else
|
||||
#endif
|
||||
if (uprv_strcmp(what, "nfkc") == 0) {
|
||||
nfkcSingleton = Norm2AllModes::createInstance(NULL, "nfkc", errorCode);
|
||||
nfkcSingleton = Norm2AllModes::createInstance(nullptr, "nfkc", errorCode);
|
||||
} else if (uprv_strcmp(what, "nfkc_cf") == 0) {
|
||||
nfkc_cfSingleton = Norm2AllModes::createInstance(NULL, "nfkc_cf", errorCode);
|
||||
nfkc_cfSingleton = Norm2AllModes::createInstance(nullptr, "nfkc_cf", errorCode);
|
||||
} else {
|
||||
UPRV_UNREACHABLE_EXIT; // Unknown singleton
|
||||
}
|
||||
|
@ -171,20 +171,20 @@ static void U_CALLCONV deleteNorm2AllModes(void *allModes) {
|
|||
static UBool U_CALLCONV uprv_loaded_normalizer2_cleanup() {
|
||||
#if !NORM2_HARDCODE_NFC_DATA
|
||||
delete nfcSingleton;
|
||||
nfcSingleton = NULL;
|
||||
nfcSingleton = nullptr;
|
||||
nfcInitOnce.reset();
|
||||
#endif
|
||||
|
||||
delete nfkcSingleton;
|
||||
nfkcSingleton = NULL;
|
||||
nfkcSingleton = nullptr;
|
||||
nfkcInitOnce.reset();
|
||||
|
||||
delete nfkc_cfSingleton;
|
||||
nfkc_cfSingleton = NULL;
|
||||
nfkc_cfSingleton = nullptr;
|
||||
nfkc_cfInitOnce.reset();
|
||||
|
||||
uhash_close(cache);
|
||||
cache=NULL;
|
||||
cache=nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ U_CDECL_END
|
|||
#if !NORM2_HARDCODE_NFC_DATA
|
||||
const Norm2AllModes *
|
||||
Norm2AllModes::getNFCInstance(UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) { return NULL; }
|
||||
if(U_FAILURE(errorCode)) { return nullptr; }
|
||||
umtx_initOnce(nfcInitOnce, &initSingletons, "nfc", errorCode);
|
||||
return nfcSingleton;
|
||||
}
|
||||
|
@ -201,14 +201,14 @@ Norm2AllModes::getNFCInstance(UErrorCode &errorCode) {
|
|||
|
||||
const Norm2AllModes *
|
||||
Norm2AllModes::getNFKCInstance(UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) { return NULL; }
|
||||
if(U_FAILURE(errorCode)) { return nullptr; }
|
||||
umtx_initOnce(nfkcInitOnce, &initSingletons, "nfkc", errorCode);
|
||||
return nfkcSingleton;
|
||||
}
|
||||
|
||||
const Norm2AllModes *
|
||||
Norm2AllModes::getNFKC_CFInstance(UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) { return NULL; }
|
||||
if(U_FAILURE(errorCode)) { return nullptr; }
|
||||
umtx_initOnce(nfkc_cfInitOnce, &initSingletons, "nfkc_cf", errorCode);
|
||||
return nfkc_cfSingleton;
|
||||
}
|
||||
|
@ -217,48 +217,48 @@ Norm2AllModes::getNFKC_CFInstance(UErrorCode &errorCode) {
|
|||
const Normalizer2 *
|
||||
Normalizer2::getNFCInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->comp : NULL;
|
||||
return allModes!=nullptr ? &allModes->comp : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *
|
||||
Normalizer2::getNFDInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->decomp : NULL;
|
||||
return allModes!=nullptr ? &allModes->decomp : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *Normalizer2Factory::getFCDInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->fcd : NULL;
|
||||
return allModes!=nullptr ? &allModes->fcd : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *Normalizer2Factory::getFCCInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->fcc : NULL;
|
||||
return allModes!=nullptr ? &allModes->fcc : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2Impl *
|
||||
Normalizer2Factory::getNFCImpl(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? allModes->impl : NULL;
|
||||
return allModes!=nullptr ? allModes->impl : nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
const Normalizer2 *
|
||||
Normalizer2::getNFKCInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFKCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->comp : NULL;
|
||||
return allModes!=nullptr ? &allModes->comp : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *
|
||||
Normalizer2::getNFKDInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFKCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->decomp : NULL;
|
||||
return allModes!=nullptr ? &allModes->decomp : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *
|
||||
Normalizer2::getNFKCCasefoldInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFKC_CFInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->comp : NULL;
|
||||
return allModes!=nullptr ? &allModes->comp : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *
|
||||
|
@ -267,14 +267,14 @@ Normalizer2::getInstance(const char *packageName,
|
|||
UNormalization2Mode mode,
|
||||
UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if(name==NULL || *name==0) {
|
||||
if(name==nullptr || *name==0) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
const Norm2AllModes *allModes=NULL;
|
||||
if(packageName==NULL) {
|
||||
const Norm2AllModes *allModes=nullptr;
|
||||
if(packageName==nullptr) {
|
||||
if(0==uprv_strcmp(name, "nfc")) {
|
||||
allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
} else if(0==uprv_strcmp(name, "nfkc")) {
|
||||
|
@ -283,34 +283,34 @@ Normalizer2::getInstance(const char *packageName,
|
|||
allModes=Norm2AllModes::getNFKC_CFInstance(errorCode);
|
||||
}
|
||||
}
|
||||
if(allModes==NULL && U_SUCCESS(errorCode)) {
|
||||
if(allModes==nullptr && U_SUCCESS(errorCode)) {
|
||||
{
|
||||
Mutex lock;
|
||||
if(cache!=NULL) {
|
||||
if(cache!=nullptr) {
|
||||
allModes=(Norm2AllModes *)uhash_get(cache, name);
|
||||
}
|
||||
}
|
||||
if(allModes==NULL) {
|
||||
if(allModes==nullptr) {
|
||||
ucln_common_registerCleanup(UCLN_COMMON_LOADED_NORMALIZER2, uprv_loaded_normalizer2_cleanup);
|
||||
LocalPointer<Norm2AllModes> localAllModes(
|
||||
Norm2AllModes::createInstance(packageName, name, errorCode));
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
Mutex lock;
|
||||
if(cache==NULL) {
|
||||
cache=uhash_open(uhash_hashChars, uhash_compareChars, NULL, &errorCode);
|
||||
if(cache==nullptr) {
|
||||
cache=uhash_open(uhash_hashChars, uhash_compareChars, nullptr, &errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
uhash_setKeyDeleter(cache, uprv_free);
|
||||
uhash_setValueDeleter(cache, deleteNorm2AllModes);
|
||||
}
|
||||
void *temp=uhash_get(cache, name);
|
||||
if(temp==NULL) {
|
||||
if(temp==nullptr) {
|
||||
int32_t keyLength= static_cast<int32_t>(uprv_strlen(name)+1);
|
||||
char *nameCopy=(char *)uprv_malloc(keyLength);
|
||||
if(nameCopy==NULL) {
|
||||
if(nameCopy==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
uprv_memcpy(nameCopy, name, keyLength);
|
||||
allModes=localAllModes.getAlias();
|
||||
|
@ -322,7 +322,7 @@ Normalizer2::getInstance(const char *packageName,
|
|||
}
|
||||
}
|
||||
}
|
||||
if(allModes!=NULL && U_SUCCESS(errorCode)) {
|
||||
if(allModes!=nullptr && U_SUCCESS(errorCode)) {
|
||||
switch(mode) {
|
||||
case UNORM2_COMPOSE:
|
||||
return &allModes->comp;
|
||||
|
@ -336,13 +336,13 @@ Normalizer2::getInstance(const char *packageName,
|
|||
break; // do nothing
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *
|
||||
Normalizer2Factory::getInstance(UNormalizationMode mode, UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
switch(mode) {
|
||||
case UNORM_NFD:
|
||||
|
@ -363,13 +363,13 @@ Normalizer2Factory::getInstance(UNormalizationMode mode, UErrorCode &errorCode)
|
|||
const Normalizer2Impl *
|
||||
Normalizer2Factory::getNFKCImpl(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFKCInstance(errorCode);
|
||||
return allModes!=NULL ? allModes->impl : NULL;
|
||||
return allModes!=nullptr ? allModes->impl : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2Impl *
|
||||
Normalizer2Factory::getNFKC_CFImpl(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFKC_CFInstance(errorCode);
|
||||
return allModes!=NULL ? allModes->impl : NULL;
|
||||
return allModes!=nullptr ? allModes->impl : nullptr;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -51,7 +51,7 @@ typedef enum ULocMatchLifetime ULocMatchLifetime;
|
|||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
LocaleMatcher::Result::Result(LocaleMatcher::Result &&src) U_NOEXCEPT :
|
||||
LocaleMatcher::Result::Result(LocaleMatcher::Result &&src) noexcept :
|
||||
desiredLocale(src.desiredLocale),
|
||||
supportedLocale(src.supportedLocale),
|
||||
desiredIndex(src.desiredIndex),
|
||||
|
@ -70,7 +70,7 @@ LocaleMatcher::Result::~Result() {
|
|||
}
|
||||
}
|
||||
|
||||
LocaleMatcher::Result &LocaleMatcher::Result::operator=(LocaleMatcher::Result &&src) U_NOEXCEPT {
|
||||
LocaleMatcher::Result &LocaleMatcher::Result::operator=(LocaleMatcher::Result &&src) noexcept {
|
||||
this->~Result();
|
||||
|
||||
desiredLocale = src.desiredLocale;
|
||||
|
@ -122,7 +122,7 @@ Locale LocaleMatcher::Result::makeResolvedLocale(UErrorCode &errorCode) const {
|
|||
return b.build(errorCode);
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder::Builder(LocaleMatcher::Builder &&src) U_NOEXCEPT :
|
||||
LocaleMatcher::Builder::Builder(LocaleMatcher::Builder &&src) noexcept :
|
||||
errorCode_(src.errorCode_),
|
||||
supportedLocales_(src.supportedLocales_),
|
||||
thresholdDistance_(src.thresholdDistance_),
|
||||
|
@ -142,7 +142,7 @@ LocaleMatcher::Builder::~Builder() {
|
|||
delete maxDistanceSupported_;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::operator=(LocaleMatcher::Builder &&src) U_NOEXCEPT {
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::operator=(LocaleMatcher::Builder &&src) noexcept {
|
||||
this->~Builder();
|
||||
|
||||
errorCode_ = src.errorCode_;
|
||||
|
@ -483,7 +483,7 @@ LocaleMatcher::LocaleMatcher(const Builder &builder, UErrorCode &errorCode) :
|
|||
}
|
||||
}
|
||||
|
||||
LocaleMatcher::LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT :
|
||||
LocaleMatcher::LocaleMatcher(LocaleMatcher &&src) noexcept :
|
||||
likelySubtags(src.likelySubtags),
|
||||
localeDistance(src.localeDistance),
|
||||
thresholdDistance(src.thresholdDistance),
|
||||
|
@ -520,7 +520,7 @@ LocaleMatcher::~LocaleMatcher() {
|
|||
delete ownedDefaultLocale;
|
||||
}
|
||||
|
||||
LocaleMatcher &LocaleMatcher::operator=(LocaleMatcher &&src) U_NOEXCEPT {
|
||||
LocaleMatcher &LocaleMatcher::operator=(LocaleMatcher &&src) noexcept {
|
||||
this->~LocaleMatcher();
|
||||
|
||||
thresholdDistance = src.thresholdDistance;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
static icu::Locale* availableLocaleList = NULL;
|
||||
static icu::Locale* availableLocaleList = nullptr;
|
||||
static int32_t availableLocaleListCount;
|
||||
static icu::UInitOnce gInitOnceLocale {};
|
||||
|
||||
|
@ -43,13 +43,13 @@ U_NAMESPACE_END
|
|||
|
||||
U_CDECL_BEGIN
|
||||
|
||||
static UBool U_CALLCONV locale_available_cleanup(void)
|
||||
static UBool U_CALLCONV locale_available_cleanup()
|
||||
{
|
||||
U_NAMESPACE_USE
|
||||
|
||||
if (availableLocaleList) {
|
||||
delete []availableLocaleList;
|
||||
availableLocaleList = NULL;
|
||||
availableLocaleList = nullptr;
|
||||
}
|
||||
availableLocaleListCount = 0;
|
||||
gInitOnceLocale.reset();
|
||||
|
@ -71,7 +71,7 @@ void U_CALLCONV locale_available_init() {
|
|||
if(availableLocaleListCount) {
|
||||
availableLocaleList = new Locale[availableLocaleListCount];
|
||||
}
|
||||
if (availableLocaleList == NULL) {
|
||||
if (availableLocaleList == nullptr) {
|
||||
availableLocaleListCount= 0;
|
||||
}
|
||||
for (int32_t locCount=availableLocaleListCount-1; locCount>=0; --locCount) {
|
||||
|
@ -106,7 +106,7 @@ icu::UInitOnce ginstalledLocalesInitOnce {};
|
|||
|
||||
class AvailableLocalesSink : public ResourceSink {
|
||||
public:
|
||||
void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) U_OVERRIDE {
|
||||
void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override {
|
||||
ResourceTable resIndexTable = value.getTable(status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
|
@ -196,7 +196,7 @@ class AvailableLocalesStringEnumeration : public StringEnumeration {
|
|||
|
||||
/* ### Get available **************************************************/
|
||||
|
||||
static UBool U_CALLCONV uloc_cleanup(void) {
|
||||
static UBool U_CALLCONV uloc_cleanup() {
|
||||
for (int32_t i = 0; i < UPRV_LENGTHOF(gAvailableLocaleNames); i++) {
|
||||
uprv_free(gAvailableLocaleNames[i]);
|
||||
gAvailableLocaleNames[i] = nullptr;
|
||||
|
@ -212,7 +212,7 @@ static UBool U_CALLCONV uloc_cleanup(void) {
|
|||
static void U_CALLCONV loadInstalledLocales(UErrorCode& status) {
|
||||
ucln_common_registerCleanup(UCLN_COMMON_ULOC, uloc_cleanup);
|
||||
|
||||
icu::LocalUResourceBundlePointer rb(ures_openDirect(NULL, "res_index", &status));
|
||||
icu::LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "res_index", &status));
|
||||
AvailableLocalesSink sink;
|
||||
ures_getAllItemsWithFallback(rb.getAlias(), "", sink, status);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ Locale LocaleBased::getLocale(ULocDataLocaleType type, UErrorCode& status) const
|
|||
|
||||
const char* LocaleBased::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const {
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
|
@ -32,7 +32,7 @@ const char* LocaleBased::getLocaleID(ULocDataLocaleType type, UErrorCode& status
|
|||
return actual;
|
||||
default:
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ Locale::getDisplayLanguage(UnicodeString& dispLang) const
|
|||
UnicodeString&
|
||||
Locale::getDisplayLanguage(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
UChar *buffer;
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
|
||||
|
@ -95,7 +95,7 @@ Locale::getDisplayScript(UnicodeString& dispScript) const
|
|||
UnicodeString&
|
||||
Locale::getDisplayScript(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
UChar *buffer;
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
|
||||
|
@ -135,7 +135,7 @@ Locale::getDisplayCountry(UnicodeString& dispCntry) const
|
|||
UnicodeString&
|
||||
Locale::getDisplayCountry(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
UChar *buffer;
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
|
||||
|
@ -175,7 +175,7 @@ Locale::getDisplayVariant(UnicodeString& dispVar) const
|
|||
UnicodeString&
|
||||
Locale::getDisplayVariant(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
UChar *buffer;
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
|
||||
|
@ -215,7 +215,7 @@ Locale::getDisplayName( UnicodeString& name ) const
|
|||
UnicodeString&
|
||||
Locale::getDisplayName(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
UChar *buffer;
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
|
||||
|
@ -302,12 +302,12 @@ _getStringOrCopyKey(const char *path, const char *locale,
|
|||
const char* subTableKey,
|
||||
const char *itemKey,
|
||||
const char *substitute,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UErrorCode *pErrorCode) {
|
||||
const UChar *s = NULL;
|
||||
const char16_t *s = nullptr;
|
||||
int32_t length = 0;
|
||||
|
||||
if(itemKey==NULL) {
|
||||
if(itemKey==nullptr) {
|
||||
/* top-level item: normal resource bundle access */
|
||||
icu::LocalUResourceBundlePointer rb(ures_open(path, locale, pErrorCode));
|
||||
|
||||
|
@ -318,7 +318,7 @@ _getStringOrCopyKey(const char *path, const char *locale,
|
|||
} else {
|
||||
bool isLanguageCode = (uprv_strncmp(tableKey, _kLanguages, 9) == 0);
|
||||
/* Language code should not be a number. If it is, set the error code. */
|
||||
if (isLanguageCode && uprv_strtol(itemKey, NULL, 10)) {
|
||||
if (isLanguageCode && uprv_strtol(itemKey, nullptr, 10)) {
|
||||
*pErrorCode = U_MISSING_RESOURCE_ERROR;
|
||||
} else {
|
||||
/* second-level item, use special fallback */
|
||||
|
@ -344,7 +344,7 @@ _getStringOrCopyKey(const char *path, const char *locale,
|
|||
|
||||
if(U_SUCCESS(*pErrorCode)) {
|
||||
int32_t copyLength=uprv_min(length, destCapacity);
|
||||
if(copyLength>0 && s != NULL) {
|
||||
if(copyLength>0 && s != nullptr) {
|
||||
u_memcpy(dest, s, copyLength);
|
||||
}
|
||||
} else {
|
||||
|
@ -362,21 +362,21 @@ typedef int32_t U_CALLCONV UDisplayNameGetter(const char *, char *, int32_t, UE
|
|||
static int32_t
|
||||
_getDisplayNameForComponent(const char *locale,
|
||||
const char *displayLocale,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UDisplayNameGetter *getter,
|
||||
const char *tag,
|
||||
UErrorCode *pErrorCode) {
|
||||
char localeBuffer[ULOC_FULLNAME_CAPACITY*4];
|
||||
int32_t length;
|
||||
UErrorCode localStatus;
|
||||
const char* root = NULL;
|
||||
const char* root = nullptr;
|
||||
|
||||
/* argument checking */
|
||||
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(destCapacity<0 || (destCapacity>0 && dest==NULL)) {
|
||||
if(destCapacity<0 || (destCapacity>0 && dest==nullptr)) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ _getDisplayNameForComponent(const char *locale,
|
|||
root = tag == _kCountries ? U_ICUDATA_REGION : U_ICUDATA_LANG;
|
||||
|
||||
return _getStringOrCopyKey(root, displayLocale,
|
||||
tag, NULL, localeBuffer,
|
||||
tag, nullptr, localeBuffer,
|
||||
localeBuffer,
|
||||
dest, destCapacity,
|
||||
pErrorCode);
|
||||
|
@ -408,7 +408,7 @@ _getDisplayNameForComponent(const char *locale,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uloc_getDisplayLanguage(const char *locale,
|
||||
const char *displayLocale,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UErrorCode *pErrorCode) {
|
||||
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
|
||||
uloc_getLanguage, _kLanguages, pErrorCode);
|
||||
|
@ -417,7 +417,7 @@ uloc_getDisplayLanguage(const char *locale,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uloc_getDisplayScript(const char* locale,
|
||||
const char* displayLocale,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UErrorCode *pErrorCode)
|
||||
{
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
|
@ -442,7 +442,7 @@ uloc_getDisplayScript(const char* locale,
|
|||
static int32_t
|
||||
uloc_getDisplayScriptInContext(const char* locale,
|
||||
const char* displayLocale,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UErrorCode *pErrorCode)
|
||||
{
|
||||
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
|
||||
|
@ -452,7 +452,7 @@ uloc_getDisplayScriptInContext(const char* locale,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uloc_getDisplayCountry(const char *locale,
|
||||
const char *displayLocale,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UErrorCode *pErrorCode) {
|
||||
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
|
||||
uloc_getCountry, _kCountries, pErrorCode);
|
||||
|
@ -466,7 +466,7 @@ uloc_getDisplayCountry(const char *locale,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uloc_getDisplayVariant(const char *locale,
|
||||
const char *displayLocale,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UErrorCode *pErrorCode) {
|
||||
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
|
||||
uloc_getVariant, _kVariants, pErrorCode);
|
||||
|
@ -487,14 +487,14 @@ uloc_getDisplayVariant(const char *locale,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uloc_getDisplayName(const char *locale,
|
||||
const char *displayLocale,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UErrorCode *pErrorCode)
|
||||
{
|
||||
static const UChar defaultSeparator[9] = { 0x007b, 0x0030, 0x007d, 0x002c, 0x0020, 0x007b, 0x0031, 0x007d, 0x0000 }; /* "{0}, {1}" */
|
||||
static const UChar sub0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 } ; /* {0} */
|
||||
static const UChar sub1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 } ; /* {1} */
|
||||
static const char16_t defaultSeparator[9] = { 0x007b, 0x0030, 0x007d, 0x002c, 0x0020, 0x007b, 0x0031, 0x007d, 0x0000 }; /* "{0}, {1}" */
|
||||
static const char16_t sub0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 } ; /* {0} */
|
||||
static const char16_t sub1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 } ; /* {1} */
|
||||
static const int32_t subLen = 3;
|
||||
static const UChar defaultPattern[10] = {
|
||||
static const char16_t defaultPattern[10] = {
|
||||
0x007b, 0x0030, 0x007d, 0x0020, 0x0028, 0x007b, 0x0031, 0x007d, 0x0029, 0x0000
|
||||
}; /* {0} ({1}) */
|
||||
static const int32_t defaultPatLen = 9;
|
||||
|
@ -503,16 +503,16 @@ uloc_getDisplayName(const char *locale,
|
|||
|
||||
int32_t length; /* of formatted result */
|
||||
|
||||
const UChar *separator;
|
||||
const char16_t *separator;
|
||||
int32_t sepLen = 0;
|
||||
const UChar *pattern;
|
||||
const char16_t *pattern;
|
||||
int32_t patLen = 0;
|
||||
int32_t sub0Pos, sub1Pos;
|
||||
|
||||
UChar formatOpenParen = 0x0028; // (
|
||||
UChar formatReplaceOpenParen = 0x005B; // [
|
||||
UChar formatCloseParen = 0x0029; // )
|
||||
UChar formatReplaceCloseParen = 0x005D; // ]
|
||||
char16_t formatOpenParen = 0x0028; // (
|
||||
char16_t formatReplaceOpenParen = 0x005B; // [
|
||||
char16_t formatCloseParen = 0x0029; // )
|
||||
char16_t formatReplaceCloseParen = 0x005D; // ]
|
||||
|
||||
UBool haveLang = true; /* assume true, set false if we find we don't have
|
||||
a lang component in the locale */
|
||||
|
@ -522,11 +522,11 @@ uloc_getDisplayName(const char *locale,
|
|||
|
||||
int32_t langi = 0; /* index of the language substitution (0 or 1), virtually always 0 */
|
||||
|
||||
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(destCapacity<0 || (destCapacity>0 && dest==NULL)) {
|
||||
if(destCapacity<0 || (destCapacity>0 && dest==nullptr)) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ uloc_getDisplayName(const char *locale,
|
|||
icu::LocalUResourceBundlePointer locbundle(
|
||||
ures_open(U_ICUDATA_LANG, displayLocale, &status));
|
||||
icu::LocalUResourceBundlePointer dspbundle(
|
||||
ures_getByKeyWithFallback(locbundle.getAlias(), _kLocaleDisplayPattern, NULL, &status));
|
||||
ures_getByKeyWithFallback(locbundle.getAlias(), _kLocaleDisplayPattern, nullptr, &status));
|
||||
|
||||
separator=ures_getStringByKeyWithFallback(dspbundle.getAlias(), _kSeparator, &sepLen, &status);
|
||||
pattern=ures_getStringByKeyWithFallback(dspbundle.getAlias(), _kPattern, &patLen, &status);
|
||||
|
@ -557,13 +557,13 @@ uloc_getDisplayName(const char *locale,
|
|||
* This is similar to how pattern is handled below.
|
||||
*/
|
||||
{
|
||||
UChar *p0=u_strstr(separator, sub0);
|
||||
UChar *p1=u_strstr(separator, sub1);
|
||||
if (p0==NULL || p1==NULL || p1<p0) {
|
||||
char16_t *p0=u_strstr(separator, sub0);
|
||||
char16_t *p1=u_strstr(separator, sub1);
|
||||
if (p0==nullptr || p1==nullptr || p1<p0) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
separator = (const UChar *)p0 + subLen;
|
||||
separator = (const char16_t *)p0 + subLen;
|
||||
sepLen = static_cast<int32_t>(p1 - separator);
|
||||
}
|
||||
|
||||
|
@ -574,9 +574,9 @@ uloc_getDisplayName(const char *locale,
|
|||
sub1Pos=defaultSub1Pos;
|
||||
// use default formatOpenParen etc. set above
|
||||
} else { /* non-default pattern */
|
||||
UChar *p0=u_strstr(pattern, sub0);
|
||||
UChar *p1=u_strstr(pattern, sub1);
|
||||
if (p0==NULL || p1==NULL) {
|
||||
char16_t *p0=u_strstr(pattern, sub0);
|
||||
char16_t *p1=u_strstr(pattern, sub1);
|
||||
if (p0==nullptr || p1==nullptr) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ uloc_getDisplayName(const char *locale,
|
|||
int32_t t=sub0Pos; sub0Pos=sub1Pos; sub1Pos=t;
|
||||
langi=1;
|
||||
}
|
||||
if (u_strchr(pattern, 0xFF08) != NULL) {
|
||||
if (u_strchr(pattern, 0xFF08) != nullptr) {
|
||||
formatOpenParen = 0xFF08; // fullwidth (
|
||||
formatReplaceOpenParen = 0xFF3B; // fullwidth [
|
||||
formatCloseParen = 0xFF09; // fullwidth )
|
||||
|
@ -602,7 +602,7 @@ uloc_getDisplayName(const char *locale,
|
|||
* adjust the parameters so padding is not added, and repeat.
|
||||
*/
|
||||
do {
|
||||
UChar* p=dest;
|
||||
char16_t* p=dest;
|
||||
int32_t patPos=0; /* position in the pattern, used for non-substitution portions */
|
||||
int32_t langLen=0; /* length of language substitution */
|
||||
int32_t langPos=0; /* position in output of language substitution */
|
||||
|
@ -665,7 +665,7 @@ uloc_getDisplayName(const char *locale,
|
|||
U_FALLTHROUGH;
|
||||
default: {
|
||||
const char* kw=uenum_next(kenum.getAlias(), &len, pErrorCode);
|
||||
if (kw == NULL) {
|
||||
if (kw == nullptr) {
|
||||
len=0; /* mark that we didn't add a component */
|
||||
subdone=true;
|
||||
} else {
|
||||
|
@ -712,7 +712,7 @@ uloc_getDisplayName(const char *locale,
|
|||
if (len>0) {
|
||||
/* we added a component, so add separator and write it if there's room. */
|
||||
if(len+sepLen<=cap) {
|
||||
const UChar * plimit = p + len;
|
||||
const char16_t * plimit = p + len;
|
||||
for (; p < plimit; p++) {
|
||||
if (*p == formatOpenParen) {
|
||||
*p = formatReplaceOpenParen;
|
||||
|
@ -788,24 +788,24 @@ uloc_getDisplayName(const char *locale,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uloc_getDisplayKeyword(const char* keyword,
|
||||
const char* displayLocale,
|
||||
UChar* dest,
|
||||
char16_t* dest,
|
||||
int32_t destCapacity,
|
||||
UErrorCode* status){
|
||||
|
||||
/* argument checking */
|
||||
if(status==NULL || U_FAILURE(*status)) {
|
||||
if(status==nullptr || U_FAILURE(*status)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(destCapacity<0 || (destCapacity>0 && dest==NULL)) {
|
||||
if(destCapacity<0 || (destCapacity>0 && dest==nullptr)) {
|
||||
*status=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* pass itemKey=NULL to look for a top-level item */
|
||||
/* pass itemKey=nullptr to look for a top-level item */
|
||||
return _getStringOrCopyKey(U_ICUDATA_LANG, displayLocale,
|
||||
_kKeys, NULL,
|
||||
_kKeys, nullptr,
|
||||
keyword,
|
||||
keyword,
|
||||
dest, destCapacity,
|
||||
|
@ -820,17 +820,17 @@ U_CAPI int32_t U_EXPORT2
|
|||
uloc_getDisplayKeywordValue( const char* locale,
|
||||
const char* keyword,
|
||||
const char* displayLocale,
|
||||
UChar* dest,
|
||||
char16_t* dest,
|
||||
int32_t destCapacity,
|
||||
UErrorCode* status){
|
||||
|
||||
|
||||
/* argument checking */
|
||||
if(status==NULL || U_FAILURE(*status)) {
|
||||
if(status==nullptr || U_FAILURE(*status)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(destCapacity<0 || (destCapacity>0 && dest==NULL)) {
|
||||
if(destCapacity<0 || (destCapacity>0 && dest==nullptr)) {
|
||||
*status=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -849,14 +849,14 @@ uloc_getDisplayKeywordValue( const char* locale,
|
|||
if(uprv_stricmp(keyword, _kCurrency)==0){
|
||||
|
||||
int32_t dispNameLen = 0;
|
||||
const UChar *dispName = NULL;
|
||||
const char16_t *dispName = nullptr;
|
||||
|
||||
icu::LocalUResourceBundlePointer bundle(
|
||||
ures_open(U_ICUDATA_CURR, displayLocale, status));
|
||||
icu::LocalUResourceBundlePointer currencies(
|
||||
ures_getByKey(bundle.getAlias(), _kCurrencies, NULL, status));
|
||||
ures_getByKey(bundle.getAlias(), _kCurrencies, nullptr, status));
|
||||
icu::LocalUResourceBundlePointer currency(
|
||||
ures_getByKeyWithFallback(currencies.getAlias(), keywordValue.data(), NULL, status));
|
||||
ures_getByKeyWithFallback(currencies.getAlias(), keywordValue.data(), nullptr, status));
|
||||
|
||||
dispName = ures_getStringByIndex(currency.getAlias(), UCURRENCY_DISPLAY_NAME_INDEX, &dispNameLen, status);
|
||||
|
||||
|
@ -869,8 +869,8 @@ uloc_getDisplayKeywordValue( const char* locale,
|
|||
}
|
||||
}
|
||||
|
||||
/* now copy the dispName over if not NULL */
|
||||
if(dispName != NULL){
|
||||
/* now copy the dispName over if not nullptr */
|
||||
if(dispName != nullptr){
|
||||
if(dispNameLen <= destCapacity){
|
||||
u_memcpy(dest, dispName, dispNameLen);
|
||||
return u_terminateUChars(dest, destCapacity, dispNameLen, status);
|
||||
|
|
|
@ -40,7 +40,7 @@ static int32_t ncat(char *buffer, uint32_t buflen, ...) {
|
|||
char *p = buffer;
|
||||
const char* e = buffer + buflen - 1;
|
||||
|
||||
if (buffer == NULL || buflen < 1) {
|
||||
if (buffer == nullptr || buflen < 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -86,16 +86,16 @@ public:
|
|||
|
||||
inline UnicodeString &
|
||||
ICUDataTable::get(const char* tableKey, const char* itemKey, UnicodeString& result) const {
|
||||
return get(tableKey, NULL, itemKey, result);
|
||||
return get(tableKey, nullptr, itemKey, result);
|
||||
}
|
||||
|
||||
inline UnicodeString &
|
||||
ICUDataTable::getNoFallback(const char* tableKey, const char* itemKey, UnicodeString& result) const {
|
||||
return getNoFallback(tableKey, NULL, itemKey, result);
|
||||
return getNoFallback(tableKey, nullptr, itemKey, result);
|
||||
}
|
||||
|
||||
ICUDataTable::ICUDataTable(const char* path, const Locale& locale)
|
||||
: path(NULL), locale(Locale::getRoot())
|
||||
: path(nullptr), locale(Locale::getRoot())
|
||||
{
|
||||
if (path) {
|
||||
int32_t len = static_cast<int32_t>(uprv_strlen(path));
|
||||
|
@ -110,7 +110,7 @@ ICUDataTable::ICUDataTable(const char* path, const Locale& locale)
|
|||
ICUDataTable::~ICUDataTable() {
|
||||
if (path) {
|
||||
uprv_free((void*) path);
|
||||
path = NULL;
|
||||
path = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ ICUDataTable::get(const char* tableKey, const char* subTableKey, const char* ite
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t len = 0;
|
||||
|
||||
const UChar *s = uloc_getTableStringWithFallback(path, locale.getName(),
|
||||
const char16_t *s = uloc_getTableStringWithFallback(path, locale.getName(),
|
||||
tableKey, subTableKey, itemKey,
|
||||
&len, &status);
|
||||
if (U_SUCCESS(status) && len > 0) {
|
||||
|
@ -140,7 +140,7 @@ ICUDataTable::getNoFallback(const char* tableKey, const char* subTableKey, const
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t len = 0;
|
||||
|
||||
const UChar *s = uloc_getTableStringWithFallback(path, locale.getName(),
|
||||
const char16_t *s = uloc_getTableStringWithFallback(path, locale.getName(),
|
||||
tableKey, subTableKey, itemKey,
|
||||
&len, &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
|
@ -347,7 +347,7 @@ private:
|
|||
UnicodeString& keyDisplayName(const char* key, UnicodeString& result, UBool skipAdjust) const;
|
||||
UnicodeString& keyValueDisplayName(const char* key, const char* value,
|
||||
UnicodeString& result, UBool skipAdjust) const;
|
||||
void initialize(void);
|
||||
void initialize();
|
||||
|
||||
struct CapitalizationContextSink;
|
||||
};
|
||||
|
@ -358,7 +358,7 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale,
|
|||
, langData(U_ICUDATA_LANG, locale)
|
||||
, regionData(U_ICUDATA_REGION, locale)
|
||||
, capitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
|
||||
, capitalizationBrkIter(NULL)
|
||||
, capitalizationBrkIter(nullptr)
|
||||
, nameLength(UDISPCTX_LENGTH_FULL)
|
||||
, substitute(UDISPCTX_SUBSTITUTE)
|
||||
{
|
||||
|
@ -371,7 +371,7 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale,
|
|||
, langData(U_ICUDATA_LANG, locale)
|
||||
, regionData(U_ICUDATA_REGION, locale)
|
||||
, capitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
|
||||
, capitalizationBrkIter(NULL)
|
||||
, capitalizationBrkIter(nullptr)
|
||||
, nameLength(UDISPCTX_LENGTH_FULL)
|
||||
, substitute(UDISPCTX_SUBSTITUTE)
|
||||
{
|
||||
|
@ -447,7 +447,7 @@ struct LocaleDisplayNamesImpl::CapitalizationContextSink : public ResourceSink {
|
|||
LocaleDisplayNamesImpl::CapitalizationContextSink::~CapitalizationContextSink() {}
|
||||
|
||||
void
|
||||
LocaleDisplayNamesImpl::initialize(void) {
|
||||
LocaleDisplayNamesImpl::initialize() {
|
||||
LocaleDisplayNamesImpl *nonConstThis = (LocaleDisplayNamesImpl *)this;
|
||||
nonConstThis->locale = langData.getLocale() == Locale::getRoot()
|
||||
? regionData.getLocale()
|
||||
|
@ -467,16 +467,16 @@ LocaleDisplayNamesImpl::initialize(void) {
|
|||
pattern = UnicodeString("{0} ({1})", -1, US_INV);
|
||||
}
|
||||
format.applyPatternMinMaxArguments(pattern, 2, 2, status);
|
||||
if (pattern.indexOf((UChar)0xFF08) >= 0) {
|
||||
formatOpenParen.setTo((UChar)0xFF08); // fullwidth (
|
||||
formatReplaceOpenParen.setTo((UChar)0xFF3B); // fullwidth [
|
||||
formatCloseParen.setTo((UChar)0xFF09); // fullwidth )
|
||||
formatReplaceCloseParen.setTo((UChar)0xFF3D); // fullwidth ]
|
||||
if (pattern.indexOf((char16_t)0xFF08) >= 0) {
|
||||
formatOpenParen.setTo((char16_t)0xFF08); // fullwidth (
|
||||
formatReplaceOpenParen.setTo((char16_t)0xFF3B); // fullwidth [
|
||||
formatCloseParen.setTo((char16_t)0xFF09); // fullwidth )
|
||||
formatReplaceCloseParen.setTo((char16_t)0xFF3D); // fullwidth ]
|
||||
} else {
|
||||
formatOpenParen.setTo((UChar)0x0028); // (
|
||||
formatReplaceOpenParen.setTo((UChar)0x005B); // [
|
||||
formatCloseParen.setTo((UChar)0x0029); // )
|
||||
formatReplaceCloseParen.setTo((UChar)0x005D); // ]
|
||||
formatOpenParen.setTo((char16_t)0x0028); // (
|
||||
formatReplaceOpenParen.setTo((char16_t)0x005B); // [
|
||||
formatCloseParen.setTo((char16_t)0x0029); // )
|
||||
formatReplaceCloseParen.setTo((char16_t)0x005D); // ]
|
||||
}
|
||||
|
||||
UnicodeString ktPattern;
|
||||
|
@ -492,7 +492,7 @@ LocaleDisplayNamesImpl::initialize(void) {
|
|||
// Also check whether we will need a break iterator (depends on the data)
|
||||
UBool needBrkIter = false;
|
||||
if (capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU || capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_STANDALONE) {
|
||||
LocalUResourceBundlePointer resource(ures_open(NULL, locale.getName(), &status));
|
||||
LocalUResourceBundlePointer resource(ures_open(nullptr, locale.getName(), &status));
|
||||
if (U_FAILURE(status)) { return; }
|
||||
CapitalizationContextSink sink(*this);
|
||||
ures_getAllItemsWithFallback(resource.getAlias(), "contextTransforms", sink, status);
|
||||
|
@ -510,7 +510,7 @@ LocaleDisplayNamesImpl::initialize(void) {
|
|||
capitalizationBrkIter = BreakIterator::createSentenceInstance(locale, status);
|
||||
if (U_FAILURE(status)) {
|
||||
delete capitalizationBrkIter;
|
||||
capitalizationBrkIter = NULL;
|
||||
capitalizationBrkIter = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -554,7 +554,7 @@ LocaleDisplayNamesImpl::adjustForUsageAndContext(CapContextUsage usage,
|
|||
UnicodeString& result) const {
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
// check to see whether we need to titlecase result
|
||||
if ( result.length() > 0 && u_islower(result.char32At(0)) && capitalizationBrkIter!= NULL &&
|
||||
if ( result.length() > 0 && u_islower(result.char32At(0)) && capitalizationBrkIter!= nullptr &&
|
||||
( capitalizationContext==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE || fCapitalization[usage] ) ) {
|
||||
// note fCapitalization[usage] won't be set unless capitalizationContext is UI_LIST_OR_MENU or STANDALONE
|
||||
static UMutex capitalizationBrkIterLock;
|
||||
|
@ -660,7 +660,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc,
|
|||
UnicodeString temp2;
|
||||
char value[ULOC_KEYWORD_AND_VALUES_CAPACITY]; // sigh, no ULOC_VALUE_CAPACITY
|
||||
const char* key;
|
||||
while ((key = e->next((int32_t *)0, status)) != NULL) {
|
||||
while ((key = e->next((int32_t *)0, status)) != nullptr) {
|
||||
value[0] = 0;
|
||||
loc.getKeywordValue(key, value, ULOC_KEYWORD_AND_VALUES_CAPACITY, status);
|
||||
if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING) {
|
||||
|
@ -680,7 +680,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc,
|
|||
appendWithSep(resultRemainder, temp3);
|
||||
} else {
|
||||
appendWithSep(resultRemainder, temp)
|
||||
.append((UChar)0x3d /* = */)
|
||||
.append((char16_t)0x3d /* = */)
|
||||
.append(temp2);
|
||||
}
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ LocaleDisplayNamesImpl::appendWithSep(UnicodeString& buffer, const UnicodeString
|
|||
} else {
|
||||
const UnicodeString *values[2] = { &buffer, &src };
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
separatorFormat.formatAndReplace(values, 2, buffer, NULL, 0, status);
|
||||
separatorFormat.formatAndReplace(values, 2, buffer, nullptr, 0, status);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ LocaleDisplayNamesImpl::localeIdName(const char* localeId,
|
|||
}
|
||||
}
|
||||
langData.getNoFallback("Languages", localeId, result);
|
||||
if (result.isBogus() && uprv_strchr(localeId, '_') == NULL) {
|
||||
if (result.isBogus() && uprv_strchr(localeId, '_') == nullptr) {
|
||||
// Canonicalize lang and try again, ICU-20870
|
||||
// (only for language codes without script or region)
|
||||
Locale canonLocale = Locale::createCanonical(localeId);
|
||||
|
@ -747,7 +747,7 @@ LocaleDisplayNamesImpl::localeIdName(const char* localeId,
|
|||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::languageDisplayName(const char* lang,
|
||||
UnicodeString& result) const {
|
||||
if (uprv_strcmp("root", lang) == 0 || uprv_strchr(lang, '_') != NULL) {
|
||||
if (uprv_strcmp("root", lang) == 0 || uprv_strchr(lang, '_') != nullptr) {
|
||||
return result = UnicodeString(lang, -1, US_INV);
|
||||
}
|
||||
if (nameLength == UDISPCTX_LENGTH_SHORT) {
|
||||
|
@ -879,7 +879,7 @@ LocaleDisplayNamesImpl::keyValueDisplayName(const char* key,
|
|||
UErrorCode sts = U_ZERO_ERROR;
|
||||
UnicodeString ustrValue(value, -1, US_INV);
|
||||
int32_t len;
|
||||
const UChar *currencyName = ucurr_getName(ustrValue.getTerminatedBuffer(),
|
||||
const char16_t *currencyName = ucurr_getName(ustrValue.getTerminatedBuffer(),
|
||||
locale.getBaseName(), UCURR_LONG_NAME, nullptr /* isChoiceFormat */, &len, &sts);
|
||||
if (U_FAILURE(sts)) {
|
||||
// Return the value as is on failure
|
||||
|
@ -922,7 +922,7 @@ LocaleDisplayNames::createInstance(const Locale& locale,
|
|||
LocaleDisplayNames*
|
||||
LocaleDisplayNames::createInstance(const Locale& locale,
|
||||
UDisplayContext *contexts, int32_t length) {
|
||||
if (contexts == NULL) {
|
||||
if (contexts == nullptr) {
|
||||
length = 0;
|
||||
}
|
||||
return new LocaleDisplayNamesImpl(locale, contexts, length);
|
||||
|
@ -941,7 +941,7 @@ uldn_open(const char * locale,
|
|||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (locale == NULL) {
|
||||
if (locale == nullptr) {
|
||||
locale = uloc_getDefault();
|
||||
}
|
||||
return (ULocaleDisplayNames *)LocaleDisplayNames::createInstance(Locale(locale), dialectHandling);
|
||||
|
@ -954,7 +954,7 @@ uldn_openForContext(const char * locale,
|
|||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (locale == NULL) {
|
||||
if (locale == nullptr) {
|
||||
locale = uloc_getDefault();
|
||||
}
|
||||
return (ULocaleDisplayNames *)LocaleDisplayNames::createInstance(Locale(locale), contexts, length);
|
||||
|
@ -971,7 +971,7 @@ uldn_getLocale(const ULocaleDisplayNames *ldn) {
|
|||
if (ldn) {
|
||||
return ((const LocaleDisplayNames *)ldn)->getLocale().getName();
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
U_CAPI UDialectHandling U_EXPORT2
|
||||
|
@ -995,13 +995,13 @@ uldn_getContext(const ULocaleDisplayNames *ldn,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
|
||||
const char *locale,
|
||||
UChar *result,
|
||||
char16_t *result,
|
||||
int32_t maxResultSize,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (ldn == NULL || locale == NULL || (result == NULL && maxResultSize > 0) || maxResultSize < 0) {
|
||||
if (ldn == nullptr || locale == nullptr || (result == nullptr && maxResultSize > 0) || maxResultSize < 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1017,13 +1017,13 @@ uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
|
||||
const char *lang,
|
||||
UChar *result,
|
||||
char16_t *result,
|
||||
int32_t maxResultSize,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (ldn == NULL || lang == NULL || (result == NULL && maxResultSize > 0) || maxResultSize < 0) {
|
||||
if (ldn == nullptr || lang == nullptr || (result == nullptr && maxResultSize > 0) || maxResultSize < 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1035,13 +1035,13 @@ uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
|
||||
const char *script,
|
||||
UChar *result,
|
||||
char16_t *result,
|
||||
int32_t maxResultSize,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (ldn == NULL || script == NULL || (result == NULL && maxResultSize > 0) || maxResultSize < 0) {
|
||||
if (ldn == nullptr || script == nullptr || (result == nullptr && maxResultSize > 0) || maxResultSize < 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1053,7 +1053,7 @@ uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
|
||||
UScriptCode scriptCode,
|
||||
UChar *result,
|
||||
char16_t *result,
|
||||
int32_t maxResultSize,
|
||||
UErrorCode *pErrorCode) {
|
||||
return uldn_scriptDisplayName(ldn, uscript_getName(scriptCode), result, maxResultSize, pErrorCode);
|
||||
|
@ -1062,13 +1062,13 @@ uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
|
||||
const char *region,
|
||||
UChar *result,
|
||||
char16_t *result,
|
||||
int32_t maxResultSize,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (ldn == NULL || region == NULL || (result == NULL && maxResultSize > 0) || maxResultSize < 0) {
|
||||
if (ldn == nullptr || region == nullptr || (result == nullptr && maxResultSize > 0) || maxResultSize < 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1080,13 +1080,13 @@ uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
|
||||
const char *variant,
|
||||
UChar *result,
|
||||
char16_t *result,
|
||||
int32_t maxResultSize,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (ldn == NULL || variant == NULL || (result == NULL && maxResultSize > 0) || maxResultSize < 0) {
|
||||
if (ldn == nullptr || variant == nullptr || (result == nullptr && maxResultSize > 0) || maxResultSize < 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1098,13 +1098,13 @@ uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
|
|||
U_CAPI int32_t U_EXPORT2
|
||||
uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
|
||||
const char *key,
|
||||
UChar *result,
|
||||
char16_t *result,
|
||||
int32_t maxResultSize,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (ldn == NULL || key == NULL || (result == NULL && maxResultSize > 0) || maxResultSize < 0) {
|
||||
if (ldn == nullptr || key == nullptr || (result == nullptr && maxResultSize > 0) || maxResultSize < 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1117,13 +1117,13 @@ U_CAPI int32_t U_EXPORT2
|
|||
uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
|
||||
const char *key,
|
||||
const char *value,
|
||||
UChar *result,
|
||||
char16_t *result,
|
||||
int32_t maxResultSize,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (ldn == NULL || key == NULL || value == NULL || (result == NULL && maxResultSize > 0)
|
||||
if (ldn == nullptr || key == nullptr || value == nullptr || (result == nullptr && maxResultSize > 0)
|
||||
|| maxResultSize < 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
|
|
|
@ -58,18 +58,18 @@
|
|||
#include "uvector.h"
|
||||
|
||||
U_CDECL_BEGIN
|
||||
static UBool U_CALLCONV locale_cleanup(void);
|
||||
static UBool U_CALLCONV locale_cleanup();
|
||||
U_CDECL_END
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
static Locale *gLocaleCache = NULL;
|
||||
static Locale *gLocaleCache = nullptr;
|
||||
static UInitOnce gLocaleCacheInitOnce {};
|
||||
|
||||
// gDefaultLocaleMutex protects all access to gDefaultLocalesHashT and gDefaultLocale.
|
||||
static UMutex gDefaultLocaleMutex;
|
||||
static UHashtable *gDefaultLocalesHashT = NULL;
|
||||
static Locale *gDefaultLocale = NULL;
|
||||
static UHashtable *gDefaultLocalesHashT = nullptr;
|
||||
static Locale *gDefaultLocale = nullptr;
|
||||
|
||||
/**
|
||||
* \def ULOC_STRING_LIMIT
|
||||
|
@ -115,19 +115,19 @@ deleteLocale(void *obj) {
|
|||
delete (icu::Locale *) obj;
|
||||
}
|
||||
|
||||
static UBool U_CALLCONV locale_cleanup(void)
|
||||
static UBool U_CALLCONV locale_cleanup()
|
||||
{
|
||||
U_NAMESPACE_USE
|
||||
|
||||
delete [] gLocaleCache;
|
||||
gLocaleCache = NULL;
|
||||
gLocaleCache = nullptr;
|
||||
gLocaleCacheInitOnce.reset();
|
||||
|
||||
if (gDefaultLocalesHashT) {
|
||||
uhash_close(gDefaultLocalesHashT); // Automatically deletes all elements, using deleter func.
|
||||
gDefaultLocalesHashT = NULL;
|
||||
gDefaultLocalesHashT = nullptr;
|
||||
}
|
||||
gDefaultLocale = NULL;
|
||||
gDefaultLocale = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -135,9 +135,9 @@ static UBool U_CALLCONV locale_cleanup(void)
|
|||
static void U_CALLCONV locale_init(UErrorCode &status) {
|
||||
U_NAMESPACE_USE
|
||||
|
||||
U_ASSERT(gLocaleCache == NULL);
|
||||
U_ASSERT(gLocaleCache == nullptr);
|
||||
gLocaleCache = new Locale[(int)eMAX_LOCALES];
|
||||
if (gLocaleCache == NULL) {
|
||||
if (gLocaleCache == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -173,11 +173,11 @@ Locale *locale_set_default_internal(const char *id, UErrorCode& status) {
|
|||
|
||||
UBool canonicalize = false;
|
||||
|
||||
// If given a NULL string for the locale id, grab the default
|
||||
// If given a nullptr string for the locale id, grab the default
|
||||
// name from the system.
|
||||
// (Different from most other locale APIs, where a null name means use
|
||||
// the current ICU default locale.)
|
||||
if (id == NULL) {
|
||||
if (id == nullptr) {
|
||||
id = uprv_getDefaultLocaleID(); // This function not thread safe? TODO: verify.
|
||||
canonicalize = true; // always canonicalize host ID
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ Locale *locale_set_default_internal(const char *id, UErrorCode& status) {
|
|||
return gDefaultLocale;
|
||||
}
|
||||
|
||||
if (gDefaultLocalesHashT == NULL) {
|
||||
gDefaultLocalesHashT = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &status);
|
||||
if (gDefaultLocalesHashT == nullptr) {
|
||||
gDefaultLocalesHashT = uhash_open(uhash_hashChars, uhash_compareChars, nullptr, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
return gDefaultLocale;
|
||||
}
|
||||
|
@ -206,9 +206,9 @@ Locale *locale_set_default_internal(const char *id, UErrorCode& status) {
|
|||
}
|
||||
|
||||
Locale *newDefault = (Locale *)uhash_get(gDefaultLocalesHashT, localeNameBuf.data());
|
||||
if (newDefault == NULL) {
|
||||
if (newDefault == nullptr) {
|
||||
newDefault = new Locale(Locale::eBOGUS);
|
||||
if (newDefault == NULL) {
|
||||
if (newDefault == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return gDefaultLocale;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ locale_set_default(const char *id)
|
|||
/* end */
|
||||
|
||||
U_CFUNC const char *
|
||||
locale_get_default(void)
|
||||
locale_get_default()
|
||||
{
|
||||
U_NAMESPACE_USE
|
||||
return Locale::getDefault().getName();
|
||||
|
@ -257,19 +257,19 @@ Locale::~Locale()
|
|||
if ((baseName != fullName) && (baseName != fullNameBuffer)) {
|
||||
uprv_free(baseName);
|
||||
}
|
||||
baseName = NULL;
|
||||
baseName = nullptr;
|
||||
/*if fullName is on the heap, we free it*/
|
||||
if (fullName != fullNameBuffer)
|
||||
{
|
||||
uprv_free(fullName);
|
||||
fullName = NULL;
|
||||
fullName = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Locale::Locale()
|
||||
: UObject(), fullName(fullNameBuffer), baseName(NULL)
|
||||
: UObject(), fullName(fullNameBuffer), baseName(nullptr)
|
||||
{
|
||||
init(NULL, false);
|
||||
init(nullptr, false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -278,7 +278,7 @@ Locale::Locale()
|
|||
* the default locale.)
|
||||
*/
|
||||
Locale::Locale(Locale::ELocaleType)
|
||||
: UObject(), fullName(fullNameBuffer), baseName(NULL)
|
||||
: UObject(), fullName(fullNameBuffer), baseName(nullptr)
|
||||
{
|
||||
setToBogus();
|
||||
}
|
||||
|
@ -288,11 +288,11 @@ Locale::Locale( const char * newLanguage,
|
|||
const char * newCountry,
|
||||
const char * newVariant,
|
||||
const char * newKeywords)
|
||||
: UObject(), fullName(fullNameBuffer), baseName(NULL)
|
||||
: UObject(), fullName(fullNameBuffer), baseName(nullptr)
|
||||
{
|
||||
if( (newLanguage==NULL) && (newCountry == NULL) && (newVariant == NULL) )
|
||||
if( (newLanguage==nullptr) && (newCountry == nullptr) && (newVariant == nullptr) )
|
||||
{
|
||||
init(NULL, false); /* shortcut */
|
||||
init(nullptr, false); /* shortcut */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -305,7 +305,7 @@ Locale::Locale( const char * newLanguage,
|
|||
// Check the sizes of the input strings.
|
||||
|
||||
// Language
|
||||
if ( newLanguage != NULL )
|
||||
if ( newLanguage != nullptr )
|
||||
{
|
||||
lsize = (int32_t)uprv_strlen(newLanguage);
|
||||
if ( lsize < 0 || lsize > ULOC_STRING_LIMIT ) { // int32 wrap
|
||||
|
@ -317,7 +317,7 @@ Locale::Locale( const char * newLanguage,
|
|||
CharString togo(newLanguage, lsize, status); // start with newLanguage
|
||||
|
||||
// _Country
|
||||
if ( newCountry != NULL )
|
||||
if ( newCountry != nullptr )
|
||||
{
|
||||
csize = (int32_t)uprv_strlen(newCountry);
|
||||
if ( csize < 0 || csize > ULOC_STRING_LIMIT ) { // int32 wrap
|
||||
|
@ -327,7 +327,7 @@ Locale::Locale( const char * newLanguage,
|
|||
}
|
||||
|
||||
// _Variant
|
||||
if ( newVariant != NULL )
|
||||
if ( newVariant != nullptr )
|
||||
{
|
||||
// remove leading _'s
|
||||
while(newVariant[0] == SEP_CHAR)
|
||||
|
@ -347,7 +347,7 @@ Locale::Locale( const char * newLanguage,
|
|||
}
|
||||
}
|
||||
|
||||
if ( newKeywords != NULL)
|
||||
if ( newKeywords != nullptr)
|
||||
{
|
||||
ksize = (int32_t)uprv_strlen(newKeywords);
|
||||
if ( ksize < 0 || ksize > ULOC_STRING_LIMIT ) {
|
||||
|
@ -402,12 +402,12 @@ Locale::Locale( const char * newLanguage,
|
|||
}
|
||||
|
||||
Locale::Locale(const Locale &other)
|
||||
: UObject(other), fullName(fullNameBuffer), baseName(NULL)
|
||||
: UObject(other), fullName(fullNameBuffer), baseName(nullptr)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
Locale::Locale(Locale&& other) U_NOEXCEPT
|
||||
Locale::Locale(Locale&& other) noexcept
|
||||
: UObject(other), fullName(fullNameBuffer), baseName(fullName) {
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ Locale& Locale::operator=(const Locale& other) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
Locale& Locale::operator=(Locale&& other) U_NOEXCEPT {
|
||||
Locale& Locale::operator=(Locale&& other) noexcept {
|
||||
if ((baseName != fullName) && (baseName != fullNameBuffer)) uprv_free(baseName);
|
||||
if (fullName != fullNameBuffer) uprv_free(fullName);
|
||||
|
||||
|
@ -1513,7 +1513,7 @@ AliasReplacer::replaceTransformedExtensions(
|
|||
CharString& transformedExtensions, CharString& output, UErrorCode& status)
|
||||
{
|
||||
// The content of the transformedExtensions will be modified in this
|
||||
// function to NULL-terminating (tkey-tvalue) pairs.
|
||||
// function to NUL-terminating (tkey-tvalue) pairs.
|
||||
if (U_FAILURE(status)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1548,7 +1548,7 @@ AliasReplacer::replaceTransformedExtensions(
|
|||
}
|
||||
const char* nextTKey = ultag_getTKeyStart(tvalue);
|
||||
if (nextTKey != nullptr) {
|
||||
*((char*)(nextTKey-1)) = '\0'; // NULL terminate tvalue
|
||||
*((char*)(nextTKey-1)) = '\0'; // NUL terminate tvalue
|
||||
}
|
||||
tfields.insertElementAt((void*)tkey, tfields.size(), status);
|
||||
if (U_FAILURE(status)) {
|
||||
|
@ -1570,7 +1570,7 @@ AliasReplacer::replaceTransformedExtensions(
|
|||
return false;
|
||||
}
|
||||
// Split the "tkey-tvalue" pair string so that we can canonicalize the tvalue.
|
||||
*((char*)tvalue++) = '\0'; // NULL terminate tkey
|
||||
*((char*)tvalue++) = '\0'; // NUL terminate tkey
|
||||
output.append(tfield, status).append('-', status);
|
||||
const char* bcpTValue = ulocimp_toBcpType(tfield, tvalue, nullptr, nullptr);
|
||||
output.append((bcpTValue == nullptr) ? tvalue : bcpTValue, status);
|
||||
|
@ -1822,7 +1822,7 @@ Locale& Locale::init(const char* localeID, UBool canonicalize)
|
|||
if ((baseName != fullName) && (baseName != fullNameBuffer)) {
|
||||
uprv_free(baseName);
|
||||
}
|
||||
baseName = NULL;
|
||||
baseName = nullptr;
|
||||
if(fullName != fullNameBuffer) {
|
||||
uprv_free(fullName);
|
||||
fullName = fullNameBuffer;
|
||||
|
@ -1840,7 +1840,7 @@ Locale& Locale::init(const char* localeID, UBool canonicalize)
|
|||
int32_t length;
|
||||
UErrorCode err;
|
||||
|
||||
if(localeID == NULL) {
|
||||
if(localeID == nullptr) {
|
||||
// not an error, just set the default locale
|
||||
return *this = getDefault();
|
||||
}
|
||||
|
@ -1889,8 +1889,8 @@ Locale& Locale::init(const char* localeID, UBool canonicalize)
|
|||
// variant may contain @foo or .foo POSIX cruft; remove it
|
||||
separator = uprv_strchr(field[fieldIdx-1], '@');
|
||||
char* sep2 = uprv_strchr(field[fieldIdx-1], '.');
|
||||
if (separator!=NULL || sep2!=NULL) {
|
||||
if (separator==NULL || (sep2!=NULL && separator > sep2)) {
|
||||
if (separator!=nullptr || sep2!=nullptr) {
|
||||
if (separator==nullptr || (sep2!=nullptr && separator > sep2)) {
|
||||
separator = sep2;
|
||||
}
|
||||
fieldLen[fieldIdx-1] = (int32_t)(separator - field[fieldIdx-1]);
|
||||
|
@ -1974,14 +1974,14 @@ Locale::initBaseName(UErrorCode &status) {
|
|||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
U_ASSERT(baseName==NULL || baseName==fullName);
|
||||
U_ASSERT(baseName==nullptr || baseName==fullName);
|
||||
const char *atPtr = uprv_strchr(fullName, '@');
|
||||
const char *eqPtr = uprv_strchr(fullName, '=');
|
||||
if (atPtr && eqPtr && atPtr < eqPtr) {
|
||||
// Key words exist.
|
||||
int32_t baseNameLength = (int32_t)(atPtr - fullName);
|
||||
baseName = (char *)uprv_malloc(baseNameLength + 1);
|
||||
if (baseName == NULL) {
|
||||
if (baseName == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -2012,7 +2012,7 @@ Locale::setToBogus() {
|
|||
if((baseName != fullName) && (baseName != fullNameBuffer)) {
|
||||
uprv_free(baseName);
|
||||
}
|
||||
baseName = NULL;
|
||||
baseName = nullptr;
|
||||
if(fullName != fullNameBuffer) {
|
||||
uprv_free(fullName);
|
||||
fullName = fullNameBuffer;
|
||||
|
@ -2030,12 +2030,12 @@ Locale::getDefault()
|
|||
{
|
||||
{
|
||||
Mutex lock(&gDefaultLocaleMutex);
|
||||
if (gDefaultLocale != NULL) {
|
||||
if (gDefaultLocale != nullptr) {
|
||||
return *gDefaultLocale;
|
||||
}
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
return *locale_set_default_internal(NULL, status);
|
||||
return *locale_set_default_internal(nullptr, status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2244,134 +2244,134 @@ void Locale::setFromPOSIXID(const char *posixID)
|
|||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getRoot(void)
|
||||
Locale::getRoot()
|
||||
{
|
||||
return getLocale(eROOT);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getEnglish(void)
|
||||
Locale::getEnglish()
|
||||
{
|
||||
return getLocale(eENGLISH);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getFrench(void)
|
||||
Locale::getFrench()
|
||||
{
|
||||
return getLocale(eFRENCH);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getGerman(void)
|
||||
Locale::getGerman()
|
||||
{
|
||||
return getLocale(eGERMAN);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getItalian(void)
|
||||
Locale::getItalian()
|
||||
{
|
||||
return getLocale(eITALIAN);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getJapanese(void)
|
||||
Locale::getJapanese()
|
||||
{
|
||||
return getLocale(eJAPANESE);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getKorean(void)
|
||||
Locale::getKorean()
|
||||
{
|
||||
return getLocale(eKOREAN);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getChinese(void)
|
||||
Locale::getChinese()
|
||||
{
|
||||
return getLocale(eCHINESE);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getSimplifiedChinese(void)
|
||||
Locale::getSimplifiedChinese()
|
||||
{
|
||||
return getLocale(eCHINA);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getTraditionalChinese(void)
|
||||
Locale::getTraditionalChinese()
|
||||
{
|
||||
return getLocale(eTAIWAN);
|
||||
}
|
||||
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getFrance(void)
|
||||
Locale::getFrance()
|
||||
{
|
||||
return getLocale(eFRANCE);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getGermany(void)
|
||||
Locale::getGermany()
|
||||
{
|
||||
return getLocale(eGERMANY);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getItaly(void)
|
||||
Locale::getItaly()
|
||||
{
|
||||
return getLocale(eITALY);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getJapan(void)
|
||||
Locale::getJapan()
|
||||
{
|
||||
return getLocale(eJAPAN);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getKorea(void)
|
||||
Locale::getKorea()
|
||||
{
|
||||
return getLocale(eKOREA);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getChina(void)
|
||||
Locale::getChina()
|
||||
{
|
||||
return getLocale(eCHINA);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getPRC(void)
|
||||
Locale::getPRC()
|
||||
{
|
||||
return getLocale(eCHINA);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getTaiwan(void)
|
||||
Locale::getTaiwan()
|
||||
{
|
||||
return getLocale(eTAIWAN);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getUK(void)
|
||||
Locale::getUK()
|
||||
{
|
||||
return getLocale(eUK);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getUS(void)
|
||||
Locale::getUS()
|
||||
{
|
||||
return getLocale(eUS);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getCanada(void)
|
||||
Locale::getCanada()
|
||||
{
|
||||
return getLocale(eCANADA);
|
||||
}
|
||||
|
||||
const Locale & U_EXPORT2
|
||||
Locale::getCanadaFrench(void)
|
||||
Locale::getCanadaFrench()
|
||||
{
|
||||
return getLocale(eCANADA_FRENCH);
|
||||
}
|
||||
|
@ -2381,12 +2381,12 @@ Locale::getLocale(int locid)
|
|||
{
|
||||
Locale *localeCache = getLocaleCache();
|
||||
U_ASSERT((locid < eMAX_LOCALES)&&(locid>=0));
|
||||
if (localeCache == NULL) {
|
||||
if (localeCache == nullptr) {
|
||||
// Failure allocating the locale cache.
|
||||
// The best we can do is return a NULL reference.
|
||||
// The best we can do is return a nullptr reference.
|
||||
locid = 0;
|
||||
}
|
||||
return localeCache[locid]; /*operating on NULL*/
|
||||
return localeCache[locid]; /*operating on nullptr*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2394,7 +2394,7 @@ This function is defined this way in order to get around static
|
|||
initialization and static destruction.
|
||||
*/
|
||||
Locale *
|
||||
Locale::getLocaleCache(void)
|
||||
Locale::getLocaleCache()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
umtx_initOnce(gLocaleCacheInitOnce, locale_init, status);
|
||||
|
@ -2410,17 +2410,17 @@ private:
|
|||
static const char fgClassID;/* Warning this is used beyond the typical RTTI usage. */
|
||||
|
||||
public:
|
||||
static UClassID U_EXPORT2 getStaticClassID(void) { return (UClassID)&fgClassID; }
|
||||
virtual UClassID getDynamicClassID(void) const override { return getStaticClassID(); }
|
||||
static UClassID U_EXPORT2 getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
virtual UClassID getDynamicClassID() const override { return getStaticClassID(); }
|
||||
public:
|
||||
KeywordEnumeration(const char *keys, int32_t keywordLen, int32_t currentIndex, UErrorCode &status)
|
||||
: keywords((char *)&fgClassID), current((char *)&fgClassID), length(0) {
|
||||
if(U_SUCCESS(status) && keywordLen != 0) {
|
||||
if(keys == NULL || keywordLen < 0) {
|
||||
if(keys == nullptr || keywordLen < 0) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
} else {
|
||||
keywords = (char *)uprv_malloc(keywordLen+1);
|
||||
if (keywords == NULL) {
|
||||
if (keywords == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
else {
|
||||
|
@ -2458,14 +2458,14 @@ public:
|
|||
result = current;
|
||||
len = (int32_t)uprv_strlen(current);
|
||||
current += len+1;
|
||||
if(resultLength != NULL) {
|
||||
if(resultLength != nullptr) {
|
||||
*resultLength = len;
|
||||
}
|
||||
} else {
|
||||
if(resultLength != NULL) {
|
||||
if(resultLength != nullptr) {
|
||||
*resultLength = 0;
|
||||
}
|
||||
result = NULL;
|
||||
result = nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -2518,7 +2518,7 @@ UnicodeKeywordEnumeration::~UnicodeKeywordEnumeration() = default;
|
|||
StringEnumeration *
|
||||
Locale::createKeywords(UErrorCode &status) const
|
||||
{
|
||||
StringEnumeration *result = NULL;
|
||||
StringEnumeration *result = nullptr;
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return result;
|
||||
|
@ -2547,7 +2547,7 @@ Locale::createKeywords(UErrorCode &status) const
|
|||
StringEnumeration *
|
||||
Locale::createUnicodeKeywords(UErrorCode &status) const
|
||||
{
|
||||
StringEnumeration *result = NULL;
|
||||
StringEnumeration *result = nullptr;
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return result;
|
||||
|
|
|
@ -54,23 +54,23 @@ findLikelySubtags(const char* localeID,
|
|||
char* buffer,
|
||||
int32_t bufferLength,
|
||||
UErrorCode* err) {
|
||||
const char* result = NULL;
|
||||
const char* result = nullptr;
|
||||
|
||||
if (!U_FAILURE(*err)) {
|
||||
int32_t resLen = 0;
|
||||
const UChar* s = NULL;
|
||||
const char16_t* s = nullptr;
|
||||
UErrorCode tmpErr = U_ZERO_ERROR;
|
||||
icu::LocalUResourceBundlePointer subtags(ures_openDirect(NULL, "likelySubtags", &tmpErr));
|
||||
icu::LocalUResourceBundlePointer subtags(ures_openDirect(nullptr, "likelySubtags", &tmpErr));
|
||||
if (U_SUCCESS(tmpErr)) {
|
||||
icu::CharString und;
|
||||
if (localeID != NULL) {
|
||||
if (localeID != nullptr) {
|
||||
if (*localeID == '\0') {
|
||||
localeID = unknownLanguage;
|
||||
} else if (*localeID == '_') {
|
||||
und.append(unknownLanguage, *err);
|
||||
und.append(localeID, *err);
|
||||
if (U_FAILURE(*err)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
localeID = und.data();
|
||||
}
|
||||
|
@ -140,12 +140,12 @@ appendTag(
|
|||
|
||||
/**
|
||||
* Create a tag string from the supplied parameters. The lang, script and region
|
||||
* parameters may be NULL pointers. If they are, their corresponding length parameters
|
||||
* parameters may be nullptr pointers. If they are, their corresponding length parameters
|
||||
* must be less than or equal to 0.
|
||||
*
|
||||
* If any of the language, script or region parameters are empty, and the alternateTags
|
||||
* parameter is not NULL, it will be parsed for potential language, script and region tags
|
||||
* to be used when constructing the new tag. If the alternateTags parameter is NULL, or
|
||||
* parameter is not nullptr, it will be parsed for potential language, script and region tags
|
||||
* to be used when constructing the new tag. If the alternateTags parameter is nullptr, or
|
||||
* it contains no language tag, the default tag for the unknown language is used.
|
||||
*
|
||||
* If the length of the new string exceeds the capacity of the output buffer,
|
||||
|
@ -211,7 +211,7 @@ createTagStringWithAlternates(
|
|||
&tagLength,
|
||||
/*withSeparator=*/false);
|
||||
}
|
||||
else if (alternateTags == NULL) {
|
||||
else if (alternateTags == nullptr) {
|
||||
/*
|
||||
* Use the empty string for an unknown language, if
|
||||
* we found no language.
|
||||
|
@ -258,7 +258,7 @@ createTagStringWithAlternates(
|
|||
&tagLength,
|
||||
/*withSeparator=*/true);
|
||||
}
|
||||
else if (alternateTags != NULL) {
|
||||
else if (alternateTags != nullptr) {
|
||||
/*
|
||||
* Parse the alternateTags string for the script.
|
||||
*/
|
||||
|
@ -295,7 +295,7 @@ createTagStringWithAlternates(
|
|||
|
||||
regionAppended = true;
|
||||
}
|
||||
else if (alternateTags != NULL) {
|
||||
else if (alternateTags != nullptr) {
|
||||
/*
|
||||
* Parse the alternateTags string for the region.
|
||||
*/
|
||||
|
@ -362,7 +362,7 @@ error:
|
|||
|
||||
/**
|
||||
* Create a tag string from the supplied parameters. The lang, script and region
|
||||
* parameters may be NULL pointers. If they are, their corresponding length parameters
|
||||
* parameters may be nullptr pointers. If they are, their corresponding length parameters
|
||||
* must be less than or equal to 0. If the lang parameter is an empty string, the
|
||||
* default value for an unknown language is written to the output buffer.
|
||||
*
|
||||
|
@ -406,7 +406,7 @@ createTagString(
|
|||
regionLength,
|
||||
trailing,
|
||||
trailingLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
sink,
|
||||
err);
|
||||
}
|
||||
|
@ -454,13 +454,13 @@ parseTagString(
|
|||
int32_t subtagLength = 0;
|
||||
|
||||
if(U_FAILURE(*err) ||
|
||||
localeID == NULL ||
|
||||
lang == NULL ||
|
||||
langLength == NULL ||
|
||||
script == NULL ||
|
||||
scriptLength == NULL ||
|
||||
region == NULL ||
|
||||
regionLength == NULL) {
|
||||
localeID == nullptr ||
|
||||
lang == nullptr ||
|
||||
langLength == nullptr ||
|
||||
script == nullptr ||
|
||||
scriptLength == nullptr ||
|
||||
region == nullptr ||
|
||||
regionLength == nullptr) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ createLikelySubtagsString(
|
|||
**/
|
||||
if (scriptLength > 0 && regionLength > 0) {
|
||||
|
||||
const char* likelySubtags = NULL;
|
||||
const char* likelySubtags = nullptr;
|
||||
|
||||
icu::CharString tagBuffer;
|
||||
{
|
||||
|
@ -587,7 +587,7 @@ createLikelySubtagsString(
|
|||
scriptLength,
|
||||
region,
|
||||
regionLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
sink,
|
||||
err);
|
||||
|
@ -606,16 +606,16 @@ createLikelySubtagsString(
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (likelySubtags != NULL) {
|
||||
if (likelySubtags != nullptr) {
|
||||
/* Always use the language tag from the
|
||||
maximal string, since it may be more
|
||||
specific than the one provided. */
|
||||
createTagStringWithAlternates(
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
variants,
|
||||
variantsLength,
|
||||
|
@ -631,7 +631,7 @@ createLikelySubtagsString(
|
|||
**/
|
||||
if (scriptLength > 0) {
|
||||
|
||||
const char* likelySubtags = NULL;
|
||||
const char* likelySubtags = nullptr;
|
||||
|
||||
icu::CharString tagBuffer;
|
||||
{
|
||||
|
@ -641,9 +641,9 @@ createLikelySubtagsString(
|
|||
langLength,
|
||||
script,
|
||||
scriptLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
sink,
|
||||
err);
|
||||
|
@ -662,14 +662,14 @@ createLikelySubtagsString(
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (likelySubtags != NULL) {
|
||||
if (likelySubtags != nullptr) {
|
||||
/* Always use the language tag from the
|
||||
maximal string, since it may be more
|
||||
specific than the one provided. */
|
||||
createTagStringWithAlternates(
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
region,
|
||||
regionLength,
|
||||
|
@ -687,7 +687,7 @@ createLikelySubtagsString(
|
|||
**/
|
||||
if (regionLength > 0) {
|
||||
|
||||
const char* likelySubtags = NULL;
|
||||
const char* likelySubtags = nullptr;
|
||||
|
||||
icu::CharString tagBuffer;
|
||||
{
|
||||
|
@ -695,11 +695,11 @@ createLikelySubtagsString(
|
|||
createTagString(
|
||||
lang,
|
||||
langLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
region,
|
||||
regionLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
sink,
|
||||
err);
|
||||
|
@ -718,16 +718,16 @@ createLikelySubtagsString(
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (likelySubtags != NULL) {
|
||||
if (likelySubtags != nullptr) {
|
||||
/* Always use the language tag from the
|
||||
maximal string, since it may be more
|
||||
specific than the one provided. */
|
||||
createTagStringWithAlternates(
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
script,
|
||||
scriptLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
variants,
|
||||
variantsLength,
|
||||
|
@ -742,7 +742,7 @@ createLikelySubtagsString(
|
|||
* Finally, try just the language.
|
||||
**/
|
||||
{
|
||||
const char* likelySubtags = NULL;
|
||||
const char* likelySubtags = nullptr;
|
||||
|
||||
icu::CharString tagBuffer;
|
||||
{
|
||||
|
@ -750,11 +750,11 @@ createLikelySubtagsString(
|
|||
createTagString(
|
||||
lang,
|
||||
langLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
sink,
|
||||
err);
|
||||
|
@ -773,12 +773,12 @@ createLikelySubtagsString(
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (likelySubtags != NULL) {
|
||||
if (likelySubtags != nullptr) {
|
||||
/* Always use the language tag from the
|
||||
maximal string, since it may be more
|
||||
specific than the one provided. */
|
||||
createTagStringWithAlternates(
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
script,
|
||||
scriptLength,
|
||||
|
@ -841,7 +841,7 @@ _uloc_addLikelySubtags(const char* localeID,
|
|||
if(U_FAILURE(*err)) {
|
||||
goto error;
|
||||
}
|
||||
if (localeID == NULL) {
|
||||
if (localeID == nullptr) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -930,7 +930,7 @@ _uloc_minimizeSubtags(const char* localeID,
|
|||
if(U_FAILURE(*err)) {
|
||||
goto error;
|
||||
}
|
||||
else if (localeID == NULL) {
|
||||
else if (localeID == nullptr) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -974,7 +974,7 @@ _uloc_minimizeSubtags(const char* localeID,
|
|||
scriptLength,
|
||||
region,
|
||||
regionLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
baseSink,
|
||||
err);
|
||||
|
@ -1031,11 +1031,11 @@ _uloc_minimizeSubtags(const char* localeID,
|
|||
createLikelySubtagsString(
|
||||
lang,
|
||||
langLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
tagSink,
|
||||
err);
|
||||
|
@ -1053,9 +1053,9 @@ _uloc_minimizeSubtags(const char* localeID,
|
|||
createTagString(
|
||||
lang,
|
||||
langLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
trailing,
|
||||
trailingLength,
|
||||
|
@ -1076,11 +1076,11 @@ _uloc_minimizeSubtags(const char* localeID,
|
|||
createLikelySubtagsString(
|
||||
lang,
|
||||
langLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
region,
|
||||
regionLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
tagSink,
|
||||
err);
|
||||
|
@ -1098,7 +1098,7 @@ _uloc_minimizeSubtags(const char* localeID,
|
|||
createTagString(
|
||||
lang,
|
||||
langLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
region,
|
||||
regionLength,
|
||||
|
@ -1124,9 +1124,9 @@ _uloc_minimizeSubtags(const char* localeID,
|
|||
langLength,
|
||||
script,
|
||||
scriptLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
tagSink,
|
||||
err);
|
||||
|
@ -1146,7 +1146,7 @@ _uloc_minimizeSubtags(const char* localeID,
|
|||
langLength,
|
||||
script,
|
||||
scriptLength,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
trailing,
|
||||
trailingLength,
|
||||
|
@ -1324,7 +1324,7 @@ uloc_isRightToLeft(const char *locale) {
|
|||
}
|
||||
if (langLength > 0) {
|
||||
const char* langPtr = uprv_strstr(LANG_DIR_STRING, lang);
|
||||
if (langPtr != NULL) {
|
||||
if (langPtr != nullptr) {
|
||||
switch (langPtr[langLength]) {
|
||||
case '-': return false;
|
||||
case '+': return true;
|
||||
|
|
|
@ -1054,7 +1054,7 @@ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UEr
|
|||
uint16_t langID;
|
||||
uint32_t localeIndex;
|
||||
UBool bLookup = true;
|
||||
const char *pPosixID = NULL;
|
||||
const char *pPosixID = nullptr;
|
||||
|
||||
#if U_PLATFORM_HAS_WIN32_API && UCONFIG_USE_WINDOWS_LCID_MAPPING_API
|
||||
static_assert(ULOC_FULLNAME_CAPACITY > LOCALE_NAME_MAX_LENGTH, "Windows locale names have smaller length than ICU locale names.");
|
||||
|
@ -1110,7 +1110,7 @@ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UEr
|
|||
#endif
|
||||
|
||||
if (bLookup) {
|
||||
const char *pCandidate = NULL;
|
||||
const char *pCandidate = nullptr;
|
||||
langID = LANGUAGE_LCID(hostid);
|
||||
|
||||
for (localeIndex = 0; localeIndex < gLocaleCount; localeIndex++) {
|
||||
|
@ -1123,7 +1123,7 @@ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UEr
|
|||
/* On Windows, when locale name has a variant, we still look up the hardcoded table.
|
||||
If a match in the hardcoded table is longer than the Windows locale name without
|
||||
variant, we use the one as the result */
|
||||
if (pCandidate && (pPosixID == NULL || uprv_strlen(pCandidate) > uprv_strlen(pPosixID))) {
|
||||
if (pCandidate && (pPosixID == nullptr || uprv_strlen(pCandidate) > uprv_strlen(pPosixID))) {
|
||||
pPosixID = pCandidate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* default locale because that would result in a mix of languages that is
|
||||
* unpredictable to the programmer and most likely useless.
|
||||
*/
|
||||
U_CAPI const UChar * U_EXPORT2
|
||||
U_CAPI const char16_t * U_EXPORT2
|
||||
uloc_getTableStringWithFallback(const char *path, const char *locale,
|
||||
const char *tableKey, const char *subTableKey,
|
||||
const char *itemKey,
|
||||
|
@ -49,7 +49,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
|
|||
UErrorCode *pErrorCode)
|
||||
{
|
||||
/* char localeBuffer[ULOC_FULLNAME_CAPACITY*4];*/
|
||||
const UChar *item=NULL;
|
||||
const char16_t *item=nullptr;
|
||||
UErrorCode errorCode;
|
||||
char explicitFallbackName[ULOC_FULLNAME_CAPACITY] = {0};
|
||||
|
||||
|
@ -63,7 +63,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
|
|||
if(U_FAILURE(errorCode)) {
|
||||
/* total failure, not even root could be opened */
|
||||
*pErrorCode=errorCode;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else if(errorCode==U_USING_DEFAULT_WARNING ||
|
||||
(errorCode==U_USING_FALLBACK_WARNING && *pErrorCode!=U_USING_DEFAULT_WARNING)
|
||||
) {
|
||||
|
@ -76,7 +76,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
|
|||
icu::StackUResourceBundle subTable;
|
||||
ures_getByKeyWithFallback(rb.getAlias(), tableKey, table.getAlias(), &errorCode);
|
||||
|
||||
if (subTableKey != NULL) {
|
||||
if (subTableKey != nullptr) {
|
||||
/*
|
||||
ures_getByKeyWithFallback(table.getAlias(), subTableKey, subTable.getAlias(), &errorCode);
|
||||
item = ures_getStringByKeyWithFallback(subTable.getAlias(), itemKey, pLength, &errorCode);
|
||||
|
@ -91,7 +91,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
|
|||
if(U_SUCCESS(errorCode)){
|
||||
item = ures_getStringByKeyWithFallback(table.getAlias(), itemKey, pLength, &errorCode);
|
||||
if(U_FAILURE(errorCode)){
|
||||
const char* replacement = NULL;
|
||||
const char* replacement = nullptr;
|
||||
*pErrorCode = errorCode; /*save the errorCode*/
|
||||
errorCode = U_ZERO_ERROR;
|
||||
/* may be a deprecated code */
|
||||
|
@ -101,7 +101,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
|
|||
replacement = uloc_getCurrentLanguageID(itemKey);
|
||||
}
|
||||
/*pointer comparison is ok since uloc_getCurrentCountryID & uloc_getCurrentLanguageID return the key itself is replacement is not found*/
|
||||
if(replacement!=NULL && itemKey != replacement){
|
||||
if(replacement!=nullptr && itemKey != replacement){
|
||||
item = ures_getStringByKeyWithFallback(table.getAlias(), replacement, pLength, &errorCode);
|
||||
if(U_SUCCESS(errorCode)){
|
||||
*pErrorCode = errorCode;
|
||||
|
@ -117,7 +117,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
|
|||
|
||||
/* still can't figure out ?.. try the fallback mechanism */
|
||||
int32_t len = 0;
|
||||
const UChar* fallbackLocale = NULL;
|
||||
const char16_t* fallbackLocale = nullptr;
|
||||
*pErrorCode = errorCode;
|
||||
errorCode = U_ZERO_ERROR;
|
||||
|
||||
|
@ -162,12 +162,12 @@ _uloc_getOrientationHelper(const char* localeId,
|
|||
uloc_canonicalize(localeId, localeBuffer, sizeof(localeBuffer), status);
|
||||
|
||||
if (!U_FAILURE(*status)) {
|
||||
const UChar* const value =
|
||||
const char16_t* const value =
|
||||
uloc_getTableStringWithFallback(
|
||||
NULL,
|
||||
nullptr,
|
||||
localeBuffer,
|
||||
"layout",
|
||||
NULL,
|
||||
nullptr,
|
||||
key,
|
||||
&length,
|
||||
status);
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
|
||||
// see LocaleUtility::getAvailableLocaleNames
|
||||
static icu::UInitOnce LocaleUtilityInitOnce {};
|
||||
static icu::Hashtable * LocaleUtility_cache = NULL;
|
||||
static icu::Hashtable * LocaleUtility_cache = nullptr;
|
||||
|
||||
#define UNDERSCORE_CHAR ((UChar)0x005f)
|
||||
#define AT_SIGN_CHAR ((UChar)64)
|
||||
#define PERIOD_CHAR ((UChar)46)
|
||||
#define UNDERSCORE_CHAR ((char16_t)0x005f)
|
||||
#define AT_SIGN_CHAR ((char16_t)64)
|
||||
#define PERIOD_CHAR ((char16_t)46)
|
||||
|
||||
/*
|
||||
******************************************************************
|
||||
|
@ -36,10 +36,10 @@ static icu::Hashtable * LocaleUtility_cache = NULL;
|
|||
* Release all static memory held by Locale Utility.
|
||||
*/
|
||||
U_CDECL_BEGIN
|
||||
static UBool U_CALLCONV service_cleanup(void) {
|
||||
static UBool U_CALLCONV service_cleanup() {
|
||||
if (LocaleUtility_cache) {
|
||||
delete LocaleUtility_cache;
|
||||
LocaleUtility_cache = NULL;
|
||||
LocaleUtility_cache = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -47,15 +47,15 @@ static UBool U_CALLCONV service_cleanup(void) {
|
|||
|
||||
static void U_CALLCONV locale_utility_init(UErrorCode &status) {
|
||||
using namespace icu;
|
||||
U_ASSERT(LocaleUtility_cache == NULL);
|
||||
U_ASSERT(LocaleUtility_cache == nullptr);
|
||||
ucln_common_registerCleanup(UCLN_COMMON_SERVICE, service_cleanup);
|
||||
LocaleUtility_cache = new Hashtable(status);
|
||||
if (U_FAILURE(status)) {
|
||||
delete LocaleUtility_cache;
|
||||
LocaleUtility_cache = NULL;
|
||||
LocaleUtility_cache = nullptr;
|
||||
return;
|
||||
}
|
||||
if (LocaleUtility_cache == NULL) {
|
||||
if (LocaleUtility_cache == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ U_NAMESPACE_BEGIN
|
|||
UnicodeString&
|
||||
LocaleUtility::canonicalLocaleString(const UnicodeString* id, UnicodeString& result)
|
||||
{
|
||||
if (id == NULL) {
|
||||
if (id == nullptr) {
|
||||
result.setToBogus();
|
||||
} else {
|
||||
// Fix case only (no other changes) up to the first '@' or '.' or
|
||||
|
@ -94,14 +94,14 @@ LocaleUtility::canonicalLocaleString(const UnicodeString* id, UnicodeString& res
|
|||
n = end;
|
||||
}
|
||||
for (; i < n; ++i) {
|
||||
UChar c = result.charAt(i);
|
||||
char16_t c = result.charAt(i);
|
||||
if (c >= 0x0041 && c <= 0x005a) {
|
||||
c += 0x20;
|
||||
result.setCharAt(i, c);
|
||||
}
|
||||
}
|
||||
for (n = end; i < n; ++i) {
|
||||
UChar c = result.charAt(i);
|
||||
char16_t c = result.charAt(i);
|
||||
if (c >= 0x0061 && c <= 0x007a) {
|
||||
c -= 0x20;
|
||||
result.setCharAt(i, c);
|
||||
|
@ -112,7 +112,7 @@ LocaleUtility::canonicalLocaleString(const UnicodeString* id, UnicodeString& res
|
|||
|
||||
#if 0
|
||||
// This code does a proper full level 2 canonicalization of id.
|
||||
// It's nasty to go from UChar to char to char to UChar -- but
|
||||
// It's nasty to go from char16_t to char to char to char16_t -- but
|
||||
// that's what you have to do to use the uloc_canonicalize
|
||||
// function on UnicodeStrings.
|
||||
|
||||
|
@ -172,7 +172,7 @@ LocaleUtility::initLocaleFromName(const UnicodeString& id, Locale& result)
|
|||
int32_t prev, i;
|
||||
prev = 0;
|
||||
for(;;) {
|
||||
i = id.indexOf((UChar)0x40, prev);
|
||||
i = id.indexOf((char16_t)0x40, prev);
|
||||
if(i < 0) {
|
||||
// no @ between prev and the rest of the string
|
||||
id.extract(prev, INT32_MAX, buffer + prev, BUFLEN - prev, US_INV);
|
||||
|
@ -214,45 +214,45 @@ LocaleUtility::getAvailableLocaleNames(const UnicodeString& bundleID)
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
umtx_initOnce(LocaleUtilityInitOnce, locale_utility_init, status);
|
||||
Hashtable *cache = LocaleUtility_cache;
|
||||
if (cache == NULL) {
|
||||
if (cache == nullptr) {
|
||||
// Catastrophic failure.
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hashtable* htp;
|
||||
umtx_lock(NULL);
|
||||
umtx_lock(nullptr);
|
||||
htp = (Hashtable*) cache->get(bundleID);
|
||||
umtx_unlock(NULL);
|
||||
umtx_unlock(nullptr);
|
||||
|
||||
if (htp == NULL) {
|
||||
if (htp == nullptr) {
|
||||
htp = new Hashtable(status);
|
||||
if (htp && U_SUCCESS(status)) {
|
||||
CharString cbundleID;
|
||||
cbundleID.appendInvariantChars(bundleID, status);
|
||||
const char* path = cbundleID.isEmpty() ? NULL : cbundleID.data();
|
||||
const char* path = cbundleID.isEmpty() ? nullptr : cbundleID.data();
|
||||
icu::LocalUEnumerationPointer uenum(ures_openAvailableLocales(path, &status));
|
||||
for (;;) {
|
||||
const UChar* id = uenum_unext(uenum.getAlias(), NULL, &status);
|
||||
if (id == NULL) {
|
||||
const char16_t* id = uenum_unext(uenum.getAlias(), nullptr, &status);
|
||||
if (id == nullptr) {
|
||||
break;
|
||||
}
|
||||
htp->put(UnicodeString(id), (void*)htp, status);
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
delete htp;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
umtx_lock(NULL);
|
||||
umtx_lock(nullptr);
|
||||
Hashtable *t = static_cast<Hashtable *>(cache->get(bundleID));
|
||||
if (t != NULL) {
|
||||
if (t != nullptr) {
|
||||
// Another thread raced through this code, creating the cache entry first.
|
||||
// Discard ours and return theirs.
|
||||
umtx_unlock(NULL);
|
||||
umtx_unlock(nullptr);
|
||||
delete htp;
|
||||
htp = t;
|
||||
} else {
|
||||
cache->put(bundleID, (void*)htp, status);
|
||||
umtx_unlock(NULL);
|
||||
umtx_unlock(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ LSR::LSR(char prefix, const char *lang, const char *scr, const char *r, int32_t
|
|||
}
|
||||
}
|
||||
|
||||
LSR::LSR(LSR &&other) U_NOEXCEPT :
|
||||
LSR::LSR(LSR &&other) noexcept :
|
||||
language(other.language), script(other.script), region(other.region), owned(other.owned),
|
||||
regionIndex(other.regionIndex), flags(other.flags),
|
||||
hashCode(other.hashCode) {
|
||||
|
@ -46,7 +46,7 @@ void LSR::deleteOwned() {
|
|||
uprv_free(owned);
|
||||
}
|
||||
|
||||
LSR &LSR::operator=(LSR &&other) U_NOEXCEPT {
|
||||
LSR &LSR::operator=(LSR &&other) noexcept {
|
||||
this->~LSR();
|
||||
language = other.language;
|
||||
script = other.script;
|
||||
|
|
|
@ -45,7 +45,7 @@ struct LSR final : public UMemory {
|
|||
*/
|
||||
LSR(char prefix, const char *lang, const char *scr, const char *r, int32_t f,
|
||||
UErrorCode &errorCode);
|
||||
LSR(LSR &&other) U_NOEXCEPT;
|
||||
LSR(LSR &&other) noexcept;
|
||||
LSR(const LSR &other) = delete;
|
||||
inline ~LSR() {
|
||||
// Pure inline code for almost all instances.
|
||||
|
@ -54,7 +54,7 @@ struct LSR final : public UMemory {
|
|||
}
|
||||
}
|
||||
|
||||
LSR &operator=(LSR &&other) U_NOEXCEPT;
|
||||
LSR &operator=(LSR &&other) noexcept;
|
||||
LSR &operator=(const LSR &other) = delete;
|
||||
|
||||
/**
|
||||
|
|
|
@ -361,7 +361,7 @@ struct LSTMData : public UMemory {
|
|||
~LSTMData();
|
||||
UHashtable* fDict;
|
||||
EmbeddingType fType;
|
||||
const UChar* fName;
|
||||
const char16_t* fName;
|
||||
ConstArray2D fEmbedding;
|
||||
ConstArray2D fForwardW;
|
||||
ConstArray2D fForwardU;
|
||||
|
@ -394,7 +394,7 @@ LSTMData::LSTMData(UResourceBundle* rb, UErrorCode &status)
|
|||
ures_getByKey(rb, "hunits", nullptr, &status));
|
||||
if (U_FAILURE(status)) return;
|
||||
int32_t hunits = ures_getInt(hunits_res.getAlias(), &status);
|
||||
const UChar* type = ures_getStringByKey(rb, "type", nullptr, &status);
|
||||
const char16_t* type = ures_getStringByKey(rb, "type", nullptr, &status);
|
||||
if (U_FAILURE(status)) return;
|
||||
if (u_strCompare(type, -1, u"codepoints", -1, false) == 0) {
|
||||
fType = CODE_POINTS;
|
||||
|
@ -419,7 +419,7 @@ LSTMData::LSTMData(UResourceBundle* rb, UErrorCode &status)
|
|||
int32_t stringLength;
|
||||
for (int32_t idx = 0; idx < num_index; idx++) {
|
||||
stringArray.getValue(idx, value);
|
||||
const UChar* str = value.getString(stringLength, status);
|
||||
const char16_t* str = value.getString(stringLength, status);
|
||||
uhash_putiAllowZero(fDict, (void*)str, idx, &status);
|
||||
if (U_FAILURE(status)) return;
|
||||
#ifdef LSTM_VECTORIZER_DEBUG
|
||||
|
@ -477,7 +477,7 @@ public:
|
|||
UVector32 &offsets, UVector32 &indices,
|
||||
UErrorCode &status) const = 0;
|
||||
protected:
|
||||
int32_t stringToIndex(const UChar* str) const {
|
||||
int32_t stringToIndex(const char16_t* str) const {
|
||||
UBool found = false;
|
||||
int32_t ret = uhash_getiAndFound(fDict, (const void*)str, &found);
|
||||
if (!found) {
|
||||
|
@ -524,13 +524,13 @@ void CodePointsVectorizer::vectorize(
|
|||
if (U_FAILURE(status)) return;
|
||||
utext_setNativeIndex(text, startPos);
|
||||
int32_t current;
|
||||
UChar str[2] = {0, 0};
|
||||
char16_t str[2] = {0, 0};
|
||||
while (U_SUCCESS(status) &&
|
||||
(current = (int32_t)utext_getNativeIndex(text)) < endPos) {
|
||||
// Since the LSTMBreakEngine is currently only accept chars in BMP,
|
||||
// we can ignore the possibility of hitting supplementary code
|
||||
// point.
|
||||
str[0] = (UChar) utext_next32(text);
|
||||
str[0] = (char16_t) utext_next32(text);
|
||||
U_ASSERT(!U_IS_SURROGATE(str[0]));
|
||||
offsets.addElement(current, status);
|
||||
indices.addElement(stringToIndex(str), status);
|
||||
|
@ -576,7 +576,7 @@ void GraphemeClusterVectorizer::vectorize(
|
|||
}
|
||||
int32_t last = startPos;
|
||||
int32_t current = startPos;
|
||||
UChar str[MAX_GRAPHEME_CLSTER_LENGTH];
|
||||
char16_t str[MAX_GRAPHEME_CLSTER_LENGTH];
|
||||
while ((current = graphemeIter->next()) != BreakIterator::DONE) {
|
||||
if (current >= endPos) {
|
||||
break;
|
||||
|
@ -777,7 +777,7 @@ LSTMBreakEngine::~LSTMBreakEngine() {
|
|||
delete fVectorizer;
|
||||
}
|
||||
|
||||
const UChar* LSTMBreakEngine::name() const {
|
||||
const char16_t* LSTMBreakEngine::name() const {
|
||||
return fData->fName;
|
||||
}
|
||||
|
||||
|
@ -846,7 +846,7 @@ U_CAPI void U_EXPORT2 DeleteLSTMData(const LSTMData* data)
|
|||
delete data;
|
||||
}
|
||||
|
||||
U_CAPI const UChar* U_EXPORT2 LSTMDataName(const LSTMData* data)
|
||||
U_CAPI const char16_t* U_EXPORT2 LSTMDataName(const LSTMData* data)
|
||||
{
|
||||
return data->fName;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
*/
|
||||
virtual ~LSTMBreakEngine();
|
||||
|
||||
virtual const UChar* name() const;
|
||||
virtual const char16_t* name() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -79,7 +79,7 @@ U_CAPI const LSTMData* U_EXPORT2 CreateLSTMDataForScript(
|
|||
UScriptCode script, UErrorCode& status);
|
||||
|
||||
U_CAPI void U_EXPORT2 DeleteLSTMData(const LSTMData* data);
|
||||
U_CAPI const UChar* U_EXPORT2 LSTMDataName(const LSTMData* data);
|
||||
U_CAPI const char16_t* U_EXPORT2 LSTMDataName(const LSTMData* data);
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
|
|
|
@ -32,56 +32,56 @@ U_NAMESPACE_BEGIN
|
|||
|
||||
// Unicode character/code point constants ---------------------------------- ***
|
||||
|
||||
static const UChar u_pound=0x23;
|
||||
static const UChar u_apos=0x27;
|
||||
static const UChar u_plus=0x2B;
|
||||
static const UChar u_comma=0x2C;
|
||||
static const UChar u_minus=0x2D;
|
||||
static const UChar u_dot=0x2E;
|
||||
static const UChar u_colon=0x3A;
|
||||
static const UChar u_lessThan=0x3C;
|
||||
static const UChar u_equal=0x3D;
|
||||
static const UChar u_A=0x41;
|
||||
static const UChar u_C=0x43;
|
||||
static const UChar u_D=0x44;
|
||||
static const UChar u_E=0x45;
|
||||
static const UChar u_H=0x48;
|
||||
static const UChar u_I=0x49;
|
||||
static const UChar u_L=0x4C;
|
||||
static const UChar u_N=0x4E;
|
||||
static const UChar u_O=0x4F;
|
||||
static const UChar u_P=0x50;
|
||||
static const UChar u_R=0x52;
|
||||
static const UChar u_S=0x53;
|
||||
static const UChar u_T=0x54;
|
||||
static const UChar u_U=0x55;
|
||||
static const UChar u_Z=0x5A;
|
||||
static const UChar u_a=0x61;
|
||||
static const UChar u_c=0x63;
|
||||
static const UChar u_d=0x64;
|
||||
static const UChar u_e=0x65;
|
||||
static const UChar u_f=0x66;
|
||||
static const UChar u_h=0x68;
|
||||
static const UChar u_i=0x69;
|
||||
static const UChar u_l=0x6C;
|
||||
static const UChar u_n=0x6E;
|
||||
static const UChar u_o=0x6F;
|
||||
static const UChar u_p=0x70;
|
||||
static const UChar u_r=0x72;
|
||||
static const UChar u_s=0x73;
|
||||
static const UChar u_t=0x74;
|
||||
static const UChar u_u=0x75;
|
||||
static const UChar u_z=0x7A;
|
||||
static const UChar u_leftCurlyBrace=0x7B;
|
||||
static const UChar u_pipe=0x7C;
|
||||
static const UChar u_rightCurlyBrace=0x7D;
|
||||
static const UChar u_lessOrEqual=0x2264; // U+2264 is <=
|
||||
static const char16_t u_pound=0x23;
|
||||
static const char16_t u_apos=0x27;
|
||||
static const char16_t u_plus=0x2B;
|
||||
static const char16_t u_comma=0x2C;
|
||||
static const char16_t u_minus=0x2D;
|
||||
static const char16_t u_dot=0x2E;
|
||||
static const char16_t u_colon=0x3A;
|
||||
static const char16_t u_lessThan=0x3C;
|
||||
static const char16_t u_equal=0x3D;
|
||||
static const char16_t u_A=0x41;
|
||||
static const char16_t u_C=0x43;
|
||||
static const char16_t u_D=0x44;
|
||||
static const char16_t u_E=0x45;
|
||||
static const char16_t u_H=0x48;
|
||||
static const char16_t u_I=0x49;
|
||||
static const char16_t u_L=0x4C;
|
||||
static const char16_t u_N=0x4E;
|
||||
static const char16_t u_O=0x4F;
|
||||
static const char16_t u_P=0x50;
|
||||
static const char16_t u_R=0x52;
|
||||
static const char16_t u_S=0x53;
|
||||
static const char16_t u_T=0x54;
|
||||
static const char16_t u_U=0x55;
|
||||
static const char16_t u_Z=0x5A;
|
||||
static const char16_t u_a=0x61;
|
||||
static const char16_t u_c=0x63;
|
||||
static const char16_t u_d=0x64;
|
||||
static const char16_t u_e=0x65;
|
||||
static const char16_t u_f=0x66;
|
||||
static const char16_t u_h=0x68;
|
||||
static const char16_t u_i=0x69;
|
||||
static const char16_t u_l=0x6C;
|
||||
static const char16_t u_n=0x6E;
|
||||
static const char16_t u_o=0x6F;
|
||||
static const char16_t u_p=0x70;
|
||||
static const char16_t u_r=0x72;
|
||||
static const char16_t u_s=0x73;
|
||||
static const char16_t u_t=0x74;
|
||||
static const char16_t u_u=0x75;
|
||||
static const char16_t u_z=0x7A;
|
||||
static const char16_t u_leftCurlyBrace=0x7B;
|
||||
static const char16_t u_pipe=0x7C;
|
||||
static const char16_t u_rightCurlyBrace=0x7D;
|
||||
static const char16_t u_lessOrEqual=0x2264; // U+2264 is <=
|
||||
|
||||
static const UChar kOffsetColon[]={ // "offset:"
|
||||
static const char16_t kOffsetColon[]={ // "offset:"
|
||||
u_o, u_f, u_f, u_s, u_e, u_t, u_colon
|
||||
};
|
||||
|
||||
static const UChar kOther[]={ // "other"
|
||||
static const char16_t kOther[]={ // "other"
|
||||
u_o, u_t, u_h, u_e, u_r
|
||||
};
|
||||
|
||||
|
@ -112,7 +112,7 @@ MessagePatternList<T, stackCapacity>::copyFrom(
|
|||
int32_t length,
|
||||
UErrorCode &errorCode) {
|
||||
if(U_SUCCESS(errorCode) && length>0) {
|
||||
if(length>a.getCapacity() && NULL==a.resize(length)) {
|
||||
if(length>a.getCapacity() && nullptr==a.resize(length)) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ MessagePatternList<T, stackCapacity>::ensureCapacityForOneMore(int32_t oldLength
|
|||
if(U_FAILURE(errorCode)) {
|
||||
return false;
|
||||
}
|
||||
if(a.getCapacity()>oldLength || a.resize(2*oldLength, oldLength)!=NULL) {
|
||||
if(a.getCapacity()>oldLength || a.resize(2*oldLength, oldLength)!=nullptr) {
|
||||
return true;
|
||||
}
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
|
@ -145,24 +145,24 @@ class MessagePatternPartsList : public MessagePatternList<MessagePattern::Part,
|
|||
|
||||
MessagePattern::MessagePattern(UErrorCode &errorCode)
|
||||
: aposMode(UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE),
|
||||
partsList(NULL), parts(NULL), partsLength(0),
|
||||
numericValuesList(NULL), numericValues(NULL), numericValuesLength(0),
|
||||
partsList(nullptr), parts(nullptr), partsLength(0),
|
||||
numericValuesList(nullptr), numericValues(nullptr), numericValuesLength(0),
|
||||
hasArgNames(false), hasArgNumbers(false), needsAutoQuoting(false) {
|
||||
init(errorCode);
|
||||
}
|
||||
|
||||
MessagePattern::MessagePattern(UMessagePatternApostropheMode mode, UErrorCode &errorCode)
|
||||
: aposMode(mode),
|
||||
partsList(NULL), parts(NULL), partsLength(0),
|
||||
numericValuesList(NULL), numericValues(NULL), numericValuesLength(0),
|
||||
partsList(nullptr), parts(nullptr), partsLength(0),
|
||||
numericValuesList(nullptr), numericValues(nullptr), numericValuesLength(0),
|
||||
hasArgNames(false), hasArgNumbers(false), needsAutoQuoting(false) {
|
||||
init(errorCode);
|
||||
}
|
||||
|
||||
MessagePattern::MessagePattern(const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode)
|
||||
: aposMode(UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE),
|
||||
partsList(NULL), parts(NULL), partsLength(0),
|
||||
numericValuesList(NULL), numericValues(NULL), numericValuesLength(0),
|
||||
partsList(nullptr), parts(nullptr), partsLength(0),
|
||||
numericValuesList(nullptr), numericValues(nullptr), numericValuesLength(0),
|
||||
hasArgNames(false), hasArgNumbers(false), needsAutoQuoting(false) {
|
||||
if(init(errorCode)) {
|
||||
parse(pattern, parseError, errorCode);
|
||||
|
@ -175,7 +175,7 @@ MessagePattern::init(UErrorCode &errorCode) {
|
|||
return false;
|
||||
}
|
||||
partsList=new MessagePatternPartsList();
|
||||
if(partsList==NULL) {
|
||||
if(partsList==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
@ -185,8 +185,8 @@ MessagePattern::init(UErrorCode &errorCode) {
|
|||
|
||||
MessagePattern::MessagePattern(const MessagePattern &other)
|
||||
: UObject(other), aposMode(other.aposMode), msg(other.msg),
|
||||
partsList(NULL), parts(NULL), partsLength(0),
|
||||
numericValuesList(NULL), numericValues(NULL), numericValuesLength(0),
|
||||
partsList(nullptr), parts(nullptr), partsLength(0),
|
||||
numericValuesList(nullptr), numericValues(nullptr), numericValuesLength(0),
|
||||
hasArgNames(other.hasArgNames), hasArgNumbers(other.hasArgNumbers),
|
||||
needsAutoQuoting(other.needsAutoQuoting) {
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
|
@ -217,13 +217,13 @@ MessagePattern::copyStorage(const MessagePattern &other, UErrorCode &errorCode)
|
|||
if(U_FAILURE(errorCode)) {
|
||||
return false;
|
||||
}
|
||||
parts=NULL;
|
||||
parts=nullptr;
|
||||
partsLength=0;
|
||||
numericValues=NULL;
|
||||
numericValues=nullptr;
|
||||
numericValuesLength=0;
|
||||
if(partsList==NULL) {
|
||||
if(partsList==nullptr) {
|
||||
partsList=new MessagePatternPartsList();
|
||||
if(partsList==NULL) {
|
||||
if(partsList==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
@ -238,9 +238,9 @@ MessagePattern::copyStorage(const MessagePattern &other, UErrorCode &errorCode)
|
|||
partsLength=other.partsLength;
|
||||
}
|
||||
if(other.numericValuesLength>0) {
|
||||
if(numericValuesList==NULL) {
|
||||
if(numericValuesList==nullptr) {
|
||||
numericValuesList=new MessagePatternDoubleList();
|
||||
if(numericValuesList==NULL) {
|
||||
if(numericValuesList==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ MessagePattern::autoQuoteApostropheDeep() const {
|
|||
for(int32_t i=count; i>0;) {
|
||||
const Part &part=getPart(--i);
|
||||
if(part.getType()==UMSGPAT_PART_TYPE_INSERT_CHAR) {
|
||||
modified.insert(part.index, (UChar)part.value);
|
||||
modified.insert(part.index, (char16_t)part.value);
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
|
@ -407,7 +407,7 @@ MessagePattern::preParse(const UnicodeString &pattern, UParseError *parseError,
|
|||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
if(parseError!=NULL) {
|
||||
if(parseError!=nullptr) {
|
||||
parseError->line=0;
|
||||
parseError->offset=0;
|
||||
parseError->preContext[0]=0;
|
||||
|
@ -422,10 +422,10 @@ MessagePattern::preParse(const UnicodeString &pattern, UParseError *parseError,
|
|||
|
||||
void
|
||||
MessagePattern::postParse() {
|
||||
if(partsList!=NULL) {
|
||||
if(partsList!=nullptr) {
|
||||
parts=partsList->a.getAlias();
|
||||
}
|
||||
if(numericValuesList!=NULL) {
|
||||
if(numericValuesList!=nullptr) {
|
||||
numericValues=numericValuesList->a.getAlias();
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ MessagePattern::parseMessage(int32_t index, int32_t msgStartLength,
|
|||
if(index>=msg.length()) {
|
||||
break;
|
||||
}
|
||||
UChar c=msg.charAt(index++);
|
||||
char16_t c=msg.charAt(index++);
|
||||
if(c==u_apos) {
|
||||
if(index==msg.length()) {
|
||||
// The apostrophe is the last character in the pattern.
|
||||
|
@ -582,7 +582,7 @@ MessagePattern::parseArg(int32_t index, int32_t argStartLength, int32_t nestingL
|
|||
errorCode=U_UNMATCHED_BRACES;
|
||||
return 0;
|
||||
}
|
||||
UChar c=msg.charAt(index);
|
||||
char16_t c=msg.charAt(index);
|
||||
if(c==u_rightCurlyBrace) {
|
||||
// all done
|
||||
} else if(c!=u_comma) {
|
||||
|
@ -663,7 +663,7 @@ MessagePattern::parseSimpleStyle(int32_t index, UParseError *parseError, UErrorC
|
|||
int32_t start=index;
|
||||
int32_t nestedBraces=0;
|
||||
while(index<msg.length()) {
|
||||
UChar c=msg.charAt(index++);
|
||||
char16_t c=msg.charAt(index++);
|
||||
if(c==u_apos) {
|
||||
// Treat apostrophe as quoting but include it in the style part.
|
||||
// Find the end of the quoted literal text.
|
||||
|
@ -738,7 +738,7 @@ MessagePattern::parseChoiceStyle(int32_t index, int32_t nestingLevel,
|
|||
errorCode=U_PATTERN_SYNTAX_ERROR;
|
||||
return 0;
|
||||
}
|
||||
UChar c=msg.charAt(index);
|
||||
char16_t c=msg.charAt(index);
|
||||
if(!(c==u_pound || c==u_lessThan || c==u_lessOrEqual)) { // U+2264 is <=
|
||||
setParseError(parseError, start); // Expected choice separator (#<\u2264) instead of c.
|
||||
errorCode=U_PATTERN_SYNTAX_ERROR;
|
||||
|
@ -895,7 +895,7 @@ MessagePattern::parseArgNumber(const UnicodeString &s, int32_t start, int32_t li
|
|||
int32_t number;
|
||||
// Defer numeric errors until we know there are only digits.
|
||||
UBool badNumber;
|
||||
UChar c=s.charAt(start++);
|
||||
char16_t c=s.charAt(start++);
|
||||
if(c==0x30) {
|
||||
if(start==limit) {
|
||||
return 0;
|
||||
|
@ -941,7 +941,7 @@ MessagePattern::parseDouble(int32_t start, int32_t limit, UBool allowInfinity,
|
|||
int32_t value=0;
|
||||
int32_t isNegative=0; // not boolean so that we can easily add it to value
|
||||
int32_t index=start;
|
||||
UChar c=msg.charAt(index++);
|
||||
char16_t c=msg.charAt(index++);
|
||||
if(c==u_minus) {
|
||||
isNegative=1;
|
||||
if(index==limit) {
|
||||
|
@ -1004,17 +1004,17 @@ MessagePattern::parseDouble(int32_t start, int32_t limit, UBool allowInfinity,
|
|||
|
||||
int32_t
|
||||
MessagePattern::skipWhiteSpace(int32_t index) {
|
||||
const UChar *s=msg.getBuffer();
|
||||
const char16_t *s=msg.getBuffer();
|
||||
int32_t msgLength=msg.length();
|
||||
const UChar *t=PatternProps::skipWhiteSpace(s+index, msgLength-index);
|
||||
const char16_t *t=PatternProps::skipWhiteSpace(s+index, msgLength-index);
|
||||
return (int32_t)(t-s);
|
||||
}
|
||||
|
||||
int32_t
|
||||
MessagePattern::skipIdentifier(int32_t index) {
|
||||
const UChar *s=msg.getBuffer();
|
||||
const char16_t *s=msg.getBuffer();
|
||||
int32_t msgLength=msg.length();
|
||||
const UChar *t=PatternProps::skipIdentifier(s+index, msgLength-index);
|
||||
const char16_t *t=PatternProps::skipIdentifier(s+index, msgLength-index);
|
||||
return (int32_t)(t-s);
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ int32_t
|
|||
MessagePattern::skipDouble(int32_t index) {
|
||||
int32_t msgLength=msg.length();
|
||||
while(index<msgLength) {
|
||||
UChar c=msg.charAt(index);
|
||||
char16_t c=msg.charAt(index);
|
||||
// U+221E: Allow the infinity symbol, for ChoiceFormat patterns.
|
||||
if((c<0x30 && c!=u_plus && c!=u_minus && c!=u_dot) || (c>0x39 && c!=u_e && c!=u_E && c!=0x221e)) {
|
||||
break;
|
||||
|
@ -1039,7 +1039,7 @@ MessagePattern::isArgTypeChar(UChar32 c) {
|
|||
|
||||
UBool
|
||||
MessagePattern::isChoice(int32_t index) {
|
||||
UChar c;
|
||||
char16_t c;
|
||||
return
|
||||
((c=msg.charAt(index++))==u_c || c==u_C) &&
|
||||
((c=msg.charAt(index++))==u_h || c==u_H) &&
|
||||
|
@ -1051,7 +1051,7 @@ MessagePattern::isChoice(int32_t index) {
|
|||
|
||||
UBool
|
||||
MessagePattern::isPlural(int32_t index) {
|
||||
UChar c;
|
||||
char16_t c;
|
||||
return
|
||||
((c=msg.charAt(index++))==u_p || c==u_P) &&
|
||||
((c=msg.charAt(index++))==u_l || c==u_L) &&
|
||||
|
@ -1063,7 +1063,7 @@ MessagePattern::isPlural(int32_t index) {
|
|||
|
||||
UBool
|
||||
MessagePattern::isSelect(int32_t index) {
|
||||
UChar c;
|
||||
char16_t c;
|
||||
return
|
||||
((c=msg.charAt(index++))==u_s || c==u_S) &&
|
||||
((c=msg.charAt(index++))==u_e || c==u_E) &&
|
||||
|
@ -1075,7 +1075,7 @@ MessagePattern::isSelect(int32_t index) {
|
|||
|
||||
UBool
|
||||
MessagePattern::isOrdinal(int32_t index) {
|
||||
UChar c;
|
||||
char16_t c;
|
||||
return
|
||||
((c=msg.charAt(index++))==u_o || c==u_O) &&
|
||||
((c=msg.charAt(index++))==u_r || c==u_R) &&
|
||||
|
@ -1127,9 +1127,9 @@ MessagePattern::addArgDoublePart(double numericValue, int32_t start, int32_t len
|
|||
return;
|
||||
}
|
||||
int32_t numericIndex=numericValuesLength;
|
||||
if(numericValuesList==NULL) {
|
||||
if(numericValuesList==nullptr) {
|
||||
numericValuesList=new MessagePatternDoubleList();
|
||||
if(numericValuesList==NULL) {
|
||||
if(numericValuesList==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -1147,7 +1147,7 @@ MessagePattern::addArgDoublePart(double numericValue, int32_t start, int32_t len
|
|||
|
||||
void
|
||||
MessagePattern::setParseError(UParseError *parseError, int32_t index) {
|
||||
if(parseError==NULL) {
|
||||
if(parseError==nullptr) {
|
||||
return;
|
||||
}
|
||||
parseError->offset=index;
|
||||
|
|
|
@ -0,0 +1,270 @@
|
|||
// © 2022 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
|
||||
#include "cmemory.h"
|
||||
#include "mlbe.h"
|
||||
#include "uassert.h"
|
||||
#include "ubrkimpl.h"
|
||||
#include "unicode/resbund.h"
|
||||
#include "unicode/udata.h"
|
||||
#include "unicode/utf16.h"
|
||||
#include "uresimp.h"
|
||||
#include "util.h"
|
||||
#include "uvectr32.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
enum class ModelIndex { kUWStart = 0, kBWStart = 6, kTWStart = 9 };
|
||||
|
||||
MlBreakEngine::MlBreakEngine(const UnicodeSet &digitOrOpenPunctuationOrAlphabetSet,
|
||||
const UnicodeSet &closePunctuationSet, UErrorCode &status)
|
||||
: fDigitOrOpenPunctuationOrAlphabetSet(digitOrOpenPunctuationOrAlphabetSet),
|
||||
fClosePunctuationSet(closePunctuationSet),
|
||||
fNegativeSum(0) {
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
loadMLModel(status);
|
||||
}
|
||||
|
||||
MlBreakEngine::~MlBreakEngine() {}
|
||||
|
||||
int32_t MlBreakEngine::divideUpRange(UText *inText, int32_t rangeStart, int32_t rangeEnd,
|
||||
UVector32 &foundBreaks, const UnicodeString &inString,
|
||||
const LocalPointer<UVector32> &inputMap,
|
||||
UErrorCode &status) const {
|
||||
if (U_FAILURE(status)) {
|
||||
return 0;
|
||||
}
|
||||
if (rangeStart >= rangeEnd) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
UVector32 boundary(inString.countChar32() + 1, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return 0;
|
||||
}
|
||||
int32_t numBreaks = 0;
|
||||
int32_t codePointLength = inString.countChar32();
|
||||
// The ML algorithm groups six char and evaluates whether the 4th char is a breakpoint.
|
||||
// In each iteration, it evaluates the 4th char and then moves forward one char like a sliding
|
||||
// window. Initially, the first six values in the indexList are [-1, -1, 0, 1, 2, 3]. After
|
||||
// moving forward, finally the last six values in the indexList are
|
||||
// [length-4, length-3, length-2, length-1, -1, -1]. The "+4" here means four extra "-1".
|
||||
int32_t indexSize = codePointLength + 4;
|
||||
int32_t *indexList = (int32_t *)uprv_malloc(indexSize * sizeof(int32_t));
|
||||
if (indexList == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
int32_t numCodeUnits = initIndexList(inString, indexList, status);
|
||||
|
||||
// Add a break for the start.
|
||||
boundary.addElement(0, status);
|
||||
numBreaks++;
|
||||
if (U_FAILURE(status)) return 0;
|
||||
|
||||
for (int32_t idx = 0; idx + 1 < codePointLength && U_SUCCESS(status); idx++) {
|
||||
numBreaks =
|
||||
evaluateBreakpoint(inString, indexList, idx, numCodeUnits, numBreaks, boundary, status);
|
||||
if (idx + 4 < codePointLength) {
|
||||
indexList[idx + 6] = numCodeUnits;
|
||||
numCodeUnits += U16_LENGTH(inString.char32At(indexList[idx + 6]));
|
||||
}
|
||||
}
|
||||
uprv_free(indexList);
|
||||
|
||||
if (U_FAILURE(status)) return 0;
|
||||
|
||||
// Add a break for the end if there is not one there already.
|
||||
if (boundary.lastElementi() != inString.countChar32()) {
|
||||
boundary.addElement(inString.countChar32(), status);
|
||||
numBreaks++;
|
||||
}
|
||||
|
||||
int32_t prevCPPos = -1;
|
||||
int32_t prevUTextPos = -1;
|
||||
int32_t correctedNumBreaks = 0;
|
||||
for (int32_t i = 0; i < numBreaks; i++) {
|
||||
int32_t cpPos = boundary.elementAti(i);
|
||||
int32_t utextPos = inputMap.isValid() ? inputMap->elementAti(cpPos) : cpPos + rangeStart;
|
||||
U_ASSERT(cpPos > prevCPPos);
|
||||
U_ASSERT(utextPos >= prevUTextPos);
|
||||
|
||||
if (utextPos > prevUTextPos) {
|
||||
if (utextPos != rangeStart ||
|
||||
(utextPos > 0 &&
|
||||
fClosePunctuationSet.contains(utext_char32At(inText, utextPos - 1)))) {
|
||||
foundBreaks.push(utextPos, status);
|
||||
correctedNumBreaks++;
|
||||
}
|
||||
} else {
|
||||
// Normalization expanded the input text, the dictionary found a boundary
|
||||
// within the expansion, giving two boundaries with the same index in the
|
||||
// original text. Ignore the second. See ticket #12918.
|
||||
--numBreaks;
|
||||
}
|
||||
prevCPPos = cpPos;
|
||||
prevUTextPos = utextPos;
|
||||
}
|
||||
(void)prevCPPos; // suppress compiler warnings about unused variable
|
||||
|
||||
UChar32 nextChar = utext_char32At(inText, rangeEnd);
|
||||
if (!foundBreaks.isEmpty() && foundBreaks.peeki() == rangeEnd) {
|
||||
// In phrase breaking, there has to be a breakpoint between Cj character and
|
||||
// the number/open punctuation.
|
||||
// E.g. る文字「そうだ、京都」->る▁文字▁「そうだ、▁京都」-> breakpoint between 字 and「
|
||||
// E.g. 乗車率90%程度だろうか -> 乗車▁率▁90%▁程度だろうか -> breakpoint between 率 and 9
|
||||
// E.g. しかもロゴがUnicode! -> しかも▁ロゴが▁Unicode!-> breakpoint between が and U
|
||||
if (!fDigitOrOpenPunctuationOrAlphabetSet.contains(nextChar)) {
|
||||
foundBreaks.popi();
|
||||
correctedNumBreaks--;
|
||||
}
|
||||
}
|
||||
|
||||
return correctedNumBreaks;
|
||||
}
|
||||
|
||||
int32_t MlBreakEngine::evaluateBreakpoint(const UnicodeString &inString, int32_t *indexList,
|
||||
int32_t startIdx, int32_t numCodeUnits, int32_t numBreaks,
|
||||
UVector32 &boundary, UErrorCode &status) const {
|
||||
if (U_FAILURE(status)) {
|
||||
return numBreaks;
|
||||
}
|
||||
int32_t start = 0, end = 0;
|
||||
int32_t score = fNegativeSum;
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
// UW1 ~ UW6
|
||||
start = startIdx + i;
|
||||
if (indexList[start] != -1) {
|
||||
end = (indexList[start + 1] != -1) ? indexList[start + 1] : numCodeUnits;
|
||||
score += fModel[static_cast<int32_t>(ModelIndex::kUWStart) + i].geti(
|
||||
inString.tempSubString(indexList[start], end - indexList[start]));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// BW1 ~ BW3
|
||||
start = startIdx + i + 1;
|
||||
if (indexList[start] != -1 && indexList[start + 1] != -1) {
|
||||
end = (indexList[start + 2] != -1) ? indexList[start + 2] : numCodeUnits;
|
||||
score += fModel[static_cast<int32_t>(ModelIndex::kBWStart) + i].geti(
|
||||
inString.tempSubString(indexList[start], end - indexList[start]));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// TW1 ~ TW4
|
||||
start = startIdx + i;
|
||||
if (indexList[start] != -1 && indexList[start + 1] != -1 && indexList[start + 2] != -1) {
|
||||
end = (indexList[start + 3] != -1) ? indexList[start + 3] : numCodeUnits;
|
||||
score += fModel[static_cast<int32_t>(ModelIndex::kTWStart) + i].geti(
|
||||
inString.tempSubString(indexList[start], end - indexList[start]));
|
||||
}
|
||||
}
|
||||
|
||||
if (score > 0) {
|
||||
boundary.addElement(startIdx + 1, status);
|
||||
numBreaks++;
|
||||
}
|
||||
return numBreaks;
|
||||
}
|
||||
|
||||
int32_t MlBreakEngine::initIndexList(const UnicodeString &inString, int32_t *indexList,
|
||||
UErrorCode &status) const {
|
||||
if (U_FAILURE(status)) {
|
||||
return 0;
|
||||
}
|
||||
int32_t index = 0;
|
||||
int32_t length = inString.countChar32();
|
||||
// Set all (lenght+4) items inside indexLength to -1 presuming -1 is 4 bytes of 0xff.
|
||||
uprv_memset(indexList, 0xff, (length + 4) * sizeof(int32_t));
|
||||
if (length > 0) {
|
||||
indexList[2] = 0;
|
||||
index = U16_LENGTH(inString.char32At(0));
|
||||
if (length > 1) {
|
||||
indexList[3] = index;
|
||||
index += U16_LENGTH(inString.char32At(index));
|
||||
if (length > 2) {
|
||||
indexList[4] = index;
|
||||
index += U16_LENGTH(inString.char32At(index));
|
||||
if (length > 3) {
|
||||
indexList[5] = index;
|
||||
index += U16_LENGTH(inString.char32At(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void MlBreakEngine::loadMLModel(UErrorCode &error) {
|
||||
// BudouX's model consists of thirteen categories, each of which is make up of pairs of the
|
||||
// feature and its score. As integrating it into jaml.txt, we define thirteen kinds of key and
|
||||
// value to represent the feature and the corresponding score respectively.
|
||||
|
||||
if (U_FAILURE(error)) return;
|
||||
|
||||
UnicodeString key;
|
||||
StackUResourceBundle stackTempBundle;
|
||||
ResourceDataValue modelKey;
|
||||
|
||||
LocalUResourceBundlePointer rbp(ures_openDirect(U_ICUDATA_BRKITR, "jaml", &error));
|
||||
UResourceBundle *rb = rbp.getAlias();
|
||||
if (U_FAILURE(error)) return;
|
||||
|
||||
int32_t index = 0;
|
||||
initKeyValue(rb, "UW1Keys", "UW1Values", fModel[index++], error);
|
||||
initKeyValue(rb, "UW2Keys", "UW2Values", fModel[index++], error);
|
||||
initKeyValue(rb, "UW3Keys", "UW3Values", fModel[index++], error);
|
||||
initKeyValue(rb, "UW4Keys", "UW4Values", fModel[index++], error);
|
||||
initKeyValue(rb, "UW5Keys", "UW5Values", fModel[index++], error);
|
||||
initKeyValue(rb, "UW6Keys", "UW6Values", fModel[index++], error);
|
||||
initKeyValue(rb, "BW1Keys", "BW1Values", fModel[index++], error);
|
||||
initKeyValue(rb, "BW2Keys", "BW2Values", fModel[index++], error);
|
||||
initKeyValue(rb, "BW3Keys", "BW3Values", fModel[index++], error);
|
||||
initKeyValue(rb, "TW1Keys", "TW1Values", fModel[index++], error);
|
||||
initKeyValue(rb, "TW2Keys", "TW2Values", fModel[index++], error);
|
||||
initKeyValue(rb, "TW3Keys", "TW3Values", fModel[index++], error);
|
||||
initKeyValue(rb, "TW4Keys", "TW4Values", fModel[index++], error);
|
||||
fNegativeSum /= 2;
|
||||
}
|
||||
|
||||
void MlBreakEngine::initKeyValue(UResourceBundle *rb, const char *keyName, const char *valueName,
|
||||
Hashtable &model, UErrorCode &error) {
|
||||
int32_t keySize = 0;
|
||||
int32_t valueSize = 0;
|
||||
int32_t stringLength = 0;
|
||||
UnicodeString key;
|
||||
StackUResourceBundle stackTempBundle;
|
||||
ResourceDataValue modelKey;
|
||||
|
||||
// get modelValues
|
||||
LocalUResourceBundlePointer modelValue(ures_getByKey(rb, valueName, nullptr, &error));
|
||||
const int32_t *value = ures_getIntVector(modelValue.getAlias(), &valueSize, &error);
|
||||
if (U_FAILURE(error)) return;
|
||||
|
||||
// get modelKeys
|
||||
ures_getValueWithFallback(rb, keyName, stackTempBundle.getAlias(), modelKey, error);
|
||||
ResourceArray stringArray = modelKey.getArray(error);
|
||||
keySize = stringArray.getSize();
|
||||
if (U_FAILURE(error)) return;
|
||||
|
||||
for (int32_t idx = 0; idx < keySize; idx++) {
|
||||
stringArray.getValue(idx, modelKey);
|
||||
key = UnicodeString(modelKey.getString(stringLength, error));
|
||||
if (U_SUCCESS(error)) {
|
||||
U_ASSERT(idx < valueSize);
|
||||
fNegativeSum -= value[idx];
|
||||
model.puti(key, value[idx], error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
|
|
@ -0,0 +1,116 @@
|
|||
// © 2022 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
|
||||
#ifndef MLBREAKENGINE_H
|
||||
#define MLBREAKENGINE_H
|
||||
|
||||
#include "hash.h"
|
||||
#include "unicode/resbund.h"
|
||||
#include "unicode/uniset.h"
|
||||
#include "unicode/utext.h"
|
||||
#include "uvectr32.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
|
||||
/**
|
||||
* A machine learning break engine for the phrase breaking in Japanese.
|
||||
*/
|
||||
class MlBreakEngine : public UMemory {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param digitOrOpenPunctuationOrAlphabetSet An UnicodeSet with the digit, open punctuation and
|
||||
* alphabet.
|
||||
* @param closePunctuationSet An UnicodeSet with close punctuation.
|
||||
* @param status Information on any errors encountered.
|
||||
*/
|
||||
MlBreakEngine(const UnicodeSet &digitOrOpenPunctuationOrAlphabetSet,
|
||||
const UnicodeSet &closePunctuationSet, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Virtual destructor.
|
||||
*/
|
||||
virtual ~MlBreakEngine();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Divide up a range of characters handled by this break engine.
|
||||
*
|
||||
* @param inText A UText representing the text
|
||||
* @param rangeStart The start of the range of the characters
|
||||
* @param rangeEnd The end of the range of the characters
|
||||
* @param foundBreaks Output of C array of int32_t break positions, or 0
|
||||
* @param inString The normalized string of text ranging from rangeStart to rangeEnd
|
||||
* @param inputMap The vector storing the native index of inText
|
||||
* @param status Information on any errors encountered.
|
||||
* @return The number of breaks found
|
||||
*/
|
||||
int32_t divideUpRange(UText *inText, int32_t rangeStart, int32_t rangeEnd,
|
||||
UVector32 &foundBreaks, const UnicodeString &inString,
|
||||
const LocalPointer<UVector32> &inputMap, UErrorCode &status) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Load the machine learning's model file.
|
||||
*
|
||||
* @param error Information on any errors encountered.
|
||||
*/
|
||||
void loadMLModel(UErrorCode &error);
|
||||
|
||||
/**
|
||||
* In the machine learning's model file, specify the name of the key and value to load the
|
||||
* corresponding feature and its score.
|
||||
*
|
||||
* @param rb A ResouceBundle corresponding to the model file.
|
||||
* @param keyName The kay name in the model file.
|
||||
* @param valueName The value name in the model file.
|
||||
* @param model A hashtable to store the pairs of the feature and its score.
|
||||
* @param error Information on any errors encountered.
|
||||
*/
|
||||
void initKeyValue(UResourceBundle *rb, const char *keyName, const char *valueName,
|
||||
Hashtable &model, UErrorCode &error);
|
||||
|
||||
/**
|
||||
* Initialize the index list from the input string.
|
||||
*
|
||||
* @param inString A input string to be segmented.
|
||||
* @param indexList A code unit index list of inString.
|
||||
* @param status Information on any errors encountered.
|
||||
* @return The number of code units of the first four characters in inString.
|
||||
*/
|
||||
int32_t initIndexList(const UnicodeString &inString, int32_t *indexList,
|
||||
UErrorCode &status) const;
|
||||
|
||||
/**
|
||||
* Evaluate whether the index is a potential breakpoint.
|
||||
*
|
||||
* @param inString A input string to be segmented.
|
||||
* @param indexList A code unit index list of the inString.
|
||||
* @param startIdx The start index of the indexList.
|
||||
* @param numCodeUnits The current code unit boundary of the indexList.
|
||||
* @param numBreaks The accumulated number of breakpoints.
|
||||
* @param boundary A vector including the index of the breakpoint.
|
||||
* @param status Information on any errors encountered.
|
||||
* @return The number of breakpoints
|
||||
*/
|
||||
int32_t evaluateBreakpoint(const UnicodeString &inString, int32_t *indexList, int32_t startIdx,
|
||||
int32_t numCodeUnits, int32_t numBreaks, UVector32 &boundary,
|
||||
UErrorCode &status) const;
|
||||
|
||||
void printUnicodeString(const UnicodeString &s) const;
|
||||
|
||||
UnicodeSet fDigitOrOpenPunctuationOrAlphabetSet;
|
||||
UnicodeSet fClosePunctuationSet;
|
||||
Hashtable fModel[13]; // {UW1, UW2, ... UW6, BW1, ... BW3, TW1, TW2, ... TW4} 6+3+4= 13
|
||||
int32_t fNegativeSum;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
/* MLBREAKENGINE_H */
|
||||
#endif
|
|
@ -38,13 +38,13 @@ public:
|
|||
virtual UnicodeString &
|
||||
normalize(const UnicodeString &src,
|
||||
UnicodeString &dest,
|
||||
UErrorCode &errorCode) const U_OVERRIDE {
|
||||
UErrorCode &errorCode) const override {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
dest.setToBogus();
|
||||
return dest;
|
||||
}
|
||||
const UChar *sArray=src.getBuffer();
|
||||
if(&dest==&src || sArray==NULL) {
|
||||
const char16_t *sArray=src.getBuffer();
|
||||
if(&dest==&src || sArray==nullptr) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
dest.setToBogus();
|
||||
return dest;
|
||||
|
@ -57,20 +57,20 @@ public:
|
|||
return dest;
|
||||
}
|
||||
virtual void
|
||||
normalize(const UChar *src, const UChar *limit,
|
||||
normalize(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const = 0;
|
||||
|
||||
// normalize and append
|
||||
virtual UnicodeString &
|
||||
normalizeSecondAndAppend(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const U_OVERRIDE {
|
||||
UErrorCode &errorCode) const override {
|
||||
return normalizeSecondAndAppend(first, second, true, errorCode);
|
||||
}
|
||||
virtual UnicodeString &
|
||||
append(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const U_OVERRIDE {
|
||||
UErrorCode &errorCode) const override {
|
||||
return normalizeSecondAndAppend(first, second, false, errorCode);
|
||||
}
|
||||
UnicodeString &
|
||||
|
@ -82,8 +82,8 @@ public:
|
|||
if(U_FAILURE(errorCode)) {
|
||||
return first;
|
||||
}
|
||||
const UChar *secondArray=second.getBuffer();
|
||||
if(&first==&second || secondArray==NULL) {
|
||||
const char16_t *secondArray=second.getBuffer();
|
||||
if(&first==&second || secondArray==nullptr) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return first;
|
||||
}
|
||||
|
@ -103,15 +103,15 @@ public:
|
|||
return first;
|
||||
}
|
||||
virtual void
|
||||
normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
|
||||
normalizeAndAppend(const char16_t *src, const char16_t *limit, UBool doNormalize,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const = 0;
|
||||
virtual UBool
|
||||
getDecomposition(UChar32 c, UnicodeString &decomposition) const U_OVERRIDE {
|
||||
UChar buffer[4];
|
||||
getDecomposition(UChar32 c, UnicodeString &decomposition) const override {
|
||||
char16_t buffer[4];
|
||||
int32_t length;
|
||||
const UChar *d=impl.getDecomposition(c, buffer, length);
|
||||
if(d==NULL) {
|
||||
const char16_t *d=impl.getDecomposition(c, buffer, length);
|
||||
if(d==nullptr) {
|
||||
return false;
|
||||
}
|
||||
if(d==buffer) {
|
||||
|
@ -122,11 +122,11 @@ public:
|
|||
return true;
|
||||
}
|
||||
virtual UBool
|
||||
getRawDecomposition(UChar32 c, UnicodeString &decomposition) const U_OVERRIDE {
|
||||
UChar buffer[30];
|
||||
getRawDecomposition(UChar32 c, UnicodeString &decomposition) const override {
|
||||
char16_t buffer[30];
|
||||
int32_t length;
|
||||
const UChar *d=impl.getRawDecomposition(c, buffer, length);
|
||||
if(d==NULL) {
|
||||
const char16_t *d=impl.getRawDecomposition(c, buffer, length);
|
||||
if(d==nullptr) {
|
||||
return false;
|
||||
}
|
||||
if(d==buffer) {
|
||||
|
@ -137,47 +137,47 @@ public:
|
|||
return true;
|
||||
}
|
||||
virtual UChar32
|
||||
composePair(UChar32 a, UChar32 b) const U_OVERRIDE {
|
||||
composePair(UChar32 a, UChar32 b) const override {
|
||||
return impl.composePair(a, b);
|
||||
}
|
||||
|
||||
virtual uint8_t
|
||||
getCombiningClass(UChar32 c) const U_OVERRIDE {
|
||||
getCombiningClass(UChar32 c) const override {
|
||||
return impl.getCC(impl.getNorm16(c));
|
||||
}
|
||||
|
||||
// quick checks
|
||||
virtual UBool
|
||||
isNormalized(const UnicodeString &s, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
isNormalized(const UnicodeString &s, UErrorCode &errorCode) const override {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return false;
|
||||
}
|
||||
const UChar *sArray=s.getBuffer();
|
||||
if(sArray==NULL) {
|
||||
const char16_t *sArray=s.getBuffer();
|
||||
if(sArray==nullptr) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return false;
|
||||
}
|
||||
const UChar *sLimit=sArray+s.length();
|
||||
const char16_t *sLimit=sArray+s.length();
|
||||
return sLimit==spanQuickCheckYes(sArray, sLimit, errorCode);
|
||||
}
|
||||
virtual UNormalizationCheckResult
|
||||
quickCheck(const UnicodeString &s, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
quickCheck(const UnicodeString &s, UErrorCode &errorCode) const override {
|
||||
return Normalizer2WithImpl::isNormalized(s, errorCode) ? UNORM_YES : UNORM_NO;
|
||||
}
|
||||
virtual int32_t
|
||||
spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const override {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return 0;
|
||||
}
|
||||
const UChar *sArray=s.getBuffer();
|
||||
if(sArray==NULL) {
|
||||
const char16_t *sArray=s.getBuffer();
|
||||
if(sArray==nullptr) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
return (int32_t)(spanQuickCheckYes(sArray, sArray+s.length(), errorCode)-sArray);
|
||||
}
|
||||
virtual const UChar *
|
||||
spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &errorCode) const = 0;
|
||||
virtual const char16_t *
|
||||
spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const = 0;
|
||||
|
||||
virtual UNormalizationCheckResult getQuickCheck(UChar32) const {
|
||||
return UNORM_YES;
|
||||
|
@ -193,21 +193,21 @@ public:
|
|||
|
||||
private:
|
||||
virtual void
|
||||
normalize(const UChar *src, const UChar *limit,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
normalize(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const override {
|
||||
impl.decompose(src, limit, &buffer, errorCode);
|
||||
}
|
||||
using Normalizer2WithImpl::normalize; // Avoid warning about hiding base class function.
|
||||
virtual void
|
||||
normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
|
||||
normalizeAndAppend(const char16_t *src, const char16_t *limit, UBool doNormalize,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const override {
|
||||
impl.decomposeAndAppend(src, limit, doNormalize, safeMiddle, buffer, errorCode);
|
||||
}
|
||||
|
||||
void
|
||||
normalizeUTF8(uint32_t options, StringPiece src, ByteSink &sink,
|
||||
Edits *edits, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
Edits *edits, UErrorCode &errorCode) const override {
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ private:
|
|||
sink.Flush();
|
||||
}
|
||||
virtual UBool
|
||||
isNormalizedUTF8(StringPiece sp, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
isNormalizedUTF8(StringPiece sp, UErrorCode &errorCode) const override {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -228,21 +228,21 @@ private:
|
|||
return sLimit == impl.decomposeUTF8(0, s, sLimit, nullptr, nullptr, errorCode);
|
||||
}
|
||||
|
||||
virtual const UChar *
|
||||
spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
return impl.decompose(src, limit, NULL, errorCode);
|
||||
virtual const char16_t *
|
||||
spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const override {
|
||||
return impl.decompose(src, limit, nullptr, errorCode);
|
||||
}
|
||||
using Normalizer2WithImpl::spanQuickCheckYes; // Avoid warning about hiding base class function.
|
||||
virtual UNormalizationCheckResult getQuickCheck(UChar32 c) const U_OVERRIDE {
|
||||
virtual UNormalizationCheckResult getQuickCheck(UChar32 c) const override {
|
||||
return impl.isDecompYes(impl.getNorm16(c)) ? UNORM_YES : UNORM_NO;
|
||||
}
|
||||
virtual UBool hasBoundaryBefore(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool hasBoundaryBefore(UChar32 c) const override {
|
||||
return impl.hasDecompBoundaryBefore(c);
|
||||
}
|
||||
virtual UBool hasBoundaryAfter(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool hasBoundaryAfter(UChar32 c) const override {
|
||||
return impl.hasDecompBoundaryAfter(c);
|
||||
}
|
||||
virtual UBool isInert(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool isInert(UChar32 c) const override {
|
||||
return impl.isDecompInert(c);
|
||||
}
|
||||
};
|
||||
|
@ -255,15 +255,15 @@ public:
|
|||
|
||||
private:
|
||||
virtual void
|
||||
normalize(const UChar *src, const UChar *limit,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
normalize(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const override {
|
||||
impl.compose(src, limit, onlyContiguous, true, buffer, errorCode);
|
||||
}
|
||||
using Normalizer2WithImpl::normalize; // Avoid warning about hiding base class function.
|
||||
|
||||
void
|
||||
normalizeUTF8(uint32_t options, StringPiece src, ByteSink &sink,
|
||||
Edits *edits, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
Edits *edits, UErrorCode &errorCode) const override {
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
|
@ -277,19 +277,19 @@ private:
|
|||
}
|
||||
|
||||
virtual void
|
||||
normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
|
||||
normalizeAndAppend(const char16_t *src, const char16_t *limit, UBool doNormalize,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const override {
|
||||
impl.composeAndAppend(src, limit, doNormalize, onlyContiguous, safeMiddle, buffer, errorCode);
|
||||
}
|
||||
|
||||
virtual UBool
|
||||
isNormalized(const UnicodeString &s, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
isNormalized(const UnicodeString &s, UErrorCode &errorCode) const override {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return false;
|
||||
}
|
||||
const UChar *sArray=s.getBuffer();
|
||||
if(sArray==NULL) {
|
||||
const char16_t *sArray=s.getBuffer();
|
||||
if(sArray==nullptr) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ private:
|
|||
return impl.compose(sArray, sArray+s.length(), onlyContiguous, false, buffer, errorCode);
|
||||
}
|
||||
virtual UBool
|
||||
isNormalizedUTF8(StringPiece sp, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
isNormalizedUTF8(StringPiece sp, UErrorCode &errorCode) const override {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -309,12 +309,12 @@ private:
|
|||
return impl.composeUTF8(0, onlyContiguous, s, s + sp.length(), nullptr, nullptr, errorCode);
|
||||
}
|
||||
virtual UNormalizationCheckResult
|
||||
quickCheck(const UnicodeString &s, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
quickCheck(const UnicodeString &s, UErrorCode &errorCode) const override {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return UNORM_MAYBE;
|
||||
}
|
||||
const UChar *sArray=s.getBuffer();
|
||||
if(sArray==NULL) {
|
||||
const char16_t *sArray=s.getBuffer();
|
||||
if(sArray==nullptr) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return UNORM_MAYBE;
|
||||
}
|
||||
|
@ -322,21 +322,21 @@ private:
|
|||
impl.composeQuickCheck(sArray, sArray+s.length(), onlyContiguous, &qcResult);
|
||||
return qcResult;
|
||||
}
|
||||
virtual const UChar *
|
||||
spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &) const U_OVERRIDE {
|
||||
return impl.composeQuickCheck(src, limit, onlyContiguous, NULL);
|
||||
virtual const char16_t *
|
||||
spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &) const override {
|
||||
return impl.composeQuickCheck(src, limit, onlyContiguous, nullptr);
|
||||
}
|
||||
using Normalizer2WithImpl::spanQuickCheckYes; // Avoid warning about hiding base class function.
|
||||
virtual UNormalizationCheckResult getQuickCheck(UChar32 c) const U_OVERRIDE {
|
||||
virtual UNormalizationCheckResult getQuickCheck(UChar32 c) const override {
|
||||
return impl.getCompQuickCheck(impl.getNorm16(c));
|
||||
}
|
||||
virtual UBool hasBoundaryBefore(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool hasBoundaryBefore(UChar32 c) const override {
|
||||
return impl.hasCompBoundaryBefore(c);
|
||||
}
|
||||
virtual UBool hasBoundaryAfter(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool hasBoundaryAfter(UChar32 c) const override {
|
||||
return impl.hasCompBoundaryAfter(c, onlyContiguous);
|
||||
}
|
||||
virtual UBool isInert(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool isInert(UChar32 c) const override {
|
||||
return impl.isCompInert(c, onlyContiguous);
|
||||
}
|
||||
|
||||
|
@ -350,29 +350,29 @@ public:
|
|||
|
||||
private:
|
||||
virtual void
|
||||
normalize(const UChar *src, const UChar *limit,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
normalize(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const override {
|
||||
impl.makeFCD(src, limit, &buffer, errorCode);
|
||||
}
|
||||
using Normalizer2WithImpl::normalize; // Avoid warning about hiding base class function.
|
||||
virtual void
|
||||
normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
|
||||
normalizeAndAppend(const char16_t *src, const char16_t *limit, UBool doNormalize,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const override {
|
||||
impl.makeFCDAndAppend(src, limit, doNormalize, safeMiddle, buffer, errorCode);
|
||||
}
|
||||
virtual const UChar *
|
||||
spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
return impl.makeFCD(src, limit, NULL, errorCode);
|
||||
virtual const char16_t *
|
||||
spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const override {
|
||||
return impl.makeFCD(src, limit, nullptr, errorCode);
|
||||
}
|
||||
using Normalizer2WithImpl::spanQuickCheckYes; // Avoid warning about hiding base class function.
|
||||
virtual UBool hasBoundaryBefore(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool hasBoundaryBefore(UChar32 c) const override {
|
||||
return impl.hasFCDBoundaryBefore(c);
|
||||
}
|
||||
virtual UBool hasBoundaryAfter(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool hasBoundaryAfter(UChar32 c) const override {
|
||||
return impl.hasFCDBoundaryAfter(c);
|
||||
}
|
||||
virtual UBool isInert(UChar32 c) const U_OVERRIDE {
|
||||
virtual UBool isInert(UChar32 c) const override {
|
||||
return impl.isFCDInert(c);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -87,7 +87,7 @@ class NoopNormalizer2 : public Normalizer2 {
|
|||
virtual UnicodeString &
|
||||
normalize(const UnicodeString &src,
|
||||
UnicodeString &dest,
|
||||
UErrorCode &errorCode) const U_OVERRIDE {
|
||||
UErrorCode &errorCode) const override {
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
if(&dest!=&src) {
|
||||
dest=src;
|
||||
|
@ -99,7 +99,7 @@ class NoopNormalizer2 : public Normalizer2 {
|
|||
}
|
||||
virtual void
|
||||
normalizeUTF8(uint32_t options, StringPiece src, ByteSink &sink,
|
||||
Edits *edits, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
Edits *edits, UErrorCode &errorCode) const override {
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
if (edits != nullptr) {
|
||||
if ((options & U_EDITS_NO_RESET) == 0) {
|
||||
|
@ -117,7 +117,7 @@ class NoopNormalizer2 : public Normalizer2 {
|
|||
virtual UnicodeString &
|
||||
normalizeSecondAndAppend(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const U_OVERRIDE {
|
||||
UErrorCode &errorCode) const override {
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
if(&first!=&second) {
|
||||
first.append(second);
|
||||
|
@ -130,7 +130,7 @@ class NoopNormalizer2 : public Normalizer2 {
|
|||
virtual UnicodeString &
|
||||
append(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const U_OVERRIDE {
|
||||
UErrorCode &errorCode) const override {
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
if(&first!=&second) {
|
||||
first.append(second);
|
||||
|
@ -141,29 +141,29 @@ class NoopNormalizer2 : public Normalizer2 {
|
|||
return first;
|
||||
}
|
||||
virtual UBool
|
||||
getDecomposition(UChar32, UnicodeString &) const U_OVERRIDE {
|
||||
getDecomposition(UChar32, UnicodeString &) const override {
|
||||
return false;
|
||||
}
|
||||
// No need to U_OVERRIDE the default getRawDecomposition().
|
||||
// No need to override the default getRawDecomposition().
|
||||
virtual UBool
|
||||
isNormalized(const UnicodeString &, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
isNormalized(const UnicodeString &, UErrorCode &errorCode) const override {
|
||||
return U_SUCCESS(errorCode);
|
||||
}
|
||||
virtual UBool
|
||||
isNormalizedUTF8(StringPiece, UErrorCode &errorCode) const U_OVERRIDE {
|
||||
isNormalizedUTF8(StringPiece, UErrorCode &errorCode) const override {
|
||||
return U_SUCCESS(errorCode);
|
||||
}
|
||||
virtual UNormalizationCheckResult
|
||||
quickCheck(const UnicodeString &, UErrorCode &) const U_OVERRIDE {
|
||||
quickCheck(const UnicodeString &, UErrorCode &) const override {
|
||||
return UNORM_YES;
|
||||
}
|
||||
virtual int32_t
|
||||
spanQuickCheckYes(const UnicodeString &s, UErrorCode &) const U_OVERRIDE {
|
||||
spanQuickCheckYes(const UnicodeString &s, UErrorCode &) const override {
|
||||
return s.length();
|
||||
}
|
||||
virtual UBool hasBoundaryBefore(UChar32) const U_OVERRIDE { return true; }
|
||||
virtual UBool hasBoundaryAfter(UChar32) const U_OVERRIDE { return true; }
|
||||
virtual UBool isInert(UChar32) const U_OVERRIDE { return true; }
|
||||
virtual UBool hasBoundaryBefore(UChar32) const override { return true; }
|
||||
virtual UBool hasBoundaryAfter(UChar32) const override { return true; }
|
||||
virtual UBool isInert(UChar32) const override { return true; }
|
||||
};
|
||||
|
||||
NoopNormalizer2::~NoopNormalizer2() {}
|
||||
|
@ -190,7 +190,7 @@ static void U_CALLCONV initNoopSingleton(UErrorCode &errorCode) {
|
|||
return;
|
||||
}
|
||||
noopSingleton=new NoopNormalizer2;
|
||||
if(noopSingleton==NULL) {
|
||||
if(noopSingleton==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ static void U_CALLCONV initNoopSingleton(UErrorCode &errorCode) {
|
|||
}
|
||||
|
||||
const Normalizer2 *Normalizer2Factory::getNoopInstance(UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) { return NULL; }
|
||||
if(U_FAILURE(errorCode)) { return nullptr; }
|
||||
umtx_initOnce(noopInitOnce, &initNoopSingleton, errorCode);
|
||||
return noopSingleton;
|
||||
}
|
||||
|
@ -216,13 +216,13 @@ Norm2AllModes *
|
|||
Norm2AllModes::createInstance(Normalizer2Impl *impl, UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
delete impl;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Norm2AllModes *allModes=new Norm2AllModes(impl);
|
||||
if(allModes==NULL) {
|
||||
if(allModes==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
delete impl;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return allModes;
|
||||
}
|
||||
|
@ -231,12 +231,12 @@ Norm2AllModes::createInstance(Normalizer2Impl *impl, UErrorCode &errorCode) {
|
|||
Norm2AllModes *
|
||||
Norm2AllModes::createNFCInstance(UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Normalizer2Impl *impl=new Normalizer2Impl;
|
||||
if(impl==NULL) {
|
||||
if(impl==nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
impl->init(norm2_nfc_data_indexes, &norm2_nfc_data_trie,
|
||||
norm2_nfc_data_extraData, norm2_nfc_data_smallFCD);
|
||||
|
@ -254,7 +254,7 @@ static void U_CALLCONV initNFCSingleton(UErrorCode &errorCode) {
|
|||
|
||||
const Norm2AllModes *
|
||||
Norm2AllModes::getNFCInstance(UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) { return NULL; }
|
||||
if(U_FAILURE(errorCode)) { return nullptr; }
|
||||
umtx_initOnce(nfcInitOnce, &initNFCSingleton, errorCode);
|
||||
return nfcSingleton;
|
||||
}
|
||||
|
@ -262,29 +262,29 @@ Norm2AllModes::getNFCInstance(UErrorCode &errorCode) {
|
|||
const Normalizer2 *
|
||||
Normalizer2::getNFCInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->comp : NULL;
|
||||
return allModes!=nullptr ? &allModes->comp : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *
|
||||
Normalizer2::getNFDInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->decomp : NULL;
|
||||
return allModes!=nullptr ? &allModes->decomp : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *Normalizer2Factory::getFCDInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->fcd : NULL;
|
||||
return allModes!=nullptr ? &allModes->fcd : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2 *Normalizer2Factory::getFCCInstance(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? &allModes->fcc : NULL;
|
||||
return allModes!=nullptr ? &allModes->fcc : nullptr;
|
||||
}
|
||||
|
||||
const Normalizer2Impl *
|
||||
Normalizer2Factory::getNFCImpl(UErrorCode &errorCode) {
|
||||
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
|
||||
return allModes!=NULL ? allModes->impl : NULL;
|
||||
return allModes!=nullptr ? allModes->impl : nullptr;
|
||||
}
|
||||
#endif // NORM2_HARDCODE_NFC_DATA
|
||||
|
||||
|
@ -292,11 +292,11 @@ U_CDECL_BEGIN
|
|||
|
||||
static UBool U_CALLCONV uprv_normalizer2_cleanup() {
|
||||
delete noopSingleton;
|
||||
noopSingleton = NULL;
|
||||
noopSingleton = nullptr;
|
||||
noopInitOnce.reset();
|
||||
#if NORM2_HARDCODE_NFC_DATA
|
||||
delete nfcSingleton;
|
||||
nfcSingleton = NULL;
|
||||
nfcSingleton = nullptr;
|
||||
nfcInitOnce.reset();
|
||||
#endif
|
||||
return true;
|
||||
|
@ -327,29 +327,29 @@ unorm2_close(UNormalizer2 *norm2) {
|
|||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
unorm2_normalize(const UNormalizer2 *norm2,
|
||||
const UChar *src, int32_t length,
|
||||
UChar *dest, int32_t capacity,
|
||||
const char16_t *src, int32_t length,
|
||||
char16_t *dest, int32_t capacity,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if( (src==NULL ? length!=0 : length<-1) ||
|
||||
(dest==NULL ? capacity!=0 : capacity<0) ||
|
||||
(src==dest && src!=NULL)
|
||||
if( (src==nullptr ? length!=0 : length<-1) ||
|
||||
(dest==nullptr ? capacity!=0 : capacity<0) ||
|
||||
(src==dest && src!=nullptr)
|
||||
) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
UnicodeString destString(dest, 0, capacity);
|
||||
// length==0: Nothing to do, and n2wi->normalize(NULL, NULL, buffer, ...) would crash.
|
||||
// length==0: Nothing to do, and n2wi->normalize(nullptr, nullptr, buffer, ...) would crash.
|
||||
if(length!=0) {
|
||||
const Normalizer2 *n2=(const Normalizer2 *)norm2;
|
||||
const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2);
|
||||
if(n2wi!=NULL) {
|
||||
if(n2wi!=nullptr) {
|
||||
// Avoid duplicate argument checking and support NUL-terminated src.
|
||||
ReorderingBuffer buffer(n2wi->impl, destString);
|
||||
if(buffer.init(length, *pErrorCode)) {
|
||||
n2wi->normalize(src, length>=0 ? src+length : NULL, buffer, *pErrorCode);
|
||||
n2wi->normalize(src, length>=0 ? src+length : nullptr, buffer, *pErrorCode);
|
||||
}
|
||||
} else {
|
||||
UnicodeString srcString(length<0, src, length);
|
||||
|
@ -361,34 +361,34 @@ unorm2_normalize(const UNormalizer2 *norm2,
|
|||
|
||||
static int32_t
|
||||
normalizeSecondAndAppend(const UNormalizer2 *norm2,
|
||||
UChar *first, int32_t firstLength, int32_t firstCapacity,
|
||||
const UChar *second, int32_t secondLength,
|
||||
char16_t *first, int32_t firstLength, int32_t firstCapacity,
|
||||
const char16_t *second, int32_t secondLength,
|
||||
UBool doNormalize,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if( (second==NULL ? secondLength!=0 : secondLength<-1) ||
|
||||
(first==NULL ? (firstCapacity!=0 || firstLength!=0) :
|
||||
if( (second==nullptr ? secondLength!=0 : secondLength<-1) ||
|
||||
(first==nullptr ? (firstCapacity!=0 || firstLength!=0) :
|
||||
(firstCapacity<0 || firstLength<-1)) ||
|
||||
(first==second && first!=NULL)
|
||||
(first==second && first!=nullptr)
|
||||
) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
UnicodeString firstString(first, firstLength, firstCapacity);
|
||||
firstLength=firstString.length(); // In case it was -1.
|
||||
// secondLength==0: Nothing to do, and n2wi->normalizeAndAppend(NULL, NULL, buffer, ...) would crash.
|
||||
// secondLength==0: Nothing to do, and n2wi->normalizeAndAppend(nullptr, nullptr, buffer, ...) would crash.
|
||||
if(secondLength!=0) {
|
||||
const Normalizer2 *n2=(const Normalizer2 *)norm2;
|
||||
const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2);
|
||||
if(n2wi!=NULL) {
|
||||
if(n2wi!=nullptr) {
|
||||
// Avoid duplicate argument checking and support NUL-terminated src.
|
||||
UnicodeString safeMiddle;
|
||||
{
|
||||
ReorderingBuffer buffer(n2wi->impl, firstString);
|
||||
if(buffer.init(firstLength+secondLength+1, *pErrorCode)) { // destCapacity>=-1
|
||||
n2wi->normalizeAndAppend(second, secondLength>=0 ? second+secondLength : NULL,
|
||||
n2wi->normalizeAndAppend(second, secondLength>=0 ? second+secondLength : nullptr,
|
||||
doNormalize, safeMiddle, buffer, *pErrorCode);
|
||||
}
|
||||
} // The ReorderingBuffer destructor finalizes firstString.
|
||||
|
@ -396,7 +396,7 @@ normalizeSecondAndAppend(const UNormalizer2 *norm2,
|
|||
// Restore the modified suffix of the first string.
|
||||
// This does not restore first[] array contents between firstLength and firstCapacity.
|
||||
// (That might be uninitialized memory, as far as we know.)
|
||||
if(first!=NULL) { /* don't dereference NULL */
|
||||
if(first!=nullptr) { /* don't dereference nullptr */
|
||||
safeMiddle.extract(0, 0x7fffffff, first+firstLength-safeMiddle.length());
|
||||
if(firstLength<firstCapacity) {
|
||||
first[firstLength]=0; // NUL-terminate in case it was originally.
|
||||
|
@ -417,8 +417,8 @@ normalizeSecondAndAppend(const UNormalizer2 *norm2,
|
|||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
|
||||
UChar *first, int32_t firstLength, int32_t firstCapacity,
|
||||
const UChar *second, int32_t secondLength,
|
||||
char16_t *first, int32_t firstLength, int32_t firstCapacity,
|
||||
const char16_t *second, int32_t secondLength,
|
||||
UErrorCode *pErrorCode) {
|
||||
return normalizeSecondAndAppend(norm2,
|
||||
first, firstLength, firstCapacity,
|
||||
|
@ -428,8 +428,8 @@ unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
|
|||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
unorm2_append(const UNormalizer2 *norm2,
|
||||
UChar *first, int32_t firstLength, int32_t firstCapacity,
|
||||
const UChar *second, int32_t secondLength,
|
||||
char16_t *first, int32_t firstLength, int32_t firstCapacity,
|
||||
const char16_t *second, int32_t secondLength,
|
||||
UErrorCode *pErrorCode) {
|
||||
return normalizeSecondAndAppend(norm2,
|
||||
first, firstLength, firstCapacity,
|
||||
|
@ -439,12 +439,12 @@ unorm2_append(const UNormalizer2 *norm2,
|
|||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
unorm2_getDecomposition(const UNormalizer2 *norm2,
|
||||
UChar32 c, UChar *decomposition, int32_t capacity,
|
||||
UChar32 c, char16_t *decomposition, int32_t capacity,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if(decomposition==NULL ? capacity!=0 : capacity<0) {
|
||||
if(decomposition==nullptr ? capacity!=0 : capacity<0) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -458,12 +458,12 @@ unorm2_getDecomposition(const UNormalizer2 *norm2,
|
|||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
unorm2_getRawDecomposition(const UNormalizer2 *norm2,
|
||||
UChar32 c, UChar *decomposition, int32_t capacity,
|
||||
UChar32 c, char16_t *decomposition, int32_t capacity,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if(decomposition==NULL ? capacity!=0 : capacity<0) {
|
||||
if(decomposition==nullptr ? capacity!=0 : capacity<0) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -487,12 +487,12 @@ unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c) {
|
|||
|
||||
U_CAPI UBool U_EXPORT2
|
||||
unorm2_isNormalized(const UNormalizer2 *norm2,
|
||||
const UChar *s, int32_t length,
|
||||
const char16_t *s, int32_t length,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if((s==NULL && length!=0) || length<-1) {
|
||||
if((s==nullptr && length!=0) || length<-1) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -502,12 +502,12 @@ unorm2_isNormalized(const UNormalizer2 *norm2,
|
|||
|
||||
U_CAPI UNormalizationCheckResult U_EXPORT2
|
||||
unorm2_quickCheck(const UNormalizer2 *norm2,
|
||||
const UChar *s, int32_t length,
|
||||
const char16_t *s, int32_t length,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return UNORM_NO;
|
||||
}
|
||||
if((s==NULL && length!=0) || length<-1) {
|
||||
if((s==nullptr && length!=0) || length<-1) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return UNORM_NO;
|
||||
}
|
||||
|
@ -517,12 +517,12 @@ unorm2_quickCheck(const UNormalizer2 *norm2,
|
|||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
|
||||
const UChar *s, int32_t length,
|
||||
const char16_t *s, int32_t length,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if((s==NULL && length!=0) || length<-1) {
|
||||
if((s==nullptr && length!=0) || length<-1) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ UChar32 codePointFromValidUTF8(const uint8_t *cpStart, const uint8_t *cpLimit) {
|
|||
case 2:
|
||||
return ((c&0x1f)<<6) | (cpStart[1]&0x3f);
|
||||
case 3:
|
||||
// no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (UChar)
|
||||
return (UChar)((c<<12) | ((cpStart[1]&0x3f)<<6) | (cpStart[2]&0x3f));
|
||||
// no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (char16_t)
|
||||
return (char16_t)((c<<12) | ((cpStart[1]&0x3f)<<6) | (cpStart[2]&0x3f));
|
||||
case 4:
|
||||
return ((c&7)<<18) | ((cpStart[1]&0x3f)<<12) | ((cpStart[2]&0x3f)<<6) | (cpStart[3]&0x3f);
|
||||
default:
|
||||
|
@ -182,7 +182,7 @@ ReorderingBuffer::ReorderingBuffer(const Normalizer2Impl &ni, UnicodeString &des
|
|||
UBool ReorderingBuffer::init(int32_t destCapacity, UErrorCode &errorCode) {
|
||||
int32_t length=str.length();
|
||||
start=str.getBuffer(destCapacity);
|
||||
if(start==NULL) {
|
||||
if(start==nullptr) {
|
||||
// getBuffer() already did str.setToBogus()
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
|
@ -204,7 +204,7 @@ UBool ReorderingBuffer::init(int32_t destCapacity, UErrorCode &errorCode) {
|
|||
return true;
|
||||
}
|
||||
|
||||
UBool ReorderingBuffer::equals(const UChar *otherStart, const UChar *otherLimit) const {
|
||||
UBool ReorderingBuffer::equals(const char16_t *otherStart, const char16_t *otherLimit) const {
|
||||
int32_t length=(int32_t)(limit-start);
|
||||
return
|
||||
length==(int32_t)(otherLimit-otherStart) &&
|
||||
|
@ -256,7 +256,7 @@ UBool ReorderingBuffer::appendSupplementary(UChar32 c, uint8_t cc, UErrorCode &e
|
|||
return true;
|
||||
}
|
||||
|
||||
UBool ReorderingBuffer::append(const UChar *s, int32_t length, UBool isNFD,
|
||||
UBool ReorderingBuffer::append(const char16_t *s, int32_t length, UBool isNFD,
|
||||
uint8_t leadCC, uint8_t trailCC,
|
||||
UErrorCode &errorCode) {
|
||||
if(length==0) {
|
||||
|
@ -272,7 +272,7 @@ UBool ReorderingBuffer::append(const UChar *s, int32_t length, UBool isNFD,
|
|||
} else if(leadCC<=1) {
|
||||
reorderStart=limit+1; // Ok if not a code point boundary.
|
||||
}
|
||||
const UChar *sLimit=s+length;
|
||||
const char16_t *sLimit=s+length;
|
||||
do { *limit++=*s++; } while(s!=sLimit);
|
||||
lastCC=trailCC;
|
||||
} else {
|
||||
|
@ -304,7 +304,7 @@ UBool ReorderingBuffer::appendZeroCC(UChar32 c, UErrorCode &errorCode) {
|
|||
}
|
||||
remainingCapacity-=cpLength;
|
||||
if(cpLength==1) {
|
||||
*limit++=(UChar)c;
|
||||
*limit++=(char16_t)c;
|
||||
} else {
|
||||
limit[0]=U16_LEAD(c);
|
||||
limit[1]=U16_TRAIL(c);
|
||||
|
@ -315,7 +315,7 @@ UBool ReorderingBuffer::appendZeroCC(UChar32 c, UErrorCode &errorCode) {
|
|||
return true;
|
||||
}
|
||||
|
||||
UBool ReorderingBuffer::appendZeroCC(const UChar *s, const UChar *sLimit, UErrorCode &errorCode) {
|
||||
UBool ReorderingBuffer::appendZeroCC(const char16_t *s, const char16_t *sLimit, UErrorCode &errorCode) {
|
||||
if(s==sLimit) {
|
||||
return true;
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ UBool ReorderingBuffer::resize(int32_t appendLength, UErrorCode &errorCode) {
|
|||
newCapacity=256;
|
||||
}
|
||||
start=str.getBuffer(newCapacity);
|
||||
if(start==NULL) {
|
||||
if(start==nullptr) {
|
||||
// getBuffer() already did str.setToBogus()
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
|
@ -375,7 +375,7 @@ UBool ReorderingBuffer::resize(int32_t appendLength, UErrorCode &errorCode) {
|
|||
|
||||
void ReorderingBuffer::skipPrevious() {
|
||||
codePointLimit=codePointStart;
|
||||
UChar c=*--codePointStart;
|
||||
char16_t c=*--codePointStart;
|
||||
if(U16_IS_TRAIL(c) && start<codePointStart && U16_IS_LEAD(*(codePointStart-1))) {
|
||||
--codePointStart;
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ uint8_t ReorderingBuffer::previousCC() {
|
|||
return 0;
|
||||
}
|
||||
UChar32 c=*--codePointStart;
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if(U16_IS_TRAIL(c) && start<codePointStart && U16_IS_LEAD(c2=*(codePointStart-1))) {
|
||||
--codePointStart;
|
||||
c=U16_GET_SUPPLEMENTARY(c2, c);
|
||||
|
@ -400,8 +400,8 @@ uint8_t ReorderingBuffer::previousCC() {
|
|||
void ReorderingBuffer::insert(UChar32 c, uint8_t cc) {
|
||||
for(setIterator(), skipPrevious(); previousCC()>cc;) {}
|
||||
// insert c at codePointLimit, after the character with prevCC<=cc
|
||||
UChar *q=limit;
|
||||
UChar *r=limit+=U16_LENGTH(c);
|
||||
char16_t *q=limit;
|
||||
char16_t *r=limit+=U16_LENGTH(c);
|
||||
do {
|
||||
*--r=*--q;
|
||||
} while(codePointLimit!=q);
|
||||
|
@ -429,9 +429,9 @@ Normalizer2Impl::~Normalizer2Impl() {
|
|||
void
|
||||
Normalizer2Impl::init(const int32_t *inIndexes, const UCPTrie *inTrie,
|
||||
const uint16_t *inExtraData, const uint8_t *inSmallFCD) {
|
||||
minDecompNoCP = static_cast<UChar>(inIndexes[IX_MIN_DECOMP_NO_CP]);
|
||||
minCompNoMaybeCP = static_cast<UChar>(inIndexes[IX_MIN_COMP_NO_MAYBE_CP]);
|
||||
minLcccCP = static_cast<UChar>(inIndexes[IX_MIN_LCCC_CP]);
|
||||
minDecompNoCP = static_cast<char16_t>(inIndexes[IX_MIN_DECOMP_NO_CP]);
|
||||
minCompNoMaybeCP = static_cast<char16_t>(inIndexes[IX_MIN_COMP_NO_MAYBE_CP]);
|
||||
minLcccCP = static_cast<char16_t>(inIndexes[IX_MIN_LCCC_CP]);
|
||||
|
||||
minYesNo = static_cast<uint16_t>(inIndexes[IX_MIN_YES_NO]);
|
||||
minYesNoMappingsOnly = static_cast<uint16_t>(inIndexes[IX_MIN_YES_NO_MAPPINGS_ONLY]);
|
||||
|
@ -503,7 +503,7 @@ Normalizer2Impl::addPropertyStarts(const USetAdder *sa, UErrorCode & /*errorCode
|
|||
}
|
||||
|
||||
/* add Hangul LV syllables and LV+1 because of skippables */
|
||||
for(UChar c=Hangul::HANGUL_BASE; c<Hangul::HANGUL_LIMIT; c+=Hangul::JAMO_T_COUNT) {
|
||||
for(char16_t c=Hangul::HANGUL_BASE; c<Hangul::HANGUL_LIMIT; c+=Hangul::JAMO_T_COUNT) {
|
||||
sa->add(sa->set, c);
|
||||
sa->add(sa->set, c+1);
|
||||
}
|
||||
|
@ -524,8 +524,8 @@ Normalizer2Impl::addCanonIterPropertyStarts(const USetAdder *sa, UErrorCode &err
|
|||
}
|
||||
}
|
||||
|
||||
const UChar *
|
||||
Normalizer2Impl::copyLowPrefixFromNulTerminated(const UChar *src,
|
||||
const char16_t *
|
||||
Normalizer2Impl::copyLowPrefixFromNulTerminated(const char16_t *src,
|
||||
UChar32 minNeedDataCP,
|
||||
ReorderingBuffer *buffer,
|
||||
UErrorCode &errorCode) const {
|
||||
|
@ -534,13 +534,13 @@ Normalizer2Impl::copyLowPrefixFromNulTerminated(const UChar *src,
|
|||
// data and check the first part of the string.
|
||||
// After this prefix, determine the string length to simplify the rest
|
||||
// of the code.
|
||||
const UChar *prevSrc=src;
|
||||
UChar c;
|
||||
const char16_t *prevSrc=src;
|
||||
char16_t c;
|
||||
while((c=*src++)<minNeedDataCP && c!=0) {}
|
||||
// Back out the last character for full processing.
|
||||
// Copy this prefix.
|
||||
if(--src!=prevSrc) {
|
||||
if(buffer!=NULL) {
|
||||
if(buffer!=nullptr) {
|
||||
buffer->appendZeroCC(prevSrc, src, errorCode);
|
||||
}
|
||||
}
|
||||
|
@ -554,8 +554,8 @@ Normalizer2Impl::decompose(const UnicodeString &src, UnicodeString &dest,
|
|||
dest.setToBogus();
|
||||
return dest;
|
||||
}
|
||||
const UChar *sArray=src.getBuffer();
|
||||
if(&dest==&src || sArray==NULL) {
|
||||
const char16_t *sArray=src.getBuffer();
|
||||
if(&dest==&src || sArray==nullptr) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
dest.setToBogus();
|
||||
return dest;
|
||||
|
@ -565,11 +565,11 @@ Normalizer2Impl::decompose(const UnicodeString &src, UnicodeString &dest,
|
|||
}
|
||||
|
||||
void
|
||||
Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
|
||||
Normalizer2Impl::decompose(const char16_t *src, const char16_t *limit,
|
||||
UnicodeString &dest,
|
||||
int32_t destLengthEstimate,
|
||||
UErrorCode &errorCode) const {
|
||||
if(destLengthEstimate<0 && limit!=NULL) {
|
||||
if(destLengthEstimate<0 && limit!=nullptr) {
|
||||
destLengthEstimate=(int32_t)(limit-src);
|
||||
}
|
||||
dest.remove();
|
||||
|
@ -580,14 +580,14 @@ Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
|
|||
}
|
||||
|
||||
// Dual functionality:
|
||||
// buffer!=NULL: normalize
|
||||
// buffer==NULL: isNormalized/spanQuickCheckYes
|
||||
const UChar *
|
||||
Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
|
||||
// buffer!=nullptr: normalize
|
||||
// buffer==nullptr: isNormalized/spanQuickCheckYes
|
||||
const char16_t *
|
||||
Normalizer2Impl::decompose(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer *buffer,
|
||||
UErrorCode &errorCode) const {
|
||||
UChar32 minNoCP=minDecompNoCP;
|
||||
if(limit==NULL) {
|
||||
if(limit==nullptr) {
|
||||
src=copyLowPrefixFromNulTerminated(src, minNoCP, buffer, errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return src;
|
||||
|
@ -595,12 +595,12 @@ Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
|
|||
limit=u_strchr(src, 0);
|
||||
}
|
||||
|
||||
const UChar *prevSrc;
|
||||
const char16_t *prevSrc;
|
||||
UChar32 c=0;
|
||||
uint16_t norm16=0;
|
||||
|
||||
// only for quick check
|
||||
const UChar *prevBoundary=src;
|
||||
const char16_t *prevBoundary=src;
|
||||
uint8_t prevCC=0;
|
||||
|
||||
for(;;) {
|
||||
|
@ -613,7 +613,7 @@ Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
|
|||
} else if(!U16_IS_LEAD(c)) {
|
||||
break;
|
||||
} else {
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if((src+1)!=limit && U16_IS_TRAIL(c2=src[1])) {
|
||||
c=U16_GET_SUPPLEMENTARY(c, c2);
|
||||
norm16=UCPTRIE_FAST_SUPP_GET(normTrie, UCPTRIE_16, c);
|
||||
|
@ -629,7 +629,7 @@ Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
|
|||
}
|
||||
// copy these code units all at once
|
||||
if(src!=prevSrc) {
|
||||
if(buffer!=NULL) {
|
||||
if(buffer!=nullptr) {
|
||||
if(!buffer->appendZeroCC(prevSrc, src, errorCode)) {
|
||||
break;
|
||||
}
|
||||
|
@ -644,7 +644,7 @@ Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
|
|||
|
||||
// Check one above-minimum, relevant code point.
|
||||
src+=U16_LENGTH(c);
|
||||
if(buffer!=NULL) {
|
||||
if(buffer!=nullptr) {
|
||||
if(!decompose(c, norm16, *buffer, errorCode)) {
|
||||
break;
|
||||
}
|
||||
|
@ -669,8 +669,8 @@ Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
|
|||
// fail the quick check loop and/or where the quick check loop's overhead
|
||||
// is unlikely to be amortized.
|
||||
// Called by the compose() and makeFCD() implementations.
|
||||
const UChar *
|
||||
Normalizer2Impl::decomposeShort(const UChar *src, const UChar *limit,
|
||||
const char16_t *
|
||||
Normalizer2Impl::decomposeShort(const char16_t *src, const char16_t *limit,
|
||||
UBool stopAtCompBoundary, UBool onlyContiguous,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const {
|
||||
if (U_FAILURE(errorCode)) {
|
||||
|
@ -680,7 +680,7 @@ Normalizer2Impl::decomposeShort(const UChar *src, const UChar *limit,
|
|||
if (stopAtCompBoundary && *src < minCompNoMaybeCP) {
|
||||
return src;
|
||||
}
|
||||
const UChar *prevSrc = src;
|
||||
const char16_t *prevSrc = src;
|
||||
UChar32 c;
|
||||
uint16_t norm16;
|
||||
UCPTRIE_FAST_U16_NEXT(normTrie, UCPTRIE_16, src, limit, c, norm16);
|
||||
|
@ -714,7 +714,7 @@ UBool Normalizer2Impl::decompose(UChar32 c, uint16_t norm16,
|
|||
return buffer.append(c, 0, errorCode);
|
||||
} else if(isHangulLV(norm16) || isHangulLVT(norm16)) {
|
||||
// Hangul syllable: decompose algorithmically
|
||||
UChar jamos[3];
|
||||
char16_t jamos[3];
|
||||
return buffer.appendZeroCC(jamos, jamos+Hangul::decompose(c, jamos), errorCode);
|
||||
}
|
||||
// c decomposes, get everything from the variable-length extra data
|
||||
|
@ -728,7 +728,7 @@ UBool Normalizer2Impl::decompose(UChar32 c, uint16_t norm16,
|
|||
} else {
|
||||
leadCC=0;
|
||||
}
|
||||
return buffer.append((const UChar *)mapping+1, length, true, leadCC, trailCC, errorCode);
|
||||
return buffer.append((const char16_t *)mapping+1, length, true, leadCC, trailCC, errorCode);
|
||||
}
|
||||
|
||||
// Dual functionality:
|
||||
|
@ -943,14 +943,14 @@ Normalizer2Impl::decomposeShort(const uint8_t *src, const uint8_t *limit,
|
|||
return src;
|
||||
}
|
||||
|
||||
const UChar *
|
||||
Normalizer2Impl::getDecomposition(UChar32 c, UChar buffer[4], int32_t &length) const {
|
||||
const char16_t *
|
||||
Normalizer2Impl::getDecomposition(UChar32 c, char16_t buffer[4], int32_t &length) const {
|
||||
uint16_t norm16;
|
||||
if(c<minDecompNoCP || isMaybeOrNonZeroCC(norm16=getNorm16(c))) {
|
||||
// c does not decompose
|
||||
return nullptr;
|
||||
}
|
||||
const UChar *decomp = nullptr;
|
||||
const char16_t *decomp = nullptr;
|
||||
if(isDecompNoAlgorithmic(norm16)) {
|
||||
// Maps to an isCompYesAndZeroCC.
|
||||
c=mapAlgorithmic(c, norm16);
|
||||
|
@ -970,19 +970,19 @@ Normalizer2Impl::getDecomposition(UChar32 c, UChar buffer[4], int32_t &length) c
|
|||
// c decomposes, get everything from the variable-length extra data
|
||||
const uint16_t *mapping=getMapping(norm16);
|
||||
length=*mapping&MAPPING_LENGTH_MASK;
|
||||
return (const UChar *)mapping+1;
|
||||
return (const char16_t *)mapping+1;
|
||||
}
|
||||
|
||||
// The capacity of the buffer must be 30=MAPPING_LENGTH_MASK-1
|
||||
// so that a raw mapping fits that consists of one unit ("rm0")
|
||||
// plus all but the first two code units of the normal mapping.
|
||||
// The maximum length of a normal mapping is 31=MAPPING_LENGTH_MASK.
|
||||
const UChar *
|
||||
Normalizer2Impl::getRawDecomposition(UChar32 c, UChar buffer[30], int32_t &length) const {
|
||||
const char16_t *
|
||||
Normalizer2Impl::getRawDecomposition(UChar32 c, char16_t buffer[30], int32_t &length) const {
|
||||
uint16_t norm16;
|
||||
if(c<minDecompNoCP || isDecompYes(norm16=getNorm16(c))) {
|
||||
// c does not decompose
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else if(isHangulLV(norm16) || isHangulLVT(norm16)) {
|
||||
// Hangul syllable: decompose algorithmically
|
||||
Hangul::getRawDecomposition(c, buffer);
|
||||
|
@ -1005,21 +1005,21 @@ Normalizer2Impl::getRawDecomposition(UChar32 c, UChar buffer[30], int32_t &lengt
|
|||
uint16_t rm0=*rawMapping;
|
||||
if(rm0<=MAPPING_LENGTH_MASK) {
|
||||
length=rm0;
|
||||
return (const UChar *)rawMapping-rm0;
|
||||
return (const char16_t *)rawMapping-rm0;
|
||||
} else {
|
||||
// Copy the normal mapping and replace its first two code units with rm0.
|
||||
buffer[0]=(UChar)rm0;
|
||||
u_memcpy(buffer+1, (const UChar *)mapping+1+2, mLength-2);
|
||||
buffer[0]=(char16_t)rm0;
|
||||
u_memcpy(buffer+1, (const char16_t *)mapping+1+2, mLength-2);
|
||||
length=mLength-1;
|
||||
return buffer;
|
||||
}
|
||||
} else {
|
||||
length=mLength;
|
||||
return (const UChar *)mapping+1;
|
||||
return (const char16_t *)mapping+1;
|
||||
}
|
||||
}
|
||||
|
||||
void Normalizer2Impl::decomposeAndAppend(const UChar *src, const UChar *limit,
|
||||
void Normalizer2Impl::decomposeAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doDecompose,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer,
|
||||
|
@ -1032,9 +1032,9 @@ void Normalizer2Impl::decomposeAndAppend(const UChar *src, const UChar *limit,
|
|||
// Just merge the strings at the boundary.
|
||||
bool isFirst = true;
|
||||
uint8_t firstCC = 0, prevCC = 0, cc;
|
||||
const UChar *p = src;
|
||||
const char16_t *p = src;
|
||||
while (p != limit) {
|
||||
const UChar *codePointStart = p;
|
||||
const char16_t *codePointStart = p;
|
||||
UChar32 c;
|
||||
uint16_t norm16;
|
||||
UCPTRIE_FAST_U16_NEXT(normTrie, UCPTRIE_16, p, limit, c, norm16);
|
||||
|
@ -1048,7 +1048,7 @@ void Normalizer2Impl::decomposeAndAppend(const UChar *src, const UChar *limit,
|
|||
}
|
||||
prevCC = cc;
|
||||
}
|
||||
if(limit==NULL) { // appendZeroCC() needs limit!=NULL
|
||||
if(limit==nullptr) { // appendZeroCC() needs limit!=nullptr
|
||||
limit=u_strchr(p, 0);
|
||||
}
|
||||
|
||||
|
@ -1218,13 +1218,13 @@ void Normalizer2Impl::addComposites(const uint16_t *list, UnicodeSet &set) const
|
|||
*/
|
||||
void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStartIndex,
|
||||
UBool onlyContiguous) const {
|
||||
UChar *p=buffer.getStart()+recomposeStartIndex;
|
||||
UChar *limit=buffer.getLimit();
|
||||
char16_t *p=buffer.getStart()+recomposeStartIndex;
|
||||
char16_t *limit=buffer.getLimit();
|
||||
if(p==limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
UChar *starter, *pRemove, *q, *r;
|
||||
char16_t *starter, *pRemove, *q, *r;
|
||||
const uint16_t *compositionsList;
|
||||
UChar32 c, compositeAndFwd;
|
||||
uint16_t norm16;
|
||||
|
@ -1233,8 +1233,8 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
|
||||
// Some of the following variables are not used until we have a forward-combining starter
|
||||
// and are only initialized now to avoid compiler warnings.
|
||||
compositionsList=NULL; // used as indicator for whether we have a forward-combining starter
|
||||
starter=NULL;
|
||||
compositionsList=nullptr; // used as indicator for whether we have a forward-combining starter
|
||||
starter=nullptr;
|
||||
starterIsSupplementary=false;
|
||||
prevCC=0;
|
||||
|
||||
|
@ -1244,7 +1244,7 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
if( // this character combines backward and
|
||||
isMaybe(norm16) &&
|
||||
// we have seen a starter that combines forward and
|
||||
compositionsList!=NULL &&
|
||||
compositionsList!=nullptr &&
|
||||
// the backward-combining character is not blocked
|
||||
(prevCC<cc || prevCC==0)
|
||||
) {
|
||||
|
@ -1252,15 +1252,15 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
// c is a Jamo V/T, see if we can compose it with the previous character.
|
||||
if(c<Hangul::JAMO_T_BASE) {
|
||||
// c is a Jamo Vowel, compose with previous Jamo L and following Jamo T.
|
||||
UChar prev=(UChar)(*starter-Hangul::JAMO_L_BASE);
|
||||
char16_t prev=(char16_t)(*starter-Hangul::JAMO_L_BASE);
|
||||
if(prev<Hangul::JAMO_L_COUNT) {
|
||||
pRemove=p-1;
|
||||
UChar syllable=(UChar)
|
||||
char16_t syllable=(char16_t)
|
||||
(Hangul::HANGUL_BASE+
|
||||
(prev*Hangul::JAMO_V_COUNT+(c-Hangul::JAMO_V_BASE))*
|
||||
Hangul::JAMO_T_COUNT);
|
||||
UChar t;
|
||||
if(p!=limit && (t=(UChar)(*p-Hangul::JAMO_T_BASE))<Hangul::JAMO_T_COUNT) {
|
||||
char16_t t;
|
||||
if(p!=limit && (t=(char16_t)(*p-Hangul::JAMO_T_BASE))<Hangul::JAMO_T_COUNT) {
|
||||
++p;
|
||||
syllable+=t; // The next character was a Jamo T.
|
||||
}
|
||||
|
@ -1284,7 +1284,7 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
if(p==limit) {
|
||||
break;
|
||||
}
|
||||
compositionsList=NULL;
|
||||
compositionsList=nullptr;
|
||||
continue;
|
||||
} else if((compositeAndFwd=combine(compositionsList, c))>=0) {
|
||||
// The starter and the combining mark (c) do combine.
|
||||
|
@ -1298,7 +1298,7 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
starter[0]=U16_LEAD(composite);
|
||||
starter[1]=U16_TRAIL(composite);
|
||||
} else {
|
||||
*starter=(UChar)composite;
|
||||
*starter=(char16_t)composite;
|
||||
// The composite is shorter than the starter,
|
||||
// move the intermediate characters forward one.
|
||||
starterIsSupplementary=false;
|
||||
|
@ -1323,7 +1323,7 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
*--starter=U16_LEAD(composite); // undo the temporary increment
|
||||
} else {
|
||||
// both are on the BMP
|
||||
*starter=(UChar)composite;
|
||||
*starter=(char16_t)composite;
|
||||
}
|
||||
|
||||
/* remove the combining mark by moving the following text over it */
|
||||
|
@ -1346,7 +1346,7 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
compositionsList=
|
||||
getCompositionsListForComposite(getRawNorm16(composite));
|
||||
} else {
|
||||
compositionsList=NULL;
|
||||
compositionsList=nullptr;
|
||||
}
|
||||
|
||||
// We combined; continue with looking for compositions.
|
||||
|
@ -1363,7 +1363,7 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
// If c did not combine, then check if it is a starter.
|
||||
if(cc==0) {
|
||||
// Found a new starter.
|
||||
if((compositionsList=getCompositionsListForDecompYes(norm16))!=NULL) {
|
||||
if((compositionsList=getCompositionsListForDecompYes(norm16))!=nullptr) {
|
||||
// It may combine with something, prepare for it.
|
||||
if(U_IS_BMP(c)) {
|
||||
starterIsSupplementary=false;
|
||||
|
@ -1375,7 +1375,7 @@ void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStart
|
|||
}
|
||||
} else if(onlyContiguous) {
|
||||
// FCC: no discontiguous compositions; any intervening character blocks.
|
||||
compositionsList=NULL;
|
||||
compositionsList=nullptr;
|
||||
}
|
||||
}
|
||||
buffer.setReorderingLimit(limit);
|
||||
|
@ -1435,16 +1435,16 @@ Normalizer2Impl::composePair(UChar32 a, UChar32 b) const {
|
|||
// doCompose: normalize
|
||||
// !doCompose: isNormalized (buffer must be empty and initialized)
|
||||
UBool
|
||||
Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
||||
Normalizer2Impl::compose(const char16_t *src, const char16_t *limit,
|
||||
UBool onlyContiguous,
|
||||
UBool doCompose,
|
||||
ReorderingBuffer &buffer,
|
||||
UErrorCode &errorCode) const {
|
||||
const UChar *prevBoundary=src;
|
||||
const char16_t *prevBoundary=src;
|
||||
UChar32 minNoMaybeCP=minCompNoMaybeCP;
|
||||
if(limit==NULL) {
|
||||
if(limit==nullptr) {
|
||||
src=copyLowPrefixFromNulTerminated(src, minNoMaybeCP,
|
||||
doCompose ? &buffer : NULL,
|
||||
doCompose ? &buffer : nullptr,
|
||||
errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return false;
|
||||
|
@ -1463,7 +1463,7 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
for (;;) {
|
||||
// Fast path: Scan over a sequence of characters below the minimum "no or maybe" code point,
|
||||
// or with (compYes && ccc==0) properties.
|
||||
const UChar *prevSrc;
|
||||
const char16_t *prevSrc;
|
||||
UChar32 c = 0;
|
||||
uint16_t norm16 = 0;
|
||||
for (;;) {
|
||||
|
@ -1482,7 +1482,7 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
if(!U16_IS_LEAD(c)) {
|
||||
break;
|
||||
} else {
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if(src!=limit && U16_IS_TRAIL(c2=*src)) {
|
||||
++src;
|
||||
c=U16_GET_SUPPLEMENTARY(c, c2);
|
||||
|
@ -1528,7 +1528,7 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
if (prevBoundary != prevSrc && !buffer.appendZeroCC(prevBoundary, prevSrc, errorCode)) {
|
||||
break;
|
||||
}
|
||||
const UChar *mapping = reinterpret_cast<const UChar *>(getMapping(norm16));
|
||||
const char16_t *mapping = reinterpret_cast<const char16_t *>(getMapping(norm16));
|
||||
int32_t length = *mapping++ & MAPPING_LENGTH_MASK;
|
||||
if(!buffer.appendZeroCC(mapping, mapping + length, errorCode)) {
|
||||
break;
|
||||
|
@ -1552,11 +1552,11 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
// Other "noNo" type, or need to examine more text around this character:
|
||||
// Fall through to the slow path.
|
||||
} else if (isJamoVT(norm16) && prevBoundary != prevSrc) {
|
||||
UChar prev=*(prevSrc-1);
|
||||
char16_t prev=*(prevSrc-1);
|
||||
if(c<Hangul::JAMO_T_BASE) {
|
||||
// The current character is a Jamo Vowel,
|
||||
// compose with previous Jamo L and following Jamo T.
|
||||
UChar l = (UChar)(prev-Hangul::JAMO_L_BASE);
|
||||
char16_t l = (char16_t)(prev-Hangul::JAMO_L_BASE);
|
||||
if(l<Hangul::JAMO_L_COUNT) {
|
||||
if (!doCompose) {
|
||||
return false;
|
||||
|
@ -1581,7 +1581,7 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
if (prevBoundary != prevSrc && !buffer.appendZeroCC(prevBoundary, prevSrc, errorCode)) {
|
||||
break;
|
||||
}
|
||||
if(!buffer.appendBMP((UChar)syllable, 0, errorCode)) {
|
||||
if(!buffer.appendBMP((char16_t)syllable, 0, errorCode)) {
|
||||
break;
|
||||
}
|
||||
prevBoundary = src;
|
||||
|
@ -1606,7 +1606,7 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
if (prevBoundary != prevSrc && !buffer.appendZeroCC(prevBoundary, prevSrc, errorCode)) {
|
||||
break;
|
||||
}
|
||||
if(!buffer.appendBMP((UChar)syllable, 0, errorCode)) {
|
||||
if(!buffer.appendBMP((char16_t)syllable, 0, errorCode)) {
|
||||
break;
|
||||
}
|
||||
prevBoundary = src;
|
||||
|
@ -1627,7 +1627,7 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
} else {
|
||||
// If !onlyContiguous (not FCC), then we ignore the tccc of
|
||||
// the previous character which passed the quick check "yes && ccc==0" test.
|
||||
const UChar *nextSrc;
|
||||
const char16_t *nextSrc;
|
||||
uint16_t n16;
|
||||
for (;;) {
|
||||
if (src == limit) {
|
||||
|
@ -1667,7 +1667,7 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
// Slow path: Find the nearest boundaries around the current character,
|
||||
// decompose and recompose.
|
||||
if (prevBoundary != prevSrc && !norm16HasCompBoundaryBefore(norm16)) {
|
||||
const UChar *p = prevSrc;
|
||||
const char16_t *p = prevSrc;
|
||||
UCPTRIE_FAST_U16_PREV(normTrie, UCPTRIE_16, prevBoundary, p, c, norm16);
|
||||
if (!norm16HasCompBoundaryAfter(norm16, onlyContiguous)) {
|
||||
prevSrc = p;
|
||||
|
@ -1703,17 +1703,17 @@ Normalizer2Impl::compose(const UChar *src, const UChar *limit,
|
|||
}
|
||||
|
||||
// Very similar to compose(): Make the same changes in both places if relevant.
|
||||
// pQCResult==NULL: spanQuickCheckYes
|
||||
// pQCResult!=NULL: quickCheck (*pQCResult must be UNORM_YES)
|
||||
const UChar *
|
||||
Normalizer2Impl::composeQuickCheck(const UChar *src, const UChar *limit,
|
||||
// pQCResult==nullptr: spanQuickCheckYes
|
||||
// pQCResult!=nullptr: quickCheck (*pQCResult must be UNORM_YES)
|
||||
const char16_t *
|
||||
Normalizer2Impl::composeQuickCheck(const char16_t *src, const char16_t *limit,
|
||||
UBool onlyContiguous,
|
||||
UNormalizationCheckResult *pQCResult) const {
|
||||
const UChar *prevBoundary=src;
|
||||
const char16_t *prevBoundary=src;
|
||||
UChar32 minNoMaybeCP=minCompNoMaybeCP;
|
||||
if(limit==NULL) {
|
||||
if(limit==nullptr) {
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
src=copyLowPrefixFromNulTerminated(src, minNoMaybeCP, NULL, errorCode);
|
||||
src=copyLowPrefixFromNulTerminated(src, minNoMaybeCP, nullptr, errorCode);
|
||||
limit=u_strchr(src, 0);
|
||||
if (prevBoundary != src) {
|
||||
if (hasCompBoundaryAfter(*(src-1), onlyContiguous)) {
|
||||
|
@ -1727,7 +1727,7 @@ Normalizer2Impl::composeQuickCheck(const UChar *src, const UChar *limit,
|
|||
for(;;) {
|
||||
// Fast path: Scan over a sequence of characters below the minimum "no or maybe" code point,
|
||||
// or with (compYes && ccc==0) properties.
|
||||
const UChar *prevSrc;
|
||||
const char16_t *prevSrc;
|
||||
UChar32 c = 0;
|
||||
uint16_t norm16 = 0;
|
||||
for (;;) {
|
||||
|
@ -1743,7 +1743,7 @@ Normalizer2Impl::composeQuickCheck(const UChar *src, const UChar *limit,
|
|||
if(!U16_IS_LEAD(c)) {
|
||||
break;
|
||||
} else {
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if(src!=limit && U16_IS_TRAIL(c2=*src)) {
|
||||
++src;
|
||||
c=U16_GET_SUPPLEMENTARY(c, c2);
|
||||
|
@ -1766,7 +1766,7 @@ Normalizer2Impl::composeQuickCheck(const UChar *src, const UChar *limit,
|
|||
if (norm16HasCompBoundaryBefore(norm16)) {
|
||||
prevBoundary = prevSrc;
|
||||
} else {
|
||||
const UChar *p = prevSrc;
|
||||
const char16_t *p = prevSrc;
|
||||
uint16_t n16;
|
||||
UCPTRIE_FAST_U16_PREV(normTrie, UCPTRIE_16, prevBoundary, p, c, n16);
|
||||
if (norm16HasCompBoundaryAfter(n16, onlyContiguous)) {
|
||||
|
@ -1788,7 +1788,7 @@ Normalizer2Impl::composeQuickCheck(const UChar *src, const UChar *limit,
|
|||
} else {
|
||||
// If !onlyContiguous (not FCC), then we ignore the tccc of
|
||||
// the previous character which passed the quick check "yes && ccc==0" test.
|
||||
const UChar *nextSrc;
|
||||
const char16_t *nextSrc;
|
||||
for (;;) {
|
||||
if (norm16 < MIN_YES_YES_WITH_CC) {
|
||||
if (pQCResult != nullptr) {
|
||||
|
@ -1821,30 +1821,30 @@ Normalizer2Impl::composeQuickCheck(const UChar *src, const UChar *limit,
|
|||
}
|
||||
}
|
||||
}
|
||||
if(pQCResult!=NULL) {
|
||||
if(pQCResult!=nullptr) {
|
||||
*pQCResult=UNORM_NO;
|
||||
}
|
||||
return prevBoundary;
|
||||
}
|
||||
}
|
||||
|
||||
void Normalizer2Impl::composeAndAppend(const UChar *src, const UChar *limit,
|
||||
void Normalizer2Impl::composeAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doCompose,
|
||||
UBool onlyContiguous,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer,
|
||||
UErrorCode &errorCode) const {
|
||||
if(!buffer.isEmpty()) {
|
||||
const UChar *firstStarterInSrc=findNextCompBoundary(src, limit, onlyContiguous);
|
||||
const char16_t *firstStarterInSrc=findNextCompBoundary(src, limit, onlyContiguous);
|
||||
if(src!=firstStarterInSrc) {
|
||||
const UChar *lastStarterInDest=findPreviousCompBoundary(buffer.getStart(),
|
||||
const char16_t *lastStarterInDest=findPreviousCompBoundary(buffer.getStart(),
|
||||
buffer.getLimit(), onlyContiguous);
|
||||
int32_t destSuffixLength=(int32_t)(buffer.getLimit()-lastStarterInDest);
|
||||
UnicodeString middle(lastStarterInDest, destSuffixLength);
|
||||
buffer.removeSuffix(destSuffixLength);
|
||||
safeMiddle=middle;
|
||||
middle.append(src, (int32_t)(firstStarterInSrc-src));
|
||||
const UChar *middleStart=middle.getBuffer();
|
||||
const char16_t *middleStart=middle.getBuffer();
|
||||
compose(middleStart, middleStart+middle.length(), onlyContiguous,
|
||||
true, buffer, errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
|
@ -1856,7 +1856,7 @@ void Normalizer2Impl::composeAndAppend(const UChar *src, const UChar *limit,
|
|||
if(doCompose) {
|
||||
compose(src, limit, onlyContiguous, true, buffer, errorCode);
|
||||
} else {
|
||||
if(limit==NULL) { // appendZeroCC() needs limit!=NULL
|
||||
if(limit==nullptr) { // appendZeroCC() needs limit!=nullptr
|
||||
limit=u_strchr(src, 0);
|
||||
}
|
||||
buffer.appendZeroCC(src, limit, errorCode);
|
||||
|
@ -1933,7 +1933,7 @@ Normalizer2Impl::composeUTF8(uint32_t options, UBool onlyContiguous,
|
|||
}
|
||||
const uint16_t *mapping = getMapping(norm16);
|
||||
int32_t length = *mapping++ & MAPPING_LENGTH_MASK;
|
||||
if (!ByteSinkUtil::appendChange(prevSrc, src, (const UChar *)mapping, length,
|
||||
if (!ByteSinkUtil::appendChange(prevSrc, src, (const char16_t *)mapping, length,
|
||||
*sink, edits, errorCode)) {
|
||||
break;
|
||||
}
|
||||
|
@ -2120,7 +2120,7 @@ Normalizer2Impl::composeUTF8(uint32_t options, UBool onlyContiguous,
|
|||
return true;
|
||||
}
|
||||
|
||||
UBool Normalizer2Impl::hasCompBoundaryBefore(const UChar *src, const UChar *limit) const {
|
||||
UBool Normalizer2Impl::hasCompBoundaryBefore(const char16_t *src, const char16_t *limit) const {
|
||||
if (src == limit || *src < minCompNoMaybeCP) {
|
||||
return true;
|
||||
}
|
||||
|
@ -2139,7 +2139,7 @@ UBool Normalizer2Impl::hasCompBoundaryBefore(const uint8_t *src, const uint8_t *
|
|||
return norm16HasCompBoundaryBefore(norm16);
|
||||
}
|
||||
|
||||
UBool Normalizer2Impl::hasCompBoundaryAfter(const UChar *start, const UChar *p,
|
||||
UBool Normalizer2Impl::hasCompBoundaryAfter(const char16_t *start, const char16_t *p,
|
||||
UBool onlyContiguous) const {
|
||||
if (start == p) {
|
||||
return true;
|
||||
|
@ -2160,10 +2160,10 @@ UBool Normalizer2Impl::hasCompBoundaryAfter(const uint8_t *start, const uint8_t
|
|||
return norm16HasCompBoundaryAfter(norm16, onlyContiguous);
|
||||
}
|
||||
|
||||
const UChar *Normalizer2Impl::findPreviousCompBoundary(const UChar *start, const UChar *p,
|
||||
const char16_t *Normalizer2Impl::findPreviousCompBoundary(const char16_t *start, const char16_t *p,
|
||||
UBool onlyContiguous) const {
|
||||
while (p != start) {
|
||||
const UChar *codePointLimit = p;
|
||||
const char16_t *codePointLimit = p;
|
||||
UChar32 c;
|
||||
uint16_t norm16;
|
||||
UCPTRIE_FAST_U16_PREV(normTrie, UCPTRIE_16, start, p, c, norm16);
|
||||
|
@ -2177,10 +2177,10 @@ const UChar *Normalizer2Impl::findPreviousCompBoundary(const UChar *start, const
|
|||
return p;
|
||||
}
|
||||
|
||||
const UChar *Normalizer2Impl::findNextCompBoundary(const UChar *p, const UChar *limit,
|
||||
const char16_t *Normalizer2Impl::findNextCompBoundary(const char16_t *p, const char16_t *limit,
|
||||
UBool onlyContiguous) const {
|
||||
while (p != limit) {
|
||||
const UChar *codePointStart = p;
|
||||
const char16_t *codePointStart = p;
|
||||
UChar32 c;
|
||||
uint16_t norm16;
|
||||
UCPTRIE_FAST_U16_NEXT(normTrie, UCPTRIE_16, p, limit, c, norm16);
|
||||
|
@ -2194,7 +2194,7 @@ const UChar *Normalizer2Impl::findNextCompBoundary(const UChar *p, const UChar *
|
|||
return p;
|
||||
}
|
||||
|
||||
uint8_t Normalizer2Impl::getPreviousTrailCC(const UChar *start, const UChar *p) const {
|
||||
uint8_t Normalizer2Impl::getPreviousTrailCC(const char16_t *start, const char16_t *p) const {
|
||||
if (start == p) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -2267,17 +2267,17 @@ uint16_t Normalizer2Impl::getFCD16FromNormData(UChar32 c) const {
|
|||
#endif
|
||||
|
||||
// Dual functionality:
|
||||
// buffer!=NULL: normalize
|
||||
// buffer==NULL: isNormalized/quickCheck/spanQuickCheckYes
|
||||
const UChar *
|
||||
Normalizer2Impl::makeFCD(const UChar *src, const UChar *limit,
|
||||
// buffer!=nullptr: normalize
|
||||
// buffer==nullptr: isNormalized/quickCheck/spanQuickCheckYes
|
||||
const char16_t *
|
||||
Normalizer2Impl::makeFCD(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer *buffer,
|
||||
UErrorCode &errorCode) const {
|
||||
// Tracks the last FCD-safe boundary, before lccc=0 or after properly-ordered tccc<=1.
|
||||
// Similar to the prevBoundary in the compose() implementation.
|
||||
const UChar *prevBoundary=src;
|
||||
const char16_t *prevBoundary=src;
|
||||
int32_t prevFCD16=0;
|
||||
if(limit==NULL) {
|
||||
if(limit==nullptr) {
|
||||
src=copyLowPrefixFromNulTerminated(src, minLcccCP, buffer, errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return src;
|
||||
|
@ -2300,7 +2300,7 @@ Normalizer2Impl::makeFCD(const UChar *src, const UChar *limit,
|
|||
// The exception is the call to decomposeShort() which uses the buffer
|
||||
// in the normal way.
|
||||
|
||||
const UChar *prevSrc;
|
||||
const char16_t *prevSrc;
|
||||
UChar32 c=0;
|
||||
uint16_t fcd16=0;
|
||||
|
||||
|
@ -2315,7 +2315,7 @@ Normalizer2Impl::makeFCD(const UChar *src, const UChar *limit,
|
|||
++src;
|
||||
} else {
|
||||
if(U16_IS_LEAD(c)) {
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if((src+1)!=limit && U16_IS_TRAIL(c2=src[1])) {
|
||||
c=U16_GET_SUPPLEMENTARY(c, c2);
|
||||
}
|
||||
|
@ -2330,7 +2330,7 @@ Normalizer2Impl::makeFCD(const UChar *src, const UChar *limit,
|
|||
}
|
||||
// copy these code units all at once
|
||||
if(src!=prevSrc) {
|
||||
if(buffer!=NULL && !buffer->appendZeroCC(prevSrc, src, errorCode)) {
|
||||
if(buffer!=nullptr && !buffer->appendZeroCC(prevSrc, src, errorCode)) {
|
||||
break;
|
||||
}
|
||||
if(src==limit) {
|
||||
|
@ -2350,7 +2350,7 @@ Normalizer2Impl::makeFCD(const UChar *src, const UChar *limit,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
const UChar *p=src-1;
|
||||
const char16_t *p=src-1;
|
||||
if(U16_IS_TRAIL(*p) && prevSrc<p && U16_IS_LEAD(*(p-1))) {
|
||||
--p;
|
||||
// Need to fetch the previous character's FCD value because
|
||||
|
@ -2376,12 +2376,12 @@ Normalizer2Impl::makeFCD(const UChar *src, const UChar *limit,
|
|||
if((fcd16&0xff)<=1) {
|
||||
prevBoundary=src;
|
||||
}
|
||||
if(buffer!=NULL && !buffer->appendZeroCC(c, errorCode)) {
|
||||
if(buffer!=nullptr && !buffer->appendZeroCC(c, errorCode)) {
|
||||
break;
|
||||
}
|
||||
prevFCD16=fcd16;
|
||||
continue;
|
||||
} else if(buffer==NULL) {
|
||||
} else if(buffer==nullptr) {
|
||||
return prevBoundary; // quick check "no"
|
||||
} else {
|
||||
/*
|
||||
|
@ -2410,22 +2410,22 @@ Normalizer2Impl::makeFCD(const UChar *src, const UChar *limit,
|
|||
return src;
|
||||
}
|
||||
|
||||
void Normalizer2Impl::makeFCDAndAppend(const UChar *src, const UChar *limit,
|
||||
void Normalizer2Impl::makeFCDAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doMakeFCD,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer,
|
||||
UErrorCode &errorCode) const {
|
||||
if(!buffer.isEmpty()) {
|
||||
const UChar *firstBoundaryInSrc=findNextFCDBoundary(src, limit);
|
||||
const char16_t *firstBoundaryInSrc=findNextFCDBoundary(src, limit);
|
||||
if(src!=firstBoundaryInSrc) {
|
||||
const UChar *lastBoundaryInDest=findPreviousFCDBoundary(buffer.getStart(),
|
||||
const char16_t *lastBoundaryInDest=findPreviousFCDBoundary(buffer.getStart(),
|
||||
buffer.getLimit());
|
||||
int32_t destSuffixLength=(int32_t)(buffer.getLimit()-lastBoundaryInDest);
|
||||
UnicodeString middle(lastBoundaryInDest, destSuffixLength);
|
||||
buffer.removeSuffix(destSuffixLength);
|
||||
safeMiddle=middle;
|
||||
middle.append(src, (int32_t)(firstBoundaryInSrc-src));
|
||||
const UChar *middleStart=middle.getBuffer();
|
||||
const char16_t *middleStart=middle.getBuffer();
|
||||
makeFCD(middleStart, middleStart+middle.length(), &buffer, errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
|
@ -2436,16 +2436,16 @@ void Normalizer2Impl::makeFCDAndAppend(const UChar *src, const UChar *limit,
|
|||
if(doMakeFCD) {
|
||||
makeFCD(src, limit, &buffer, errorCode);
|
||||
} else {
|
||||
if(limit==NULL) { // appendZeroCC() needs limit!=NULL
|
||||
if(limit==nullptr) { // appendZeroCC() needs limit!=nullptr
|
||||
limit=u_strchr(src, 0);
|
||||
}
|
||||
buffer.appendZeroCC(src, limit, errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
const UChar *Normalizer2Impl::findPreviousFCDBoundary(const UChar *start, const UChar *p) const {
|
||||
const char16_t *Normalizer2Impl::findPreviousFCDBoundary(const char16_t *start, const char16_t *p) const {
|
||||
while(start<p) {
|
||||
const UChar *codePointLimit = p;
|
||||
const char16_t *codePointLimit = p;
|
||||
UChar32 c;
|
||||
uint16_t norm16;
|
||||
UCPTRIE_FAST_U16_PREV(normTrie, UCPTRIE_16, start, p, c, norm16);
|
||||
|
@ -2459,9 +2459,9 @@ const UChar *Normalizer2Impl::findPreviousFCDBoundary(const UChar *start, const
|
|||
return p;
|
||||
}
|
||||
|
||||
const UChar *Normalizer2Impl::findNextFCDBoundary(const UChar *p, const UChar *limit) const {
|
||||
const char16_t *Normalizer2Impl::findNextFCDBoundary(const char16_t *p, const char16_t *limit) const {
|
||||
while(p<limit) {
|
||||
const UChar *codePointStart=p;
|
||||
const char16_t *codePointStart=p;
|
||||
UChar32 c;
|
||||
uint16_t norm16;
|
||||
UCPTRIE_FAST_U16_NEXT(normTrie, UCPTRIE_16, p, limit, c, norm16);
|
||||
|
@ -2479,7 +2479,7 @@ const UChar *Normalizer2Impl::findNextFCDBoundary(const UChar *p, const UChar *l
|
|||
|
||||
CanonIterData::CanonIterData(UErrorCode &errorCode) :
|
||||
mutableTrie(umutablecptrie_open(0, 0, &errorCode)), trie(nullptr),
|
||||
canonStartSets(uprv_deleteUObject, NULL, errorCode) {}
|
||||
canonStartSets(uprv_deleteUObject, nullptr, errorCode) {}
|
||||
|
||||
CanonIterData::~CanonIterData() {
|
||||
umutablecptrie_close(mutableTrie);
|
||||
|
@ -2535,9 +2535,9 @@ initCanonIterData(Normalizer2Impl *impl, UErrorCode &errorCode) {
|
|||
U_CDECL_END
|
||||
|
||||
void InitCanonIterData::doInit(Normalizer2Impl *impl, UErrorCode &errorCode) {
|
||||
U_ASSERT(impl->fCanonIterData == NULL);
|
||||
U_ASSERT(impl->fCanonIterData == nullptr);
|
||||
impl->fCanonIterData = new CanonIterData(errorCode);
|
||||
if (impl->fCanonIterData == NULL) {
|
||||
if (impl->fCanonIterData == nullptr) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
if (U_SUCCESS(errorCode)) {
|
||||
|
@ -2562,7 +2562,7 @@ void InitCanonIterData::doInit(Normalizer2Impl *impl, UErrorCode &errorCode) {
|
|||
}
|
||||
if (U_FAILURE(errorCode)) {
|
||||
delete impl->fCanonIterData;
|
||||
impl->fCanonIterData = NULL;
|
||||
impl->fCanonIterData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2710,7 +2710,7 @@ unorm2_swap(const UDataSwapper *ds,
|
|||
|
||||
/* udata_swapDataHeader checks the arguments */
|
||||
headerSize=udata_swapDataHeader(ds, inData, length, outData, pErrorCode);
|
||||
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2733,7 +2733,7 @@ unorm2_swap(const UDataSwapper *ds,
|
|||
}
|
||||
|
||||
inBytes=(const uint8_t *)inData+headerSize;
|
||||
outBytes=(uint8_t *)outData+headerSize;
|
||||
outBytes=(outData == nullptr) ? nullptr : (uint8_t *)outData+headerSize;
|
||||
|
||||
inIndexes=(const int32_t *)inBytes;
|
||||
int32_t minIndexesLength;
|
||||
|
|
|
@ -99,16 +99,16 @@ public:
|
|||
* Decomposes c, which must be a Hangul syllable, into buffer
|
||||
* and returns the length of the decomposition (2 or 3).
|
||||
*/
|
||||
static inline int32_t decompose(UChar32 c, UChar buffer[3]) {
|
||||
static inline int32_t decompose(UChar32 c, char16_t buffer[3]) {
|
||||
c-=HANGUL_BASE;
|
||||
UChar32 c2=c%JAMO_T_COUNT;
|
||||
c/=JAMO_T_COUNT;
|
||||
buffer[0]=(UChar)(JAMO_L_BASE+c/JAMO_V_COUNT);
|
||||
buffer[1]=(UChar)(JAMO_V_BASE+c%JAMO_V_COUNT);
|
||||
buffer[0]=(char16_t)(JAMO_L_BASE+c/JAMO_V_COUNT);
|
||||
buffer[1]=(char16_t)(JAMO_V_BASE+c%JAMO_V_COUNT);
|
||||
if(c2==0) {
|
||||
return 2;
|
||||
} else {
|
||||
buffer[2]=(UChar)(JAMO_T_BASE+c2);
|
||||
buffer[2]=(char16_t)(JAMO_T_BASE+c2);
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
@ -117,17 +117,17 @@ public:
|
|||
* Decomposes c, which must be a Hangul syllable, into buffer.
|
||||
* This is the raw, not recursive, decomposition. Its length is always 2.
|
||||
*/
|
||||
static inline void getRawDecomposition(UChar32 c, UChar buffer[2]) {
|
||||
static inline void getRawDecomposition(UChar32 c, char16_t buffer[2]) {
|
||||
UChar32 orig=c;
|
||||
c-=HANGUL_BASE;
|
||||
UChar32 c2=c%JAMO_T_COUNT;
|
||||
if(c2==0) {
|
||||
c/=JAMO_T_COUNT;
|
||||
buffer[0]=(UChar)(JAMO_L_BASE+c/JAMO_V_COUNT);
|
||||
buffer[1]=(UChar)(JAMO_V_BASE+c%JAMO_V_COUNT);
|
||||
buffer[0]=(char16_t)(JAMO_L_BASE+c/JAMO_V_COUNT);
|
||||
buffer[1]=(char16_t)(JAMO_V_BASE+c%JAMO_V_COUNT);
|
||||
} else {
|
||||
buffer[0]=(UChar)(orig-c2); // LV syllable
|
||||
buffer[1]=(UChar)(JAMO_T_BASE+c2);
|
||||
buffer[0]=(char16_t)(orig-c2); // LV syllable
|
||||
buffer[1]=(char16_t)(JAMO_T_BASE+c2);
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
@ -154,22 +154,22 @@ public:
|
|||
|
||||
UBool isEmpty() const { return start==limit; }
|
||||
int32_t length() const { return (int32_t)(limit-start); }
|
||||
UChar *getStart() { return start; }
|
||||
UChar *getLimit() { return limit; }
|
||||
char16_t *getStart() { return start; }
|
||||
char16_t *getLimit() { return limit; }
|
||||
uint8_t getLastCC() const { return lastCC; }
|
||||
|
||||
UBool equals(const UChar *start, const UChar *limit) const;
|
||||
UBool equals(const char16_t *start, const char16_t *limit) const;
|
||||
UBool equals(const uint8_t *otherStart, const uint8_t *otherLimit) const;
|
||||
|
||||
UBool append(UChar32 c, uint8_t cc, UErrorCode &errorCode) {
|
||||
return (c<=0xffff) ?
|
||||
appendBMP((UChar)c, cc, errorCode) :
|
||||
appendBMP((char16_t)c, cc, errorCode) :
|
||||
appendSupplementary(c, cc, errorCode);
|
||||
}
|
||||
UBool append(const UChar *s, int32_t length, UBool isNFD,
|
||||
UBool append(const char16_t *s, int32_t length, UBool isNFD,
|
||||
uint8_t leadCC, uint8_t trailCC,
|
||||
UErrorCode &errorCode);
|
||||
UBool appendBMP(UChar c, uint8_t cc, UErrorCode &errorCode) {
|
||||
UBool appendBMP(char16_t c, uint8_t cc, UErrorCode &errorCode) {
|
||||
if(remainingCapacity==0 && !resize(1, errorCode)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -186,10 +186,10 @@ public:
|
|||
return true;
|
||||
}
|
||||
UBool appendZeroCC(UChar32 c, UErrorCode &errorCode);
|
||||
UBool appendZeroCC(const UChar *s, const UChar *sLimit, UErrorCode &errorCode);
|
||||
UBool appendZeroCC(const char16_t *s, const char16_t *sLimit, UErrorCode &errorCode);
|
||||
void remove();
|
||||
void removeSuffix(int32_t suffixLength);
|
||||
void setReorderingLimit(UChar *newLimit) {
|
||||
void setReorderingLimit(char16_t *newLimit) {
|
||||
remainingCapacity+=(int32_t)(limit-newLimit);
|
||||
reorderStart=limit=newLimit;
|
||||
lastCC=0;
|
||||
|
@ -213,9 +213,9 @@ private:
|
|||
|
||||
UBool appendSupplementary(UChar32 c, uint8_t cc, UErrorCode &errorCode);
|
||||
void insert(UChar32 c, uint8_t cc);
|
||||
static void writeCodePoint(UChar *p, UChar32 c) {
|
||||
static void writeCodePoint(char16_t *p, UChar32 c) {
|
||||
if(c<=0xffff) {
|
||||
*p=(UChar)c;
|
||||
*p=(char16_t)c;
|
||||
} else {
|
||||
p[0]=U16_LEAD(c);
|
||||
p[1]=U16_TRAIL(c);
|
||||
|
@ -225,7 +225,7 @@ private:
|
|||
|
||||
const Normalizer2Impl &impl;
|
||||
UnicodeString &str;
|
||||
UChar *start, *reorderStart, *limit;
|
||||
char16_t *start, *reorderStart, *limit;
|
||||
int32_t remainingCapacity;
|
||||
uint8_t lastCC;
|
||||
|
||||
|
@ -234,7 +234,7 @@ private:
|
|||
void skipPrevious(); // Requires start<codePointStart.
|
||||
uint8_t previousCC(); // Returns 0 if there is no previous character.
|
||||
|
||||
UChar *codePointStart, *codePointLimit;
|
||||
char16_t *codePointStart, *codePointLimit;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -322,12 +322,12 @@ public:
|
|||
* @param limit The end of the string, or NULL.
|
||||
* @return The lccc(c) in bits 15..8 and tccc(c) in bits 7..0.
|
||||
*/
|
||||
uint16_t nextFCD16(const UChar *&s, const UChar *limit) const {
|
||||
uint16_t nextFCD16(const char16_t *&s, const char16_t *limit) const {
|
||||
UChar32 c=*s++;
|
||||
if(c<minDecompNoCP || !singleLeadMightHaveNonZeroFCD16(c)) {
|
||||
return 0;
|
||||
}
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if(U16_IS_LEAD(c) && s!=limit && U16_IS_TRAIL(c2=*s)) {
|
||||
c=U16_GET_SUPPLEMENTARY(c, c2);
|
||||
++s;
|
||||
|
@ -340,7 +340,7 @@ public:
|
|||
* @param s A valid pointer into a string. Requires start<s.
|
||||
* @return The lccc(c) in bits 15..8 and tccc(c) in bits 7..0.
|
||||
*/
|
||||
uint16_t previousFCD16(const UChar *start, const UChar *&s) const {
|
||||
uint16_t previousFCD16(const char16_t *start, const char16_t *&s) const {
|
||||
UChar32 c=*--s;
|
||||
if(c<minDecompNoCP) {
|
||||
return 0;
|
||||
|
@ -350,7 +350,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
} else {
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if(start<s && U16_IS_LEAD(c2=*(s-1))) {
|
||||
c=U16_GET_SUPPLEMENTARY(c2, c);
|
||||
--s;
|
||||
|
@ -376,7 +376,7 @@ public:
|
|||
* @param length out-only, takes the length of the decomposition, if any
|
||||
* @return pointer to the decomposition, or NULL if none
|
||||
*/
|
||||
const UChar *getDecomposition(UChar32 c, UChar buffer[4], int32_t &length) const;
|
||||
const char16_t *getDecomposition(UChar32 c, char16_t buffer[4], int32_t &length) const;
|
||||
|
||||
/**
|
||||
* Gets the raw decomposition for one code point.
|
||||
|
@ -385,7 +385,7 @@ public:
|
|||
* @param length out-only, takes the length of the decomposition, if any
|
||||
* @return pointer to the decomposition, or NULL if none
|
||||
*/
|
||||
const UChar *getRawDecomposition(UChar32 c, UChar buffer[30], int32_t &length) const;
|
||||
const char16_t *getRawDecomposition(UChar32 c, char16_t buffer[30], int32_t &length) const;
|
||||
|
||||
UChar32 composePair(UChar32 a, UChar32 b) const;
|
||||
|
||||
|
@ -480,13 +480,13 @@ public:
|
|||
* limit can be NULL if src is NUL-terminated.
|
||||
* destLengthEstimate is the initial dest buffer capacity and can be -1.
|
||||
*/
|
||||
void decompose(const UChar *src, const UChar *limit,
|
||||
void decompose(const char16_t *src, const char16_t *limit,
|
||||
UnicodeString &dest, int32_t destLengthEstimate,
|
||||
UErrorCode &errorCode) const;
|
||||
|
||||
const UChar *decompose(const UChar *src, const UChar *limit,
|
||||
const char16_t *decompose(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer *buffer, UErrorCode &errorCode) const;
|
||||
void decomposeAndAppend(const UChar *src, const UChar *limit,
|
||||
void decomposeAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doDecompose,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer,
|
||||
|
@ -497,15 +497,15 @@ public:
|
|||
const uint8_t *src, const uint8_t *limit,
|
||||
ByteSink *sink, Edits *edits, UErrorCode &errorCode) const;
|
||||
|
||||
UBool compose(const UChar *src, const UChar *limit,
|
||||
UBool compose(const char16_t *src, const char16_t *limit,
|
||||
UBool onlyContiguous,
|
||||
UBool doCompose,
|
||||
ReorderingBuffer &buffer,
|
||||
UErrorCode &errorCode) const;
|
||||
const UChar *composeQuickCheck(const UChar *src, const UChar *limit,
|
||||
const char16_t *composeQuickCheck(const char16_t *src, const char16_t *limit,
|
||||
UBool onlyContiguous,
|
||||
UNormalizationCheckResult *pQCResult) const;
|
||||
void composeAndAppend(const UChar *src, const UChar *limit,
|
||||
void composeAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doCompose,
|
||||
UBool onlyContiguous,
|
||||
UnicodeString &safeMiddle,
|
||||
|
@ -517,9 +517,9 @@ public:
|
|||
const uint8_t *src, const uint8_t *limit,
|
||||
ByteSink *sink, icu::Edits *edits, UErrorCode &errorCode) const;
|
||||
|
||||
const UChar *makeFCD(const UChar *src, const UChar *limit,
|
||||
const char16_t *makeFCD(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer *buffer, UErrorCode &errorCode) const;
|
||||
void makeFCDAndAppend(const UChar *src, const UChar *limit,
|
||||
void makeFCDAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doMakeFCD,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer,
|
||||
|
@ -608,7 +608,7 @@ private:
|
|||
return (uint8_t)(*getMapping(norm16)>>8); // tccc from yesNo
|
||||
}
|
||||
}
|
||||
uint8_t getPreviousTrailCC(const UChar *start, const UChar *p) const;
|
||||
uint8_t getPreviousTrailCC(const char16_t *start, const char16_t *p) const;
|
||||
uint8_t getPreviousTrailCC(const uint8_t *start, const uint8_t *p) const;
|
||||
|
||||
// Requires algorithmic-NoNo.
|
||||
|
@ -651,14 +651,14 @@ private:
|
|||
getCompositionsListForComposite(norm16);
|
||||
}
|
||||
|
||||
const UChar *copyLowPrefixFromNulTerminated(const UChar *src,
|
||||
const char16_t *copyLowPrefixFromNulTerminated(const char16_t *src,
|
||||
UChar32 minNeedDataCP,
|
||||
ReorderingBuffer *buffer,
|
||||
UErrorCode &errorCode) const;
|
||||
|
||||
enum StopAt { STOP_AT_LIMIT, STOP_AT_DECOMP_BOUNDARY, STOP_AT_COMP_BOUNDARY };
|
||||
|
||||
const UChar *decomposeShort(const UChar *src, const UChar *limit,
|
||||
const char16_t *decomposeShort(const char16_t *src, const char16_t *limit,
|
||||
UBool stopAtCompBoundary, UBool onlyContiguous,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const;
|
||||
UBool decompose(UChar32 c, uint16_t norm16,
|
||||
|
@ -679,9 +679,9 @@ private:
|
|||
UBool norm16HasCompBoundaryBefore(uint16_t norm16) const {
|
||||
return norm16 < minNoNoCompNoMaybeCC || isAlgorithmicNoNo(norm16);
|
||||
}
|
||||
UBool hasCompBoundaryBefore(const UChar *src, const UChar *limit) const;
|
||||
UBool hasCompBoundaryBefore(const char16_t *src, const char16_t *limit) const;
|
||||
UBool hasCompBoundaryBefore(const uint8_t *src, const uint8_t *limit) const;
|
||||
UBool hasCompBoundaryAfter(const UChar *start, const UChar *p,
|
||||
UBool hasCompBoundaryAfter(const char16_t *start, const char16_t *p,
|
||||
UBool onlyContiguous) const;
|
||||
UBool hasCompBoundaryAfter(const uint8_t *start, const uint8_t *p,
|
||||
UBool onlyContiguous) const;
|
||||
|
@ -695,11 +695,11 @@ private:
|
|||
(norm16 & DELTA_TCCC_MASK) <= DELTA_TCCC_1 : *getMapping(norm16) <= 0x1ff);
|
||||
}
|
||||
|
||||
const UChar *findPreviousCompBoundary(const UChar *start, const UChar *p, UBool onlyContiguous) const;
|
||||
const UChar *findNextCompBoundary(const UChar *p, const UChar *limit, UBool onlyContiguous) const;
|
||||
const char16_t *findPreviousCompBoundary(const char16_t *start, const char16_t *p, UBool onlyContiguous) const;
|
||||
const char16_t *findNextCompBoundary(const char16_t *p, const char16_t *limit, UBool onlyContiguous) const;
|
||||
|
||||
const UChar *findPreviousFCDBoundary(const UChar *start, const UChar *p) const;
|
||||
const UChar *findNextFCDBoundary(const UChar *p, const UChar *limit) const;
|
||||
const char16_t *findPreviousFCDBoundary(const char16_t *start, const char16_t *p) const;
|
||||
const char16_t *findNextFCDBoundary(const char16_t *p, const char16_t *limit) const;
|
||||
|
||||
void makeCanonIterDataFromNorm16(UChar32 start, UChar32 end, const uint16_t norm16,
|
||||
CanonIterData &newData, UErrorCode &errorCode) const;
|
||||
|
@ -710,9 +710,9 @@ private:
|
|||
// UVersionInfo dataVersion;
|
||||
|
||||
// BMP code point thresholds for quick check loops looking at single UTF-16 code units.
|
||||
UChar minDecompNoCP;
|
||||
UChar minCompNoMaybeCP;
|
||||
UChar minLcccCP;
|
||||
char16_t minDecompNoCP;
|
||||
char16_t minCompNoMaybeCP;
|
||||
char16_t minLcccCP;
|
||||
|
||||
// Norm16 value thresholds for quick check combinations and types of extra data.
|
||||
uint16_t minYesNo;
|
||||
|
|
|
@ -38,7 +38,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Normalizer)
|
|||
//-------------------------------------------------------------------------
|
||||
|
||||
Normalizer::Normalizer(const UnicodeString& str, UNormalizationMode mode) :
|
||||
UObject(), fFilteredNorm2(NULL), fNorm2(NULL), fUMode(mode), fOptions(0),
|
||||
UObject(), fFilteredNorm2(nullptr), fNorm2(nullptr), fUMode(mode), fOptions(0),
|
||||
text(new StringCharacterIterator(str)),
|
||||
currentIndex(0), nextIndex(0),
|
||||
buffer(), bufferPos(0)
|
||||
|
@ -47,7 +47,7 @@ Normalizer::Normalizer(const UnicodeString& str, UNormalizationMode mode) :
|
|||
}
|
||||
|
||||
Normalizer::Normalizer(ConstChar16Ptr str, int32_t length, UNormalizationMode mode) :
|
||||
UObject(), fFilteredNorm2(NULL), fNorm2(NULL), fUMode(mode), fOptions(0),
|
||||
UObject(), fFilteredNorm2(nullptr), fNorm2(nullptr), fUMode(mode), fOptions(0),
|
||||
text(new UCharCharacterIterator(str, length)),
|
||||
currentIndex(0), nextIndex(0),
|
||||
buffer(), bufferPos(0)
|
||||
|
@ -56,7 +56,7 @@ Normalizer::Normalizer(ConstChar16Ptr str, int32_t length, UNormalizationMode mo
|
|||
}
|
||||
|
||||
Normalizer::Normalizer(const CharacterIterator& iter, UNormalizationMode mode) :
|
||||
UObject(), fFilteredNorm2(NULL), fNorm2(NULL), fUMode(mode), fOptions(0),
|
||||
UObject(), fFilteredNorm2(nullptr), fNorm2(nullptr), fUMode(mode), fOptions(0),
|
||||
text(iter.clone()),
|
||||
currentIndex(0), nextIndex(0),
|
||||
buffer(), bufferPos(0)
|
||||
|
@ -65,7 +65,7 @@ Normalizer::Normalizer(const CharacterIterator& iter, UNormalizationMode mode) :
|
|||
}
|
||||
|
||||
Normalizer::Normalizer(const Normalizer ©) :
|
||||
UObject(copy), fFilteredNorm2(NULL), fNorm2(NULL), fUMode(copy.fUMode), fOptions(copy.fOptions),
|
||||
UObject(copy), fFilteredNorm2(nullptr), fNorm2(nullptr), fUMode(copy.fUMode), fOptions(copy.fOptions),
|
||||
text(copy.text->clone()),
|
||||
currentIndex(copy.currentIndex), nextIndex(copy.nextIndex),
|
||||
buffer(copy.buffer), bufferPos(copy.bufferPos)
|
||||
|
@ -410,7 +410,7 @@ Normalizer::setText(const UnicodeString& newText,
|
|||
return;
|
||||
}
|
||||
CharacterIterator *newIter = new StringCharacterIterator(newText);
|
||||
if (newIter == NULL) {
|
||||
if (newIter == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ Normalizer::setText(const CharacterIterator& newText,
|
|||
return;
|
||||
}
|
||||
CharacterIterator *newIter = newText.clone();
|
||||
if (newIter == NULL) {
|
||||
if (newIter == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ Normalizer::setText(ConstChar16Ptr newText,
|
|||
return;
|
||||
}
|
||||
CharacterIterator *newIter = new UCharCharacterIterator(newText, length);
|
||||
if (newIter == NULL) {
|
||||
if (newIter == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -164,8 +164,8 @@ PatternProps::isWhiteSpace(UChar32 c) {
|
|||
}
|
||||
}
|
||||
|
||||
const UChar *
|
||||
PatternProps::skipWhiteSpace(const UChar *s, int32_t length) {
|
||||
const char16_t *
|
||||
PatternProps::skipWhiteSpace(const char16_t *s, int32_t length) {
|
||||
while(length>0 && isWhiteSpace(*s)) {
|
||||
++s;
|
||||
--length;
|
||||
|
@ -183,8 +183,8 @@ PatternProps::skipWhiteSpace(const UnicodeString& s, int32_t start) {
|
|||
return i;
|
||||
}
|
||||
|
||||
const UChar *
|
||||
PatternProps::trimWhiteSpace(const UChar *s, int32_t &length) {
|
||||
const char16_t *
|
||||
PatternProps::trimWhiteSpace(const char16_t *s, int32_t &length) {
|
||||
if(length<=0 || (!isWhiteSpace(s[0]) && !isWhiteSpace(s[length-1]))) {
|
||||
return s;
|
||||
}
|
||||
|
@ -205,11 +205,11 @@ PatternProps::trimWhiteSpace(const UChar *s, int32_t &length) {
|
|||
}
|
||||
|
||||
UBool
|
||||
PatternProps::isIdentifier(const UChar *s, int32_t length) {
|
||||
PatternProps::isIdentifier(const char16_t *s, int32_t length) {
|
||||
if(length<=0) {
|
||||
return false;
|
||||
}
|
||||
const UChar *limit=s+length;
|
||||
const char16_t *limit=s+length;
|
||||
do {
|
||||
if(isSyntaxOrWhiteSpace(*s++)) {
|
||||
return false;
|
||||
|
@ -218,8 +218,8 @@ PatternProps::isIdentifier(const UChar *s, int32_t length) {
|
|||
return true;
|
||||
}
|
||||
|
||||
const UChar *
|
||||
PatternProps::skipIdentifier(const UChar *s, int32_t length) {
|
||||
const char16_t *
|
||||
PatternProps::skipIdentifier(const char16_t *s, int32_t length) {
|
||||
while(length>0 && !isSyntaxOrWhiteSpace(*s)) {
|
||||
++s;
|
||||
--length;
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
* Skips over Pattern_White_Space starting at s.
|
||||
* @return The smallest pointer at or after s with a non-white space character.
|
||||
*/
|
||||
static const UChar *skipWhiteSpace(const UChar *s, int32_t length);
|
||||
static const char16_t *skipWhiteSpace(const char16_t *s, int32_t length);
|
||||
|
||||
/**
|
||||
* Skips over Pattern_White_Space starting at index start in s.
|
||||
|
@ -73,21 +73,21 @@ public:
|
|||
/**
|
||||
* @return s except with leading and trailing Pattern_White_Space removed and length adjusted.
|
||||
*/
|
||||
static const UChar *trimWhiteSpace(const UChar *s, int32_t &length);
|
||||
static const char16_t *trimWhiteSpace(const char16_t *s, int32_t &length);
|
||||
|
||||
/**
|
||||
* Tests whether the string contains a "pattern identifier", that is,
|
||||
* whether it contains only non-Pattern_White_Space, non-Pattern_Syntax characters.
|
||||
* @return true if there are no Pattern_White_Space or Pattern_Syntax characters in s.
|
||||
*/
|
||||
static UBool isIdentifier(const UChar *s, int32_t length);
|
||||
static UBool isIdentifier(const char16_t *s, int32_t length);
|
||||
|
||||
/**
|
||||
* Skips over a "pattern identifier" starting at index s.
|
||||
* @return The smallest pointer at or after s with
|
||||
* a Pattern_White_Space or Pattern_Syntax character.
|
||||
*/
|
||||
static const UChar *skipIdentifier(const UChar *s, int32_t length);
|
||||
static const char16_t *skipIdentifier(const char16_t *s, int32_t length);
|
||||
|
||||
private:
|
||||
PatternProps() = delete; // no constructor: all static methods
|
||||
|
|
|
@ -36,7 +36,7 @@ PluralMapBase::toCategory(const UnicodeString &pluralForm) {
|
|||
const char *PluralMapBase::getCategoryName(Category c) {
|
||||
int32_t index = c;
|
||||
return (index < 0 || index >= UPRV_LENGTHOF(gPluralForms)) ?
|
||||
NULL : gPluralForms[index];
|
||||
nullptr : gPluralForms[index];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
/**
|
||||
* Converts a category to a name.
|
||||
* Passing NONE or CATEGORY_COUNT for category returns NULL.
|
||||
* Passing NONE or CATEGORY_COUNT for category returns nullptr.
|
||||
*/
|
||||
static const char *getCategoryName(Category category);
|
||||
};
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
fVariants[0] = &fOtherVariant;
|
||||
for (int32_t i = 1; i < UPRV_LENGTHOF(fVariants); ++i) {
|
||||
fVariants[i] = other.fVariants[i] ?
|
||||
new T(*other.fVariants[i]) : NULL;
|
||||
new T(*other.fVariants[i]) : nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,12 +98,12 @@ public:
|
|||
return *this;
|
||||
}
|
||||
for (int32_t i = 0; i < UPRV_LENGTHOF(fVariants); ++i) {
|
||||
if (fVariants[i] != NULL && other.fVariants[i] != NULL) {
|
||||
if (fVariants[i] != nullptr && other.fVariants[i] != nullptr) {
|
||||
*fVariants[i] = *other.fVariants[i];
|
||||
} else if (fVariants[i] != NULL) {
|
||||
} else if (fVariants[i] != nullptr) {
|
||||
delete fVariants[i];
|
||||
fVariants[i] = NULL;
|
||||
} else if (other.fVariants[i] != NULL) {
|
||||
fVariants[i] = nullptr;
|
||||
} else if (other.fVariants[i] != nullptr) {
|
||||
fVariants[i] = new T(*other.fVariants[i]);
|
||||
} else {
|
||||
// do nothing
|
||||
|
@ -125,28 +125,28 @@ public:
|
|||
*fVariants[0] = T();
|
||||
for (int32_t i = 1; i < UPRV_LENGTHOF(fVariants); ++i) {
|
||||
delete fVariants[i];
|
||||
fVariants[i] = NULL;
|
||||
fVariants[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through the mappings in this instance, set index to NONE
|
||||
* prior to using. Call next repeatedly to get the values until it
|
||||
* returns NULL. Each time next returns, caller may pass index
|
||||
* returns nullptr. Each time next returns, caller may pass index
|
||||
* to getCategoryName() to get the name of the plural category.
|
||||
* When this function returns NULL, index is CATEGORY_COUNT
|
||||
* When this function returns nullptr, index is CATEGORY_COUNT
|
||||
*/
|
||||
const T *next(Category &index) const {
|
||||
int32_t idx = index;
|
||||
++idx;
|
||||
for (; idx < UPRV_LENGTHOF(fVariants); ++idx) {
|
||||
if (fVariants[idx] != NULL) {
|
||||
if (fVariants[idx] != nullptr) {
|
||||
index = static_cast<Category>(idx);
|
||||
return fVariants[idx];
|
||||
}
|
||||
}
|
||||
index = static_cast<Category>(idx);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
*/
|
||||
const T &get(Category v) const {
|
||||
int32_t index = v;
|
||||
if (index < 0 || index >= UPRV_LENGTHOF(fVariants) || fVariants[index] == NULL) {
|
||||
if (index < 0 || index >= UPRV_LENGTHOF(fVariants) || fVariants[index] == nullptr) {
|
||||
return *fVariants[0];
|
||||
}
|
||||
return *fVariants[index];
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
T *getMutable(
|
||||
Category category,
|
||||
UErrorCode &status) {
|
||||
return getMutable(category, NULL, status);
|
||||
return getMutable(category, nullptr, status);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,7 +218,7 @@ public:
|
|||
T *getMutable(
|
||||
const char *category,
|
||||
UErrorCode &status) {
|
||||
return getMutable(toCategory(category), NULL, status);
|
||||
return getMutable(toCategory(category), nullptr, status);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,7 +243,7 @@ public:
|
|||
if (fVariants[i] == rhs.fVariants[i]) {
|
||||
continue;
|
||||
}
|
||||
if (fVariants[i] == NULL || rhs.fVariants[i] == NULL) {
|
||||
if (fVariants[i] == nullptr || rhs.fVariants[i] == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (!eqFunc(*fVariants[i], *rhs.fVariants[i])) {
|
||||
|
@ -262,15 +262,15 @@ private:
|
|||
const T *defaultValue,
|
||||
UErrorCode &status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
int32_t index = category;
|
||||
if (index < 0 || index >= UPRV_LENGTHOF(fVariants)) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (fVariants[index] == NULL) {
|
||||
fVariants[index] = defaultValue == NULL ?
|
||||
if (fVariants[index] == nullptr) {
|
||||
fVariants[index] = defaultValue == nullptr ?
|
||||
new T() : new T(*defaultValue);
|
||||
}
|
||||
if (!fVariants[index]) {
|
||||
|
@ -282,7 +282,7 @@ private:
|
|||
void initializeNew() {
|
||||
fVariants[0] = &fOtherVariant;
|
||||
for (int32_t i = 1; i < UPRV_LENGTHOF(fVariants); ++i) {
|
||||
fVariants[i] = NULL;
|
||||
fVariants[i] = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -204,20 +204,20 @@ int32_t PropNameData::findPropertyValueNameGroup(int32_t valueMapIndex, int32_t
|
|||
const char *PropNameData::getName(const char *nameGroup, int32_t nameIndex) {
|
||||
int32_t numNames=*nameGroup++;
|
||||
if(nameIndex<0 || numNames<=nameIndex) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
// Skip nameIndex names.
|
||||
for(; nameIndex>0; --nameIndex) {
|
||||
nameGroup=uprv_strchr(nameGroup, 0)+1;
|
||||
}
|
||||
if(*nameGroup==0) {
|
||||
return NULL; // no name (Property[Value]Aliases.txt has "n/a")
|
||||
return nullptr; // no name (Property[Value]Aliases.txt has "n/a")
|
||||
}
|
||||
return nameGroup;
|
||||
}
|
||||
|
||||
UBool PropNameData::containsName(BytesTrie &trie, const char *name) {
|
||||
if(name==NULL) {
|
||||
if(name==nullptr) {
|
||||
return false;
|
||||
}
|
||||
UStringTrieResult result=USTRINGTRIE_NO_VALUE;
|
||||
|
@ -239,7 +239,7 @@ UBool PropNameData::containsName(BytesTrie &trie, const char *name) {
|
|||
const char *PropNameData::getPropertyName(int32_t property, int32_t nameChoice) {
|
||||
int32_t valueMapIndex=findProperty(property);
|
||||
if(valueMapIndex==0) {
|
||||
return NULL; // Not a known property.
|
||||
return nullptr; // Not a known property.
|
||||
}
|
||||
return getName(nameGroups+valueMaps[valueMapIndex], nameChoice);
|
||||
}
|
||||
|
@ -247,11 +247,11 @@ const char *PropNameData::getPropertyName(int32_t property, int32_t nameChoice)
|
|||
const char *PropNameData::getPropertyValueName(int32_t property, int32_t value, int32_t nameChoice) {
|
||||
int32_t valueMapIndex=findProperty(property);
|
||||
if(valueMapIndex==0) {
|
||||
return NULL; // Not a known property.
|
||||
return nullptr; // Not a known property.
|
||||
}
|
||||
int32_t nameGroupOffset=findPropertyValueNameGroup(valueMaps[valueMapIndex+1], value);
|
||||
if(nameGroupOffset==0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return getName(nameGroups+nameGroupOffset, nameChoice);
|
||||
}
|
||||
|
@ -289,7 +289,10 @@ U_NAMESPACE_END
|
|||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
u_getPropertyName(UProperty property,
|
||||
UPropertyNameChoice nameChoice) {
|
||||
UPropertyNameChoice nameChoice) UPRV_NO_SANITIZE_UNDEFINED {
|
||||
// The nameChoice is really an integer with a couple of named constants.
|
||||
// Unicode allows for names other than short and long ones.
|
||||
// If present, these will be returned for U_LONG_PROPERTY_NAME + i, where i=1, 2,...
|
||||
U_NAMESPACE_USE
|
||||
return PropNameData::getPropertyName(property, nameChoice);
|
||||
}
|
||||
|
@ -303,7 +306,10 @@ u_getPropertyEnum(const char* alias) {
|
|||
U_CAPI const char* U_EXPORT2
|
||||
u_getPropertyValueName(UProperty property,
|
||||
int32_t value,
|
||||
UPropertyNameChoice nameChoice) {
|
||||
UPropertyNameChoice nameChoice) UPRV_NO_SANITIZE_UNDEFINED {
|
||||
// The nameChoice is really an integer with a couple of named constants.
|
||||
// Unicode allows for names other than short and long ones.
|
||||
// If present, these will be returned for U_LONG_PROPERTY_NAME + i, where i=1, 2,...
|
||||
U_NAMESPACE_USE
|
||||
return PropNameData::getPropertyValueName(property, value, nameChoice);
|
||||
}
|
||||
|
|
|
@ -47,21 +47,21 @@ upvec_open(int32_t columns, UErrorCode *pErrorCode) {
|
|||
uint32_t cp;
|
||||
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if(columns<1) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
columns+=2; /* count range start and limit columns */
|
||||
|
||||
pv=(UPropsVectors *)uprv_malloc(sizeof(UPropsVectors));
|
||||
v=(uint32_t *)uprv_malloc(UPVEC_INITIAL_ROWS*columns*4);
|
||||
if(pv==NULL || v==NULL) {
|
||||
if(pv==nullptr || v==nullptr) {
|
||||
uprv_free(pv);
|
||||
uprv_free(v);
|
||||
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
uprv_memset(pv, 0, sizeof(UPropsVectors));
|
||||
pv->v=v;
|
||||
|
@ -85,7 +85,7 @@ upvec_open(int32_t columns, UErrorCode *pErrorCode) {
|
|||
|
||||
U_CAPI void U_EXPORT2
|
||||
upvec_close(UPropsVectors *pv) {
|
||||
if(pv!=NULL) {
|
||||
if(pv!=nullptr) {
|
||||
uprv_free(pv->v);
|
||||
uprv_free(pv);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ upvec_setValue(UPropsVectors *pv,
|
|||
if(U_FAILURE(*pErrorCode)) {
|
||||
return;
|
||||
}
|
||||
if( pv==NULL ||
|
||||
if( pv==nullptr ||
|
||||
start<0 || start>end || end>UPVEC_MAX_CP ||
|
||||
column<0 || column>=(pv->columns-2)
|
||||
) {
|
||||
|
@ -216,7 +216,7 @@ upvec_setValue(UPropsVectors *pv,
|
|||
return;
|
||||
}
|
||||
newVectors=(uint32_t *)uprv_malloc(newMaxRows*columns*4);
|
||||
if(newVectors==NULL) {
|
||||
if(newVectors==nullptr) {
|
||||
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -296,15 +296,15 @@ upvec_getRow(const UPropsVectors *pv, int32_t rowIndex,
|
|||
int32_t columns;
|
||||
|
||||
if(pv->isCompacted || rowIndex<0 || rowIndex>=pv->rows) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
columns=pv->columns;
|
||||
row=pv->v+rowIndex*columns;
|
||||
if(pRangeStart!=NULL) {
|
||||
if(pRangeStart!=nullptr) {
|
||||
*pRangeStart=(UChar32)row[0];
|
||||
}
|
||||
if(pRangeEnd!=NULL) {
|
||||
if(pRangeEnd!=nullptr) {
|
||||
*pRangeEnd=(UChar32)row[1]-1;
|
||||
}
|
||||
return row+2;
|
||||
|
@ -342,7 +342,7 @@ upvec_compact(UPropsVectors *pv, UPVecCompactHandler *handler, void *context, UE
|
|||
if(U_FAILURE(*pErrorCode)) {
|
||||
return;
|
||||
}
|
||||
if(handler==NULL) {
|
||||
if(handler==nullptr) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -437,12 +437,12 @@ upvec_compact(UPropsVectors *pv, UPVecCompactHandler *handler, void *context, UE
|
|||
U_CAPI const uint32_t * U_EXPORT2
|
||||
upvec_getArray(const UPropsVectors *pv, int32_t *pRows, int32_t *pColumns) {
|
||||
if(!pv->isCompacted) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if(pRows!=NULL) {
|
||||
if(pRows!=nullptr) {
|
||||
*pRows=pv->rows;
|
||||
}
|
||||
if(pColumns!=NULL) {
|
||||
if(pColumns!=nullptr) {
|
||||
*pColumns=pv->columns-2;
|
||||
}
|
||||
return pv->v;
|
||||
|
@ -455,23 +455,23 @@ upvec_cloneArray(const UPropsVectors *pv,
|
|||
int32_t byteLength;
|
||||
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if(!pv->isCompacted) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
byteLength=pv->rows*(pv->columns-2)*4;
|
||||
clonedArray=(uint32_t *)uprv_malloc(byteLength);
|
||||
if(clonedArray==NULL) {
|
||||
if(clonedArray==nullptr) {
|
||||
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
uprv_memcpy(clonedArray, pv->v, byteLength);
|
||||
if(pRows!=NULL) {
|
||||
if(pRows!=nullptr) {
|
||||
*pRows=pv->rows;
|
||||
}
|
||||
if(pColumns!=NULL) {
|
||||
if(pColumns!=nullptr) {
|
||||
*pColumns=pv->columns-2;
|
||||
}
|
||||
return clonedArray;
|
||||
|
@ -479,12 +479,12 @@ upvec_cloneArray(const UPropsVectors *pv,
|
|||
|
||||
U_CAPI UTrie2 * U_EXPORT2
|
||||
upvec_compactToUTrie2WithRowIndexes(UPropsVectors *pv, UErrorCode *pErrorCode) {
|
||||
UPVecToUTrie2Context toUTrie2={ NULL, 0, 0, 0 };
|
||||
UPVecToUTrie2Context toUTrie2={ nullptr, 0, 0, 0 };
|
||||
upvec_compact(pv, upvec_compactToUTrie2Handler, &toUTrie2, pErrorCode);
|
||||
utrie2_freeze(toUTrie2.trie, UTRIE2_16_VALUE_BITS, pErrorCode);
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
utrie2_close(toUTrie2.trie);
|
||||
toUTrie2.trie=NULL;
|
||||
toUTrie2.trie=nullptr;
|
||||
}
|
||||
return toUTrie2.trie;
|
||||
}
|
||||
|
|
|
@ -179,21 +179,21 @@ constexpr int32_t DECODE_MAX_CHARS=2000;
|
|||
|
||||
// encode
|
||||
U_CAPI int32_t
|
||||
u_strToPunycode(const UChar *src, int32_t srcLength,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
u_strToPunycode(const char16_t *src, int32_t srcLength,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
const UBool *caseFlags,
|
||||
UErrorCode *pErrorCode) {
|
||||
|
||||
int32_t cpBuffer[ENCODE_MAX_CODE_UNITS];
|
||||
int32_t n, delta, handledCPCount, basicLength, destLength, bias, j, m, q, k, t, srcCPCount;
|
||||
UChar c, c2;
|
||||
char16_t c, c2;
|
||||
|
||||
/* argument checking */
|
||||
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(src==NULL || srcLength<-1 || (dest==NULL && destCapacity!=0)) {
|
||||
if(src==nullptr || srcLength<-1 || (dest==nullptr && destCapacity!=0)) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -221,13 +221,13 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
|
|||
cpBuffer[srcCPCount++]=0;
|
||||
if(destLength<destCapacity) {
|
||||
dest[destLength]=
|
||||
caseFlags!=NULL ?
|
||||
caseFlags!=nullptr ?
|
||||
asciiCaseMap((char)c, caseFlags[j]) :
|
||||
(char)c;
|
||||
}
|
||||
++destLength;
|
||||
} else {
|
||||
n=(caseFlags!=NULL && caseFlags[j])<<31L;
|
||||
n=(caseFlags!=nullptr && caseFlags[j])<<31L;
|
||||
if(U16_IS_SINGLE(c)) {
|
||||
n|=c;
|
||||
} else if(U16_IS_LEAD(c) && U16_IS_TRAIL(c2=src[j+1])) {
|
||||
|
@ -249,13 +249,13 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
|
|||
cpBuffer[srcCPCount++]=0;
|
||||
if(destLength<destCapacity) {
|
||||
dest[destLength]=
|
||||
caseFlags!=NULL ?
|
||||
caseFlags!=nullptr ?
|
||||
asciiCaseMap((char)c, caseFlags[j]) :
|
||||
(char)c;
|
||||
}
|
||||
++destLength;
|
||||
} else {
|
||||
n=(caseFlags!=NULL && caseFlags[j])<<31L;
|
||||
n=(caseFlags!=nullptr && caseFlags[j])<<31L;
|
||||
if(U16_IS_SINGLE(c)) {
|
||||
n|=c;
|
||||
} else if(U16_IS_LEAD(c) && (j+1)<srcLength && U16_IS_TRAIL(c2=src[j+1])) {
|
||||
|
@ -371,20 +371,20 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
|
|||
|
||||
// decode
|
||||
U_CAPI int32_t
|
||||
u_strFromPunycode(const UChar *src, int32_t srcLength,
|
||||
UChar *dest, int32_t destCapacity,
|
||||
u_strFromPunycode(const char16_t *src, int32_t srcLength,
|
||||
char16_t *dest, int32_t destCapacity,
|
||||
UBool *caseFlags,
|
||||
UErrorCode *pErrorCode) {
|
||||
int32_t n, destLength, i, bias, basicLength, j, in, oldi, w, k, digit, t,
|
||||
destCPCount, firstSupplementaryIndex, cpLength;
|
||||
UChar b;
|
||||
char16_t b;
|
||||
|
||||
/* argument checking */
|
||||
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(src==NULL || srcLength<-1 || (dest==NULL && destCapacity!=0)) {
|
||||
if(src==nullptr || srcLength<-1 || (dest==nullptr && destCapacity!=0)) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
@ -421,9 +421,9 @@ u_strFromPunycode(const UChar *src, int32_t srcLength,
|
|||
}
|
||||
|
||||
if(j<destCapacity) {
|
||||
dest[j]=(UChar)b;
|
||||
dest[j]=(char16_t)b;
|
||||
|
||||
if(caseFlags!=NULL) {
|
||||
if(caseFlags!=nullptr) {
|
||||
caseFlags[j]=IS_BASIC_UPPERCASE(b);
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ u_strFromPunycode(const UChar *src, int32_t srcLength,
|
|||
|
||||
/* Insert n at position i of the output: */
|
||||
cpLength=U16_LENGTH(n);
|
||||
if(dest!=NULL && ((destLength+cpLength)<=destCapacity)) {
|
||||
if(dest!=nullptr && ((destLength+cpLength)<=destCapacity)) {
|
||||
int32_t codeUnitIndex;
|
||||
|
||||
/*
|
||||
|
@ -550,12 +550,12 @@ u_strFromPunycode(const UChar *src, int32_t srcLength,
|
|||
U16_FWD_N(dest, codeUnitIndex, destLength, i-codeUnitIndex);
|
||||
}
|
||||
|
||||
/* use the UChar index codeUnitIndex instead of the code point index i */
|
||||
/* use the char16_t index codeUnitIndex instead of the code point index i */
|
||||
if(codeUnitIndex<destLength) {
|
||||
uprv_memmove(dest+codeUnitIndex+cpLength,
|
||||
dest+codeUnitIndex,
|
||||
(destLength-codeUnitIndex)*U_SIZEOF_UCHAR);
|
||||
if(caseFlags!=NULL) {
|
||||
if(caseFlags!=nullptr) {
|
||||
uprv_memmove(caseFlags+codeUnitIndex+cpLength,
|
||||
caseFlags+codeUnitIndex,
|
||||
destLength-codeUnitIndex);
|
||||
|
@ -563,13 +563,13 @@ u_strFromPunycode(const UChar *src, int32_t srcLength,
|
|||
}
|
||||
if(cpLength==1) {
|
||||
/* BMP, insert one code unit */
|
||||
dest[codeUnitIndex]=(UChar)n;
|
||||
dest[codeUnitIndex]=(char16_t)n;
|
||||
} else {
|
||||
/* supplementary character, insert two code units */
|
||||
dest[codeUnitIndex]=U16_LEAD(n);
|
||||
dest[codeUnitIndex+1]=U16_TRAIL(n);
|
||||
}
|
||||
if(caseFlags!=NULL) {
|
||||
if(caseFlags!=nullptr) {
|
||||
/* Case of last character determines uppercase flag: */
|
||||
caseFlags[codeUnitIndex]=IS_BASIC_UPPERCASE(src[in-1]);
|
||||
if(cpLength==2) {
|
||||
|
|
|
@ -248,7 +248,7 @@ UBool fakeClock_set = false; /** True if fake clock has spun up **/
|
|||
|
||||
static UDate getUTCtime_real() {
|
||||
struct timeval posixTime;
|
||||
gettimeofday(&posixTime, NULL);
|
||||
gettimeofday(&posixTime, nullptr);
|
||||
return (UDate)(((int64_t)posixTime.tv_sec * U_MILLIS_PER_SECOND) + (posixTime.tv_usec/1000));
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ static UDate getUTCtime_fake() {
|
|||
if(!fakeClock_set) {
|
||||
UDate real = getUTCtime_real();
|
||||
const char *fake_start = getenv("U_FAKETIME_START");
|
||||
if((fake_start!=NULL) && (fake_start[0]!=0)) {
|
||||
if((fake_start!=nullptr) && (fake_start[0]!=0)) {
|
||||
sscanf(fake_start,"%lf",&fakeClock_t0);
|
||||
fakeClock_dt = fakeClock_t0 - real;
|
||||
fprintf(stderr,"U_DEBUG_FAKETIME was set at compile time, so the ICU clock will start at a preset value\n"
|
||||
|
@ -319,7 +319,7 @@ uprv_getRawUTCtime()
|
|||
|
||||
#if HAVE_GETTIMEOFDAY
|
||||
struct timeval posixTime;
|
||||
gettimeofday(&posixTime, NULL);
|
||||
gettimeofday(&posixTime, nullptr);
|
||||
return (UDate)(((int64_t)posixTime.tv_sec * U_MILLIS_PER_SECOND) + (posixTime.tv_usec/1000));
|
||||
#else
|
||||
time_t epochtime;
|
||||
|
@ -580,7 +580,7 @@ uprv_trunc(double d)
|
|||
* type of arbitrary bit length.
|
||||
*/
|
||||
U_CAPI double U_EXPORT2
|
||||
uprv_maxMantissa(void)
|
||||
uprv_maxMantissa()
|
||||
{
|
||||
return pow(2.0, DBL_MANT_DIG + 1.0) - 1.0;
|
||||
}
|
||||
|
@ -612,11 +612,11 @@ uprv_maximumPtr(void * base)
|
|||
* Unlike other operating systems, the pointer model isn't determined at
|
||||
* compile time on i5/OS.
|
||||
*/
|
||||
if ((base != NULL) && (_TESTPTR(base, _C_TERASPACE_CHECK))) {
|
||||
if ((base != nullptr) && (_TESTPTR(base, _C_TERASPACE_CHECK))) {
|
||||
/* if it is a TERASPACE pointer the max is 2GB - 4k */
|
||||
return ((void *)(((char *)base)-((uint32_t)(base))+((uint32_t)0x7fffefff)));
|
||||
}
|
||||
/* otherwise 16MB since NULL ptr is not checkable or the ptr is not TERASPACE */
|
||||
/* otherwise 16MB since nullptr ptr is not checkable or the ptr is not TERASPACE */
|
||||
return ((void *)(((char *)base)-((uint32_t)(base))+((uint32_t)0xffefff)));
|
||||
|
||||
#else
|
||||
|
@ -722,7 +722,7 @@ extern U_IMPORT char *U_TZNAME[];
|
|||
#include <dirent.h> /* Needed to search through system timezone files */
|
||||
#endif
|
||||
static char gTimeZoneBuffer[PATH_MAX];
|
||||
static char *gTimeZoneBufferPtr = NULL;
|
||||
static const char *gTimeZoneBufferPtr = nullptr;
|
||||
#endif
|
||||
|
||||
#if !U_PLATFORM_USES_ONLY_WIN32_API
|
||||
|
@ -879,7 +879,7 @@ static const char* remapShortTimeZone(const char *stdID, const char *dstID, int3
|
|||
return OFFSET_ZONE_MAPPINGS[idx].olsonID;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -907,14 +907,14 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
|
|||
char bufferFile[MAX_READ_SIZE];
|
||||
UBool result = true;
|
||||
|
||||
if (tzInfo->defaultTZFilePtr == NULL) {
|
||||
if (tzInfo->defaultTZFilePtr == nullptr) {
|
||||
tzInfo->defaultTZFilePtr = fopen(defaultTZFileName, "r");
|
||||
}
|
||||
file = fopen(TZFileName, "r");
|
||||
|
||||
tzInfo->defaultTZPosition = 0; /* reset position to begin search */
|
||||
|
||||
if (file != NULL && tzInfo->defaultTZFilePtr != NULL) {
|
||||
if (file != nullptr && tzInfo->defaultTZFilePtr != nullptr) {
|
||||
/* First check that the file size are equal. */
|
||||
if (tzInfo->defaultTZFileSize == 0) {
|
||||
fseek(tzInfo->defaultTZFilePtr, 0, SEEK_END);
|
||||
|
@ -930,7 +930,7 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
|
|||
/* Store the data from the files in separate buffers and
|
||||
* compare each byte to determine equality.
|
||||
*/
|
||||
if (tzInfo->defaultTZBuffer == NULL) {
|
||||
if (tzInfo->defaultTZBuffer == nullptr) {
|
||||
rewind(tzInfo->defaultTZFilePtr);
|
||||
tzInfo->defaultTZBuffer = (char*)uprv_malloc(sizeof(char) * tzInfo->defaultTZFileSize);
|
||||
sizeFileRead = fread(tzInfo->defaultTZBuffer, 1, tzInfo->defaultTZFileSize, tzInfo->defaultTZFilePtr);
|
||||
|
@ -953,7 +953,7 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
|
|||
result = false;
|
||||
}
|
||||
|
||||
if (file != NULL) {
|
||||
if (file != nullptr) {
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
|
@ -964,17 +964,17 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
|
|||
/* dirent also lists two entries: "." and ".." that we can safely ignore. */
|
||||
#define SKIP1 "."
|
||||
#define SKIP2 ".."
|
||||
static UBool U_CALLCONV putil_cleanup(void);
|
||||
static CharString *gSearchTZFileResult = NULL;
|
||||
static UBool U_CALLCONV putil_cleanup();
|
||||
static CharString *gSearchTZFileResult = nullptr;
|
||||
|
||||
/*
|
||||
* This method recursively traverses the directory given for a matching TZ file and returns the first match.
|
||||
* This function is not thread safe - it uses a global, gSearchTZFileResult, to hold its results.
|
||||
*/
|
||||
static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
||||
DIR* dirp = NULL;
|
||||
struct dirent* dirEntry = NULL;
|
||||
char* result = NULL;
|
||||
DIR* dirp = nullptr;
|
||||
struct dirent* dirEntry = nullptr;
|
||||
char* result = nullptr;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
/* Save the current path */
|
||||
|
@ -984,20 +984,20 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
|||
}
|
||||
|
||||
dirp = opendir(path);
|
||||
if (dirp == NULL) {
|
||||
if (dirp == nullptr) {
|
||||
goto cleanupAndReturn;
|
||||
}
|
||||
|
||||
if (gSearchTZFileResult == NULL) {
|
||||
if (gSearchTZFileResult == nullptr) {
|
||||
gSearchTZFileResult = new CharString;
|
||||
if (gSearchTZFileResult == NULL) {
|
||||
if (gSearchTZFileResult == nullptr) {
|
||||
goto cleanupAndReturn;
|
||||
}
|
||||
ucln_common_registerCleanup(UCLN_COMMON_PUTIL, putil_cleanup);
|
||||
}
|
||||
|
||||
/* Check each entry in the directory. */
|
||||
while((dirEntry = readdir(dirp)) != NULL) {
|
||||
while((dirEntry = readdir(dirp)) != nullptr) {
|
||||
const char* dirName = dirEntry->d_name;
|
||||
if (uprv_strcmp(dirName, SKIP1) != 0 && uprv_strcmp(dirName, SKIP2) != 0
|
||||
&& uprv_strcmp(TZFILE_SKIP, dirName) != 0 && uprv_strcmp(TZFILE_SKIP2, dirName) != 0) {
|
||||
|
@ -1008,8 +1008,8 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
|||
break;
|
||||
}
|
||||
|
||||
DIR* subDirp = NULL;
|
||||
if ((subDirp = opendir(newpath.data())) != NULL) {
|
||||
DIR* subDirp = nullptr;
|
||||
if ((subDirp = opendir(newpath.data())) != nullptr) {
|
||||
/* If this new path is a directory, make a recursive call with the newpath. */
|
||||
closedir(subDirp);
|
||||
newpath.append('/', status);
|
||||
|
@ -1021,11 +1021,11 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
|||
Have to get out here. Otherwise, we'd keep looking
|
||||
and return the first match in the top-level directory
|
||||
if there's a match in the top-level. If not, this function
|
||||
would return NULL and set gTimeZoneBufferPtr to NULL in initDefault().
|
||||
would return nullptr and set gTimeZoneBufferPtr to nullptr in initDefault().
|
||||
It worked without this in most cases because we have a fallback of calling
|
||||
localtime_r to figure out the default timezone.
|
||||
*/
|
||||
if (result != NULL)
|
||||
if (result != nullptr)
|
||||
break;
|
||||
} else {
|
||||
if(compareBinaryFiles(TZDEFAULT, newpath.data(), tzInfo)) {
|
||||
|
@ -1074,7 +1074,7 @@ static void u_property_read(void* cookie, const char* name, const char* value,
|
|||
#endif
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uprv_tzname_clear_cache(void)
|
||||
uprv_tzname_clear_cache()
|
||||
{
|
||||
#if U_PLATFORM == U_PF_ANDROID
|
||||
/* Android's timezone is stored in system property. */
|
||||
|
@ -1104,7 +1104,7 @@ uprv_tzname_clear_cache(void)
|
|||
#endif
|
||||
|
||||
#if defined(CHECK_LOCALTIME_LINK) && !defined(DEBUG_SKIP_LOCALTIME_LINK)
|
||||
gTimeZoneBufferPtr = NULL;
|
||||
gTimeZoneBufferPtr = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1112,11 +1112,11 @@ U_CAPI const char* U_EXPORT2
|
|||
uprv_tzname(int n)
|
||||
{
|
||||
(void)n; // Avoid unreferenced parameter warning.
|
||||
const char *tzid = NULL;
|
||||
const char *tzid = nullptr;
|
||||
#if U_PLATFORM_USES_ONLY_WIN32_API
|
||||
tzid = uprv_detectWindowsTimeZone();
|
||||
|
||||
if (tzid != NULL) {
|
||||
if (tzid != nullptr) {
|
||||
return tzid;
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ uprv_tzname(int n)
|
|||
int ret;
|
||||
|
||||
tzid = getenv("TZFILE");
|
||||
if (tzid != NULL) {
|
||||
if (tzid != nullptr) {
|
||||
return tzid;
|
||||
}
|
||||
#endif*/
|
||||
|
@ -1146,7 +1146,7 @@ uprv_tzname(int n)
|
|||
#else
|
||||
tzid = getenv("TZ");
|
||||
#endif
|
||||
if (tzid != NULL && isValidOlsonID(tzid)
|
||||
if (tzid != nullptr && isValidOlsonID(tzid)
|
||||
#if U_PLATFORM == U_PF_SOLARIS
|
||||
/* Don't misinterpret TZ "localtime" on Solaris as a time zone name. */
|
||||
&& uprv_strcmp(tzid, TZ_ENV_CHECK) != 0
|
||||
|
@ -1165,46 +1165,46 @@ uprv_tzname(int n)
|
|||
|
||||
#if defined(CHECK_LOCALTIME_LINK) && !defined(DEBUG_SKIP_LOCALTIME_LINK)
|
||||
/* Caller must handle threading issues */
|
||||
if (gTimeZoneBufferPtr == NULL) {
|
||||
if (gTimeZoneBufferPtr == nullptr) {
|
||||
/*
|
||||
This is a trick to look at the name of the link to get the Olson ID
|
||||
because the tzfile contents is underspecified.
|
||||
This isn't guaranteed to work because it may not be a symlink.
|
||||
*/
|
||||
int32_t ret = (int32_t)readlink(TZDEFAULT, gTimeZoneBuffer, sizeof(gTimeZoneBuffer)-1);
|
||||
if (0 < ret) {
|
||||
char *ret = realpath(TZDEFAULT, gTimeZoneBuffer);
|
||||
if (ret != nullptr && uprv_strcmp(TZDEFAULT, gTimeZoneBuffer) != 0) {
|
||||
int32_t tzZoneInfoTailLen = uprv_strlen(TZZONEINFOTAIL);
|
||||
gTimeZoneBuffer[ret] = 0;
|
||||
char * tzZoneInfoTailPtr = uprv_strstr(gTimeZoneBuffer, TZZONEINFOTAIL);
|
||||
|
||||
if (tzZoneInfoTailPtr != NULL
|
||||
&& isValidOlsonID(tzZoneInfoTailPtr + tzZoneInfoTailLen))
|
||||
{
|
||||
return (gTimeZoneBufferPtr = tzZoneInfoTailPtr + tzZoneInfoTailLen);
|
||||
const char *tzZoneInfoTailPtr = uprv_strstr(gTimeZoneBuffer, TZZONEINFOTAIL);
|
||||
if (tzZoneInfoTailPtr != nullptr) {
|
||||
tzZoneInfoTailPtr += tzZoneInfoTailLen;
|
||||
skipZoneIDPrefix(&tzZoneInfoTailPtr);
|
||||
if (isValidOlsonID(tzZoneInfoTailPtr)) {
|
||||
return (gTimeZoneBufferPtr = tzZoneInfoTailPtr);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#if defined(SEARCH_TZFILE)
|
||||
DefaultTZInfo* tzInfo = (DefaultTZInfo*)uprv_malloc(sizeof(DefaultTZInfo));
|
||||
if (tzInfo != NULL) {
|
||||
tzInfo->defaultTZBuffer = NULL;
|
||||
if (tzInfo != nullptr) {
|
||||
tzInfo->defaultTZBuffer = nullptr;
|
||||
tzInfo->defaultTZFileSize = 0;
|
||||
tzInfo->defaultTZFilePtr = NULL;
|
||||
tzInfo->defaultTZFilePtr = nullptr;
|
||||
tzInfo->defaultTZstatus = false;
|
||||
tzInfo->defaultTZPosition = 0;
|
||||
|
||||
gTimeZoneBufferPtr = searchForTZFile(TZZONEINFO, tzInfo);
|
||||
|
||||
/* Free previously allocated memory */
|
||||
if (tzInfo->defaultTZBuffer != NULL) {
|
||||
if (tzInfo->defaultTZBuffer != nullptr) {
|
||||
uprv_free(tzInfo->defaultTZBuffer);
|
||||
}
|
||||
if (tzInfo->defaultTZFilePtr != NULL) {
|
||||
if (tzInfo->defaultTZFilePtr != nullptr) {
|
||||
fclose(tzInfo->defaultTZFilePtr);
|
||||
}
|
||||
uprv_free(tzInfo);
|
||||
}
|
||||
|
||||
if (gTimeZoneBufferPtr != NULL && isValidOlsonID(gTimeZoneBufferPtr)) {
|
||||
if (gTimeZoneBufferPtr != nullptr && isValidOlsonID(gTimeZoneBufferPtr)) {
|
||||
return gTimeZoneBufferPtr;
|
||||
}
|
||||
#endif
|
||||
|
@ -1247,7 +1247,7 @@ uprv_tzname(int n)
|
|||
daylightType = U_DAYLIGHT_NONE;
|
||||
}
|
||||
tzid = remapShortTimeZone(U_TZNAME[0], U_TZNAME[1], daylightType, uprv_timezone());
|
||||
if (tzid != NULL) {
|
||||
if (tzid != nullptr) {
|
||||
return tzid;
|
||||
}
|
||||
}
|
||||
|
@ -1261,37 +1261,37 @@ uprv_tzname(int n)
|
|||
/* Get and set the ICU data directory --------------------------------------- */
|
||||
|
||||
static icu::UInitOnce gDataDirInitOnce {};
|
||||
static char *gDataDirectory = NULL;
|
||||
static char *gDataDirectory = nullptr;
|
||||
|
||||
UInitOnce gTimeZoneFilesInitOnce {};
|
||||
static CharString *gTimeZoneFilesDirectory = NULL;
|
||||
static CharString *gTimeZoneFilesDirectory = nullptr;
|
||||
|
||||
#if U_POSIX_LOCALE || U_PLATFORM_USES_ONLY_WIN32_API
|
||||
static const char *gCorrectedPOSIXLocale = NULL; /* Sometimes heap allocated */
|
||||
static const char *gCorrectedPOSIXLocale = nullptr; /* Sometimes heap allocated */
|
||||
static bool gCorrectedPOSIXLocaleHeapAllocated = false;
|
||||
#endif
|
||||
|
||||
static UBool U_CALLCONV putil_cleanup(void)
|
||||
static UBool U_CALLCONV putil_cleanup()
|
||||
{
|
||||
if (gDataDirectory && *gDataDirectory) {
|
||||
uprv_free(gDataDirectory);
|
||||
}
|
||||
gDataDirectory = NULL;
|
||||
gDataDirectory = nullptr;
|
||||
gDataDirInitOnce.reset();
|
||||
|
||||
delete gTimeZoneFilesDirectory;
|
||||
gTimeZoneFilesDirectory = NULL;
|
||||
gTimeZoneFilesDirectory = nullptr;
|
||||
gTimeZoneFilesInitOnce.reset();
|
||||
|
||||
#ifdef SEARCH_TZFILE
|
||||
delete gSearchTZFileResult;
|
||||
gSearchTZFileResult = NULL;
|
||||
gSearchTZFileResult = nullptr;
|
||||
#endif
|
||||
|
||||
#if U_POSIX_LOCALE || U_PLATFORM_USES_ONLY_WIN32_API
|
||||
if (gCorrectedPOSIXLocale && gCorrectedPOSIXLocaleHeapAllocated) {
|
||||
uprv_free(const_cast<char *>(gCorrectedPOSIXLocale));
|
||||
gCorrectedPOSIXLocale = NULL;
|
||||
gCorrectedPOSIXLocale = nullptr;
|
||||
gCorrectedPOSIXLocaleHeapAllocated = false;
|
||||
}
|
||||
#endif
|
||||
|
@ -1307,9 +1307,9 @@ u_setDataDirectory(const char *directory) {
|
|||
char *newDataDir;
|
||||
int32_t length;
|
||||
|
||||
if(directory==NULL || *directory==0) {
|
||||
if(directory==nullptr || *directory==0) {
|
||||
/* A small optimization to prevent the malloc and copy when the
|
||||
shared library is used, and this is a way to make sure that NULL
|
||||
shared library is used, and this is a way to make sure that nullptr
|
||||
is never returned.
|
||||
*/
|
||||
newDataDir = (char *)"";
|
||||
|
@ -1318,7 +1318,7 @@ u_setDataDirectory(const char *directory) {
|
|||
length=(int32_t)uprv_strlen(directory);
|
||||
newDataDir = (char *)uprv_malloc(length + 2);
|
||||
/* Exit out if newDataDir could not be created. */
|
||||
if (newDataDir == NULL) {
|
||||
if (newDataDir == nullptr) {
|
||||
return;
|
||||
}
|
||||
uprv_strcpy(newDataDir, directory);
|
||||
|
@ -1326,7 +1326,7 @@ u_setDataDirectory(const char *directory) {
|
|||
#if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR)
|
||||
{
|
||||
char *p;
|
||||
while((p = uprv_strchr(newDataDir, U_FILE_ALT_SEP_CHAR)) != NULL) {
|
||||
while((p = uprv_strchr(newDataDir, U_FILE_ALT_SEP_CHAR)) != nullptr) {
|
||||
*p = U_FILE_SEP_CHAR;
|
||||
}
|
||||
}
|
||||
|
@ -1389,7 +1389,7 @@ static BOOL U_CALLCONV getIcuDataDirectoryUnderWindowsDirectory(char* directoryB
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t windowsPathUtf8Len = 0;
|
||||
u_strToUTF8(windowsPathUtf8, static_cast<int32_t>(UPRV_LENGTHOF(windowsPathUtf8)),
|
||||
&windowsPathUtf8Len, reinterpret_cast<const UChar*>(windowsPath), -1, &status);
|
||||
&windowsPathUtf8Len, reinterpret_cast<const char16_t*>(windowsPath), -1, &status);
|
||||
|
||||
if (U_SUCCESS(status) && (status != U_STRING_NOT_TERMINATED_WARNING) &&
|
||||
(windowsPathUtf8Len < (UPRV_LENGTHOF(windowsPathUtf8) - 1))) {
|
||||
|
@ -1419,7 +1419,7 @@ static void U_CALLCONV dataDirectoryInitFn() {
|
|||
return;
|
||||
}
|
||||
|
||||
const char *path = NULL;
|
||||
const char *path = nullptr;
|
||||
#if defined(ICU_DATA_DIR_PREFIX_ENV_VAR)
|
||||
char datadir_path_buffer[PATH_MAX];
|
||||
#endif
|
||||
|
@ -1452,7 +1452,7 @@ static void U_CALLCONV dataDirectoryInitFn() {
|
|||
* set their own path.
|
||||
*/
|
||||
#if defined(ICU_DATA_DIR) || defined(U_ICU_DATA_DEFAULT_DIR)
|
||||
if(path==NULL || *path==0) {
|
||||
if(path==nullptr || *path==0) {
|
||||
# if defined(ICU_DATA_DIR_PREFIX_ENV_VAR)
|
||||
const char *prefix = getenv(ICU_DATA_DIR_PREFIX_ENV_VAR);
|
||||
# endif
|
||||
|
@ -1462,8 +1462,8 @@ static void U_CALLCONV dataDirectoryInitFn() {
|
|||
path=U_ICU_DATA_DEFAULT_DIR;
|
||||
# endif
|
||||
# if defined(ICU_DATA_DIR_PREFIX_ENV_VAR)
|
||||
if (prefix != NULL) {
|
||||
snprintf(datadir_path_buffer, PATH_MAX, "%s%s", prefix, path);
|
||||
if (prefix != nullptr) {
|
||||
snprintf(datadir_path_buffer, sizeof(datadir_path_buffer), "%s%s", prefix, path);
|
||||
path=datadir_path_buffer;
|
||||
}
|
||||
# endif
|
||||
|
@ -1477,7 +1477,7 @@ static void U_CALLCONV dataDirectoryInitFn() {
|
|||
}
|
||||
#endif
|
||||
|
||||
if(path==NULL) {
|
||||
if(path==nullptr) {
|
||||
/* It looks really bad, set it to something. */
|
||||
path = "";
|
||||
}
|
||||
|
@ -1487,7 +1487,7 @@ static void U_CALLCONV dataDirectoryInitFn() {
|
|||
}
|
||||
|
||||
U_CAPI const char * U_EXPORT2
|
||||
u_getDataDirectory(void) {
|
||||
u_getDataDirectory() {
|
||||
umtx_initOnce(gDataDirInitOnce, &dataDirectoryInitFn);
|
||||
return gDataDirectory;
|
||||
}
|
||||
|
@ -1500,7 +1500,7 @@ static void setTimeZoneFilesDir(const char *path, UErrorCode &status) {
|
|||
gTimeZoneFilesDirectory->append(path, status);
|
||||
#if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR)
|
||||
char *p = gTimeZoneFilesDirectory->data();
|
||||
while ((p = uprv_strchr(p, U_FILE_ALT_SEP_CHAR)) != NULL) {
|
||||
while ((p = uprv_strchr(p, U_FILE_ALT_SEP_CHAR)) != nullptr) {
|
||||
*p = U_FILE_SEP_CHAR;
|
||||
}
|
||||
#endif
|
||||
|
@ -1510,10 +1510,10 @@ static void setTimeZoneFilesDir(const char *path, UErrorCode &status) {
|
|||
#define TO_STRING_2(x) #x
|
||||
|
||||
static void U_CALLCONV TimeZoneDataDirInitFn(UErrorCode &status) {
|
||||
U_ASSERT(gTimeZoneFilesDirectory == NULL);
|
||||
U_ASSERT(gTimeZoneFilesDirectory == nullptr);
|
||||
ucln_common_registerCleanup(UCLN_COMMON_PUTIL, putil_cleanup);
|
||||
gTimeZoneFilesDirectory = new CharString();
|
||||
if (gTimeZoneFilesDirectory == NULL) {
|
||||
if (gTimeZoneFilesDirectory == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -1541,19 +1541,19 @@ static void U_CALLCONV TimeZoneDataDirInitFn(UErrorCode &status) {
|
|||
#endif // U_PLATFORM_HAS_WINUWP_API
|
||||
|
||||
#if defined(U_TIMEZONE_FILES_DIR)
|
||||
if (dir == NULL) {
|
||||
if (dir == nullptr) {
|
||||
// Build time configuration setting.
|
||||
dir = TO_STRING(U_TIMEZONE_FILES_DIR);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dir == NULL) {
|
||||
if (dir == nullptr) {
|
||||
dir = "";
|
||||
}
|
||||
|
||||
#if defined(ICU_TIMEZONE_FILES_DIR_PREFIX_ENV_VAR)
|
||||
if (prefix != NULL) {
|
||||
snprintf(timezonefilesdir_path_buffer, PATH_MAX, "%s%s", prefix, dir);
|
||||
if (prefix != nullptr) {
|
||||
snprintf(timezonefilesdir_path_buffer, sizeof(timezonefilesdir_path_buffer), "%s%s", prefix, dir);
|
||||
dir = timezonefilesdir_path_buffer;
|
||||
}
|
||||
#endif
|
||||
|
@ -1586,7 +1586,7 @@ u_setTimeZoneFilesDirectory(const char *path, UErrorCode *status) {
|
|||
*/
|
||||
static const char *uprv_getPOSIXIDForCategory(int category)
|
||||
{
|
||||
const char* posixID = NULL;
|
||||
const char* posixID = nullptr;
|
||||
if (category == LC_MESSAGES || category == LC_CTYPE) {
|
||||
/*
|
||||
* On Solaris two different calls to setlocale can result in
|
||||
|
@ -1596,7 +1596,7 @@ static const char *uprv_getPOSIXIDForCategory(int category)
|
|||
*
|
||||
* LC_ALL can't be used because it's platform dependent. The LANG
|
||||
* environment variable seems to affect LC_CTYPE variable by default.
|
||||
* Here is what setlocale(LC_ALL, NULL) can return.
|
||||
* Here is what setlocale(LC_ALL, nullptr) can return.
|
||||
* HPUX can return 'C C C C C C C'
|
||||
* Solaris can return /en_US/C/C/C/C/C on the second try.
|
||||
* Linux can return LC_CTYPE=C;LC_NUMERIC=C;...
|
||||
|
@ -1604,9 +1604,9 @@ static const char *uprv_getPOSIXIDForCategory(int category)
|
|||
* The default codepage detection also needs to use LC_CTYPE.
|
||||
*
|
||||
* Do not call setlocale(LC_*, "")! Using an empty string instead
|
||||
* of NULL, will modify the libc behavior.
|
||||
* of nullptr, will modify the libc behavior.
|
||||
*/
|
||||
posixID = setlocale(category, NULL);
|
||||
posixID = setlocale(category, nullptr);
|
||||
if ((posixID == 0)
|
||||
|| (uprv_strcmp("C", posixID) == 0)
|
||||
|| (uprv_strcmp("POSIX", posixID) == 0))
|
||||
|
@ -1647,9 +1647,9 @@ static const char *uprv_getPOSIXIDForCategory(int category)
|
|||
/* Return just the POSIX id for the default locale, whatever happens to be in
|
||||
* it. It gets the value from LC_MESSAGES and indirectly from LC_ALL and LANG.
|
||||
*/
|
||||
static const char *uprv_getPOSIXIDForDefaultLocale(void)
|
||||
static const char *uprv_getPOSIXIDForDefaultLocale()
|
||||
{
|
||||
static const char* posixID = NULL;
|
||||
static const char* posixID = nullptr;
|
||||
if (posixID == 0) {
|
||||
posixID = uprv_getPOSIXIDForCategory(LC_MESSAGES);
|
||||
}
|
||||
|
@ -1660,9 +1660,9 @@ static const char *uprv_getPOSIXIDForDefaultLocale(void)
|
|||
/* Return just the POSIX id for the default codepage, whatever happens to be in
|
||||
* it. It gets the value from LC_CTYPE and indirectly from LC_ALL and LANG.
|
||||
*/
|
||||
static const char *uprv_getPOSIXIDForDefaultCodepage(void)
|
||||
static const char *uprv_getPOSIXIDForDefaultCodepage()
|
||||
{
|
||||
static const char* posixID = NULL;
|
||||
static const char* posixID = nullptr;
|
||||
if (posixID == 0) {
|
||||
posixID = uprv_getPOSIXIDForCategory(LC_CTYPE);
|
||||
}
|
||||
|
@ -1861,16 +1861,16 @@ The leftmost codepage (.xxx) wins.
|
|||
const char *localeID = getenv("LC_ALL");
|
||||
char *p;
|
||||
|
||||
if (localeID == NULL)
|
||||
if (localeID == nullptr)
|
||||
localeID = getenv("LANG");
|
||||
if (localeID == NULL)
|
||||
localeID = setlocale(LC_ALL, NULL);
|
||||
if (localeID == nullptr)
|
||||
localeID = setlocale(LC_ALL, nullptr);
|
||||
/* Make sure we have something... */
|
||||
if (localeID == NULL)
|
||||
if (localeID == nullptr)
|
||||
return "en_US_POSIX";
|
||||
|
||||
/* Extract the locale name from the path. */
|
||||
if((p = uprv_strrchr(localeID, '/')) != NULL)
|
||||
if((p = uprv_strrchr(localeID, '/')) != nullptr)
|
||||
{
|
||||
/* Increment p to start of locale name. */
|
||||
p++;
|
||||
|
@ -1881,7 +1881,7 @@ The leftmost codepage (.xxx) wins.
|
|||
uprv_strcpy(correctedLocale, localeID);
|
||||
|
||||
/* Strip off the '.locale' extension. */
|
||||
if((p = uprv_strchr(correctedLocale, '.')) != NULL) {
|
||||
if((p = uprv_strchr(correctedLocale, '.')) != nullptr) {
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
|
@ -1961,12 +1961,12 @@ names to the ICU alias table in the data directory.
|
|||
*/
|
||||
static const char*
|
||||
remapPlatformDependentCodepage(const char *locale, const char *name) {
|
||||
if (locale != NULL && *locale == 0) {
|
||||
if (locale != nullptr && *locale == 0) {
|
||||
/* Make sure that an empty locale is handled the same way. */
|
||||
locale = NULL;
|
||||
locale = nullptr;
|
||||
}
|
||||
if (name == NULL) {
|
||||
return NULL;
|
||||
if (name == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
#if U_PLATFORM == U_PF_AIX
|
||||
if (uprv_strcmp(name, "IBM-943") == 0) {
|
||||
|
@ -1978,7 +1978,7 @@ remapPlatformDependentCodepage(const char *locale, const char *name) {
|
|||
name = "IBM-5348";
|
||||
}
|
||||
#elif U_PLATFORM == U_PF_SOLARIS
|
||||
if (locale != NULL && uprv_strcmp(name, "EUC") == 0) {
|
||||
if (locale != nullptr && uprv_strcmp(name, "EUC") == 0) {
|
||||
/* Solaris underspecifies the "EUC" name. */
|
||||
if (uprv_strcmp(locale, "zh_CN") == 0) {
|
||||
name = "EUC-CN";
|
||||
|
@ -2005,7 +2005,7 @@ remapPlatformDependentCodepage(const char *locale, const char *name) {
|
|||
name = "ISO-8859-1";
|
||||
}
|
||||
#elif U_PLATFORM_IS_DARWIN_BASED
|
||||
if (locale == NULL && *name == 0) {
|
||||
if (locale == nullptr && *name == 0) {
|
||||
/*
|
||||
No locale was specified, and an empty name was passed in.
|
||||
This usually indicates that nl_langinfo didn't return valid information.
|
||||
|
@ -2017,7 +2017,7 @@ remapPlatformDependentCodepage(const char *locale, const char *name) {
|
|||
/* Remap CP949 to a similar codepage to avoid issues with backslash and won symbol. */
|
||||
name = "EUC-KR";
|
||||
}
|
||||
else if (locale != NULL && uprv_strcmp(locale, "en_US_POSIX") != 0 && uprv_strcmp(name, "US-ASCII") == 0) {
|
||||
else if (locale != nullptr && uprv_strcmp(locale, "en_US_POSIX") != 0 && uprv_strcmp(name, "US-ASCII") == 0) {
|
||||
/*
|
||||
* For non C/POSIX locale, default the code page to UTF-8 instead of US-ASCII.
|
||||
*/
|
||||
|
@ -2029,7 +2029,7 @@ remapPlatformDependentCodepage(const char *locale, const char *name) {
|
|||
name = "EUC-KR";
|
||||
}
|
||||
#elif U_PLATFORM == U_PF_HPUX
|
||||
if (locale != NULL && uprv_strcmp(locale, "zh_HK") == 0 && uprv_strcmp(name, "big5") == 0) {
|
||||
if (locale != nullptr && uprv_strcmp(locale, "zh_HK") == 0 && uprv_strcmp(name, "big5") == 0) {
|
||||
/* HP decided to extend big5 as hkbig5 even though it's not compatible :-( */
|
||||
/* zh_TW.big5 is not the same charset as zh_HK.big5! */
|
||||
name = "hkbig5";
|
||||
|
@ -2043,7 +2043,7 @@ remapPlatformDependentCodepage(const char *locale, const char *name) {
|
|||
name = "eucjis";
|
||||
}
|
||||
#elif U_PLATFORM == U_PF_LINUX
|
||||
if (locale != NULL && uprv_strcmp(name, "euc") == 0) {
|
||||
if (locale != nullptr && uprv_strcmp(name, "euc") == 0) {
|
||||
/* Linux underspecifies the "EUC" name. */
|
||||
if (uprv_strcmp(locale, "korean") == 0) {
|
||||
name = "EUC-KR";
|
||||
|
@ -2061,7 +2061,7 @@ remapPlatformDependentCodepage(const char *locale, const char *name) {
|
|||
*/
|
||||
name = "eucjis";
|
||||
}
|
||||
else if (locale != NULL && uprv_strcmp(locale, "en_US_POSIX") != 0 &&
|
||||
else if (locale != nullptr && uprv_strcmp(locale, "en_US_POSIX") != 0 &&
|
||||
(uprv_strcmp(name, "ANSI_X3.4-1968") == 0 || uprv_strcmp(name, "US-ASCII") == 0)) {
|
||||
/*
|
||||
* For non C/POSIX locale, default the code page to UTF-8 instead of US-ASCII.
|
||||
|
@ -2070,13 +2070,13 @@ remapPlatformDependentCodepage(const char *locale, const char *name) {
|
|||
}
|
||||
/*
|
||||
* Linux returns ANSI_X3.4-1968 for C/POSIX, but the call site takes care of
|
||||
* it by falling back to 'US-ASCII' when NULL is returned from this
|
||||
* it by falling back to 'US-ASCII' when nullptr is returned from this
|
||||
* function. So, we don't have to worry about it here.
|
||||
*/
|
||||
#endif
|
||||
/* return NULL when "" is passed in */
|
||||
/* return nullptr when "" is passed in */
|
||||
if (*name == 0) {
|
||||
name = NULL;
|
||||
name = nullptr;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
@ -2085,16 +2085,16 @@ static const char*
|
|||
getCodepageFromPOSIXID(const char *localeName, char * buffer, int32_t buffCapacity)
|
||||
{
|
||||
char localeBuf[100];
|
||||
const char *name = NULL;
|
||||
char *variant = NULL;
|
||||
const char *name = nullptr;
|
||||
char *variant = nullptr;
|
||||
|
||||
if (localeName != NULL && (name = (uprv_strchr(localeName, '.'))) != NULL) {
|
||||
if (localeName != nullptr && (name = (uprv_strchr(localeName, '.'))) != nullptr) {
|
||||
size_t localeCapacity = uprv_min(sizeof(localeBuf), (name-localeName)+1);
|
||||
uprv_strncpy(localeBuf, localeName, localeCapacity);
|
||||
localeBuf[localeCapacity-1] = 0; /* ensure NULL termination */
|
||||
localeBuf[localeCapacity-1] = 0; /* ensure NUL termination */
|
||||
name = uprv_strncpy(buffer, name+1, buffCapacity);
|
||||
buffer[buffCapacity-1] = 0; /* ensure NULL termination */
|
||||
if ((variant = const_cast<char *>(uprv_strchr(name, '@'))) != NULL) {
|
||||
buffer[buffCapacity-1] = 0; /* ensure NUL termination */
|
||||
if ((variant = const_cast<char *>(uprv_strchr(name, '@'))) != nullptr) {
|
||||
*variant = 0;
|
||||
}
|
||||
name = remapPlatformDependentCodepage(localeBuf, name);
|
||||
|
@ -2124,7 +2124,7 @@ int_getDefaultCodepage()
|
|||
}
|
||||
/* else use the default */
|
||||
}
|
||||
sprintf(codepage,"ibm-%d", ccsid);
|
||||
snprintf(codepage, sizeof(codepage), "ibm-%d", ccsid);
|
||||
return codepage;
|
||||
|
||||
#elif U_PLATFORM == U_PF_OS390
|
||||
|
@ -2132,7 +2132,7 @@ int_getDefaultCodepage()
|
|||
|
||||
strncpy(codepage, nl_langinfo(CODESET),63-strlen(UCNV_SWAP_LFNL_OPTION_STRING));
|
||||
strcat(codepage,UCNV_SWAP_LFNL_OPTION_STRING);
|
||||
codepage[63] = 0; /* NULL terminate */
|
||||
codepage[63] = 0; /* NUL terminate */
|
||||
|
||||
return codepage;
|
||||
|
||||
|
@ -2161,7 +2161,7 @@ int_getDefaultCodepage()
|
|||
// are between 3 and 19999
|
||||
if (codepageNumber > 0 && codepageNumber < 20000)
|
||||
{
|
||||
sprintf(codepage, "windows-%ld", codepageNumber);
|
||||
snprintf(codepage, sizeof(codepage), "windows-%ld", codepageNumber);
|
||||
return codepage;
|
||||
}
|
||||
// If the codepage number call failed then return UTF-8
|
||||
|
@ -2169,8 +2169,8 @@ int_getDefaultCodepage()
|
|||
|
||||
#elif U_POSIX_LOCALE
|
||||
static char codesetName[100];
|
||||
const char *localeName = NULL;
|
||||
const char *name = NULL;
|
||||
const char *localeName = nullptr;
|
||||
const char *name = nullptr;
|
||||
|
||||
localeName = uprv_getPOSIXIDForDefaultCodepage();
|
||||
uprv_memset(codesetName, 0, sizeof(codesetName));
|
||||
|
@ -2193,10 +2193,10 @@ int_getDefaultCodepage()
|
|||
} else
|
||||
#endif
|
||||
{
|
||||
codeset = remapPlatformDependentCodepage(NULL, codeset);
|
||||
codeset = remapPlatformDependentCodepage(nullptr, codeset);
|
||||
}
|
||||
|
||||
if (codeset != NULL) {
|
||||
if (codeset != nullptr) {
|
||||
uprv_strncpy(codesetName, codeset, sizeof(codesetName));
|
||||
codesetName[sizeof(codesetName)-1] = 0;
|
||||
return codesetName;
|
||||
|
@ -2229,12 +2229,12 @@ int_getDefaultCodepage()
|
|||
U_CAPI const char* U_EXPORT2
|
||||
uprv_getDefaultCodepage()
|
||||
{
|
||||
static char const *name = NULL;
|
||||
umtx_lock(NULL);
|
||||
if (name == NULL) {
|
||||
static char const *name = nullptr;
|
||||
umtx_lock(nullptr);
|
||||
if (name == nullptr) {
|
||||
name = int_getDefaultCodepage();
|
||||
}
|
||||
umtx_unlock(NULL);
|
||||
umtx_unlock(nullptr);
|
||||
return name;
|
||||
}
|
||||
#endif /* !U_CHARSET_IS_UTF8 */
|
||||
|
@ -2249,11 +2249,11 @@ u_versionFromString(UVersionInfo versionArray, const char *versionString) {
|
|||
char *end;
|
||||
uint16_t part=0;
|
||||
|
||||
if(versionArray==NULL) {
|
||||
if(versionArray==nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(versionString!=NULL) {
|
||||
if(versionString!=nullptr) {
|
||||
for(;;) {
|
||||
versionArray[part]=(uint8_t)uprv_strtoul(versionString, &end, 10);
|
||||
if(end==versionString || ++part==U_MAX_VERSION_LENGTH || *end!=U_VERSION_DELIMITER) {
|
||||
|
@ -2269,8 +2269,8 @@ u_versionFromString(UVersionInfo versionArray, const char *versionString) {
|
|||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
u_versionFromUString(UVersionInfo versionArray, const UChar *versionString) {
|
||||
if(versionArray!=NULL && versionString!=NULL) {
|
||||
u_versionFromUString(UVersionInfo versionArray, const char16_t *versionString) {
|
||||
if(versionArray!=nullptr && versionString!=nullptr) {
|
||||
char versionChars[U_MAX_VERSION_STRING_LENGTH+1];
|
||||
int32_t len = u_strlen(versionString);
|
||||
if(len>U_MAX_VERSION_STRING_LENGTH) {
|
||||
|
@ -2287,11 +2287,11 @@ u_versionToString(const UVersionInfo versionArray, char *versionString) {
|
|||
uint16_t count, part;
|
||||
uint8_t field;
|
||||
|
||||
if(versionString==NULL) {
|
||||
if(versionString==nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(versionArray==NULL) {
|
||||
if(versionArray==nullptr) {
|
||||
versionString[0]=0;
|
||||
return;
|
||||
}
|
||||
|
@ -2362,10 +2362,10 @@ u_getVersion(UVersionInfo versionArray) {
|
|||
|
||||
U_CAPI void * U_EXPORT2
|
||||
uprv_dl_open(const char *libName, UErrorCode *status) {
|
||||
void *ret = NULL;
|
||||
void *ret = nullptr;
|
||||
if(U_FAILURE(*status)) return ret;
|
||||
ret = dlopen(libName, RTLD_NOW|RTLD_GLOBAL);
|
||||
if(ret==NULL) {
|
||||
if(ret==nullptr) {
|
||||
#ifdef U_TRACE_DYLOAD
|
||||
printf("dlerror on dlopen(%s): %s\n", libName, dlerror());
|
||||
#endif
|
||||
|
@ -2386,10 +2386,10 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
|
|||
UVoidFunction *fp;
|
||||
void *vp;
|
||||
} uret;
|
||||
uret.fp = NULL;
|
||||
uret.fp = nullptr;
|
||||
if(U_FAILURE(*status)) return uret.fp;
|
||||
uret.vp = dlsym(lib, sym);
|
||||
if(uret.vp == NULL) {
|
||||
if(uret.vp == nullptr) {
|
||||
#ifdef U_TRACE_DYLOAD
|
||||
printf("dlerror on dlsym(%p,%s): %s\n", lib,sym, dlerror());
|
||||
#endif
|
||||
|
@ -2405,13 +2405,13 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
|
|||
|
||||
U_CAPI void * U_EXPORT2
|
||||
uprv_dl_open(const char *libName, UErrorCode *status) {
|
||||
HMODULE lib = NULL;
|
||||
HMODULE lib = nullptr;
|
||||
|
||||
if(U_FAILURE(*status)) return NULL;
|
||||
if(U_FAILURE(*status)) return nullptr;
|
||||
|
||||
lib = LoadLibraryA(libName);
|
||||
|
||||
if(lib==NULL) {
|
||||
if(lib==nullptr) {
|
||||
*status = U_MISSING_RESOURCE_ERROR;
|
||||
}
|
||||
|
||||
|
@ -2431,13 +2431,13 @@ uprv_dl_close(void *lib, UErrorCode *status) {
|
|||
U_CAPI UVoidFunction* U_EXPORT2
|
||||
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
|
||||
HMODULE handle = (HMODULE)lib;
|
||||
UVoidFunction* addr = NULL;
|
||||
UVoidFunction* addr = nullptr;
|
||||
|
||||
if(U_FAILURE(*status) || lib==NULL) return NULL;
|
||||
if(U_FAILURE(*status) || lib==nullptr) return nullptr;
|
||||
|
||||
addr = (UVoidFunction*)GetProcAddress(handle, sym);
|
||||
|
||||
if(addr==NULL) {
|
||||
if(addr==nullptr) {
|
||||
DWORD lastError = GetLastError();
|
||||
if(lastError == ERROR_PROC_NOT_FOUND) {
|
||||
*status = U_MISSING_RESOURCE_ERROR;
|
||||
|
@ -2456,9 +2456,9 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
|
|||
U_CAPI void * U_EXPORT2
|
||||
uprv_dl_open(const char *libName, UErrorCode *status) {
|
||||
(void)libName;
|
||||
if(U_FAILURE(*status)) return NULL;
|
||||
if(U_FAILURE(*status)) return nullptr;
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
|
@ -2476,7 +2476,7 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
|
|||
if(U_SUCCESS(*status)) {
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
}
|
||||
return (UVoidFunction*)NULL;
|
||||
return (UVoidFunction*)nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,9 +63,8 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RuleBasedBreakIterator)
|
|||
* tables object that is passed in as a parameter.
|
||||
*/
|
||||
RuleBasedBreakIterator::RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode &status)
|
||||
: fSCharIter(UnicodeString())
|
||||
: RuleBasedBreakIterator(&status)
|
||||
{
|
||||
init(status);
|
||||
fData = new RBBIDataWrapper(data, status); // status checked in constructor
|
||||
if (U_FAILURE(status)) {return;}
|
||||
if(fData == nullptr) {
|
||||
|
@ -102,13 +101,12 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(UDataMemory* udm, UBool isPhraseB
|
|||
RuleBasedBreakIterator::RuleBasedBreakIterator(const uint8_t *compiledRules,
|
||||
uint32_t ruleLength,
|
||||
UErrorCode &status)
|
||||
: fSCharIter(UnicodeString())
|
||||
: RuleBasedBreakIterator(&status)
|
||||
{
|
||||
init(status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
if (compiledRules == NULL || ruleLength < sizeof(RBBIDataHeader)) {
|
||||
if (compiledRules == nullptr || ruleLength < sizeof(RBBIDataHeader)) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -141,9 +139,8 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(const uint8_t *compiledRules,
|
|||
//
|
||||
//-------------------------------------------------------------------------------
|
||||
RuleBasedBreakIterator::RuleBasedBreakIterator(UDataMemory* udm, UErrorCode &status)
|
||||
: fSCharIter(UnicodeString())
|
||||
: RuleBasedBreakIterator(&status)
|
||||
{
|
||||
init(status);
|
||||
fData = new RBBIDataWrapper(udm, status); // status checked in constructor
|
||||
if (U_FAILURE(status)) {return;}
|
||||
if(fData == nullptr) {
|
||||
|
@ -170,9 +167,8 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(UDataMemory* udm, UErrorCode &sta
|
|||
RuleBasedBreakIterator::RuleBasedBreakIterator( const UnicodeString &rules,
|
||||
UParseError &parseError,
|
||||
UErrorCode &status)
|
||||
: fSCharIter(UnicodeString())
|
||||
: RuleBasedBreakIterator(&status)
|
||||
{
|
||||
init(status);
|
||||
if (U_FAILURE(status)) {return;}
|
||||
RuleBasedBreakIterator *bi = (RuleBasedBreakIterator *)
|
||||
RBBIRuleBuilder::createRuleBasedBreakIterator(rules, &parseError, status);
|
||||
|
@ -194,10 +190,39 @@ RuleBasedBreakIterator::RuleBasedBreakIterator( const UnicodeString &rules,
|
|||
// of rules.
|
||||
//-------------------------------------------------------------------------------
|
||||
RuleBasedBreakIterator::RuleBasedBreakIterator()
|
||||
: fSCharIter(UnicodeString())
|
||||
: RuleBasedBreakIterator(nullptr)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
init(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple Constructor with an error code.
|
||||
* Handles common initialization for all other constructors.
|
||||
*/
|
||||
RuleBasedBreakIterator::RuleBasedBreakIterator(UErrorCode *status) {
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
if (status == nullptr) {
|
||||
status = &ec;
|
||||
}
|
||||
utext_openUChars(&fText, nullptr, 0, status);
|
||||
LocalPointer<DictionaryCache> lpDictionaryCache(new DictionaryCache(this, *status), *status);
|
||||
LocalPointer<BreakCache> lpBreakCache(new BreakCache(this, *status), *status);
|
||||
if (U_FAILURE(*status)) {
|
||||
fErrorCode = *status;
|
||||
return;
|
||||
}
|
||||
fDictionaryCache = lpDictionaryCache.orphan();
|
||||
fBreakCache = lpBreakCache.orphan();
|
||||
|
||||
#ifdef RBBI_DEBUG
|
||||
static UBool debugInitDone = false;
|
||||
if (debugInitDone == false) {
|
||||
char *debugEnv = getenv("U_RBBIDEBUG");
|
||||
if (debugEnv && uprv_strstr(debugEnv, "trace")) {
|
||||
gTrace = true;
|
||||
}
|
||||
debugInitDone = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -208,11 +233,8 @@ RuleBasedBreakIterator::RuleBasedBreakIterator()
|
|||
//
|
||||
//-------------------------------------------------------------------------------
|
||||
RuleBasedBreakIterator::RuleBasedBreakIterator(const RuleBasedBreakIterator& other)
|
||||
: BreakIterator(other),
|
||||
fSCharIter(UnicodeString())
|
||||
: RuleBasedBreakIterator()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
this->init(status);
|
||||
*this = other;
|
||||
}
|
||||
|
||||
|
@ -261,9 +283,9 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
|
|||
}
|
||||
BreakIterator::operator=(that);
|
||||
|
||||
if (fLanguageBreakEngines != NULL) {
|
||||
if (fLanguageBreakEngines != nullptr) {
|
||||
delete fLanguageBreakEngines;
|
||||
fLanguageBreakEngines = NULL; // Just rebuild for now
|
||||
fLanguageBreakEngines = nullptr; // Just rebuild for now
|
||||
}
|
||||
// TODO: clone fLanguageBreakEngines from "that"
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
@ -274,22 +296,22 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
|
|||
}
|
||||
fCharIter = &fSCharIter;
|
||||
|
||||
if (that.fCharIter != NULL && that.fCharIter != &that.fSCharIter) {
|
||||
if (that.fCharIter != nullptr && that.fCharIter != &that.fSCharIter) {
|
||||
// This is a little bit tricky - it will initially appear that
|
||||
// this->fCharIter is adopted, even if that->fCharIter was
|
||||
// not adopted. That's ok.
|
||||
fCharIter = that.fCharIter->clone();
|
||||
}
|
||||
fSCharIter = that.fSCharIter;
|
||||
if (fCharIter == NULL) {
|
||||
if (fCharIter == nullptr) {
|
||||
fCharIter = &fSCharIter;
|
||||
}
|
||||
|
||||
if (fData != NULL) {
|
||||
if (fData != nullptr) {
|
||||
fData->removeReference();
|
||||
fData = NULL;
|
||||
fData = nullptr;
|
||||
}
|
||||
if (that.fData != NULL) {
|
||||
if (that.fData != nullptr) {
|
||||
fData = that.fData->addReference();
|
||||
}
|
||||
|
||||
|
@ -315,58 +337,6 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// init() Shared initialization routine. Used by all the constructors.
|
||||
// Initializes all fields, leaving the object in a consistent state.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void RuleBasedBreakIterator::init(UErrorCode &status) {
|
||||
fCharIter = nullptr;
|
||||
fData = nullptr;
|
||||
fPosition = 0;
|
||||
fRuleStatusIndex = 0;
|
||||
fDone = false;
|
||||
fDictionaryCharCount = 0;
|
||||
fLanguageBreakEngines = nullptr;
|
||||
fUnhandledBreakEngine = nullptr;
|
||||
fBreakCache = nullptr;
|
||||
fDictionaryCache = nullptr;
|
||||
fLookAheadMatches = nullptr;
|
||||
fIsPhraseBreaking = false;
|
||||
|
||||
// Note: IBM xlC is unable to assign or initialize member fText from UTEXT_INITIALIZER.
|
||||
// fText = UTEXT_INITIALIZER;
|
||||
static const UText initializedUText = UTEXT_INITIALIZER;
|
||||
uprv_memcpy(&fText, &initializedUText, sizeof(UText));
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
utext_openUChars(&fText, NULL, 0, &status);
|
||||
fDictionaryCache = new DictionaryCache(this, status);
|
||||
fBreakCache = new BreakCache(this, status);
|
||||
if (U_SUCCESS(status) && (fDictionaryCache == NULL || fBreakCache == NULL)) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
|
||||
#ifdef RBBI_DEBUG
|
||||
static UBool debugInitDone = false;
|
||||
if (debugInitDone == false) {
|
||||
char *debugEnv = getenv("U_RBBIDEBUG");
|
||||
if (debugEnv && uprv_strstr(debugEnv, "trace")) {
|
||||
gTrace = true;
|
||||
}
|
||||
debugInitDone = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// clone - Returns a newly-constructed RuleBasedBreakIterator with the same
|
||||
|
@ -396,7 +366,7 @@ RuleBasedBreakIterator::operator==(const BreakIterator& that) const {
|
|||
// and does not implement an equality function that would otherwise be
|
||||
// checked at this point.
|
||||
|
||||
const RuleBasedBreakIterator& that2 = (const RuleBasedBreakIterator&) that;
|
||||
const RuleBasedBreakIterator& that2 = static_cast<const RuleBasedBreakIterator&>(that);
|
||||
|
||||
if (!utext_equals(&fText, &that2.fText)) {
|
||||
// The two break iterators are operating on different text,
|
||||
|
@ -412,7 +382,7 @@ RuleBasedBreakIterator::operator==(const BreakIterator& that) const {
|
|||
}
|
||||
|
||||
if (that2.fData == fData ||
|
||||
(fData != NULL && that2.fData != NULL && *that2.fData == *fData)) {
|
||||
(fData != nullptr && that2.fData != nullptr && *that2.fData == *fData)) {
|
||||
// The two break iterators are using the same rules.
|
||||
return true;
|
||||
}
|
||||
|
@ -424,9 +394,9 @@ RuleBasedBreakIterator::operator==(const BreakIterator& that) const {
|
|||
* @return A hash code
|
||||
*/
|
||||
int32_t
|
||||
RuleBasedBreakIterator::hashCode(void) const {
|
||||
RuleBasedBreakIterator::hashCode() const {
|
||||
int32_t hash = 0;
|
||||
if (fData != NULL) {
|
||||
if (fData != nullptr) {
|
||||
hash = fData->hashCode();
|
||||
}
|
||||
return hash;
|
||||
|
@ -447,7 +417,7 @@ void RuleBasedBreakIterator::setText(UText *ut, UErrorCode &status) {
|
|||
// Return one over an empty string instead - this is the closest
|
||||
// we can come to signaling a failure.
|
||||
// (GetText() is obsolete, this failure is sort of OK)
|
||||
fSCharIter.setText(UnicodeString());
|
||||
fSCharIter.setText(u"", 0);
|
||||
|
||||
if (fCharIter != &fSCharIter) {
|
||||
// existing fCharIter was adopted from the outside. Delete it now.
|
||||
|
@ -494,10 +464,10 @@ RuleBasedBreakIterator::adoptText(CharacterIterator* newText) {
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
fBreakCache->reset();
|
||||
fDictionaryCache->reset();
|
||||
if (newText==NULL || newText->startIndex() != 0) {
|
||||
if (newText==nullptr || newText->startIndex() != 0) {
|
||||
// startIndex !=0 wants to be an error, but there's no way to report it.
|
||||
// Make the iterator text be an empty string.
|
||||
utext_openUChars(&fText, NULL, 0, &status);
|
||||
utext_openUChars(&fText, nullptr, 0, &status);
|
||||
} else {
|
||||
utext_openCharacterIterator(&fText, newText, &status);
|
||||
}
|
||||
|
@ -520,7 +490,7 @@ RuleBasedBreakIterator::setText(const UnicodeString& newText) {
|
|||
// Needed in case someone calls getText().
|
||||
// Can not, unfortunately, do this lazily on the (probably never)
|
||||
// call to getText(), because getText is const.
|
||||
fSCharIter.setText(newText);
|
||||
fSCharIter.setText(newText.getBuffer(), newText.length());
|
||||
|
||||
if (fCharIter != &fSCharIter) {
|
||||
// old fCharIter was adopted from the outside. Delete it.
|
||||
|
@ -542,7 +512,7 @@ RuleBasedBreakIterator &RuleBasedBreakIterator::refreshInputText(UText *input, U
|
|||
if (U_FAILURE(status)) {
|
||||
return *this;
|
||||
}
|
||||
if (input == NULL) {
|
||||
if (input == nullptr) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return *this;
|
||||
}
|
||||
|
@ -568,7 +538,7 @@ RuleBasedBreakIterator &RuleBasedBreakIterator::refreshInputText(UText *input, U
|
|||
* Sets the current iteration position to the beginning of the text, position zero.
|
||||
* @return The new iterator position, which is zero.
|
||||
*/
|
||||
int32_t RuleBasedBreakIterator::first(void) {
|
||||
int32_t RuleBasedBreakIterator::first() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
if (!fBreakCache->seek(0)) {
|
||||
fBreakCache->populateNear(0, status);
|
||||
|
@ -582,7 +552,7 @@ int32_t RuleBasedBreakIterator::first(void) {
|
|||
* Sets the current iteration position to the end of the text.
|
||||
* @return The text's past-the-end offset.
|
||||
*/
|
||||
int32_t RuleBasedBreakIterator::last(void) {
|
||||
int32_t RuleBasedBreakIterator::last() {
|
||||
int32_t endPos = (int32_t)utext_nativeLength(&fText);
|
||||
UBool endShouldBeBoundary = isBoundary(endPos); // Has side effect of setting iterator position.
|
||||
(void)endShouldBeBoundary;
|
||||
|
@ -620,7 +590,7 @@ int32_t RuleBasedBreakIterator::next(int32_t n) {
|
|||
* Advances the iterator to the next boundary position.
|
||||
* @return The position of the first boundary after this one.
|
||||
*/
|
||||
int32_t RuleBasedBreakIterator::next(void) {
|
||||
int32_t RuleBasedBreakIterator::next() {
|
||||
fBreakCache->next();
|
||||
return fDone ? UBRK_DONE : fPosition;
|
||||
}
|
||||
|
@ -633,7 +603,7 @@ int32_t RuleBasedBreakIterator::next(void) {
|
|||
*
|
||||
* @return The position of the boundary position immediately preceding the starting position.
|
||||
*/
|
||||
int32_t RuleBasedBreakIterator::previous(void) {
|
||||
int32_t RuleBasedBreakIterator::previous() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
fBreakCache->previous(status);
|
||||
return fDone ? UBRK_DONE : fPosition;
|
||||
|
@ -730,7 +700,7 @@ UBool RuleBasedBreakIterator::isBoundary(int32_t offset) {
|
|||
* Returns the current iteration position.
|
||||
* @return The current iteration position.
|
||||
*/
|
||||
int32_t RuleBasedBreakIterator::current(void) const {
|
||||
int32_t RuleBasedBreakIterator::current() const {
|
||||
return fPosition;
|
||||
}
|
||||
|
||||
|
@ -1009,7 +979,7 @@ int32_t RuleBasedBreakIterator::handleSafePrevious(int32_t fromPosition) {
|
|||
#endif
|
||||
|
||||
// if we're already at the start of the text, return DONE.
|
||||
if (fData == NULL || UTEXT_GETNATIVEINDEX(&fText)==0) {
|
||||
if (fData == nullptr || UTEXT_GETNATIVEINDEX(&fText)==0) {
|
||||
return BreakIterator::DONE;
|
||||
}
|
||||
|
||||
|
@ -1117,10 +1087,10 @@ int32_t RuleBasedBreakIterator::getRuleStatusVec(
|
|||
//
|
||||
//-------------------------------------------------------------------------------
|
||||
const uint8_t *RuleBasedBreakIterator::getBinaryRules(uint32_t &length) {
|
||||
const uint8_t *retPtr = NULL;
|
||||
const uint8_t *retPtr = nullptr;
|
||||
length = 0;
|
||||
|
||||
if (fData != NULL) {
|
||||
if (fData != nullptr) {
|
||||
retPtr = (const uint8_t *)fData->fHeader;
|
||||
length = fData->fHeader->fLength;
|
||||
}
|
||||
|
@ -1131,16 +1101,16 @@ const uint8_t *RuleBasedBreakIterator::getBinaryRules(uint32_t &length) {
|
|||
RuleBasedBreakIterator *RuleBasedBreakIterator::createBufferClone(
|
||||
void * /*stackBuffer*/, int32_t &bufferSize, UErrorCode &status) {
|
||||
if (U_FAILURE(status)){
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (bufferSize == 0) {
|
||||
bufferSize = 1; // preflighting for deprecated functionality
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BreakIterator *clonedBI = clone();
|
||||
if (clonedBI == NULL) {
|
||||
if (clonedBI == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
} else {
|
||||
status = U_SAFECLONE_ALLOCATED_WARNING;
|
||||
|
@ -1160,7 +1130,7 @@ static icu::UInitOnce gRBBIInitOnce {};
|
|||
* Release all static memory held by breakiterator.
|
||||
*/
|
||||
U_CDECL_BEGIN
|
||||
UBool U_CALLCONV rbbi_cleanup(void) {
|
||||
UBool U_CALLCONV rbbi_cleanup() {
|
||||
delete gLanguageBreakFactories;
|
||||
gLanguageBreakFactories = nullptr;
|
||||
delete gEmptyString;
|
||||
|
@ -1185,14 +1155,14 @@ static void U_CALLCONV rbbiInit() {
|
|||
|
||||
static void U_CALLCONV initLanguageFactories() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
U_ASSERT(gLanguageBreakFactories == NULL);
|
||||
gLanguageBreakFactories = new UStack(_deleteFactory, NULL, status);
|
||||
if (gLanguageBreakFactories != NULL && U_SUCCESS(status)) {
|
||||
U_ASSERT(gLanguageBreakFactories == nullptr);
|
||||
gLanguageBreakFactories = new UStack(_deleteFactory, nullptr, status);
|
||||
if (gLanguageBreakFactories != nullptr && U_SUCCESS(status)) {
|
||||
ICULanguageBreakFactory *builtIn = new ICULanguageBreakFactory(status);
|
||||
gLanguageBreakFactories->push(builtIn, status);
|
||||
#ifdef U_LOCAL_SERVICE_HOOK
|
||||
LanguageBreakFactory *extra = (LanguageBreakFactory *)uprv_svc_hook("languageBreakFactory", &status);
|
||||
if (extra != NULL) {
|
||||
if (extra != nullptr) {
|
||||
gLanguageBreakFactories->push(extra, status);
|
||||
}
|
||||
#endif
|
||||
|
@ -1205,16 +1175,16 @@ static const LanguageBreakEngine*
|
|||
getLanguageBreakEngineFromFactory(UChar32 c)
|
||||
{
|
||||
umtx_initOnce(gLanguageBreakFactoriesInitOnce, &initLanguageFactories);
|
||||
if (gLanguageBreakFactories == NULL) {
|
||||
return NULL;
|
||||
if (gLanguageBreakFactories == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t i = gLanguageBreakFactories->size();
|
||||
const LanguageBreakEngine *lbe = NULL;
|
||||
const LanguageBreakEngine *lbe = nullptr;
|
||||
while (--i >= 0) {
|
||||
LanguageBreakFactory *factory = (LanguageBreakFactory *)(gLanguageBreakFactories->elementAt(i));
|
||||
lbe = factory->getEngineFor(c);
|
||||
if (lbe != NULL) {
|
||||
if (lbe != nullptr) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1230,15 +1200,15 @@ getLanguageBreakEngineFromFactory(UChar32 c)
|
|||
//-------------------------------------------------------------------------------
|
||||
const LanguageBreakEngine *
|
||||
RuleBasedBreakIterator::getLanguageBreakEngine(UChar32 c) {
|
||||
const LanguageBreakEngine *lbe = NULL;
|
||||
const LanguageBreakEngine *lbe = nullptr;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
if (fLanguageBreakEngines == NULL) {
|
||||
if (fLanguageBreakEngines == nullptr) {
|
||||
fLanguageBreakEngines = new UStack(status);
|
||||
if (fLanguageBreakEngines == NULL || U_FAILURE(status)) {
|
||||
if (fLanguageBreakEngines == nullptr || U_FAILURE(status)) {
|
||||
delete fLanguageBreakEngines;
|
||||
fLanguageBreakEngines = 0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1255,7 +1225,7 @@ RuleBasedBreakIterator::getLanguageBreakEngine(UChar32 c) {
|
|||
lbe = getLanguageBreakEngineFromFactory(c);
|
||||
|
||||
// If we got one, use it and push it on our stack.
|
||||
if (lbe != NULL) {
|
||||
if (lbe != nullptr) {
|
||||
fLanguageBreakEngines->push((void *)lbe, status);
|
||||
// Even if we can't remember it, we can keep looking it up, so
|
||||
// return it even if the push fails.
|
||||
|
@ -1264,9 +1234,9 @@ RuleBasedBreakIterator::getLanguageBreakEngine(UChar32 c) {
|
|||
|
||||
// No engine is forthcoming for this character. Add it to the
|
||||
// reject set. Create the reject break engine if needed.
|
||||
if (fUnhandledBreakEngine == NULL) {
|
||||
if (fUnhandledBreakEngine == nullptr) {
|
||||
fUnhandledBreakEngine = new UnhandledEngine(status);
|
||||
if (U_SUCCESS(status) && fUnhandledBreakEngine == NULL) {
|
||||
if (U_SUCCESS(status) && fUnhandledBreakEngine == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1278,7 +1248,7 @@ RuleBasedBreakIterator::getLanguageBreakEngine(UChar32 c) {
|
|||
if (U_FAILURE(status)) {
|
||||
delete fUnhandledBreakEngine;
|
||||
fUnhandledBreakEngine = 0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1303,7 +1273,7 @@ void RuleBasedBreakIterator::dumpTables() {
|
|||
|
||||
const UnicodeString&
|
||||
RuleBasedBreakIterator::getRules() const {
|
||||
if (fData != NULL) {
|
||||
if (fData != nullptr) {
|
||||
return fData->getRuleSourceString();
|
||||
} else {
|
||||
umtx_initOnce(gRBBIInitOnce, &rbbiInit);
|
||||
|
|
|
@ -162,7 +162,7 @@ void RuleBasedBreakIterator::DictionaryCache::populateDictionary(int32_t startPo
|
|||
|
||||
// Ask the language object if there are any breaks. It will add them to the cache and
|
||||
// leave the text pointer on the other side of its range, ready to search for the next one.
|
||||
if (lbe != NULL) {
|
||||
if (lbe != nullptr) {
|
||||
foundBreakCount += lbe->findBreaks(text, rangeStart, rangeEnd, fBreaks, fBI->fIsPhraseBreaking, status);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,13 +78,13 @@ UBool RBBIDataWrapper::isDataVersionAcceptable(const UVersionInfo version) {
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void RBBIDataWrapper::init0() {
|
||||
fHeader = NULL;
|
||||
fForwardTable = NULL;
|
||||
fReverseTable = NULL;
|
||||
fRuleSource = NULL;
|
||||
fRuleStatusTable = NULL;
|
||||
fTrie = NULL;
|
||||
fUDataMem = NULL;
|
||||
fHeader = nullptr;
|
||||
fForwardTable = nullptr;
|
||||
fReverseTable = nullptr;
|
||||
fRuleSource = nullptr;
|
||||
fRuleStatusTable = nullptr;
|
||||
fTrie = nullptr;
|
||||
fUDataMem = nullptr;
|
||||
fRefCount = 0;
|
||||
fDontFreeData = true;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ void RBBIDataWrapper::printTable(const char *heading, const RBBIStateTable *tab
|
|||
}
|
||||
RBBIDebugPrintf("\n");
|
||||
|
||||
if (table == NULL) {
|
||||
if (table == nullptr) {
|
||||
RBBIDebugPrintf(" N U L L T A B L E\n\n");
|
||||
return;
|
||||
}
|
||||
|
@ -305,10 +305,10 @@ U_CAPI int32_t U_EXPORT2
|
|||
ubrk_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outData,
|
||||
UErrorCode *status) {
|
||||
|
||||
if (status == NULL || U_FAILURE(*status)) {
|
||||
if (status == nullptr || U_FAILURE(*status)) {
|
||||
return 0;
|
||||
}
|
||||
if(ds==NULL || inData==NULL || length<-1 || (length>0 && outData==NULL)) {
|
||||
if(ds==nullptr || inData==nullptr || length<-1 || (length>0 && outData==nullptr)) {
|
||||
*status=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ struct RBBIDataHeader {
|
|||
uint32_t fTrie; /* Offset to Trie data for character categories */
|
||||
uint32_t fTrieLen;
|
||||
uint32_t fRuleSource; /* Offset to the source for for the break */
|
||||
uint32_t fRuleSourceLen; /* rules. Stored UChar *. */
|
||||
uint32_t fRuleSourceLen; /* rules. Stored char16_t *. */
|
||||
uint32_t fStatusTable; /* Offset to the table of rule status values */
|
||||
uint32_t fStatusTableLen;
|
||||
|
||||
|
@ -205,7 +205,7 @@ private:
|
|||
|
||||
U_NAMESPACE_END
|
||||
|
||||
U_CFUNC UBool rbbi_cleanup(void);
|
||||
U_CFUNC UBool rbbi_cleanup();
|
||||
|
||||
#endif /* C++ */
|
||||
|
||||
|
|
|
@ -52,10 +52,10 @@ RBBINode::RBBINode(NodeType t) : UMemory() {
|
|||
fSerialNum = ++gLastSerial;
|
||||
#endif
|
||||
fType = t;
|
||||
fParent = NULL;
|
||||
fLeftChild = NULL;
|
||||
fRightChild = NULL;
|
||||
fInputSet = NULL;
|
||||
fParent = nullptr;
|
||||
fLeftChild = nullptr;
|
||||
fRightChild = nullptr;
|
||||
fInputSet = nullptr;
|
||||
fFirstPos = 0;
|
||||
fLastPos = 0;
|
||||
fNullable = false;
|
||||
|
@ -82,9 +82,9 @@ RBBINode::RBBINode(const RBBINode &other) : UMemory(other) {
|
|||
fSerialNum = ++gLastSerial;
|
||||
#endif
|
||||
fType = other.fType;
|
||||
fParent = NULL;
|
||||
fLeftChild = NULL;
|
||||
fRightChild = NULL;
|
||||
fParent = nullptr;
|
||||
fLeftChild = nullptr;
|
||||
fRightChild = nullptr;
|
||||
fInputSet = other.fInputSet;
|
||||
fPrecedence = other.fPrecedence;
|
||||
fText = other.fText;
|
||||
|
@ -113,7 +113,7 @@ RBBINode::RBBINode(const RBBINode &other) : UMemory(other) {
|
|||
RBBINode::~RBBINode() {
|
||||
// printf("deleting node %8x serial %4d\n", this, this->fSerialNum);
|
||||
delete fInputSet;
|
||||
fInputSet = NULL;
|
||||
fInputSet = nullptr;
|
||||
|
||||
switch (this->fType) {
|
||||
case varRef:
|
||||
|
@ -124,9 +124,9 @@ RBBINode::~RBBINode() {
|
|||
|
||||
default:
|
||||
delete fLeftChild;
|
||||
fLeftChild = NULL;
|
||||
fLeftChild = nullptr;
|
||||
delete fRightChild;
|
||||
fRightChild = NULL;
|
||||
fRightChild = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,12 +158,12 @@ RBBINode *RBBINode::cloneTree() {
|
|||
} else {
|
||||
n = new RBBINode(*this);
|
||||
// Check for null pointer.
|
||||
if (n != NULL) {
|
||||
if (fLeftChild != NULL) {
|
||||
if (n != nullptr) {
|
||||
if (fLeftChild != nullptr) {
|
||||
n->fLeftChild = fLeftChild->cloneTree();
|
||||
n->fLeftChild->fParent = n;
|
||||
}
|
||||
if (fRightChild != NULL) {
|
||||
if (fRightChild != nullptr) {
|
||||
n->fRightChild = fRightChild->cloneTree();
|
||||
n->fRightChild->fParent = n;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ RBBINode *RBBINode::cloneTree() {
|
|||
RBBINode *RBBINode::flattenVariables() {
|
||||
if (fType == varRef) {
|
||||
RBBINode *retNode = fLeftChild->cloneTree();
|
||||
if (retNode != NULL) {
|
||||
if (retNode != nullptr) {
|
||||
retNode->fRuleRoot = this->fRuleRoot;
|
||||
retNode->fChainIn = this->fChainIn;
|
||||
}
|
||||
|
@ -203,11 +203,11 @@ RBBINode *RBBINode::flattenVariables() {
|
|||
return retNode;
|
||||
}
|
||||
|
||||
if (fLeftChild != NULL) {
|
||||
if (fLeftChild != nullptr) {
|
||||
fLeftChild = fLeftChild->flattenVariables();
|
||||
fLeftChild->fParent = this;
|
||||
}
|
||||
if (fRightChild != NULL) {
|
||||
if (fRightChild != nullptr) {
|
||||
fRightChild = fRightChild->flattenVariables();
|
||||
fRightChild->fParent = this;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ RBBINode *RBBINode::flattenVariables() {
|
|||
void RBBINode::flattenSets() {
|
||||
U_ASSERT(fType != setRef);
|
||||
|
||||
if (fLeftChild != NULL) {
|
||||
if (fLeftChild != nullptr) {
|
||||
if (fLeftChild->fType==setRef) {
|
||||
RBBINode *setRefNode = fLeftChild;
|
||||
RBBINode *usetNode = setRefNode->fLeftChild;
|
||||
|
@ -239,7 +239,7 @@ void RBBINode::flattenSets() {
|
|||
}
|
||||
}
|
||||
|
||||
if (fRightChild != NULL) {
|
||||
if (fRightChild != nullptr) {
|
||||
if (fRightChild->fType==setRef) {
|
||||
RBBINode *setRefNode = fRightChild;
|
||||
RBBINode *usetNode = setRefNode->fLeftChild;
|
||||
|
@ -270,10 +270,10 @@ void RBBINode::findNodes(UVector *dest, RBBINode::NodeType kind, UErrorCode &s
|
|||
if (fType == kind) {
|
||||
dest->addElement(this, status);
|
||||
}
|
||||
if (fLeftChild != NULL) {
|
||||
if (fLeftChild != nullptr) {
|
||||
fLeftChild->findNodes(dest, kind, status);
|
||||
}
|
||||
if (fRightChild != NULL) {
|
||||
if (fRightChild != nullptr) {
|
||||
fRightChild->findNodes(dest, kind, status);
|
||||
}
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ void RBBINode::findNodes(UVector *dest, RBBINode::NodeType kind, UErrorCode &s
|
|||
#ifdef RBBI_DEBUG
|
||||
|
||||
static int32_t serial(const RBBINode *node) {
|
||||
return (node == NULL? -1 : node->fSerialNum);
|
||||
return (node == nullptr? -1 : node->fSerialNum);
|
||||
}
|
||||
|
||||
|
||||
|
@ -311,7 +311,7 @@ void RBBINode::printNode(const RBBINode *node) {
|
|||
"opLParen"
|
||||
};
|
||||
|
||||
if (node==NULL) {
|
||||
if (node==nullptr) {
|
||||
RBBIDebugPrintf("%10p", (void *)node);
|
||||
} else {
|
||||
RBBIDebugPrintf("%10p %5d %12s %c%c %5d %5d %5d %6d %d ",
|
||||
|
@ -350,15 +350,15 @@ void RBBINode::printTree(const RBBINode *node, UBool printHeading) {
|
|||
printNodeHeader();
|
||||
}
|
||||
printNode(node);
|
||||
if (node != NULL) {
|
||||
if (node != nullptr) {
|
||||
// Only dump the definition under a variable reference if asked to.
|
||||
// Unconditionally dump children of all other node types.
|
||||
if (node->fType != varRef) {
|
||||
if (node->fLeftChild != NULL) {
|
||||
if (node->fLeftChild != nullptr) {
|
||||
printTree(node->fLeftChild, false);
|
||||
}
|
||||
|
||||
if (node->fRightChild != NULL) {
|
||||
if (node->fRightChild != nullptr) {
|
||||
printTree(node->fRightChild, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,26 +52,26 @@ RBBIRuleBuilder::RBBIRuleBuilder(const UnicodeString &rules,
|
|||
{
|
||||
fStatus = &status; // status is checked below
|
||||
fParseError = parseErr;
|
||||
fDebugEnv = NULL;
|
||||
fDebugEnv = nullptr;
|
||||
#ifdef RBBI_DEBUG
|
||||
fDebugEnv = getenv("U_RBBIDEBUG");
|
||||
#endif
|
||||
|
||||
|
||||
fForwardTree = NULL;
|
||||
fReverseTree = NULL;
|
||||
fSafeFwdTree = NULL;
|
||||
fSafeRevTree = NULL;
|
||||
fForwardTree = nullptr;
|
||||
fReverseTree = nullptr;
|
||||
fSafeFwdTree = nullptr;
|
||||
fSafeRevTree = nullptr;
|
||||
fDefaultTree = &fForwardTree;
|
||||
fForwardTable = NULL;
|
||||
fRuleStatusVals = NULL;
|
||||
fForwardTable = nullptr;
|
||||
fRuleStatusVals = nullptr;
|
||||
fChainRules = false;
|
||||
fLBCMNoChain = false;
|
||||
fLookAheadHardBreak = false;
|
||||
fUSetNodes = NULL;
|
||||
fRuleStatusVals = NULL;
|
||||
fScanner = NULL;
|
||||
fSetBuilder = NULL;
|
||||
fUSetNodes = nullptr;
|
||||
fRuleStatusVals = nullptr;
|
||||
fScanner = nullptr;
|
||||
fSetBuilder = nullptr;
|
||||
if (parseErr) {
|
||||
uprv_memset(parseErr, 0, sizeof(UParseError));
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ RBBIRuleBuilder::~RBBIRuleBuilder() {
|
|||
int i;
|
||||
for (i=0; ; i++) {
|
||||
RBBINode *n = (RBBINode *)fUSetNodes->elementAt(i);
|
||||
if (n==NULL) {
|
||||
if (n==nullptr) {
|
||||
break;
|
||||
}
|
||||
delete n;
|
||||
|
@ -138,7 +138,7 @@ RBBIDataHeader *RBBIRuleBuilder::flattenData() {
|
|||
int32_t i;
|
||||
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Remove whitespace from the rules to make it smaller.
|
||||
|
@ -183,9 +183,9 @@ RBBIDataHeader *RBBIRuleBuilder::flattenData() {
|
|||
#endif
|
||||
|
||||
RBBIDataHeader *data = (RBBIDataHeader *)uprv_malloc(totalSize);
|
||||
if (data == NULL) {
|
||||
if (data == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
uprv_memset(data, 0, totalSize);
|
||||
|
||||
|
@ -226,7 +226,7 @@ RBBIDataHeader *RBBIRuleBuilder::flattenData() {
|
|||
fStrippedRules.getBuffer(), fStrippedRules.length(),
|
||||
0xfffd, nullptr, fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -250,7 +250,7 @@ RBBIRuleBuilder::createRuleBasedBreakIterator( const UnicodeString &rules,
|
|||
//
|
||||
RBBIRuleBuilder builder(rules, parseError, status);
|
||||
if (U_FAILURE(status)) { // status checked here bcos build below doesn't
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RBBIDataHeader *data = builder.build(status);
|
||||
|
@ -267,9 +267,9 @@ RBBIRuleBuilder::createRuleBasedBreakIterator( const UnicodeString &rules,
|
|||
RuleBasedBreakIterator *This = new RuleBasedBreakIterator(data, status);
|
||||
if (U_FAILURE(status)) {
|
||||
delete This;
|
||||
This = NULL;
|
||||
This = nullptr;
|
||||
}
|
||||
else if(This == NULL) { // test for NULL
|
||||
else if(This == nullptr) { // test for nullptr
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
return This;
|
||||
|
@ -328,7 +328,7 @@ RBBIDataHeader *RBBIRuleBuilder::build(UErrorCode &status) {
|
|||
// Package up the compiled data into a memory image
|
||||
// in the run-time format.
|
||||
//
|
||||
RBBIDataHeader *data = flattenData(); // returns NULL if error
|
||||
RBBIDataHeader *data = flattenData(); // returns nullptr if error
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
// source form of the state transition table for the RBBI rule parser.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
static const UChar gRuleSet_rule_char_pattern[] = {
|
||||
static const char16_t gRuleSet_rule_char_pattern[] = {
|
||||
// Characters that may appear as literals in patterns without escaping or quoting.
|
||||
// [ ^ [ \ p { Z } \ u 0 0 2 0
|
||||
0x5b, 0x5e, 0x5b, 0x5c, 0x70, 0x7b, 0x5a, 0x7d, 0x5c, 0x75, 0x30, 0x30, 0x32, 0x30,
|
||||
|
@ -55,19 +55,19 @@ static const UChar gRuleSet_rule_char_pattern[] = {
|
|||
// { L } ] - [ \ p { N } ] ]
|
||||
0x7b, 0x4c, 0x7d, 0x5d, 0x2d, 0x5b, 0x5c, 0x70, 0x7b, 0x4e, 0x7d, 0x5d, 0x5d, 0};
|
||||
|
||||
static const UChar gRuleSet_name_char_pattern[] = {
|
||||
static const char16_t gRuleSet_name_char_pattern[] = {
|
||||
// [ _ \ p { L } \ p { N } ]
|
||||
0x5b, 0x5f, 0x5c, 0x70, 0x7b, 0x4c, 0x7d, 0x5c, 0x70, 0x7b, 0x4e, 0x7d, 0x5d, 0};
|
||||
|
||||
static const UChar gRuleSet_digit_char_pattern[] = {
|
||||
static const char16_t gRuleSet_digit_char_pattern[] = {
|
||||
// [ 0 - 9 ]
|
||||
0x5b, 0x30, 0x2d, 0x39, 0x5d, 0};
|
||||
|
||||
static const UChar gRuleSet_name_start_char_pattern[] = {
|
||||
static const char16_t gRuleSet_name_start_char_pattern[] = {
|
||||
// [ _ \ p { L } ]
|
||||
0x5b, 0x5f, 0x5c, 0x70, 0x7b, 0x4c, 0x7d, 0x5d, 0 };
|
||||
|
||||
static const UChar kAny[] = {0x61, 0x6e, 0x79, 0x00}; // "any"
|
||||
static const char16_t kAny[] = {0x61, 0x6e, 0x79, 0x00}; // "any"
|
||||
|
||||
|
||||
U_CDECL_BEGIN
|
||||
|
@ -97,18 +97,18 @@ RBBIRuleScanner::RBBIRuleScanner(RBBIRuleBuilder *rb)
|
|||
fCharNum = 0;
|
||||
fLastChar = 0;
|
||||
|
||||
fStateTable = NULL;
|
||||
fStateTable = nullptr;
|
||||
fStack[0] = 0;
|
||||
fStackPtr = 0;
|
||||
fNodeStack[0] = NULL;
|
||||
fNodeStack[0] = nullptr;
|
||||
fNodeStackPtr = 0;
|
||||
|
||||
fReverseRule = false;
|
||||
fLookAheadRule = false;
|
||||
fNoChainInRule = false;
|
||||
|
||||
fSymbolTable = NULL;
|
||||
fSetTable = NULL;
|
||||
fSymbolTable = nullptr;
|
||||
fSetTable = nullptr;
|
||||
fRuleNum = 0;
|
||||
fOptionStart = 0;
|
||||
|
||||
|
@ -146,11 +146,11 @@ RBBIRuleScanner::RBBIRuleScanner(RBBIRuleBuilder *rb)
|
|||
}
|
||||
|
||||
fSymbolTable = new RBBISymbolTable(this, rb->fRules, *rb->fStatus);
|
||||
if (fSymbolTable == NULL) {
|
||||
if (fSymbolTable == nullptr) {
|
||||
*rb->fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fSetTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, rb->fStatus);
|
||||
fSetTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, nullptr, rb->fStatus);
|
||||
if (U_FAILURE(*rb->fStatus)) {
|
||||
return;
|
||||
}
|
||||
|
@ -166,9 +166,9 @@ RBBIRuleScanner::RBBIRuleScanner(RBBIRuleBuilder *rb)
|
|||
//------------------------------------------------------------------------------
|
||||
RBBIRuleScanner::~RBBIRuleScanner() {
|
||||
delete fSymbolTable;
|
||||
if (fSetTable != NULL) {
|
||||
if (fSetTable != nullptr) {
|
||||
uhash_close(fSetTable);
|
||||
fSetTable = NULL;
|
||||
fSetTable = nullptr;
|
||||
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ RBBIRuleScanner::~RBBIRuleScanner() {
|
|||
//------------------------------------------------------------------------------
|
||||
UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
{
|
||||
RBBINode *n = NULL;
|
||||
RBBINode *n = nullptr;
|
||||
|
||||
UBool returnVal = true;
|
||||
|
||||
|
@ -374,7 +374,7 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
|||
//
|
||||
RBBINode **destRules = (fReverseRule? &fRB->fSafeRevTree : fRB->fDefaultTree);
|
||||
|
||||
if (*destRules != NULL) {
|
||||
if (*destRules != nullptr) {
|
||||
// This is not the first rule encountered.
|
||||
// OR previous stuff (from *destRules)
|
||||
// with the current rule expression (on the Node Stack)
|
||||
|
@ -583,7 +583,7 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
|||
|
||||
case doEndVariableName:
|
||||
n = fNodeStack[fNodeStackPtr];
|
||||
if (n==NULL || n->fType != RBBINode::varRef) {
|
||||
if (n==nullptr || n->fType != RBBINode::varRef) {
|
||||
error(U_BRK_INTERNAL_ERROR);
|
||||
break;
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
|||
|
||||
case doCheckVarDef:
|
||||
n = fNodeStack[fNodeStackPtr];
|
||||
if (n->fLeftChild == NULL) {
|
||||
if (n->fLeftChild == nullptr) {
|
||||
error(U_BRK_UNDEFINED_VARIABLE);
|
||||
returnVal = false;
|
||||
}
|
||||
|
@ -737,7 +737,7 @@ void RBBIRuleScanner::findSetFor(const UnicodeString &s, RBBINode *node, Unicode
|
|||
// If so, just use the cached set in the new node.
|
||||
// delete any set provided by the caller, since we own it.
|
||||
el = (RBBISetTableEl *)uhash_get(fSetTable, &s);
|
||||
if (el != NULL) {
|
||||
if (el != nullptr) {
|
||||
delete setToAdopt;
|
||||
node->fLeftChild = el->val;
|
||||
U_ASSERT(node->fLeftChild->fType == RBBINode::uset);
|
||||
|
@ -747,7 +747,7 @@ void RBBIRuleScanner::findSetFor(const UnicodeString &s, RBBINode *node, Unicode
|
|||
// Haven't seen this set before.
|
||||
// If the caller didn't provide us with a prebuilt set,
|
||||
// create a new UnicodeSet now.
|
||||
if (setToAdopt == NULL) {
|
||||
if (setToAdopt == nullptr) {
|
||||
if (s.compare(kAny, -1) == 0) {
|
||||
setToAdopt = new UnicodeSet(0x000000, 0x10ffff);
|
||||
} else {
|
||||
|
@ -762,7 +762,7 @@ void RBBIRuleScanner::findSetFor(const UnicodeString &s, RBBINode *node, Unicode
|
|||
// This new uset node becomes the child of the caller's setReference node.
|
||||
//
|
||||
RBBINode *usetNode = new RBBINode(RBBINode::uset);
|
||||
if (usetNode == NULL) {
|
||||
if (usetNode == nullptr) {
|
||||
error(U_MEMORY_ALLOCATION_ERROR);
|
||||
return;
|
||||
}
|
||||
|
@ -783,14 +783,14 @@ void RBBIRuleScanner::findSetFor(const UnicodeString &s, RBBINode *node, Unicode
|
|||
//
|
||||
el = (RBBISetTableEl *)uprv_malloc(sizeof(RBBISetTableEl));
|
||||
UnicodeString *tkey = new UnicodeString(s);
|
||||
if (tkey == NULL || el == NULL || setToAdopt == NULL) {
|
||||
if (tkey == nullptr || el == nullptr || setToAdopt == nullptr) {
|
||||
// Delete to avoid memory leak
|
||||
delete tkey;
|
||||
tkey = NULL;
|
||||
tkey = nullptr;
|
||||
uprv_free(el);
|
||||
el = NULL;
|
||||
el = nullptr;
|
||||
delete setToAdopt;
|
||||
setToAdopt = NULL;
|
||||
setToAdopt = nullptr;
|
||||
|
||||
error(U_MEMORY_ALLOCATION_ERROR);
|
||||
return;
|
||||
|
@ -809,15 +809,15 @@ void RBBIRuleScanner::findSetFor(const UnicodeString &s, RBBINode *node, Unicode
|
|||
// Numeric because there is no portable way to enter them as literals.
|
||||
// (Think EBCDIC).
|
||||
//
|
||||
static const UChar chCR = 0x0d; // New lines, for terminating comments.
|
||||
static const UChar chLF = 0x0a;
|
||||
static const UChar chNEL = 0x85; // NEL newline variant
|
||||
static const UChar chLS = 0x2028; // Unicode Line Separator
|
||||
static const UChar chApos = 0x27; // single quote, for quoted chars.
|
||||
static const UChar chPound = 0x23; // '#', introduces a comment.
|
||||
static const UChar chBackSlash = 0x5c; // '\' introduces a char escape
|
||||
static const UChar chLParen = 0x28;
|
||||
static const UChar chRParen = 0x29;
|
||||
static const char16_t chCR = 0x0d; // New lines, for terminating comments.
|
||||
static const char16_t chLF = 0x0a;
|
||||
static const char16_t chNEL = 0x85; // NEL newline variant
|
||||
static const char16_t chLS = 0x2028; // Unicode Line Separator
|
||||
static const char16_t chApos = 0x27; // single quote, for quoted chars.
|
||||
static const char16_t chPound = 0x23; // '#', introduces a comment.
|
||||
static const char16_t chBackSlash = 0x5c; // '\' introduces a char escape
|
||||
static const char16_t chLParen = 0x28;
|
||||
static const char16_t chRParen = 0x29;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -1119,7 +1119,7 @@ void RBBIRuleScanner::parse() {
|
|||
|
||||
// If there are no forward rules set an error.
|
||||
//
|
||||
if (fRB->fForwardTree == NULL) {
|
||||
if (fRB->fForwardTree == nullptr) {
|
||||
error(U_BRK_RULE_SYNTAX);
|
||||
return;
|
||||
}
|
||||
|
@ -1169,16 +1169,16 @@ void RBBIRuleScanner::printNodeStack(const char *title) {
|
|||
//------------------------------------------------------------------------------
|
||||
RBBINode *RBBIRuleScanner::pushNewNode(RBBINode::NodeType t) {
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (fNodeStackPtr >= kStackSize - 1) {
|
||||
error(U_BRK_RULE_SYNTAX);
|
||||
RBBIDebugPuts("RBBIRuleScanner::pushNewNode - stack overflow.");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
fNodeStackPtr++;
|
||||
fNodeStack[fNodeStackPtr] = new RBBINode(t);
|
||||
if (fNodeStack[fNodeStackPtr] == NULL) {
|
||||
if (fNodeStack[fNodeStackPtr] == nullptr) {
|
||||
*fRB->fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
return fNodeStack[fNodeStackPtr];
|
||||
|
@ -1214,7 +1214,7 @@ void RBBIRuleScanner::scanSet() {
|
|||
startPos = fScanIndex;
|
||||
UErrorCode localStatus = U_ZERO_ERROR;
|
||||
uset = new UnicodeSet();
|
||||
if (uset == NULL) {
|
||||
if (uset == nullptr) {
|
||||
localStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
} else {
|
||||
uset->applyPatternIgnoreSpace(fRB->fRules, pos, fSymbolTable, localStatus);
|
||||
|
@ -1232,7 +1232,7 @@ void RBBIRuleScanner::scanSet() {
|
|||
|
||||
// Verify that the set contains at least one code point.
|
||||
//
|
||||
U_ASSERT(uset!=NULL);
|
||||
U_ASSERT(uset!=nullptr);
|
||||
if (uset->isEmpty()) {
|
||||
// This set is empty.
|
||||
// Make it an error, because it almost certainly is not what the user wanted.
|
||||
|
|
|
@ -86,7 +86,7 @@ private:
|
|||
void error(UErrorCode e); // error reporting convenience function.
|
||||
void fixOpStack(RBBINode::OpPrecedence p);
|
||||
// a character.
|
||||
void findSetFor(const UnicodeString &s, RBBINode *node, UnicodeSet *setToAdopt = NULL);
|
||||
void findSetFor(const UnicodeString &s, RBBINode *node, UnicodeSet *setToAdopt = nullptr);
|
||||
|
||||
UChar32 nextCharLL();
|
||||
#ifdef RBBI_DEBUG
|
||||
|
|
|
@ -74,7 +74,7 @@ RBBISetBuilder::~RBBISetBuilder()
|
|||
RangeDescriptor *nextRangeDesc;
|
||||
|
||||
// Walk through & delete the linked list of RangeDescriptors
|
||||
for (nextRangeDesc = fRangeList; nextRangeDesc!=NULL;) {
|
||||
for (nextRangeDesc = fRangeList; nextRangeDesc!=nullptr;) {
|
||||
RangeDescriptor *r = nextRangeDesc;
|
||||
nextRangeDesc = r->fNext;
|
||||
delete r;
|
||||
|
@ -104,7 +104,7 @@ void RBBISetBuilder::buildRanges() {
|
|||
// that is in no sets.
|
||||
//
|
||||
fRangeList = new RangeDescriptor(*fStatus); // will check for status here
|
||||
if (fRangeList == NULL) {
|
||||
if (fRangeList == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ void RBBISetBuilder::buildRanges() {
|
|||
int ni;
|
||||
for (ni=0; ; ni++) { // Loop over each of the UnicodeSets encountered in the input rules
|
||||
usetNode = (RBBINode *)this->fRB->fUSetNodes->elementAt(ni);
|
||||
if (usetNode==NULL) {
|
||||
if (usetNode==nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ void RBBISetBuilder::buildRanges() {
|
|||
UnicodeString bofString(u"bof");
|
||||
for (ni=0; ; ni++) { // Loop over each of the UnicodeSets encountered in the input rules
|
||||
usetNode = (RBBINode *)this->fRB->fUSetNodes->elementAt(ni);
|
||||
if (usetNode==NULL) {
|
||||
if (usetNode==nullptr) {
|
||||
break;
|
||||
}
|
||||
UnicodeSet *inputSet = usetNode->fInputSet;
|
||||
|
@ -376,12 +376,12 @@ void RBBISetBuilder::addValToSets(UVector *sets, uint32_t val) {
|
|||
|
||||
void RBBISetBuilder::addValToSet(RBBINode *usetNode, uint32_t val) {
|
||||
RBBINode *leafNode = new RBBINode(RBBINode::leafChar);
|
||||
if (leafNode == NULL) {
|
||||
if (leafNode == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
leafNode->fVal = (unsigned short)val;
|
||||
if (usetNode->fLeftChild == NULL) {
|
||||
if (usetNode->fLeftChild == nullptr) {
|
||||
usetNode->fLeftChild = leafNode;
|
||||
leafNode->fParent = usetNode;
|
||||
} else {
|
||||
|
@ -389,7 +389,7 @@ void RBBISetBuilder::addValToSet(RBBINode *usetNode, uint32_t val) {
|
|||
// Set up an OR node, with the previous stuff as the left child
|
||||
// and the new value as the right child.
|
||||
RBBINode *orNode = new RBBINode(RBBINode::opOr);
|
||||
if (orNode == NULL) {
|
||||
if (orNode == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -507,9 +507,9 @@ void RBBISetBuilder::printRangeGroups() {
|
|||
RBBINode *usetNode = (RBBINode *)rlRange->fIncludesSets->elementAt(i);
|
||||
UnicodeString setName = UNICODE_STRING("anon", 4);
|
||||
RBBINode *setRef = usetNode->fParent;
|
||||
if (setRef != NULL) {
|
||||
if (setRef != nullptr) {
|
||||
RBBINode *varRef = setRef->fParent;
|
||||
if (varRef != NULL && varRef->fType == RBBINode::varRef) {
|
||||
if (varRef != nullptr && varRef->fType == RBBINode::varRef) {
|
||||
setName = varRef->fText;
|
||||
}
|
||||
}
|
||||
|
@ -551,16 +551,16 @@ void RBBISetBuilder::printSets() {
|
|||
UnicodeString setName;
|
||||
|
||||
usetNode = (RBBINode *)fRB->fUSetNodes->elementAt(i);
|
||||
if (usetNode == NULL) {
|
||||
if (usetNode == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
RBBIDebugPrintf("%3d ", i);
|
||||
setName = UNICODE_STRING("anonymous", 9);
|
||||
setRef = usetNode->fParent;
|
||||
if (setRef != NULL) {
|
||||
if (setRef != nullptr) {
|
||||
varRef = setRef->fParent;
|
||||
if (varRef != NULL && varRef->fType == RBBINode::varRef) {
|
||||
if (varRef != nullptr && varRef->fType == RBBINode::varRef) {
|
||||
setName = varRef->fText;
|
||||
}
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ void RBBISetBuilder::printSets() {
|
|||
RBBIDebugPrintf(" ");
|
||||
RBBI_DEBUG_printUnicodeString(usetNode->fText);
|
||||
RBBIDebugPrintf("\n");
|
||||
if (usetNode->fLeftChild != NULL) {
|
||||
if (usetNode->fLeftChild != nullptr) {
|
||||
RBBINode::printTree(usetNode->fLeftChild, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,12 +41,12 @@ U_CDECL_END
|
|||
U_NAMESPACE_BEGIN
|
||||
|
||||
RBBISymbolTable::RBBISymbolTable(RBBIRuleScanner *rs, const UnicodeString &rules, UErrorCode &status)
|
||||
:fRules(rules), fRuleScanner(rs), ffffString(UChar(0xffff))
|
||||
:fRules(rules), fRuleScanner(rs), ffffString(char16_t(0xffff))
|
||||
{
|
||||
fHashTable = NULL;
|
||||
fCachedSetLookup = NULL;
|
||||
fHashTable = nullptr;
|
||||
fCachedSetLookup = nullptr;
|
||||
|
||||
fHashTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, &status);
|
||||
fHashTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, nullptr, &status);
|
||||
// uhash_open checks status
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
|
@ -79,8 +79,8 @@ const UnicodeString *RBBISymbolTable::lookup(const UnicodeString& s) const
|
|||
RBBISymbolTable *This = (RBBISymbolTable *)this; // cast off const
|
||||
|
||||
el = (RBBISymbolTableEntry *)uhash_get(fHashTable, &s);
|
||||
if (el == NULL) {
|
||||
return NULL;
|
||||
if (el == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
varRefNode = el->val;
|
||||
|
@ -98,7 +98,7 @@ const UnicodeString *RBBISymbolTable::lookup(const UnicodeString& s) const
|
|||
// The variable refers to something other than just a set.
|
||||
// return the original source string for the expression
|
||||
retString = &exprNode->fText;
|
||||
This->fCachedSetLookup = NULL;
|
||||
This->fCachedSetLookup = nullptr;
|
||||
}
|
||||
return retString;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ const UnicodeString *RBBISymbolTable::lookup(const UnicodeString& s) const
|
|||
// and we just need to remember what set to return between these two calls.
|
||||
const UnicodeFunctor *RBBISymbolTable::lookupMatcher(UChar32 ch) const
|
||||
{
|
||||
UnicodeSet *retVal = NULL;
|
||||
UnicodeSet *retVal = nullptr;
|
||||
RBBISymbolTable *This = (RBBISymbolTable *)this; // cast off const
|
||||
if (ch == 0xffff) {
|
||||
retVal = fCachedSetLookup;
|
||||
|
@ -144,7 +144,7 @@ UnicodeString RBBISymbolTable::parseReference(const UnicodeString& text,
|
|||
int32_t i = start;
|
||||
UnicodeString result;
|
||||
while (i < limit) {
|
||||
UChar c = text.charAt(i);
|
||||
char16_t c = text.charAt(i);
|
||||
if ((i==start && !u_isIDStart(c)) || !u_isIDPart(c)) {
|
||||
break;
|
||||
}
|
||||
|
@ -163,15 +163,15 @@ UnicodeString RBBISymbolTable::parseReference(const UnicodeString& text,
|
|||
//
|
||||
// RBBISymbolTable::lookupNode Given a key (a variable name), return the
|
||||
// corresponding RBBI Node. If there is no entry
|
||||
// in the table for this name, return NULL.
|
||||
// in the table for this name, return nullptr.
|
||||
//
|
||||
RBBINode *RBBISymbolTable::lookupNode(const UnicodeString &key) const{
|
||||
|
||||
RBBINode *retNode = NULL;
|
||||
RBBINode *retNode = nullptr;
|
||||
RBBISymbolTableEntry *el;
|
||||
|
||||
el = (RBBISymbolTableEntry *)uhash_get(fHashTable, &key);
|
||||
if (el != NULL) {
|
||||
if (el != nullptr) {
|
||||
retNode = el->val;
|
||||
}
|
||||
return retNode;
|
||||
|
@ -191,13 +191,13 @@ void RBBISymbolTable::addEntry (const UnicodeString &key, RBBINode *
|
|||
return;
|
||||
}
|
||||
e = (RBBISymbolTableEntry *)uhash_get(fHashTable, &key);
|
||||
if (e != NULL) {
|
||||
if (e != nullptr) {
|
||||
err = U_BRK_VARIABLE_REDFINITION;
|
||||
return;
|
||||
}
|
||||
|
||||
e = new RBBISymbolTableEntry;
|
||||
if (e == NULL) {
|
||||
if (e == nullptr) {
|
||||
err = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ void RBBISymbolTable::addEntry (const UnicodeString &key, RBBINode *
|
|||
}
|
||||
|
||||
|
||||
RBBISymbolTableEntry::RBBISymbolTableEntry() : UMemory(), key(), val(NULL) {}
|
||||
RBBISymbolTableEntry::RBBISymbolTableEntry() : UMemory(), key(), val(nullptr) {}
|
||||
|
||||
RBBISymbolTableEntry::~RBBISymbolTableEntry() {
|
||||
// The "val" of a symbol table entry is a variable reference node.
|
||||
|
@ -215,7 +215,7 @@ RBBISymbolTableEntry::~RBBISymbolTableEntry() {
|
|||
// Unlike other node types, children of variable reference nodes are not
|
||||
// automatically recursively deleted. We do it manually here.
|
||||
delete val->fLeftChild;
|
||||
val->fLeftChild = NULL;
|
||||
val->fLeftChild = nullptr;
|
||||
|
||||
delete val;
|
||||
|
||||
|
@ -233,10 +233,10 @@ void RBBISymbolTable::rbbiSymtablePrint() const {
|
|||
"-------------------------------------------------------------------\n");
|
||||
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *e = NULL;
|
||||
const UHashElement *e = nullptr;
|
||||
for (;;) {
|
||||
e = uhash_nextElement(fHashTable, &pos);
|
||||
if (e == NULL ) {
|
||||
if (e == nullptr ) {
|
||||
break;
|
||||
}
|
||||
RBBISymbolTableEntry *s = (RBBISymbolTableEntry *)e->value.pointer;
|
||||
|
@ -249,7 +249,7 @@ void RBBISymbolTable::rbbiSymtablePrint() const {
|
|||
pos = -1;
|
||||
for (;;) {
|
||||
e = uhash_nextElement(fHashTable, &pos);
|
||||
if (e == NULL ) {
|
||||
if (e == nullptr ) {
|
||||
break;
|
||||
}
|
||||
RBBISymbolTableEntry *s = (RBBISymbolTableEntry *)e->value.pointer;
|
||||
|
|
|
@ -73,7 +73,7 @@ void RBBITableBuilder::buildForwardTable() {
|
|||
|
||||
// If there were no rules, just return. This situation can easily arise
|
||||
// for the reverse rules.
|
||||
if (fTree==NULL) {
|
||||
if (fTree==nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ void RBBITableBuilder::buildForwardTable() {
|
|||
RBBINode *bofTop = new RBBINode(RBBINode::opCat);
|
||||
RBBINode *bofLeaf = new RBBINode(RBBINode::leafChar);
|
||||
// Delete and exit if memory allocation failed.
|
||||
if (bofTop == NULL || bofLeaf == NULL) {
|
||||
if (bofTop == nullptr || bofLeaf == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete bofTop;
|
||||
delete bofLeaf;
|
||||
|
@ -119,7 +119,7 @@ void RBBITableBuilder::buildForwardTable() {
|
|||
//
|
||||
RBBINode *cn = new RBBINode(RBBINode::opCat);
|
||||
// Exit if memory allocation failed.
|
||||
if (cn == NULL) {
|
||||
if (cn == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void RBBITableBuilder::buildForwardTable() {
|
|||
fTree->fParent = cn;
|
||||
RBBINode *endMarkerNode = cn->fRightChild = new RBBINode(RBBINode::endMark);
|
||||
// Delete and exit if memory allocation failed.
|
||||
if (cn->fRightChild == NULL) {
|
||||
if (cn->fRightChild == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete cn;
|
||||
return;
|
||||
|
@ -203,7 +203,7 @@ void RBBITableBuilder::buildForwardTable() {
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void RBBITableBuilder::calcNullable(RBBINode *n) {
|
||||
if (n == NULL) {
|
||||
if (n == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (n->fType == RBBINode::setRef ||
|
||||
|
@ -250,7 +250,7 @@ void RBBITableBuilder::calcNullable(RBBINode *n) {
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void RBBITableBuilder::calcFirstPos(RBBINode *n) {
|
||||
if (n == NULL) {
|
||||
if (n == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (n->fType == RBBINode::leafChar ||
|
||||
|
@ -296,7 +296,7 @@ void RBBITableBuilder::calcFirstPos(RBBINode *n) {
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void RBBITableBuilder::calcLastPos(RBBINode *n) {
|
||||
if (n == NULL) {
|
||||
if (n == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (n->fType == RBBINode::leafChar ||
|
||||
|
@ -342,7 +342,7 @@ void RBBITableBuilder::calcLastPos(RBBINode *n) {
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void RBBITableBuilder::calcFollowPos(RBBINode *n) {
|
||||
if (n == NULL ||
|
||||
if (n == nullptr ||
|
||||
n->fType == RBBINode::leafChar ||
|
||||
n->fType == RBBINode::endMark) {
|
||||
return;
|
||||
|
@ -387,7 +387,7 @@ void RBBITableBuilder::calcFollowPos(RBBINode *n) {
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void RBBITableBuilder::addRuleRootNodes(UVector *dest, RBBINode *node) {
|
||||
if (node == NULL || U_FAILURE(*fStatus)) {
|
||||
if (node == nullptr || U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
U_ASSERT(!dest->hasDeleter());
|
||||
|
@ -567,21 +567,21 @@ void RBBITableBuilder::buildStateTable() {
|
|||
return;
|
||||
}
|
||||
RBBIStateDescriptor *failState;
|
||||
// Set it to NULL to avoid uninitialized warning
|
||||
RBBIStateDescriptor *initialState = NULL;
|
||||
// Set it to nullptr to avoid uninitialized warning
|
||||
RBBIStateDescriptor *initialState = nullptr;
|
||||
//
|
||||
// Add a dummy state 0 - the stop state. Not from Aho.
|
||||
int lastInputSymbol = fRB->fSetBuilder->getNumCharCategories() - 1;
|
||||
failState = new RBBIStateDescriptor(lastInputSymbol, fStatus);
|
||||
if (failState == NULL) {
|
||||
if (failState == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto ExitBuildSTdeleteall;
|
||||
}
|
||||
failState->fPositions = new UVector(*fStatus);
|
||||
if (failState->fPositions == NULL) {
|
||||
if (failState->fPositions == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
if (failState->fPositions == NULL || U_FAILURE(*fStatus)) {
|
||||
if (failState->fPositions == nullptr || U_FAILURE(*fStatus)) {
|
||||
goto ExitBuildSTdeleteall;
|
||||
}
|
||||
fDStates->addElement(failState, *fStatus);
|
||||
|
@ -592,14 +592,14 @@ void RBBITableBuilder::buildStateTable() {
|
|||
// initially, the only unmarked state in Dstates is firstpos(root),
|
||||
// where toot is the root of the syntax tree for (r)#;
|
||||
initialState = new RBBIStateDescriptor(lastInputSymbol, fStatus);
|
||||
if (initialState == NULL) {
|
||||
if (initialState == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
goto ExitBuildSTdeleteall;
|
||||
}
|
||||
initialState->fPositions = new UVector(*fStatus);
|
||||
if (initialState->fPositions == NULL) {
|
||||
if (initialState->fPositions == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
|
@ -613,7 +613,7 @@ void RBBITableBuilder::buildStateTable() {
|
|||
|
||||
// while there is an unmarked state T in Dstates do begin
|
||||
for (;;) {
|
||||
RBBIStateDescriptor *T = NULL;
|
||||
RBBIStateDescriptor *T = nullptr;
|
||||
int32_t tx;
|
||||
for (tx=1; tx<fDStates->size(); tx++) {
|
||||
RBBIStateDescriptor *temp;
|
||||
|
@ -623,7 +623,7 @@ void RBBITableBuilder::buildStateTable() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (T == NULL) {
|
||||
if (T == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -636,15 +636,15 @@ void RBBITableBuilder::buildStateTable() {
|
|||
// let U be the set of positions that are in followpos(p)
|
||||
// for some position p in T
|
||||
// such that the symbol at position p is a;
|
||||
UVector *U = NULL;
|
||||
UVector *U = nullptr;
|
||||
RBBINode *p;
|
||||
int32_t px;
|
||||
for (px=0; px<T->fPositions->size(); px++) {
|
||||
p = (RBBINode *)T->fPositions->elementAt(px);
|
||||
if ((p->fType == RBBINode::leafChar) && (p->fVal == a)) {
|
||||
if (U == NULL) {
|
||||
if (U == nullptr) {
|
||||
U = new UVector(*fStatus);
|
||||
if (U == NULL) {
|
||||
if (U == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto ExitBuildSTdeleteall;
|
||||
}
|
||||
|
@ -656,7 +656,7 @@ void RBBITableBuilder::buildStateTable() {
|
|||
// if U is not empty and not in DStates then
|
||||
int32_t ux = 0;
|
||||
UBool UinDstates = false;
|
||||
if (U != NULL) {
|
||||
if (U != nullptr) {
|
||||
U_ASSERT(U->size() > 0);
|
||||
int ix;
|
||||
for (ix=0; ix<fDStates->size(); ix++) {
|
||||
|
@ -675,7 +675,7 @@ void RBBITableBuilder::buildStateTable() {
|
|||
if (!UinDstates)
|
||||
{
|
||||
RBBIStateDescriptor *newState = new RBBIStateDescriptor(lastInputSymbol, fStatus);
|
||||
if (newState == NULL) {
|
||||
if (newState == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
|
@ -942,7 +942,7 @@ void RBBITableBuilder::mergeRuleStatusVals() {
|
|||
for (n=0; n<fDStates->size(); n++) {
|
||||
RBBIStateDescriptor *sd = (RBBIStateDescriptor *)fDStates->elementAt(n);
|
||||
UVector *thisStatesTagValues = sd->fTagVals;
|
||||
if (thisStatesTagValues == NULL) {
|
||||
if (thisStatesTagValues == nullptr) {
|
||||
// No tag values are explicitly associated with this state.
|
||||
// Set the default tag value.
|
||||
sd->fTagsIdx = 0;
|
||||
|
@ -1012,10 +1012,10 @@ void RBBITableBuilder::mergeRuleStatusVals() {
|
|||
void RBBITableBuilder::sortedAdd(UVector **vector, int32_t val) {
|
||||
int32_t i;
|
||||
|
||||
if (*vector == NULL) {
|
||||
if (*vector == nullptr) {
|
||||
*vector = new UVector(*fStatus);
|
||||
}
|
||||
if (*vector == NULL || U_FAILURE(*fStatus)) {
|
||||
if (*vector == nullptr || U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
UVector *vec = *vector;
|
||||
|
@ -1053,7 +1053,7 @@ void RBBITableBuilder::setAdd(UVector *dest, UVector *source) {
|
|||
void **destLim, **sourceLim;
|
||||
|
||||
if (destOriginalSize > destArray.getCapacity()) {
|
||||
if (destArray.resize(destOriginalSize) == NULL) {
|
||||
if (destArray.resize(destOriginalSize) == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1061,7 +1061,7 @@ void RBBITableBuilder::setAdd(UVector *dest, UVector *source) {
|
|||
destLim = destPtr + destOriginalSize; // destArray.getArrayLimit()?
|
||||
|
||||
if (sourceSize > sourceArray.getCapacity()) {
|
||||
if (sourceArray.resize(sourceSize) == NULL) {
|
||||
if (sourceArray.resize(sourceSize) == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1125,7 +1125,7 @@ UBool RBBITableBuilder::setEquals(UVector *a, UVector *b) {
|
|||
//-----------------------------------------------------------------------------
|
||||
#ifdef RBBI_DEBUG
|
||||
void RBBITableBuilder::printPosSets(RBBINode *n) {
|
||||
if (n==NULL) {
|
||||
if (n==nullptr) {
|
||||
return;
|
||||
}
|
||||
printf("\n");
|
||||
|
@ -1339,7 +1339,7 @@ int32_t RBBITableBuilder::getTableSize() const {
|
|||
int32_t numCols;
|
||||
int32_t rowSize;
|
||||
|
||||
if (fTree == NULL) {
|
||||
if (fTree == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1373,7 +1373,7 @@ void RBBITableBuilder::exportTable(void *where) {
|
|||
uint32_t state;
|
||||
int col;
|
||||
|
||||
if (U_FAILURE(*fStatus) || fTree == NULL) {
|
||||
if (U_FAILURE(*fStatus) || fTree == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1651,7 +1651,7 @@ void RBBITableBuilder::printSet(UVector *s) {
|
|||
int32_t i;
|
||||
for (i=0; i<s->size(); i++) {
|
||||
const RBBINode *v = static_cast<const RBBINode *>(s->elementAt(i));
|
||||
RBBIDebugPrintf("%5d", v==NULL? -1 : v->fSerialNum);
|
||||
RBBIDebugPrintf("%5d", v==nullptr? -1 : v->fSerialNum);
|
||||
}
|
||||
RBBIDebugPrintf("\n");
|
||||
}
|
||||
|
@ -1777,15 +1777,15 @@ RBBIStateDescriptor::RBBIStateDescriptor(int lastInputSymbol, UErrorCode *fStatu
|
|||
fAccepting = 0;
|
||||
fLookAhead = 0;
|
||||
fTagsIdx = 0;
|
||||
fTagVals = NULL;
|
||||
fPositions = NULL;
|
||||
fDtran = NULL;
|
||||
fTagVals = nullptr;
|
||||
fPositions = nullptr;
|
||||
fDtran = nullptr;
|
||||
|
||||
fDtran = new UVector32(lastInputSymbol+1, *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
if (fDtran == NULL) {
|
||||
if (fDtran == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
@ -1800,9 +1800,9 @@ RBBIStateDescriptor::~RBBIStateDescriptor() {
|
|||
delete fPositions;
|
||||
delete fDtran;
|
||||
delete fTagVals;
|
||||
fPositions = NULL;
|
||||
fDtran = NULL;
|
||||
fTagVals = NULL;
|
||||
fPositions = nullptr;
|
||||
fDtran = nullptr;
|
||||
fTagVals = nullptr;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
|
@ -156,7 +156,7 @@ private:
|
|||
public:
|
||||
#ifdef RBBI_DEBUG
|
||||
void printSet(UVector *s);
|
||||
void printPosSets(RBBINode *n /* = NULL*/);
|
||||
void printPosSets(RBBINode *n /* = nullptr */);
|
||||
void printStates();
|
||||
void printRuleStatusTable();
|
||||
void printReverseTable();
|
||||
|
|
|
@ -177,13 +177,13 @@ U_NAMESPACE_BEGIN
|
|||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ResourceBundle)
|
||||
|
||||
ResourceBundle::ResourceBundle(UErrorCode &err)
|
||||
:UObject(), fLocale(NULL)
|
||||
:UObject(), fLocale(nullptr)
|
||||
{
|
||||
fResource = ures_open(0, Locale::getDefault().getName(), &err);
|
||||
}
|
||||
|
||||
ResourceBundle::ResourceBundle(const ResourceBundle &other)
|
||||
:UObject(other), fLocale(NULL)
|
||||
:UObject(other), fLocale(nullptr)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
@ -191,23 +191,23 @@ ResourceBundle::ResourceBundle(const ResourceBundle &other)
|
|||
fResource = ures_copyResb(0, other.fResource, &status);
|
||||
} else {
|
||||
/* Copying a bad resource bundle */
|
||||
fResource = NULL;
|
||||
fResource = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ResourceBundle::ResourceBundle(UResourceBundle *res, UErrorCode& err)
|
||||
:UObject(), fLocale(NULL)
|
||||
:UObject(), fLocale(nullptr)
|
||||
{
|
||||
if (res) {
|
||||
fResource = ures_copyResb(0, res, &err);
|
||||
} else {
|
||||
/* Copying a bad resource bundle */
|
||||
fResource = NULL;
|
||||
fResource = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ResourceBundle::ResourceBundle(const char* path, const Locale& locale, UErrorCode& err)
|
||||
:UObject(), fLocale(NULL)
|
||||
:UObject(), fLocale(nullptr)
|
||||
{
|
||||
fResource = ures_open(path, locale.getName(), &err);
|
||||
}
|
||||
|
@ -220,18 +220,18 @@ ResourceBundle& ResourceBundle::operator=(const ResourceBundle& other)
|
|||
}
|
||||
if(fResource != 0) {
|
||||
ures_close(fResource);
|
||||
fResource = NULL;
|
||||
fResource = nullptr;
|
||||
}
|
||||
if (fLocale != NULL) {
|
||||
if (fLocale != nullptr) {
|
||||
delete fLocale;
|
||||
fLocale = NULL;
|
||||
fLocale = nullptr;
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
if (other.fResource) {
|
||||
fResource = ures_copyResb(0, other.fResource, &status);
|
||||
} else {
|
||||
/* Copying a bad resource bundle */
|
||||
fResource = NULL;
|
||||
fResource = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ ResourceBundle::~ResourceBundle()
|
|||
if(fResource != 0) {
|
||||
ures_close(fResource);
|
||||
}
|
||||
if(fLocale != NULL) {
|
||||
if(fLocale != nullptr) {
|
||||
delete(fLocale);
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ ResourceBundle::clone() const {
|
|||
|
||||
UnicodeString ResourceBundle::getString(UErrorCode& status) const {
|
||||
int32_t len = 0;
|
||||
const UChar *r = ures_getString(fResource, &len, &status);
|
||||
const char16_t *r = ures_getString(fResource, &len, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
|
@ -273,27 +273,27 @@ int32_t ResourceBundle::getInt(UErrorCode& status) const {
|
|||
return ures_getInt(fResource, &status);
|
||||
}
|
||||
|
||||
const char *ResourceBundle::getName(void) const {
|
||||
const char *ResourceBundle::getName() const {
|
||||
return ures_getName(fResource);
|
||||
}
|
||||
|
||||
const char *ResourceBundle::getKey(void) const {
|
||||
const char *ResourceBundle::getKey() const {
|
||||
return ures_getKey(fResource);
|
||||
}
|
||||
|
||||
UResType ResourceBundle::getType(void) const {
|
||||
UResType ResourceBundle::getType() const {
|
||||
return ures_getType(fResource);
|
||||
}
|
||||
|
||||
int32_t ResourceBundle::getSize(void) const {
|
||||
int32_t ResourceBundle::getSize() const {
|
||||
return ures_getSize(fResource);
|
||||
}
|
||||
|
||||
UBool ResourceBundle::hasNext(void) const {
|
||||
UBool ResourceBundle::hasNext() const {
|
||||
return ures_hasNext(fResource);
|
||||
}
|
||||
|
||||
void ResourceBundle::resetIterator(void) {
|
||||
void ResourceBundle::resetIterator() {
|
||||
ures_resetIterator(fResource);
|
||||
}
|
||||
|
||||
|
@ -311,13 +311,13 @@ ResourceBundle ResourceBundle::getNext(UErrorCode& status) {
|
|||
|
||||
UnicodeString ResourceBundle::getNextString(UErrorCode& status) {
|
||||
int32_t len = 0;
|
||||
const UChar* r = ures_getNextString(fResource, &len, 0, &status);
|
||||
const char16_t* r = ures_getNextString(fResource, &len, 0, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
UnicodeString ResourceBundle::getNextString(const char ** key, UErrorCode& status) {
|
||||
int32_t len = 0;
|
||||
const UChar* r = ures_getNextString(fResource, &len, key, &status);
|
||||
const char16_t* r = ures_getNextString(fResource, &len, key, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ ResourceBundle ResourceBundle::get(int32_t indexR, UErrorCode& status) const {
|
|||
|
||||
UnicodeString ResourceBundle::getStringEx(int32_t indexS, UErrorCode& status) const {
|
||||
int32_t len = 0;
|
||||
const UChar* r = ures_getStringByIndex(fResource, indexS, &len, &status);
|
||||
const char16_t* r = ures_getStringByIndex(fResource, indexS, &len, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ ResourceBundle ResourceBundle::getWithFallback(const char* key, UErrorCode& stat
|
|||
}
|
||||
UnicodeString ResourceBundle::getStringEx(const char* key, UErrorCode& status) const {
|
||||
int32_t len = 0;
|
||||
const UChar* r = ures_getStringByKey(fResource, key, &len, &status);
|
||||
const char16_t* r = ures_getStringByKey(fResource, key, &len, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
|
@ -377,17 +377,17 @@ void ResourceBundle::getVersion(UVersionInfo versionInfo) const {
|
|||
ures_getVersion(fResource, versionInfo);
|
||||
}
|
||||
|
||||
const Locale &ResourceBundle::getLocale(void) const {
|
||||
const Locale &ResourceBundle::getLocale() const {
|
||||
static UMutex gLocaleLock;
|
||||
Mutex lock(&gLocaleLock);
|
||||
if (fLocale != NULL) {
|
||||
if (fLocale != nullptr) {
|
||||
return *fLocale;
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
const char *localeName = ures_getLocaleInternal(fResource, &status);
|
||||
ResourceBundle *ncThis = const_cast<ResourceBundle *>(this);
|
||||
ncThis->fLocale = new Locale(localeName);
|
||||
return ncThis->fLocale != NULL ? *ncThis->fLocale : Locale::getDefault();
|
||||
return ncThis->fLocale != nullptr ? *ncThis->fLocale : Locale::getDefault();
|
||||
}
|
||||
|
||||
const Locale ResourceBundle::getLocale(ULocDataLocaleType type, UErrorCode &status) const
|
||||
|
|
|
@ -27,14 +27,14 @@ U_NAMESPACE_BEGIN
|
|||
ResourceBundle::ResourceBundle( const UnicodeString& path,
|
||||
const Locale& locale,
|
||||
UErrorCode& error)
|
||||
:UObject(), fLocale(NULL)
|
||||
:UObject(), fLocale(nullptr)
|
||||
{
|
||||
constructForLocale(path, locale, error);
|
||||
}
|
||||
|
||||
ResourceBundle::ResourceBundle( const UnicodeString& path,
|
||||
UErrorCode& error)
|
||||
:UObject(), fLocale(NULL)
|
||||
:UObject(), fLocale(nullptr)
|
||||
{
|
||||
constructForLocale(path, Locale::getDefault(), error);
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ ResourceBundle::constructForLocale(const UnicodeString& path,
|
|||
UErrorCode& error)
|
||||
{
|
||||
if (path.isEmpty()) {
|
||||
fResource = ures_open(NULL, locale.getName(), &error);
|
||||
fResource = ures_open(nullptr, locale.getName(), &error);
|
||||
}
|
||||
else {
|
||||
UnicodeString nullTerminatedPath(path);
|
||||
nullTerminatedPath.append((UChar)0);
|
||||
nullTerminatedPath.append((char16_t)0);
|
||||
fResource = ures_openU(nullTerminatedPath.getBuffer(), locale.getName(), &error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class ResourceValue;
|
|||
class U_COMMON_API ResourceArray {
|
||||
public:
|
||||
/** Constructs an empty array object. */
|
||||
ResourceArray() : items16(NULL), items32(NULL), length(0) {}
|
||||
ResourceArray() : items16(nullptr), items32(nullptr), length(0) {}
|
||||
|
||||
/** Only for implementation use. @internal */
|
||||
ResourceArray(const uint16_t *i16, const uint32_t *i32, int32_t len,
|
||||
|
@ -80,7 +80,7 @@ private:
|
|||
class U_COMMON_API ResourceTable {
|
||||
public:
|
||||
/** Constructs an empty table object. */
|
||||
ResourceTable() : keys16(NULL), keys32(NULL), items16(NULL), items32(NULL), length(0) {}
|
||||
ResourceTable() : keys16(nullptr), keys32(nullptr), items16(nullptr), items32(nullptr), length(0) {}
|
||||
|
||||
/** Only for implementation use. @internal */
|
||||
ResourceTable(const uint16_t *k16, const int32_t *k32,
|
||||
|
@ -136,22 +136,22 @@ public:
|
|||
*
|
||||
* @see ures_getString()
|
||||
*/
|
||||
virtual const UChar *getString(int32_t &length, UErrorCode &errorCode) const = 0;
|
||||
virtual const char16_t *getString(int32_t &length, UErrorCode &errorCode) const = 0;
|
||||
|
||||
inline UnicodeString getUnicodeString(UErrorCode &errorCode) const {
|
||||
int32_t len = 0;
|
||||
const UChar *r = getString(len, errorCode);
|
||||
const char16_t *r = getString(len, errorCode);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets U_RESOURCE_TYPE_MISMATCH if this is not an alias resource.
|
||||
*/
|
||||
virtual const UChar *getAliasString(int32_t &length, UErrorCode &errorCode) const = 0;
|
||||
virtual const char16_t *getAliasString(int32_t &length, UErrorCode &errorCode) const = 0;
|
||||
|
||||
inline UnicodeString getAliasUnicodeString(UErrorCode &errorCode) const {
|
||||
int32_t len = 0;
|
||||
const UChar *r = getAliasString(len, errorCode);
|
||||
const char16_t *r = getAliasString(len, errorCode);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ void RuleCharacterIterator::jumpahead(int32_t count) {
|
|||
UnicodeString& RuleCharacterIterator::toString(UnicodeString& result) const {
|
||||
int32_t b = pos.getIndex();
|
||||
text.extract(0, b, result);
|
||||
return result.append((UChar) 0x7C).append(text, b, 0x7FFFFFFF); // Insert '|' at index
|
||||
return result.append((char16_t) 0x7C).append(text, b, 0x7FFFFFFF); // Insert '|' at index
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const
|
|||
return false;
|
||||
}
|
||||
|
||||
StringCharacterIterator& realThat = (StringCharacterIterator&)that;
|
||||
const StringCharacterIterator& realThat = static_cast<const StringCharacterIterator&>(that);
|
||||
|
||||
return text == realThat.text
|
||||
&& pos == realThat.pos
|
||||
|
|
|
@ -25,7 +25,7 @@ U_NAMESPACE_BEGIN
|
|||
******************************************************************
|
||||
*/
|
||||
|
||||
const UChar ICUServiceKey::PREFIX_DELIMITER = 0x002F; /* '/' */
|
||||
const char16_t ICUServiceKey::PREFIX_DELIMITER = 0x002F; /* '/' */
|
||||
|
||||
ICUServiceKey::ICUServiceKey(const UnicodeString& id)
|
||||
: _id(id) {
|
||||
|
@ -144,7 +144,7 @@ SimpleFactory::create(const ICUServiceKey& key, const ICUService* service, UErro
|
|||
return service->cloneInstance(_instance);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -243,7 +243,7 @@ public:
|
|||
CacheEntry* unref() {
|
||||
if ((--refcount) == 0) {
|
||||
delete this;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -294,14 +294,14 @@ StringPair::create(const UnicodeString& displayName,
|
|||
{
|
||||
if (U_SUCCESS(status)) {
|
||||
StringPair* sp = new StringPair(displayName, id);
|
||||
if (sp == NULL || sp->isBogus()) {
|
||||
if (sp == nullptr || sp->isBogus()) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete sp;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return sp;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UBool
|
||||
|
@ -332,20 +332,20 @@ static UMutex lock;
|
|||
ICUService::ICUService()
|
||||
: name()
|
||||
, timestamp(0)
|
||||
, factories(NULL)
|
||||
, serviceCache(NULL)
|
||||
, idCache(NULL)
|
||||
, dnCache(NULL)
|
||||
, factories(nullptr)
|
||||
, serviceCache(nullptr)
|
||||
, idCache(nullptr)
|
||||
, dnCache(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ICUService::ICUService(const UnicodeString& newName)
|
||||
: name(newName)
|
||||
, timestamp(0)
|
||||
, factories(NULL)
|
||||
, serviceCache(NULL)
|
||||
, idCache(NULL)
|
||||
, dnCache(NULL)
|
||||
, factories(nullptr)
|
||||
, serviceCache(nullptr)
|
||||
, idCache(nullptr)
|
||||
, dnCache(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -355,20 +355,20 @@ ICUService::~ICUService()
|
|||
Mutex mutex(&lock);
|
||||
clearCaches();
|
||||
delete factories;
|
||||
factories = NULL;
|
||||
factories = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
UObject*
|
||||
ICUService::get(const UnicodeString& descriptor, UErrorCode& status) const
|
||||
{
|
||||
return get(descriptor, NULL, status);
|
||||
return get(descriptor, nullptr, status);
|
||||
}
|
||||
|
||||
UObject*
|
||||
ICUService::get(const UnicodeString& descriptor, UnicodeString* actualReturn, UErrorCode& status) const
|
||||
{
|
||||
UObject* result = NULL;
|
||||
UObject* result = nullptr;
|
||||
ICUServiceKey* key = createKey(&descriptor, status);
|
||||
if (key) {
|
||||
result = getKey(*key, actualReturn, status);
|
||||
|
@ -380,7 +380,7 @@ ICUService::get(const UnicodeString& descriptor, UnicodeString* actualReturn, UE
|
|||
UObject*
|
||||
ICUService::getKey(ICUServiceKey& key, UErrorCode& status) const
|
||||
{
|
||||
return getKey(key, NULL, status);
|
||||
return getKey(key, nullptr, status);
|
||||
}
|
||||
|
||||
// this is a vector that subclasses of ICUService can override to further customize the result object
|
||||
|
@ -389,7 +389,7 @@ ICUService::getKey(ICUServiceKey& key, UErrorCode& status) const
|
|||
UObject*
|
||||
ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& status) const
|
||||
{
|
||||
return getKey(key, actualReturn, NULL, status);
|
||||
return getKey(key, actualReturn, nullptr, status);
|
||||
}
|
||||
|
||||
// make it possible to call reentrantly on systems that don't have reentrant mutexes.
|
||||
|
@ -417,7 +417,7 @@ UObject*
|
|||
ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUServiceFactory* factory, UErrorCode& status) const
|
||||
{
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (isDefault()) {
|
||||
|
@ -426,7 +426,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
|
|||
|
||||
ICUService* ncthis = (ICUService*)this; // cast away semantic const
|
||||
|
||||
CacheEntry* result = NULL;
|
||||
CacheEntry* result = nullptr;
|
||||
{
|
||||
// The factory list can't be modified until we're done,
|
||||
// otherwise we might update the cache with an invalid result.
|
||||
|
@ -437,17 +437,17 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
|
|||
// if factory is not null, we're calling from within the mutex,
|
||||
// and since some unix machines don't have reentrant mutexes we
|
||||
// need to make sure not to try to lock it again.
|
||||
XMutex mutex(&lock, factory != NULL);
|
||||
XMutex mutex(&lock, factory != nullptr);
|
||||
|
||||
if (serviceCache == NULL) {
|
||||
if (serviceCache == nullptr) {
|
||||
ncthis->serviceCache = new Hashtable(status);
|
||||
if (ncthis->serviceCache == NULL) {
|
||||
if (ncthis->serviceCache == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
delete serviceCache;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
serviceCache->setValueDeleter(cacheDeleter);
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
|
|||
int32_t limit = factories->size();
|
||||
UBool cacheResult = true;
|
||||
|
||||
if (factory != NULL) {
|
||||
if (factory != nullptr) {
|
||||
for (int32_t i = 0; i < limit; ++i) {
|
||||
if (factory == (const ICUServiceFactory*)factories->elementAt(i)) {
|
||||
startIndex = i + 1;
|
||||
|
@ -470,7 +470,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
|
|||
if (startIndex == 0) {
|
||||
// throw new InternalError("Factory " + factory + "not registered with service: " + this);
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cacheResult = false;
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
|
|||
currentDescriptor.remove();
|
||||
key.currentDescriptor(currentDescriptor);
|
||||
result = (CacheEntry*)serviceCache->get(currentDescriptor);
|
||||
if (result != NULL) {
|
||||
if (result != nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -493,13 +493,13 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
|
|||
ICUServiceFactory* f = (ICUServiceFactory*)factories->elementAt(index++);
|
||||
LocalPointer<UObject> service(f->create(key, this, status));
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (service.isValid()) {
|
||||
result = new CacheEntry(currentDescriptor, service.getAlias());
|
||||
if (result == NULL) {
|
||||
if (result == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
service.orphan(); // result now owns service.
|
||||
|
||||
|
@ -513,32 +513,32 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer
|
|||
// fallback to the one that succeeded, we want to hit the
|
||||
// cache the first time next goaround.
|
||||
if (cacheDescriptorList.isNull()) {
|
||||
cacheDescriptorList.adoptInsteadAndCheckErrorCode(new UVector(uprv_deleteUObject, NULL, 5, status), status);
|
||||
cacheDescriptorList.adoptInsteadAndCheckErrorCode(new UVector(uprv_deleteUObject, nullptr, 5, status), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
LocalPointer<UnicodeString> idToCache(new UnicodeString(currentDescriptor), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (idToCache->isBogus()) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cacheDescriptorList->adoptElement(idToCache.orphan(), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
} while (key.fallback());
|
||||
outerEnd:
|
||||
|
||||
if (result != NULL) {
|
||||
if (result != nullptr) {
|
||||
if (putInCache && cacheResult) {
|
||||
serviceCache->put(result->actualDescriptor, result, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (cacheDescriptorList.isValid()) {
|
||||
|
@ -547,7 +547,7 @@ outerEnd:
|
|||
|
||||
serviceCache->put(*desc, result, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
result->ref();
|
||||
|
@ -556,9 +556,9 @@ outerEnd:
|
|||
}
|
||||
}
|
||||
|
||||
if (actualReturn != NULL) {
|
||||
if (actualReturn != nullptr) {
|
||||
// strip null prefix
|
||||
if (result->actualDescriptor.indexOf((UChar)0x2f) == 0) { // U+002f=slash (/)
|
||||
if (result->actualDescriptor.indexOf((char16_t)0x2f) == 0) { // U+002f=slash (/)
|
||||
actualReturn->remove();
|
||||
actualReturn->append(result->actualDescriptor,
|
||||
1,
|
||||
|
@ -570,7 +570,7 @@ outerEnd:
|
|||
if (actualReturn->isBogus()) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete result;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -588,12 +588,12 @@ outerEnd:
|
|||
UObject*
|
||||
ICUService::handleDefault(const ICUServiceKey& /* key */, UnicodeString* /* actualIDReturn */, UErrorCode& /* status */) const
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UVector&
|
||||
ICUService::getVisibleIDs(UVector& result, UErrorCode& status) const {
|
||||
return getVisibleIDs(result, NULL, status);
|
||||
return getVisibleIDs(result, nullptr, status);
|
||||
}
|
||||
|
||||
UVector&
|
||||
|
@ -609,17 +609,17 @@ ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorC
|
|||
{
|
||||
Mutex mutex(&lock);
|
||||
const Hashtable* map = getVisibleIDMap(status);
|
||||
if (map != NULL) {
|
||||
if (map != nullptr) {
|
||||
ICUServiceKey* fallbackKey = createKey(matchID, status);
|
||||
|
||||
for (int32_t pos = UHASH_FIRST; U_SUCCESS(status); ) {
|
||||
const UHashElement* e = map->nextElement(pos);
|
||||
if (e == NULL) {
|
||||
if (e == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
const UnicodeString* id = (const UnicodeString*)e->key.pointer;
|
||||
if (fallbackKey != NULL) {
|
||||
if (fallbackKey != nullptr) {
|
||||
if (!fallbackKey->isFallbackOf(*id)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -640,23 +640,23 @@ ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorC
|
|||
|
||||
const Hashtable*
|
||||
ICUService::getVisibleIDMap(UErrorCode& status) const {
|
||||
if (U_FAILURE(status)) return NULL;
|
||||
if (U_FAILURE(status)) return nullptr;
|
||||
|
||||
// must only be called when lock is already held
|
||||
|
||||
ICUService* ncthis = (ICUService*)this; // cast away semantic const
|
||||
if (idCache == NULL) {
|
||||
if (idCache == nullptr) {
|
||||
ncthis->idCache = new Hashtable(status);
|
||||
if (idCache == NULL) {
|
||||
if (idCache == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
} else if (factories != NULL) {
|
||||
} else if (factories != nullptr) {
|
||||
for (int32_t pos = factories->size(); --pos >= 0;) {
|
||||
ICUServiceFactory* f = (ICUServiceFactory*)factories->elementAt(pos);
|
||||
f->updateVisibleIDs(*idCache, status);
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
delete idCache;
|
||||
ncthis->idCache = NULL;
|
||||
ncthis->idCache = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -678,9 +678,9 @@ ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
Mutex mutex(&lock);
|
||||
const Hashtable* map = getVisibleIDMap(status);
|
||||
if (map != NULL) {
|
||||
if (map != nullptr) {
|
||||
ICUServiceFactory* f = (ICUServiceFactory*)map->get(id);
|
||||
if (f != NULL) {
|
||||
if (f != nullptr) {
|
||||
f->getDisplayName(id, locale, result);
|
||||
return result;
|
||||
}
|
||||
|
@ -688,11 +688,11 @@ ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const
|
|||
// fallback
|
||||
status = U_ZERO_ERROR;
|
||||
ICUServiceKey* fallbackKey = createKey(&id, status);
|
||||
while (fallbackKey != NULL && fallbackKey->fallback()) {
|
||||
while (fallbackKey != nullptr && fallbackKey->fallback()) {
|
||||
UnicodeString us;
|
||||
fallbackKey->currentID(us);
|
||||
f = (ICUServiceFactory*)map->get(us);
|
||||
if (f != NULL) {
|
||||
if (f != nullptr) {
|
||||
f->getDisplayName(id, locale, result);
|
||||
delete fallbackKey;
|
||||
return result;
|
||||
|
@ -708,14 +708,14 @@ ICUService::getDisplayName(const UnicodeString& id, UnicodeString& result, const
|
|||
UVector&
|
||||
ICUService::getDisplayNames(UVector& result, UErrorCode& status) const
|
||||
{
|
||||
return getDisplayNames(result, Locale::getDefault(), NULL, status);
|
||||
return getDisplayNames(result, Locale::getDefault(), nullptr, status);
|
||||
}
|
||||
|
||||
|
||||
UVector&
|
||||
ICUService::getDisplayNames(UVector& result, const Locale& locale, UErrorCode& status) const
|
||||
{
|
||||
return getDisplayNames(result, locale, NULL, status);
|
||||
return getDisplayNames(result, locale, nullptr, status);
|
||||
}
|
||||
|
||||
UVector&
|
||||
|
@ -730,25 +730,25 @@ ICUService::getDisplayNames(UVector& result,
|
|||
ICUService* ncthis = (ICUService*)this; // cast away semantic const
|
||||
Mutex mutex(&lock);
|
||||
|
||||
if (dnCache != NULL && dnCache->locale != locale) {
|
||||
if (dnCache != nullptr && dnCache->locale != locale) {
|
||||
delete dnCache;
|
||||
ncthis->dnCache = NULL;
|
||||
ncthis->dnCache = nullptr;
|
||||
}
|
||||
|
||||
if (dnCache == NULL) {
|
||||
if (dnCache == nullptr) {
|
||||
const Hashtable* m = getVisibleIDMap(status);
|
||||
if (U_FAILURE(status)) {
|
||||
return result;
|
||||
}
|
||||
ncthis->dnCache = new DNCache(locale);
|
||||
if (dnCache == NULL) {
|
||||
if (dnCache == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement* entry = NULL;
|
||||
while ((entry = m->nextElement(pos)) != NULL) {
|
||||
const UHashElement* entry = nullptr;
|
||||
while ((entry = m->nextElement(pos)) != nullptr) {
|
||||
const UnicodeString* id = (const UnicodeString*)entry->key.pointer;
|
||||
ICUServiceFactory* f = (ICUServiceFactory*)entry->value.pointer;
|
||||
UnicodeString dname;
|
||||
|
@ -762,7 +762,7 @@ ICUService::getDisplayNames(UVector& result,
|
|||
}
|
||||
}
|
||||
delete dnCache;
|
||||
ncthis->dnCache = NULL;
|
||||
ncthis->dnCache = nullptr;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -774,10 +774,10 @@ ICUService::getDisplayNames(UVector& result,
|
|||
* at the next position, which in this case will be 0.
|
||||
*/
|
||||
int32_t pos = UHASH_FIRST;
|
||||
const UHashElement *entry = NULL;
|
||||
while ((entry = dnCache->cache.nextElement(pos)) != NULL) {
|
||||
const UHashElement *entry = nullptr;
|
||||
while ((entry = dnCache->cache.nextElement(pos)) != nullptr) {
|
||||
const UnicodeString* id = (const UnicodeString*)entry->value.pointer;
|
||||
if (matchKey != NULL && !matchKey->isFallbackOf(*id)) {
|
||||
if (matchKey != nullptr && !matchKey->isFallbackOf(*id)) {
|
||||
continue;
|
||||
}
|
||||
const UnicodeString* dn = (const UnicodeString*)entry->key.pointer;
|
||||
|
@ -803,30 +803,30 @@ URegistryKey
|
|||
ICUService::registerInstance(UObject* objToAdopt, const UnicodeString& id, UBool visible, UErrorCode& status)
|
||||
{
|
||||
ICUServiceKey* key = createKey(&id, status);
|
||||
if (key != NULL) {
|
||||
if (key != nullptr) {
|
||||
UnicodeString canonicalID;
|
||||
key->canonicalID(canonicalID);
|
||||
delete key;
|
||||
|
||||
ICUServiceFactory* f = createSimpleFactory(objToAdopt, canonicalID, visible, status);
|
||||
if (f != NULL) {
|
||||
if (f != nullptr) {
|
||||
return registerFactory(f, status);
|
||||
}
|
||||
}
|
||||
delete objToAdopt;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ICUServiceFactory*
|
||||
ICUService::createSimpleFactory(UObject* objToAdopt, const UnicodeString& id, UBool visible, UErrorCode& status)
|
||||
{
|
||||
if (U_SUCCESS(status)) {
|
||||
if ((objToAdopt != NULL) && (!id.isBogus())) {
|
||||
if ((objToAdopt != nullptr) && (!id.isBogus())) {
|
||||
return new SimpleFactory(objToAdopt, id, visible);
|
||||
}
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
URegistryKey
|
||||
|
@ -865,7 +865,7 @@ ICUService::unregister(URegistryKey rkey, UErrorCode& status)
|
|||
{
|
||||
ICUServiceFactory *factory = (ICUServiceFactory*)rkey;
|
||||
UBool result = false;
|
||||
if (factory != NULL && factories != NULL) {
|
||||
if (factory != nullptr && factories != nullptr) {
|
||||
Mutex mutex(&lock);
|
||||
|
||||
if (factories->removeElement(factory)) {
|
||||
|
@ -896,7 +896,7 @@ ICUService::reset()
|
|||
void
|
||||
ICUService::reInitializeFactories()
|
||||
{
|
||||
if (factories != NULL) {
|
||||
if (factories != nullptr) {
|
||||
factories->removeAllElements();
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ ICUService::isDefault() const
|
|||
ICUServiceKey*
|
||||
ICUService::createKey(const UnicodeString* id, UErrorCode& status) const
|
||||
{
|
||||
return (U_FAILURE(status) || id == NULL) ? NULL : new ICUServiceKey(*id);
|
||||
return (U_FAILURE(status) || id == nullptr) ? nullptr : new ICUServiceKey(*id);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -919,29 +919,29 @@ ICUService::clearCaches()
|
|||
// callers synchronize before use
|
||||
++timestamp;
|
||||
delete dnCache;
|
||||
dnCache = NULL;
|
||||
dnCache = nullptr;
|
||||
delete idCache;
|
||||
idCache = NULL;
|
||||
delete serviceCache; serviceCache = NULL;
|
||||
idCache = nullptr;
|
||||
delete serviceCache; serviceCache = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ICUService::clearServiceCache()
|
||||
{
|
||||
// callers synchronize before use
|
||||
delete serviceCache; serviceCache = NULL;
|
||||
delete serviceCache; serviceCache = nullptr;
|
||||
}
|
||||
|
||||
UBool
|
||||
ICUService::acceptsListener(const EventListener& l) const
|
||||
{
|
||||
return dynamic_cast<const ServiceListener*>(&l) != NULL;
|
||||
return dynamic_cast<const ServiceListener*>(&l) != nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ICUService::notifyListener(EventListener& l) const
|
||||
{
|
||||
((ServiceListener&)l).serviceChanged(*this);
|
||||
(static_cast<ServiceListener&>(l)).serviceChanged(*this);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
|
@ -953,7 +953,7 @@ ICUService::getName(UnicodeString& result) const
|
|||
int32_t
|
||||
ICUService::countFactories() const
|
||||
{
|
||||
return factories == NULL ? 0 : factories->size();
|
||||
return factories == nullptr ? 0 : factories->size();
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
|
|
@ -74,7 +74,7 @@ class U_COMMON_API ICUServiceKey : public UObject {
|
|||
const UnicodeString _id;
|
||||
|
||||
protected:
|
||||
static const UChar PREFIX_DELIMITER;
|
||||
static const char16_t PREFIX_DELIMITER;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -217,7 +217,7 @@ class U_COMMON_API ICUServiceFactory : public UObject {
|
|||
|
||||
/**
|
||||
* <p>Create a service object from the key, if this factory
|
||||
* supports the key. Otherwise, return NULL.</p>
|
||||
* supports the key. Otherwise, return nullptr.</p>
|
||||
*
|
||||
* <p>If the factory supports the key, then it can call
|
||||
* the service's getKey(ICUServiceKey, String[], ICUServiceFactory) method
|
||||
|
@ -230,7 +230,7 @@ class U_COMMON_API ICUServiceFactory : public UObject {
|
|||
* @param key the service key.
|
||||
* @param service the service with which this factory is registered.
|
||||
* @param status the error code status.
|
||||
* @return the service object, or NULL if the factory does not support the key.
|
||||
* @return the service object, or nullptr if the factory does not support the key.
|
||||
*/
|
||||
virtual UObject* create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const = 0;
|
||||
|
||||
|
@ -292,7 +292,7 @@ class U_COMMON_API SimpleFactory : public ICUServiceFactory {
|
|||
/**
|
||||
* <p>Construct a SimpleFactory that maps a single ID to a single
|
||||
* service instance. If visible is true, the ID will be visible.
|
||||
* The instance must not be NULL. The SimpleFactory will adopt
|
||||
* The instance must not be nullptr. The SimpleFactory will adopt
|
||||
* the instance, which must not be changed subsequent to this call.</p>
|
||||
*
|
||||
* @param instanceToAdopt the service instance to adopt.
|
||||
|
@ -313,7 +313,7 @@ class U_COMMON_API SimpleFactory : public ICUServiceFactory {
|
|||
* @param key the service key.
|
||||
* @param service the service with which this factory is registered.
|
||||
* @param status the error code status.
|
||||
* @return the service object, or NULL if the factory does not support the key.
|
||||
* @return the service object, or nullptr if the factory does not support the key.
|
||||
*/
|
||||
virtual UObject* create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const override;
|
||||
|
||||
|
@ -420,7 +420,7 @@ public:
|
|||
* @param displayName the displayName.
|
||||
* @param id the ID.
|
||||
* @param status the error code status.
|
||||
* @return a StringPair if the creation was successful, otherwise NULL.
|
||||
* @return a StringPair if the creation was successful, otherwise nullptr.
|
||||
*/
|
||||
static StringPair* create(const UnicodeString& displayName,
|
||||
const UnicodeString& id,
|
||||
|
@ -593,7 +593,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
*
|
||||
* @param descriptor the descriptor.
|
||||
* @param status the error code status.
|
||||
* @return the service instance, or NULL.
|
||||
* @return the service instance, or nullptr.
|
||||
*/
|
||||
UObject* get(const UnicodeString& descriptor, UErrorCode& status) const;
|
||||
|
||||
|
@ -602,9 +602,9 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* createKey to create a key from the provided descriptor.</p>
|
||||
*
|
||||
* @param descriptor the descriptor.
|
||||
* @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or NULL.
|
||||
* @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or nullptr.
|
||||
* @param status the error code status.
|
||||
* @return the service instance, or NULL.
|
||||
* @return the service instance, or nullptr.
|
||||
*/
|
||||
UObject* get(const UnicodeString& descriptor, UnicodeString* actualReturn, UErrorCode& status) const;
|
||||
|
||||
|
@ -613,15 +613,15 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
*
|
||||
* @param key the key.
|
||||
* @param status the error code status.
|
||||
* @return the service instance, or NULL.
|
||||
* @return the service instance, or nullptr.
|
||||
*/
|
||||
UObject* getKey(ICUServiceKey& key, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* <p>Given a key, return a service object, and, if actualReturn
|
||||
* is not NULL, the descriptor with which it was found in the
|
||||
* is not nullptr, the descriptor with which it was found in the
|
||||
* first element of actualReturn. If no service object matches
|
||||
* this key, returns NULL and leaves actualReturn unchanged.</p>
|
||||
* this key, returns nullptr and leaves actualReturn unchanged.</p>
|
||||
*
|
||||
* <p>This queries the cache using the key's descriptor, and if no
|
||||
* object in the cache matches, tries the key on each
|
||||
|
@ -635,9 +635,9 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* result before returning it.
|
||||
*
|
||||
* @param key the key.
|
||||
* @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or NULL.
|
||||
* @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or nullptr.
|
||||
* @param status the error code status.
|
||||
* @return the service instance, or NULL.
|
||||
* @return the service instance, or nullptr.
|
||||
*/
|
||||
virtual UObject* getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& status) const;
|
||||
|
||||
|
@ -648,10 +648,10 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* should not call it directly, but call through one of the other get functions.</p>
|
||||
*
|
||||
* @param key the key.
|
||||
* @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or NULL.
|
||||
* @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or nullptr.
|
||||
* @param factory the factory making the recursive call.
|
||||
* @param status the error code status.
|
||||
* @return the service instance, or NULL.
|
||||
* @return the service instance, or nullptr.
|
||||
*/
|
||||
UObject* getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUServiceFactory* factory, UErrorCode& status) const;
|
||||
|
||||
|
@ -677,11 +677,11 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* new elements, if any, are added.</p>
|
||||
*
|
||||
* <p>matchID is passed to createKey to create a key. If the key
|
||||
* is not NULL, its isFallbackOf method is used to filter out IDs
|
||||
* is not nullptr, its isFallbackOf method is used to filter out IDs
|
||||
* that don't match the key or have it as a fallback.</p>
|
||||
*
|
||||
* @param result a vector to hold the returned IDs.
|
||||
* @param matchID an ID used to filter the result, or NULL if all IDs are desired.
|
||||
* @param matchID an ID used to filter the result, or nullptr if all IDs are desired.
|
||||
* @param status the error code status.
|
||||
* @return the result vector.
|
||||
*/
|
||||
|
@ -711,7 +711,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
|
||||
/**
|
||||
* <p>Convenience override of getDisplayNames(const Locale&, const UnicodeString*) that
|
||||
* uses the current default Locale as the locale and NULL for
|
||||
* uses the current default Locale as the locale and nullptr for
|
||||
* the matchID.</p>
|
||||
*
|
||||
* @param result a vector to hold the returned displayName/id StringPairs.
|
||||
|
@ -722,7 +722,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
|
||||
/**
|
||||
* <p>Convenience override of getDisplayNames(const Locale&, const UnicodeString*) that
|
||||
* uses NULL for the matchID.</p>
|
||||
* uses nullptr for the matchID.</p>
|
||||
*
|
||||
* @param result a vector to hold the returned displayName/id StringPairs.
|
||||
* @param locale the locale in which to localize the ID.
|
||||
|
@ -746,12 +746,12 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* discarded before new elements, if any, are added.</p>
|
||||
*
|
||||
* <p>matchID is passed to createKey to create a key. If the key
|
||||
* is not NULL, its isFallbackOf method is used to filter out IDs
|
||||
* is not nullptr, its isFallbackOf method is used to filter out IDs
|
||||
* that don't match the key or have it as a fallback.</p>
|
||||
*
|
||||
* @param result a vector to hold the returned displayName/id StringPairs.
|
||||
* @param locale the locale in which to localize the ID.
|
||||
* @param matchID an ID used to filter the result, or NULL if all IDs are desired.
|
||||
* @param matchID an ID used to filter the result, or nullptr if all IDs are desired.
|
||||
* @param status the error code status.
|
||||
* @return the result vector. */
|
||||
UVector& getDisplayNames(UVector& result,
|
||||
|
@ -830,7 +830,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
*
|
||||
* <p>This issues a serviceChanged notification to registered listeners.</p>
|
||||
*/
|
||||
virtual void reset(void);
|
||||
virtual void reset();
|
||||
|
||||
/**
|
||||
* <p>Return true if the service is in its default state.</p>
|
||||
|
@ -838,10 +838,10 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* <p>The default implementation returns true if there are no
|
||||
* factories registered.</p>
|
||||
*/
|
||||
virtual UBool isDefault(void) const;
|
||||
virtual UBool isDefault() const;
|
||||
|
||||
/**
|
||||
* <p>Create a key from an ID. If ID is NULL, returns NULL.</p>
|
||||
* <p>Create a key from an ID. If ID is nullptr, returns nullptr.</p>
|
||||
*
|
||||
* <p>The default implementation creates an ICUServiceKey instance.
|
||||
* Subclasses can override to define more useful keys appropriate
|
||||
|
@ -849,7 +849,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
*
|
||||
* @param a pointer to the ID for which to create a default ICUServiceKey.
|
||||
* @param status the error code status.
|
||||
* @return the ICUServiceKey corresponding to ID, or NULL.
|
||||
* @return the ICUServiceKey corresponding to ID, or nullptr.
|
||||
*/
|
||||
virtual ICUServiceKey* createKey(const UnicodeString* id, UErrorCode& status) const;
|
||||
|
||||
|
@ -859,7 +859,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* This is public so factories can call it, but should really be protected.</p>
|
||||
*
|
||||
* @param instance the service instance to clone.
|
||||
* @return a clone of the passed-in instance, or NULL if cloning was unsuccessful.
|
||||
* @return a clone of the passed-in instance, or nullptr if cloning was unsuccessful.
|
||||
*/
|
||||
virtual UObject* cloneInstance(UObject* instance) const = 0;
|
||||
|
||||
|
@ -895,18 +895,18 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* directly, since it must only be called while holding write
|
||||
* access to the factory list.</p>
|
||||
*/
|
||||
virtual void reInitializeFactories(void);
|
||||
virtual void reInitializeFactories();
|
||||
|
||||
/**
|
||||
* <p>Default handler for this service if no factory in the factory list
|
||||
* handled the key passed to getKey.</p>
|
||||
*
|
||||
* <p>The default implementation returns NULL.</p>
|
||||
* <p>The default implementation returns nullptr.</p>
|
||||
*
|
||||
* @param key the key.
|
||||
* @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or NULL.
|
||||
* @param actualReturn a pointer to a UnicodeString to hold the matched descriptor, or nullptr.
|
||||
* @param status the error code status.
|
||||
* @return the service instance, or NULL.
|
||||
* @return the service instance, or nullptr.
|
||||
*/
|
||||
virtual UObject* handleDefault(const ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& status) const;
|
||||
|
||||
|
@ -918,7 +918,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* should generally not call this method directly, as it must only
|
||||
* be called while synchronized on the factory lock.</p>
|
||||
*/
|
||||
virtual void clearCaches(void);
|
||||
virtual void clearCaches();
|
||||
|
||||
/**
|
||||
* <p>Return true if the listener is accepted.</p>
|
||||
|
@ -955,7 +955,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
* the resolution of IDs also changes, requiring the cache to be
|
||||
* flushed, but not the visible IDs themselves.</p>
|
||||
*/
|
||||
void clearServiceCache(void);
|
||||
void clearServiceCache();
|
||||
|
||||
/**
|
||||
* <p>Return a map from visible IDs to factories.
|
||||
|
@ -972,14 +972,14 @@ class U_COMMON_API ICUService : public ICUNotifier {
|
|||
*
|
||||
* @return the timestamp.
|
||||
*/
|
||||
int32_t getTimestamp(void) const;
|
||||
int32_t getTimestamp() const;
|
||||
|
||||
/**
|
||||
* <p>Return the number of registered factories.</p>
|
||||
*
|
||||
* @return the number of factories registered at the time of the call.
|
||||
*/
|
||||
int32_t countFactories(void) const;
|
||||
int32_t countFactories() const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include "charstr.h"
|
||||
#include "uassert.h"
|
||||
|
||||
#define UNDERSCORE_CHAR ((UChar)0x005f)
|
||||
#define AT_SIGN_CHAR ((UChar)64)
|
||||
#define PERIOD_CHAR ((UChar)46)
|
||||
#define UNDERSCORE_CHAR ((char16_t)0x005f)
|
||||
#define AT_SIGN_CHAR ((char16_t)64)
|
||||
#define PERIOD_CHAR ((char16_t)46)
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -41,8 +41,8 @@ LocaleKey::createWithCanonicalFallback(const UnicodeString* primaryID,
|
|||
int32_t kind,
|
||||
UErrorCode& status)
|
||||
{
|
||||
if (primaryID == NULL || U_FAILURE(status)) {
|
||||
return NULL;
|
||||
if (primaryID == nullptr || U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
UnicodeString canonicalPrimaryID;
|
||||
LocaleUtility::canonicalLocaleString(primaryID, canonicalPrimaryID);
|
||||
|
@ -61,7 +61,7 @@ LocaleKey::LocaleKey(const UnicodeString& primaryID,
|
|||
{
|
||||
_fallbackID.setToBogus();
|
||||
if (_primaryID.length() != 0) {
|
||||
if (canonicalFallbackID != NULL && _primaryID != *canonicalFallbackID) {
|
||||
if (canonicalFallbackID != nullptr && _primaryID != *canonicalFallbackID) {
|
||||
_fallbackID = *canonicalFallbackID;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ LocaleKey::~LocaleKey() {}
|
|||
UnicodeString&
|
||||
LocaleKey::prefix(UnicodeString& result) const {
|
||||
if (_kind != KIND_ANY) {
|
||||
UChar buffer[64];
|
||||
char16_t buffer[64];
|
||||
uprv_itou(buffer, 64, _kind, 10, 0);
|
||||
UnicodeString temp(buffer);
|
||||
result.append(temp);
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#include "ucln_cmn.h"
|
||||
#include "uassert.h"
|
||||
|
||||
#define UNDERSCORE_CHAR ((UChar)0x005f)
|
||||
#define AT_SIGN_CHAR ((UChar)64)
|
||||
#define PERIOD_CHAR ((UChar)46)
|
||||
#define UNDERSCORE_CHAR ((char16_t)0x005f)
|
||||
#define AT_SIGN_CHAR ((char16_t)64)
|
||||
#define PERIOD_CHAR ((char16_t)46)
|
||||
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
@ -47,14 +47,14 @@ LocaleKeyFactory::~LocaleKeyFactory() {
|
|||
UObject*
|
||||
LocaleKeyFactory::create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const {
|
||||
if (handlesKey(key, status)) {
|
||||
const LocaleKey& lkey = (const LocaleKey&)key;
|
||||
const LocaleKey& lkey = static_cast<const LocaleKey&>(key);
|
||||
int32_t kind = lkey.kind();
|
||||
Locale loc;
|
||||
lkey.currentLocale(loc);
|
||||
|
||||
return handleCreate(loc, kind, service, status);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UBool
|
||||
|
@ -63,7 +63,7 @@ LocaleKeyFactory::handlesKey(const ICUServiceKey& key, UErrorCode& status) const
|
|||
if (supported) {
|
||||
UnicodeString id;
|
||||
key.currentID(id);
|
||||
return supported->get(id) != NULL;
|
||||
return supported->get(id) != nullptr;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ LocaleKeyFactory::updateVisibleIDs(Hashtable& result, UErrorCode& status) const
|
|||
const Hashtable* supported = getSupportedIDs(status);
|
||||
if (supported) {
|
||||
UBool visible = (_coverage & 0x1) == 0;
|
||||
const UHashElement* elem = NULL;
|
||||
const UHashElement* elem = nullptr;
|
||||
int32_t pos = UHASH_FIRST;
|
||||
while ((elem = supported->nextElement(pos)) != NULL) {
|
||||
while ((elem = supported->nextElement(pos)) != nullptr) {
|
||||
const UnicodeString& id = *((const UnicodeString*)elem->key.pointer);
|
||||
if (!visible) {
|
||||
result.remove(id);
|
||||
|
@ -109,7 +109,7 @@ LocaleKeyFactory::handleCreate(const Locale& /* loc */,
|
|||
int32_t /* kind */,
|
||||
const ICUService* /* service */,
|
||||
UErrorCode& /* status */) const {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//UBool
|
||||
|
@ -120,7 +120,7 @@ LocaleKeyFactory::handleCreate(const Locale& /* loc */,
|
|||
|
||||
const Hashtable*
|
||||
LocaleKeyFactory::getSupportedIDs(UErrorCode& /* status */) const {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef SERVICE_DEBUG
|
||||
|
|
|
@ -258,7 +258,7 @@ public:
|
|||
protected:
|
||||
/**
|
||||
* Utility method used by create(ICUServiceKey, ICUService). Subclasses can implement
|
||||
* this instead of create. The default returns NULL.
|
||||
* this instead of create. The default returns nullptr.
|
||||
*/
|
||||
virtual UObject* handleCreate(const Locale& loc, int32_t kind, const ICUService* service, UErrorCode& status) const;
|
||||
|
||||
|
@ -518,7 +518,7 @@ class U_COMMON_API ICULocaleService : public ICUService
|
|||
* Convenience method for callers using locales. This returns the standard
|
||||
* service ID enumeration.
|
||||
*/
|
||||
virtual StringEnumeration* getAvailableLocales(void) const;
|
||||
virtual StringEnumeration* getAvailableLocales() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include "charstr.h"
|
||||
#include "uassert.h"
|
||||
|
||||
#define UNDERSCORE_CHAR ((UChar)0x005f)
|
||||
#define AT_SIGN_CHAR ((UChar)64)
|
||||
#define PERIOD_CHAR ((UChar)46)
|
||||
#define UNDERSCORE_CHAR ((char16_t)0x005f)
|
||||
#define AT_SIGN_CHAR ((char16_t)64)
|
||||
#define PERIOD_CHAR ((char16_t)46)
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -44,13 +44,13 @@ ICULocaleService::~ICULocaleService()
|
|||
UObject*
|
||||
ICULocaleService::get(const Locale& locale, UErrorCode& status) const
|
||||
{
|
||||
return get(locale, LocaleKey::KIND_ANY, NULL, status);
|
||||
return get(locale, LocaleKey::KIND_ANY, nullptr, status);
|
||||
}
|
||||
|
||||
UObject*
|
||||
ICULocaleService::get(const Locale& locale, int32_t kind, UErrorCode& status) const
|
||||
{
|
||||
return get(locale, kind, NULL, status);
|
||||
return get(locale, kind, nullptr, status);
|
||||
}
|
||||
|
||||
UObject*
|
||||
|
@ -62,7 +62,7 @@ ICULocaleService::get(const Locale& locale, Locale* actualReturn, UErrorCode& st
|
|||
UObject*
|
||||
ICULocaleService::get(const Locale& locale, int32_t kind, Locale* actualReturn, UErrorCode& status) const
|
||||
{
|
||||
UObject* result = NULL;
|
||||
UObject* result = nullptr;
|
||||
if (U_FAILURE(status)) {
|
||||
return result;
|
||||
}
|
||||
|
@ -73,13 +73,13 @@ ICULocaleService::get(const Locale& locale, int32_t kind, Locale* actualReturn,
|
|||
} else {
|
||||
ICUServiceKey* key = createKey(&locName, kind, status);
|
||||
if (key) {
|
||||
if (actualReturn == NULL) {
|
||||
if (actualReturn == nullptr) {
|
||||
result = getKey(*key, status);
|
||||
} else {
|
||||
UnicodeString temp;
|
||||
result = getKey(*key, &temp, status);
|
||||
|
||||
if (result != NULL) {
|
||||
if (result != nullptr) {
|
||||
key->parseSuffix(temp);
|
||||
LocaleUtility::initLocaleFromName(temp, *actualReturn);
|
||||
}
|
||||
|
@ -117,11 +117,11 @@ URegistryKey
|
|||
ICULocaleService::registerInstance(UObject* objToAdopt, const Locale& locale, int32_t kind, int32_t coverage, UErrorCode& status)
|
||||
{
|
||||
ICUServiceFactory * factory = new SimpleLocaleKeyFactory(objToAdopt, locale, kind, coverage);
|
||||
if (factory != NULL) {
|
||||
if (factory != nullptr) {
|
||||
return registerFactory(factory, status);
|
||||
}
|
||||
delete objToAdopt;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -143,11 +143,11 @@ URegistryKey
|
|||
ICULocaleService::registerInstance(UObject* objToAdopt, const UnicodeString& locale, int32_t kind, int32_t coverage, UErrorCode& status)
|
||||
{
|
||||
ICUServiceFactory * factory = new SimpleLocaleKeyFactory(objToAdopt, locale, kind, coverage);
|
||||
if (factory != NULL) {
|
||||
if (factory != nullptr) {
|
||||
return registerFactory(factory, status);
|
||||
}
|
||||
delete objToAdopt;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -162,7 +162,7 @@ private:
|
|||
ServiceEnumeration(const ICULocaleService* service, UErrorCode &status)
|
||||
: _service(service)
|
||||
, _timestamp(service->getTimestamp())
|
||||
, _ids(uprv_deleteUObject, NULL, status)
|
||||
, _ids(uprv_deleteUObject, nullptr, status)
|
||||
, _pos(0)
|
||||
{
|
||||
_service->getVisibleIDs(_ids, status);
|
||||
|
@ -171,7 +171,7 @@ private:
|
|||
ServiceEnumeration(const ServiceEnumeration &other, UErrorCode &status)
|
||||
: _service(other._service)
|
||||
, _timestamp(other._timestamp)
|
||||
, _ids(uprv_deleteUObject, NULL, status)
|
||||
, _ids(uprv_deleteUObject, nullptr, status)
|
||||
, _pos(0)
|
||||
{
|
||||
if(U_SUCCESS(status)) {
|
||||
|
@ -197,7 +197,7 @@ public:
|
|||
return result;
|
||||
}
|
||||
delete result;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual ~ServiceEnumeration();
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
ServiceEnumeration *cl = new ServiceEnumeration(*this, status);
|
||||
if(U_FAILURE(status)) {
|
||||
delete cl;
|
||||
cl = NULL;
|
||||
cl = nullptr;
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public:
|
|||
if (upToDate(status) && (_pos < _ids.size())) {
|
||||
return (const UnicodeString*)_ids[_pos++];
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void reset(UErrorCode& status) override {
|
||||
|
@ -245,8 +245,8 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
virtual UClassID getDynamicClassID(void) const override;
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
virtual UClassID getDynamicClassID() const override;
|
||||
};
|
||||
|
||||
ServiceEnumeration::~ServiceEnumeration() {}
|
||||
|
@ -254,7 +254,7 @@ ServiceEnumeration::~ServiceEnumeration() {}
|
|||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ServiceEnumeration)
|
||||
|
||||
StringEnumeration*
|
||||
ICULocaleService::getAvailableLocales(void) const
|
||||
ICULocaleService::getAvailableLocales() const
|
||||
{
|
||||
return ServiceEnumeration::create(this);
|
||||
}
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче