aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/i18n/rulebasedcollator.cpp
diff options
context:
space:
mode:
authorromankoshelev <romankoshelev@yandex-team.com>2023-08-14 19:51:50 +0300
committerromankoshelev <romankoshelev@yandex-team.com>2023-08-15 01:24:11 +0300
commitcfcd865e05c0d0525ea27d1e153a043b32a85138 (patch)
tree68d3b3b25271e8a4998505897a269ff7ce119b76 /contrib/libs/icu/i18n/rulebasedcollator.cpp
parentccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff)
downloadydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/i18n/rulebasedcollator.cpp')
-rw-r--r--contrib/libs/icu/i18n/rulebasedcollator.cpp205
1 files changed, 103 insertions, 102 deletions
diff --git a/contrib/libs/icu/i18n/rulebasedcollator.cpp b/contrib/libs/icu/i18n/rulebasedcollator.cpp
index 5e5cc3db62..e9482628d9 100644
--- a/contrib/libs/icu/i18n/rulebasedcollator.cpp
+++ b/contrib/libs/icu/i18n/rulebasedcollator.cpp
@@ -74,7 +74,7 @@ FixedSortKeyByteSink::~FixedSortKeyByteSink() {}
void
FixedSortKeyByteSink::AppendBeyondCapacity(const char *bytes, int32_t /*n*/, int32_t length) {
- // buffer_ != NULL && bytes != NULL && n > 0 && appended_ > capacity_
+ // buffer_ != nullptr && bytes != nullptr && n > 0 && appended_ > capacity_
// Fill the buffer completely.
int32_t available = capacity_ - length;
if (available > 0) {
@@ -84,7 +84,7 @@ FixedSortKeyByteSink::AppendBeyondCapacity(const char *bytes, int32_t /*n*/, int
UBool
FixedSortKeyByteSink::Resize(int32_t /*appendCapacity*/, int32_t /*length*/) {
- return FALSE;
+ return false;
}
} // namespace
@@ -108,7 +108,7 @@ CollationKeyByteSink::~CollationKeyByteSink() {}
void
CollationKeyByteSink::AppendBeyondCapacity(const char *bytes, int32_t n, int32_t length) {
- // buffer_ != NULL && bytes != NULL && n > 0 && appended_ > capacity_
+ // buffer_ != nullptr && bytes != nullptr && n > 0 && appended_ > capacity_
if (Resize(n, length)) {
uprv_memcpy(buffer_ + length, bytes, n);
}
@@ -116,8 +116,8 @@ CollationKeyByteSink::AppendBeyondCapacity(const char *bytes, int32_t n, int32_t
UBool
CollationKeyByteSink::Resize(int32_t appendCapacity, int32_t length) {
- if (buffer_ == NULL) {
- return FALSE; // allocation failed before already
+ if (buffer_ == nullptr) {
+ return false; // allocation failed before already
}
int32_t newCapacity = 2 * capacity_;
int32_t altCapacity = length + 2 * appendCapacity;
@@ -128,13 +128,13 @@ CollationKeyByteSink::Resize(int32_t appendCapacity, int32_t length) {
newCapacity = 200;
}
uint8_t *newBuffer = key_.reallocate(newCapacity, length);
- if (newBuffer == NULL) {
+ if (newBuffer == nullptr) {
SetNotOk();
- return FALSE;
+ return false;
}
buffer_ = reinterpret_cast<char *>(newBuffer);
capacity_ = newCapacity;
- return TRUE;
+ return true;
}
RuleBasedCollator::RuleBasedCollator(const RuleBasedCollator &other)
@@ -152,15 +152,15 @@ RuleBasedCollator::RuleBasedCollator(const RuleBasedCollator &other)
RuleBasedCollator::RuleBasedCollator(const uint8_t *bin, int32_t length,
const RuleBasedCollator *base, UErrorCode &errorCode)
- : data(NULL),
- settings(NULL),
- tailoring(NULL),
- cacheEntry(NULL),
+ : data(nullptr),
+ settings(nullptr),
+ tailoring(nullptr),
+ cacheEntry(nullptr),
validLocale(""),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
+ actualLocaleIsSameAsValid(false) {
if(U_FAILURE(errorCode)) { return; }
- if(bin == NULL || length == 0 || base == NULL) {
+ if(bin == nullptr || length == 0 || base == nullptr) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -188,7 +188,7 @@ RuleBasedCollator::RuleBasedCollator(const CollationCacheEntry *entry)
cacheEntry(entry),
validLocale(entry->validLocale),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
+ actualLocaleIsSameAsValid(false) {
settings->addRef();
cacheEntry->addRef();
}
@@ -204,9 +204,9 @@ RuleBasedCollator::adoptTailoring(CollationTailoring *t, UErrorCode &errorCode)
t->deleteIfZeroRefCount();
return;
}
- U_ASSERT(settings == NULL && data == NULL && tailoring == NULL && cacheEntry == NULL);
+ U_ASSERT(settings == nullptr && data == nullptr && tailoring == nullptr && cacheEntry == nullptr);
cacheEntry = new CollationCacheEntry(t->actualLocale, t);
- if(cacheEntry == NULL) {
+ if(cacheEntry == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
t->deleteIfZeroRefCount();
return;
@@ -217,7 +217,7 @@ RuleBasedCollator::adoptTailoring(CollationTailoring *t, UErrorCode &errorCode)
tailoring = t;
cacheEntry->addRef();
validLocale = t->actualLocale;
- actualLocaleIsSameAsValid = FALSE;
+ actualLocaleIsSameAsValid = false;
}
RuleBasedCollator *
@@ -246,8 +246,8 @@ RuleBasedCollator::operator==(const Collator& other) const {
const RuleBasedCollator &o = static_cast<const RuleBasedCollator &>(other);
if(*settings != *o.settings) { return false; }
if(data == o.data) { return true; }
- UBool thisIsRoot = data->base == NULL;
- UBool otherIsRoot = o.data->base == NULL;
+ UBool thisIsRoot = data->base == nullptr;
+ UBool otherIsRoot = o.data->base == nullptr;
U_ASSERT(!thisIsRoot || !otherIsRoot); // otherwise their data pointers should be ==
if(thisIsRoot != otherIsRoot) { return false; }
if((thisIsRoot || !tailoring->rules.isEmpty()) &&
@@ -274,7 +274,7 @@ RuleBasedCollator::operator==(const Collator& other) const {
int32_t
RuleBasedCollator::hashCode() const {
int32_t h = settings->hashCode();
- if(data->base == NULL) { return h; } // root collator
+ if(data->base == nullptr) { return h; } // root collator
// Do not rely on the rule string, see comments in operator==().
UErrorCode errorCode = U_ZERO_ERROR;
LocalPointer<UnicodeSet> set(getTailoredSet(errorCode));
@@ -290,10 +290,10 @@ void
RuleBasedCollator::setLocales(const Locale &requested, const Locale &valid,
const Locale &actual) {
if(actual == tailoring->actualLocale) {
- actualLocaleIsSameAsValid = FALSE;
+ actualLocaleIsSameAsValid = false;
} else {
U_ASSERT(actual == valid);
- actualLocaleIsSameAsValid = TRUE;
+ actualLocaleIsSameAsValid = true;
}
// Do not modify tailoring.actualLocale:
// We cannot be sure that that would be thread-safe.
@@ -321,7 +321,7 @@ RuleBasedCollator::getLocale(ULocDataLocaleType type, UErrorCode& errorCode) con
const char *
RuleBasedCollator::internalGetLocaleID(ULocDataLocaleType type, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) {
- return NULL;
+ return nullptr;
}
const Locale *result;
switch(type) {
@@ -334,9 +334,9 @@ RuleBasedCollator::internalGetLocaleID(ULocDataLocaleType type, UErrorCode &erro
case ULOC_REQUESTED_LOCALE:
default:
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
- if(result->isBogus()) { return NULL; }
+ if(result->isBogus()) { return nullptr; }
const char *id = result->getName();
return id[0] == 0 ? "root" : id;
}
@@ -366,17 +366,17 @@ RuleBasedCollator::getVersion(UVersionInfo version) const {
UnicodeSet *
RuleBasedCollator::getTailoredSet(UErrorCode &errorCode) const {
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
UnicodeSet *tailored = new UnicodeSet();
- if(tailored == NULL) {
+ if(tailored == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
- if(data->base != NULL) {
+ if(data->base != nullptr) {
TailoredSet(tailored).forData(data, errorCode);
if(U_FAILURE(errorCode)) {
delete tailored;
- return NULL;
+ return nullptr;
}
}
return tailored;
@@ -387,19 +387,19 @@ RuleBasedCollator::internalGetContractionsAndExpansions(
UnicodeSet *contractions, UnicodeSet *expansions,
UBool addPrefixes, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- if(contractions != NULL) {
+ if(contractions != nullptr) {
contractions->clear();
}
- if(expansions != NULL) {
+ if(expansions != nullptr) {
expansions->clear();
}
- ContractionsAndExpansions(contractions, expansions, NULL, addPrefixes).forData(data, errorCode);
+ ContractionsAndExpansions(contractions, expansions, nullptr, addPrefixes).forData(data, errorCode);
}
void
RuleBasedCollator::internalAddContractions(UChar32 c, UnicodeSet &set, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- ContractionsAndExpansions(&set, NULL, NULL, FALSE).forCodePoint(data, c, errorCode);
+ ContractionsAndExpansions(&set, nullptr, nullptr, false).forCodePoint(data, c, errorCode);
}
const CollationSettings &
@@ -457,7 +457,7 @@ RuleBasedCollator::setAttribute(UColAttribute attr, UColAttributeValue value,
}
}
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -532,13 +532,14 @@ RuleBasedCollator::setMaxVariable(UColReorderCode group, UErrorCode &errorCode)
}
}
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return *this;
}
if(group == UCOL_REORDER_CODE_DEFAULT) {
- group = (UColReorderCode)(UCOL_REORDER_CODE_FIRST + defaultSettings.getMaxVariable());
+ group = (UColReorderCode)(
+ UCOL_REORDER_CODE_FIRST + int32_t{defaultSettings.getMaxVariable()});
}
uint32_t varTop = data->getLastPrimaryForGroup(group);
U_ASSERT(varTop != 0);
@@ -556,7 +557,7 @@ RuleBasedCollator::setMaxVariable(UColReorderCode group, UErrorCode &errorCode)
UColReorderCode
RuleBasedCollator::getMaxVariable() const {
- return (UColReorderCode)(UCOL_REORDER_CODE_FIRST + settings->getMaxVariable());
+ return (UColReorderCode)(UCOL_REORDER_CODE_FIRST + int32_t{settings->getMaxVariable()});
}
uint32_t
@@ -565,9 +566,9 @@ RuleBasedCollator::getVariableTop(UErrorCode & /*errorCode*/) const {
}
uint32_t
-RuleBasedCollator::setVariableTop(const UChar *varTop, int32_t len, UErrorCode &errorCode) {
+RuleBasedCollator::setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return 0; }
- if(varTop == NULL && len !=0) {
+ if(varTop == nullptr && len !=0) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -616,7 +617,7 @@ RuleBasedCollator::setVariableTop(uint32_t varTop, UErrorCode &errorCode) {
varTop = v;
if(varTop != settings->variableTop) {
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -638,7 +639,7 @@ int32_t
RuleBasedCollator::getReorderCodes(int32_t *dest, int32_t capacity,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return 0; }
- if(capacity < 0 || (dest == NULL && capacity > 0)) {
+ if(capacity < 0 || (dest == nullptr && capacity > 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -656,7 +657,7 @@ void
RuleBasedCollator::setReorderCodes(const int32_t *reorderCodes, int32_t length,
UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- if(length < 0 || (reorderCodes == NULL && length > 0)) {
+ if(length < 0 || (reorderCodes == nullptr && length > 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -671,7 +672,7 @@ RuleBasedCollator::setReorderCodes(const int32_t *reorderCodes, int32_t length,
if(length == 1 && reorderCodes[0] == UCOL_REORDER_CODE_DEFAULT) {
if(settings != &defaultSettings) {
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -681,7 +682,7 @@ RuleBasedCollator::setReorderCodes(const int32_t *reorderCodes, int32_t length,
return;
}
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -721,11 +722,11 @@ RuleBasedCollator::compare(const UnicodeString &left, const UnicodeString &right
}
UCollationResult
-RuleBasedCollator::compare(const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength,
+RuleBasedCollator::compare(const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return UCOL_EQUAL; }
- if((left == NULL && leftLength != 0) || (right == NULL && rightLength != 0)) {
+ if((left == nullptr && leftLength != 0) || (right == nullptr && rightLength != 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return UCOL_EQUAL;
}
@@ -745,7 +746,7 @@ RuleBasedCollator::compareUTF8(const StringPiece &left, const StringPiece &right
if(U_FAILURE(errorCode)) { return UCOL_EQUAL; }
const uint8_t *leftBytes = reinterpret_cast<const uint8_t *>(left.data());
const uint8_t *rightBytes = reinterpret_cast<const uint8_t *>(right.data());
- if((leftBytes == NULL && !left.empty()) || (rightBytes == NULL && !right.empty())) {
+ if((leftBytes == nullptr && !left.empty()) || (rightBytes == nullptr && !right.empty())) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return UCOL_EQUAL;
}
@@ -757,7 +758,7 @@ RuleBasedCollator::internalCompareUTF8(const char *left, int32_t leftLength,
const char *right, int32_t rightLength,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return UCOL_EQUAL; }
- if((left == NULL && leftLength != 0) || (right == NULL && rightLength != 0)) {
+ if((left == nullptr && leftLength != 0) || (right == nullptr && rightLength != 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return UCOL_EQUAL;
}
@@ -808,7 +809,7 @@ public:
UChar32 nextDecomposedCodePoint(const Normalizer2Impl &nfcImpl, UChar32 c) {
if(index >= 0) { return c; }
decomp = nfcImpl.getDecomposition(c, buffer, length);
- if(decomp == NULL) { return c; }
+ if(decomp == nullptr) { return c; }
index = 0;
U16_NEXT_UNSAFE(decomp, index, c);
return c;
@@ -820,24 +821,24 @@ protected:
*/
virtual UChar32 nextRawCodePoint() = 0;
private:
- const UChar *decomp;
- UChar buffer[4];
+ const char16_t *decomp;
+ char16_t buffer[4];
int32_t index;
int32_t length;
};
class UTF16NFDIterator : public NFDIterator {
public:
- UTF16NFDIterator(const UChar *text, const UChar *textLimit) : s(text), limit(textLimit) {}
+ UTF16NFDIterator(const char16_t *text, const char16_t *textLimit) : s(text), limit(textLimit) {}
protected:
virtual UChar32 nextRawCodePoint() override {
if(s == limit) { return U_SENTINEL; }
UChar32 c = *s++;
- if(limit == NULL && c == 0) {
- s = NULL;
+ if(limit == nullptr && c == 0) {
+ s = nullptr;
return U_SENTINEL;
}
- UChar trail;
+ char16_t trail;
if(U16_IS_LEAD(c) && s != limit && U16_IS_TRAIL(trail = *s)) {
++s;
c = U16_GET_SUPPLEMENTARY(c, trail);
@@ -845,18 +846,18 @@ protected:
return c;
}
- const UChar *s;
- const UChar *limit;
+ const char16_t *s;
+ const char16_t *limit;
};
class FCDUTF16NFDIterator : public UTF16NFDIterator {
public:
- FCDUTF16NFDIterator(const Normalizer2Impl &nfcImpl, const UChar *text, const UChar *textLimit)
- : UTF16NFDIterator(NULL, NULL) {
+ FCDUTF16NFDIterator(const Normalizer2Impl &nfcImpl, const char16_t *text, const char16_t *textLimit)
+ : UTF16NFDIterator(nullptr, nullptr) {
UErrorCode errorCode = U_ZERO_ERROR;
- const UChar *spanLimit = nfcImpl.makeFCD(text, textLimit, NULL, errorCode);
+ const char16_t *spanLimit = nfcImpl.makeFCD(text, textLimit, nullptr, errorCode);
if(U_FAILURE(errorCode)) { return; }
- if(spanLimit == textLimit || (textLimit == NULL && *spanLimit == 0)) {
+ if(spanLimit == textLimit || (textLimit == nullptr && *spanLimit == 0)) {
s = text;
limit = spanLimit;
} else {
@@ -897,7 +898,7 @@ protected:
class FCDUTF8NFDIterator : public NFDIterator {
public:
FCDUTF8NFDIterator(const CollationData *data, const uint8_t *text, int32_t textLength)
- : u8ci(data, FALSE, text, 0, textLength) {}
+ : u8ci(data, false, text, 0, textLength) {}
protected:
virtual UChar32 nextRawCodePoint() override {
UErrorCode errorCode = U_ZERO_ERROR;
@@ -921,7 +922,7 @@ private:
class FCDUIterNFDIterator : public NFDIterator {
public:
FCDUIterNFDIterator(const CollationData *data, UCharIterator &it, int32_t startIndex)
- : uici(data, FALSE, it, startIndex) {}
+ : uici(data, false, it, startIndex) {}
protected:
virtual UChar32 nextRawCodePoint() override {
UErrorCode errorCode = U_ZERO_ERROR;
@@ -965,8 +966,8 @@ UCollationResult compareNFDIter(const Normalizer2Impl &nfcImpl,
} // namespace
UCollationResult
-RuleBasedCollator::doCompare(const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength,
+RuleBasedCollator::doCompare(const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength,
UErrorCode &errorCode) const {
// U_FAILURE(errorCode) checked by caller.
if(left == right && leftLength == rightLength) {
@@ -974,13 +975,13 @@ RuleBasedCollator::doCompare(const UChar *left, int32_t leftLength,
}
// Identical-prefix test.
- const UChar *leftLimit;
- const UChar *rightLimit;
+ const char16_t *leftLimit;
+ const char16_t *rightLimit;
int32_t equalPrefixLength = 0;
if(leftLength < 0) {
- leftLimit = NULL;
- rightLimit = NULL;
- UChar c;
+ leftLimit = nullptr;
+ rightLimit = nullptr;
+ char16_t c;
while((c = left[equalPrefixLength]) == right[equalPrefixLength]) {
if(c == 0) { return UCOL_EQUAL; }
++equalPrefixLength;
@@ -1121,7 +1122,7 @@ RuleBasedCollator::doCompare(const uint8_t *left, int32_t leftLength,
UBool numeric = settings->isNumeric();
if(equalPrefixLength > 0) {
- UBool unsafe = FALSE;
+ UBool unsafe = false;
if(equalPrefixLength != leftLength) {
int32_t i = equalPrefixLength;
UChar32 c;
@@ -1282,12 +1283,12 @@ RuleBasedCollator::getCollationKey(const UnicodeString &s, CollationKey &key,
}
CollationKey &
-RuleBasedCollator::getCollationKey(const UChar *s, int32_t length, CollationKey& key,
+RuleBasedCollator::getCollationKey(const char16_t *s, int32_t length, CollationKey& key,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) {
return key.setToBogus();
}
- if(s == NULL && length != 0) {
+ if(s == nullptr && length != 0) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return key.setToBogus();
}
@@ -1311,13 +1312,13 @@ RuleBasedCollator::getSortKey(const UnicodeString &s,
}
int32_t
-RuleBasedCollator::getSortKey(const UChar *s, int32_t length,
+RuleBasedCollator::getSortKey(const char16_t *s, int32_t length,
uint8_t *dest, int32_t capacity) const {
- if((s == NULL && length != 0) || capacity < 0 || (dest == NULL && capacity > 0)) {
+ if((s == nullptr && length != 0) || capacity < 0 || (dest == nullptr && capacity > 0)) {
return 0;
}
uint8_t noDest[1] = { 0 };
- if(dest == NULL) {
+ if(dest == nullptr) {
// Distinguish pure preflighting from an allocation error.
dest = noDest;
capacity = 0;
@@ -1329,22 +1330,22 @@ RuleBasedCollator::getSortKey(const UChar *s, int32_t length,
}
void
-RuleBasedCollator::writeSortKey(const UChar *s, int32_t length,
+RuleBasedCollator::writeSortKey(const char16_t *s, int32_t length,
SortKeyByteSink &sink, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- const UChar *limit = (length >= 0) ? s + length : NULL;
+ const char16_t *limit = (length >= 0) ? s + length : nullptr;
UBool numeric = settings->isNumeric();
CollationKeys::LevelCallback callback;
if(settings->dontCheckFCD()) {
UTF16CollationIterator iter(data, numeric, s, s, limit);
CollationKeys::writeSortKeyUpToQuaternary(iter, data->compressibleBytes, *settings,
sink, Collation::PRIMARY_LEVEL,
- callback, TRUE, errorCode);
+ callback, true, errorCode);
} else {
FCDUTF16CollationIterator iter(data, numeric, s, s, limit);
CollationKeys::writeSortKeyUpToQuaternary(iter, data->compressibleBytes, *settings,
sink, Collation::PRIMARY_LEVEL,
- callback, TRUE, errorCode);
+ callback, true, errorCode);
}
if(settings->getStrength() == UCOL_IDENTICAL) {
writeIdenticalLevel(s, limit, sink, errorCode);
@@ -1354,10 +1355,10 @@ RuleBasedCollator::writeSortKey(const UChar *s, int32_t length,
}
void
-RuleBasedCollator::writeIdenticalLevel(const UChar *s, const UChar *limit,
+RuleBasedCollator::writeIdenticalLevel(const char16_t *s, const char16_t *limit,
SortKeyByteSink &sink, UErrorCode &errorCode) const {
// NFD quick check
- const UChar *nfdQCYesLimit = data->nfcImpl.decompose(s, limit, NULL, errorCode);
+ const char16_t *nfdQCYesLimit = data->nfcImpl.decompose(s, limit, nullptr, errorCode);
if(U_FAILURE(errorCode)) { return; }
sink.Append(Collation::LEVEL_SEPARATOR_BYTE);
UChar32 prev = 0;
@@ -1366,7 +1367,7 @@ RuleBasedCollator::writeIdenticalLevel(const UChar *s, const UChar *limit,
}
// Is there non-NFD text?
int32_t destLengthEstimate;
- if(limit != NULL) {
+ if(limit != nullptr) {
if(nfdQCYesLimit == limit) { return; }
destLengthEstimate = (int32_t)(limit - nfdQCYesLimit);
} else {
@@ -1403,9 +1404,9 @@ public:
// Remember a level that will be at least partially written.
level = l;
levelCapacity = sink.GetRemainingCapacity();
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
Collation::Level getLevel() const { return level; }
@@ -1423,7 +1424,7 @@ int32_t
RuleBasedCollator::internalNextSortKeyPart(UCharIterator *iter, uint32_t state[2],
uint8_t *dest, int32_t count, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return 0; }
- if(iter == NULL || state == NULL || count < 0 || (count > 0 && dest == NULL)) {
+ if(iter == nullptr || state == nullptr || count < 0 || (count > 0 && dest == nullptr)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -1440,11 +1441,11 @@ RuleBasedCollator::internalNextSortKeyPart(UCharIterator *iter, uint32_t state[2
if(settings->dontCheckFCD()) {
UIterCollationIterator ci(data, numeric, *iter);
CollationKeys::writeSortKeyUpToQuaternary(ci, data->compressibleBytes, *settings,
- sink, level, callback, FALSE, errorCode);
+ sink, level, callback, false, errorCode);
} else {
FCDUIterCollationIterator ci(data, numeric, *iter, 0);
CollationKeys::writeSortKeyUpToQuaternary(ci, data->compressibleBytes, *settings,
- sink, level, callback, FALSE, errorCode);
+ sink, level, callback, false, errorCode);
}
if(U_FAILURE(errorCode)) { return 0; }
if(sink.NumberOfBytesAppended() > count) {
@@ -1466,9 +1467,9 @@ RuleBasedCollator::internalNextSortKeyPart(UCharIterator *iter, uint32_t state[2
for(;;) {
UChar32 c = iter->next(iter);
if(c < 0) { break; }
- s.append((UChar)c);
+ s.append((char16_t)c);
}
- const UChar *sArray = s.getBuffer();
+ const char16_t *sArray = s.getBuffer();
writeIdenticalLevel(sArray, sArray + s.length(), sink, errorCode);
if(U_FAILURE(errorCode)) { return 0; }
if(sink.NumberOfBytesAppended() > count) {
@@ -1491,8 +1492,8 @@ void
RuleBasedCollator::internalGetCEs(const UnicodeString &str, UVector64 &ces,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- const UChar *s = str.getBuffer();
- const UChar *limit = s + str.length();
+ const char16_t *s = str.getBuffer();
+ const char16_t *limit = s + str.length();
UBool numeric = settings->isNumeric();
if(settings->dontCheckFCD()) {
UTF16CollationIterator iter(data, numeric, s, s, limit);
@@ -1541,18 +1542,18 @@ RuleBasedCollator::internalGetShortDefinitionString(const char *locale,
char *buffer, int32_t capacity,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return 0; }
- if(buffer == NULL ? capacity != 0 : capacity < 0) {
+ if(buffer == nullptr ? capacity != 0 : capacity < 0) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
- if(locale == NULL) {
+ if(locale == nullptr) {
locale = internalGetLocaleID(ULOC_VALID_LOCALE, errorCode);
}
char resultLocale[ULOC_FULLNAME_CAPACITY + 1];
int32_t length = ucol_getFunctionalEquivalent(resultLocale, ULOC_FULLNAME_CAPACITY,
"collation", locale,
- NULL, &errorCode);
+ nullptr, &errorCode);
if(U_FAILURE(errorCode)) { return 0; }
resultLocale[length] = 0;
@@ -1622,11 +1623,11 @@ RuleBasedCollator::initMaxExpansions(UErrorCode &errorCode) const {
CollationElementIterator *
RuleBasedCollator::createCollationElementIterator(const UnicodeString& source) const {
UErrorCode errorCode = U_ZERO_ERROR;
- if(!initMaxExpansions(errorCode)) { return NULL; }
+ if(!initMaxExpansions(errorCode)) { return nullptr; }
CollationElementIterator *cei = new CollationElementIterator(source, this, errorCode);
if(U_FAILURE(errorCode)) {
delete cei;
- return NULL;
+ return nullptr;
}
return cei;
}
@@ -1634,11 +1635,11 @@ RuleBasedCollator::createCollationElementIterator(const UnicodeString& source) c
CollationElementIterator *
RuleBasedCollator::createCollationElementIterator(const CharacterIterator& source) const {
UErrorCode errorCode = U_ZERO_ERROR;
- if(!initMaxExpansions(errorCode)) { return NULL; }
+ if(!initMaxExpansions(errorCode)) { return nullptr; }
CollationElementIterator *cei = new CollationElementIterator(source, this, errorCode);
if(U_FAILURE(errorCode)) {
delete cei;
- return NULL;
+ return nullptr;
}
return cei;
}