mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
deps: update icu to 79.1
This commit is contained in:
1 parent
cb05e4d0c2
commit
503702e89b
356 files changed
+18716
-15155
No files matched your search
Vendored
+1
-1
@@ -2,7 +2,7 @@ UNICODE LICENSE V3
|
||||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright © 2016-2025 Unicode, Inc.
|
||||
Copyright © 1991-2026 Unicode, Inc.
|
||||
|
||||
NOTICE TO USER: Carefully read the following legal agreement. BY
|
||||
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
ICU sources - auto generated by shrink-icu-src.py
|
||||
|
||||
This directory contains the ICU subset used by --with-intl=full-icu
|
||||
It is a strict subset of ICU 78 source files with the following exception(s):
|
||||
* deps/icu-small/source/data/in/icudt78l.dat.bz2 : compressed data file
|
||||
It is a strict subset of ICU 79 source files with the following exception(s):
|
||||
* deps/icu-small/source/data/in/icudt79l.dat.bz2 : compressed data file
|
||||
|
||||
|
||||
To rebuild this directory, see ../../tools/icu/README.md
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 105
|
||||
ColumnLimit: 100
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
...
|
||||
+3
@@ -36,6 +36,9 @@ cc_library(
|
||||
# Bazel workspace:
|
||||
# https://stackoverflow.com/a/65635893/2077918
|
||||
includes = ["."],
|
||||
defines = [
|
||||
"U_DEBUG", # enable U_ASSERT()
|
||||
],
|
||||
local_defines = [
|
||||
"U_COMMON_IMPLEMENTATION",
|
||||
],
|
||||
|
||||
+4
-3
@@ -56,11 +56,12 @@ Appendable::reserveAppendCapacity(int32_t /*appendCapacity*/) {
|
||||
return true;
|
||||
}
|
||||
|
||||
char16_t *
|
||||
char16_t*
|
||||
Appendable::getAppendBuffer(int32_t minCapacity,
|
||||
int32_t /*desiredCapacityHint*/,
|
||||
char16_t *scratch, int32_t scratchCapacity,
|
||||
int32_t *resultCapacity) {
|
||||
char16_t* scratch U_LIFETIME_BOUND,
|
||||
int32_t scratchCapacity,
|
||||
int32_t* resultCapacity) U_LIFETIME_BOUND {
|
||||
if(minCapacity<1 || scratchCapacity<minCapacity) {
|
||||
*resultCapacity=0;
|
||||
return nullptr;
|
||||
|
||||
+3
-3
@@ -213,7 +213,7 @@ BreakIterator::BreakIterator(const BreakIterator &other)
|
||||
requestLocale(other.requestLocale) {
|
||||
}
|
||||
|
||||
BreakIterator &BreakIterator::operator =(const BreakIterator &other) {
|
||||
BreakIterator& BreakIterator::operator=(const BreakIterator& other) U_LIFETIME_BOUND {
|
||||
if (this != &other) {
|
||||
actualLocale = other.actualLocale;
|
||||
validLocale = other.validLocale;
|
||||
@@ -504,8 +504,8 @@ BreakIterator::getLocale(ULocDataLocaleType type, UErrorCode& status) const {
|
||||
return LocaleBased::getLocale(validLocale, actualLocale, type, status);
|
||||
}
|
||||
|
||||
const char *
|
||||
BreakIterator::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const {
|
||||
const char*
|
||||
BreakIterator::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+2
-2
@@ -136,9 +136,9 @@ CharStringByteSink::Append(const char* bytes, int32_t n) {
|
||||
char*
|
||||
CharStringByteSink::GetAppendBuffer(int32_t min_capacity,
|
||||
int32_t desired_capacity_hint,
|
||||
char* scratch,
|
||||
char* scratch U_LIFETIME_BOUND,
|
||||
int32_t scratch_capacity,
|
||||
int32_t* result_capacity) {
|
||||
int32_t* result_capacity) U_LIFETIME_BOUND {
|
||||
if (min_capacity < 1 || scratch_capacity < min_capacity) {
|
||||
*result_capacity = 0;
|
||||
return nullptr;
|
||||
|
||||
+2
-2
@@ -35,9 +35,9 @@ public:
|
||||
|
||||
char* GetAppendBuffer(int32_t min_capacity,
|
||||
int32_t desired_capacity_hint,
|
||||
char* scratch,
|
||||
char* scratch U_LIFETIME_BOUND,
|
||||
int32_t scratch_capacity,
|
||||
int32_t* result_capacity) override;
|
||||
int32_t* result_capacity) U_LIFETIME_BOUND override;
|
||||
|
||||
private:
|
||||
CharString& dest_;
|
||||
|
||||
+6
-5
@@ -16,8 +16,9 @@ ByteSink::~ByteSink() {}
|
||||
|
||||
char* ByteSink::GetAppendBuffer(int32_t min_capacity,
|
||||
int32_t /*desired_capacity_hint*/,
|
||||
char* scratch, int32_t scratch_capacity,
|
||||
int32_t* result_capacity) {
|
||||
char* scratch U_LIFETIME_BOUND,
|
||||
int32_t scratch_capacity,
|
||||
int32_t* result_capacity) U_LIFETIME_BOUND {
|
||||
if (min_capacity < 1 || scratch_capacity < min_capacity) {
|
||||
*result_capacity = 0;
|
||||
return nullptr;
|
||||
@@ -35,7 +36,7 @@ CheckedArrayByteSink::CheckedArrayByteSink(char* outbuf, int32_t capacity)
|
||||
|
||||
CheckedArrayByteSink::~CheckedArrayByteSink() {}
|
||||
|
||||
CheckedArrayByteSink& CheckedArrayByteSink::Reset() {
|
||||
CheckedArrayByteSink& CheckedArrayByteSink::Reset() U_LIFETIME_BOUND {
|
||||
size_ = appended_ = 0;
|
||||
overflowed_ = false;
|
||||
return *this;
|
||||
@@ -65,9 +66,9 @@ void CheckedArrayByteSink::Append(const char* bytes, int32_t n) {
|
||||
|
||||
char* CheckedArrayByteSink::GetAppendBuffer(int32_t min_capacity,
|
||||
int32_t /*desired_capacity_hint*/,
|
||||
char* scratch,
|
||||
char* scratch U_LIFETIME_BOUND,
|
||||
int32_t scratch_capacity,
|
||||
int32_t* result_capacity) {
|
||||
int32_t* result_capacity) U_LIFETIME_BOUND {
|
||||
if (min_capacity < 1 || scratch_capacity < min_capacity) {
|
||||
*result_capacity = 0;
|
||||
return nullptr;
|
||||
|
||||
+7
-5
@@ -45,8 +45,8 @@ BytesTrie::readValue(const uint8_t *pos, int32_t leadByte) {
|
||||
return value;
|
||||
}
|
||||
|
||||
const uint8_t *
|
||||
BytesTrie::jumpByDelta(const uint8_t *pos) {
|
||||
const uint8_t*
|
||||
BytesTrie::jumpByDelta(const uint8_t* pos U_LIFETIME_BOUND) {
|
||||
int32_t delta=*pos++;
|
||||
if(delta<kMinTwoByteDeltaLead) {
|
||||
// nothing to do
|
||||
@@ -312,9 +312,11 @@ BytesTrie::next(const char *s, int32_t sLength) {
|
||||
}
|
||||
}
|
||||
|
||||
const uint8_t *
|
||||
BytesTrie::findUniqueValueFromBranch(const uint8_t *pos, int32_t length,
|
||||
UBool haveUniqueValue, int32_t &uniqueValue) {
|
||||
const uint8_t*
|
||||
BytesTrie::findUniqueValueFromBranch(const uint8_t* pos U_LIFETIME_BOUND,
|
||||
int32_t length,
|
||||
UBool haveUniqueValue,
|
||||
int32_t& uniqueValue) {
|
||||
while(length>kMaxBranchLinearSubNodeLength) {
|
||||
++pos; // ignore the comparison byte
|
||||
if(nullptr==findUniqueValueFromBranch(jumpByDelta(pos), length>>1, haveUniqueValue, uniqueValue)) {
|
||||
|
||||
+8
-7
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
void setTo(StringPiece s, int32_t val, CharString &strings, UErrorCode &errorCode);
|
||||
|
||||
StringPiece getString(const CharString &strings) const {
|
||||
StringPiece getString(const CharString& strings U_LIFETIME_BOUND) const {
|
||||
int32_t offset=stringOffset;
|
||||
int32_t length;
|
||||
if(offset>=0) {
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
int32_t compareStringTo(const BytesTrieElement &o, const CharString &strings) const;
|
||||
|
||||
private:
|
||||
const char *data(const CharString &strings) const {
|
||||
const char* data(const CharString& strings U_LIFETIME_BOUND) const {
|
||||
int32_t offset=stringOffset;
|
||||
if(offset>=0) {
|
||||
++offset;
|
||||
@@ -144,8 +144,8 @@ BytesTrieBuilder::~BytesTrieBuilder() {
|
||||
uprv_free(bytes);
|
||||
}
|
||||
|
||||
BytesTrieBuilder &
|
||||
BytesTrieBuilder::add(StringPiece s, int32_t value, UErrorCode &errorCode) {
|
||||
BytesTrieBuilder&
|
||||
BytesTrieBuilder::add(StringPiece s, int32_t value, UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
@@ -206,7 +206,8 @@ BytesTrieBuilder::build(UStringTrieBuildOption buildOption, UErrorCode &errorCod
|
||||
}
|
||||
|
||||
StringPiece
|
||||
BytesTrieBuilder::buildStringPiece(UStringTrieBuildOption buildOption, UErrorCode &errorCode) {
|
||||
BytesTrieBuilder::buildStringPiece(UStringTrieBuildOption buildOption,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
buildBytes(buildOption, errorCode);
|
||||
StringPiece result;
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
@@ -269,8 +270,8 @@ BytesTrieBuilder::buildBytes(UStringTrieBuildOption buildOption, UErrorCode &err
|
||||
}
|
||||
}
|
||||
|
||||
BytesTrieBuilder &
|
||||
BytesTrieBuilder::clear() {
|
||||
BytesTrieBuilder&
|
||||
BytesTrieBuilder::clear() U_LIFETIME_BOUND {
|
||||
strings->clear();
|
||||
elementsLength=0;
|
||||
bytesLength=0;
|
||||
|
||||
+10
-7
@@ -22,8 +22,9 @@
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
BytesTrie::Iterator::Iterator(const void *trieBytes, int32_t maxStringLength,
|
||||
UErrorCode &errorCode)
|
||||
BytesTrie::Iterator::Iterator(const void* trieBytes U_LIFETIME_BOUND,
|
||||
int32_t maxStringLength,
|
||||
UErrorCode& errorCode)
|
||||
: bytes_(static_cast<const uint8_t *>(trieBytes)),
|
||||
pos_(bytes_), initialPos_(bytes_),
|
||||
remainingMatchLength_(-1), initialRemainingMatchLength_(-1),
|
||||
@@ -80,8 +81,8 @@ BytesTrie::Iterator::~Iterator() {
|
||||
delete stack_;
|
||||
}
|
||||
|
||||
BytesTrie::Iterator &
|
||||
BytesTrie::Iterator::reset() {
|
||||
BytesTrie::Iterator&
|
||||
BytesTrie::Iterator::reset() U_LIFETIME_BOUND {
|
||||
pos_=initialPos_;
|
||||
remainingMatchLength_=initialRemainingMatchLength_;
|
||||
int32_t length=remainingMatchLength_+1; // Remaining match length.
|
||||
@@ -169,7 +170,7 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
||||
}
|
||||
|
||||
StringPiece
|
||||
BytesTrie::Iterator::getString() const {
|
||||
BytesTrie::Iterator::getString() const U_LIFETIME_BOUND {
|
||||
return str_ == nullptr ? StringPiece() : str_->toStringPiece();
|
||||
}
|
||||
|
||||
@@ -181,8 +182,10 @@ BytesTrie::Iterator::truncateAndStop() {
|
||||
}
|
||||
|
||||
// Branch node, needs to take the first outbound edge and push state for the rest.
|
||||
const uint8_t *
|
||||
BytesTrie::Iterator::branchNext(const uint8_t *pos, int32_t length, UErrorCode &errorCode) {
|
||||
const uint8_t*
|
||||
BytesTrie::Iterator::branchNext(const uint8_t* pos U_LIFETIME_BOUND,
|
||||
int32_t length,
|
||||
UErrorCode& errorCode) {
|
||||
while(length>kMaxBranchLinearSubNodeLength) {
|
||||
++pos; // ignore the comparison byte
|
||||
// Push state for the greater-or-equal edge.
|
||||
|
||||
+10
-3
@@ -440,8 +440,10 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const char16_t *segment, int32_t segLen, UErrorCode &status) {
|
||||
|
||||
Hashtable* CanonicalIterator::getEquivalents2(Hashtable* fillinResult U_LIFETIME_BOUND,
|
||||
const char16_t* segment,
|
||||
int32_t segLen,
|
||||
UErrorCode& status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -518,7 +520,12 @@ Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const cha
|
||||
* (with canonical rearrangement!)
|
||||
* If so, take the remainder, and return the equivalents
|
||||
*/
|
||||
Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, const char16_t *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
|
||||
Hashtable* CanonicalIterator::extract(Hashtable* fillinResult U_LIFETIME_BOUND,
|
||||
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);
|
||||
|
||||
+2
-2
@@ -73,8 +73,8 @@ textLength(that.textLength), pos(that.pos), begin(that.begin), end(that.end)
|
||||
{
|
||||
}
|
||||
|
||||
CharacterIterator &
|
||||
CharacterIterator::operator=(const CharacterIterator &that) {
|
||||
CharacterIterator&
|
||||
CharacterIterator::operator=(const CharacterIterator& that) U_LIFETIME_BOUND {
|
||||
ForwardCharacterIterator::operator=(that);
|
||||
textLength = that.textLength;
|
||||
pos = that.pos;
|
||||
|
||||
+64
-13
@@ -21,6 +21,7 @@
|
||||
#include "charstr.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "putilimp.h"
|
||||
#include "uinvchar.h"
|
||||
#include "ustr_imp.h"
|
||||
|
||||
@@ -111,7 +112,15 @@ CharString &CharString::truncate(int32_t newLength) {
|
||||
}
|
||||
|
||||
CharString &CharString::append(char c, UErrorCode &errorCode) {
|
||||
if(ensureCapacity(len+2, 0, errorCode)) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
int32_t newCapacity;
|
||||
if (uprv_add32_overflow(len, 2, &newCapacity)) {
|
||||
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return *this;
|
||||
}
|
||||
if(ensureCapacity(newCapacity, 0, errorCode)) {
|
||||
buffer[len++]=c;
|
||||
buffer[len]=0;
|
||||
}
|
||||
@@ -138,15 +147,21 @@ CharString &CharString::append(const char *s, int32_t sLength, UErrorCode &error
|
||||
} else {
|
||||
buffer[len+=sLength]=0;
|
||||
}
|
||||
} else if(buffer.getAlias()<=s && s<(buffer.getAlias()+len) &&
|
||||
sLength>=(buffer.getCapacity()-len)
|
||||
) {
|
||||
// (Part of) this string is appended to itself which requires reallocation,
|
||||
// so we have to make a copy of the substring and append that.
|
||||
return append(CharString(s, sLength, errorCode), errorCode);
|
||||
} else if(ensureCapacity(len+sLength+1, 0, errorCode)) {
|
||||
uprv_memcpy(buffer.getAlias()+len, s, sLength);
|
||||
buffer[len+=sLength]=0;
|
||||
} else {
|
||||
int32_t newCapacity;
|
||||
if(uprv_add32_overflow(len, sLength, &newCapacity) ||
|
||||
uprv_add32_overflow(newCapacity, 1, &newCapacity)) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
} else if(buffer.getAlias()<=s && s<(buffer.getAlias()+len) &&
|
||||
newCapacity>buffer.getCapacity()
|
||||
) {
|
||||
// (Part of) this string is appended to itself which requires reallocation,
|
||||
// so we have to make a copy of the substring and append that.
|
||||
return append(CharString(s, sLength, errorCode), errorCode);
|
||||
} else if(ensureCapacity(newCapacity, 0, errorCode)) {
|
||||
uprv_memcpy(buffer.getAlias()+len, s, sLength);
|
||||
buffer[len+=sLength]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@@ -192,12 +207,30 @@ char *CharString::getAppendBuffer(int32_t minCapacity,
|
||||
resultCapacity=0;
|
||||
return nullptr;
|
||||
}
|
||||
if(minCapacity<0 || desiredCapacityHint<0) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
resultCapacity=0;
|
||||
return nullptr;
|
||||
}
|
||||
int32_t appendCapacity=buffer.getCapacity()-len-1; // -1 for NUL
|
||||
if(appendCapacity>=minCapacity) {
|
||||
resultCapacity=appendCapacity;
|
||||
return buffer.getAlias()+len;
|
||||
}
|
||||
if(ensureCapacity(len+minCapacity+1, len+desiredCapacityHint+1, errorCode)) {
|
||||
int32_t newCapacity;
|
||||
if(uprv_add32_overflow(len, minCapacity, &newCapacity) ||
|
||||
uprv_add32_overflow(newCapacity, 1, &newCapacity)) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
resultCapacity=0;
|
||||
return nullptr;
|
||||
}
|
||||
int32_t newDesiredCapacity = 0;
|
||||
if(desiredCapacityHint > 0 &&
|
||||
(uprv_add32_overflow(len, desiredCapacityHint, &newDesiredCapacity) ||
|
||||
uprv_add32_overflow(newDesiredCapacity, 1, &newDesiredCapacity))) {
|
||||
newDesiredCapacity = 0;
|
||||
}
|
||||
if(ensureCapacity(newCapacity, newDesiredCapacity, errorCode)) {
|
||||
resultCapacity=buffer.getCapacity()-len-1;
|
||||
return buffer.getAlias()+len;
|
||||
}
|
||||
@@ -213,11 +246,21 @@ CharString &CharString::appendInvariantChars(const char16_t* uchars, int32_t uch
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
if(ucharsLen < 0 || (uchars == nullptr && ucharsLen != 0)) {
|
||||
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return *this;
|
||||
}
|
||||
if (!uprv_isInvariantUString(uchars, ucharsLen)) {
|
||||
errorCode = U_INVARIANT_CONVERSION_ERROR;
|
||||
return *this;
|
||||
}
|
||||
if(ensureCapacity(len+ucharsLen+1, 0, errorCode)) {
|
||||
int32_t newCapacity;
|
||||
if (uprv_add32_overflow(len, ucharsLen, &newCapacity) ||
|
||||
uprv_add32_overflow(newCapacity, 1, &newCapacity)) {
|
||||
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return *this;
|
||||
}
|
||||
if(ensureCapacity(newCapacity, 0, errorCode)) {
|
||||
u_UCharsToChars(uchars, buffer.getAlias()+len, ucharsLen);
|
||||
len += ucharsLen;
|
||||
buffer[len] = 0;
|
||||
@@ -231,9 +274,17 @@ UBool CharString::ensureCapacity(int32_t capacity,
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return false;
|
||||
}
|
||||
if(capacity<0) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return false;
|
||||
}
|
||||
if(capacity>buffer.getCapacity()) {
|
||||
if(desiredCapacityHint==0) {
|
||||
desiredCapacityHint=capacity+buffer.getCapacity();
|
||||
// Default growth heuristic. If it overflows, skip the extra headroom
|
||||
// and allocate exactly the requested capacity, which is still valid.
|
||||
if(uprv_add32_overflow(capacity, buffer.getCapacity(), &desiredCapacityHint)) {
|
||||
desiredCapacityHint=0;
|
||||
}
|
||||
}
|
||||
if( (desiredCapacityHint<=capacity || buffer.resize(desiredCapacityHint, len+1)==nullptr) &&
|
||||
buffer.resize(capacity, len+1)==nullptr
|
||||
|
||||
+308
-40
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "unicode/localpointer.h"
|
||||
@@ -171,17 +172,23 @@ uprv_deleteUObject(void *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* "Smart pointer" class, deletes memory via uprv_free().
|
||||
* ICU 79+: Use prv::make_unique & prv::make_unique_for_overwrite instead.
|
||||
*
|
||||
* For most methods see the LocalPointerBase base class.
|
||||
* Adds operator[] for array item access.
|
||||
*
|
||||
* @see LocalPointerBase
|
||||
* @see prv::make_unique
|
||||
* @deprecated use prv::make_unique & prv::make_unique_for_overwrite
|
||||
*/
|
||||
template<typename T>
|
||||
class LocalMemory : public LocalPointerBase<T> {
|
||||
@@ -212,7 +219,7 @@ public:
|
||||
* @param src source smart pointer
|
||||
* @return *this
|
||||
*/
|
||||
LocalMemory<T> &operator=(LocalMemory<T> &&src) noexcept {
|
||||
LocalMemory<T>& operator=(LocalMemory<T>&& src) noexcept U_LIFETIME_BOUND {
|
||||
uprv_free(LocalPointerBase<T>::ptr);
|
||||
LocalPointerBase<T>::ptr=src.ptr;
|
||||
src.ptr=nullptr;
|
||||
@@ -252,7 +259,7 @@ public:
|
||||
* @param newCapacity must be >0
|
||||
* @return the allocated array pointer, or nullptr if the allocation failed
|
||||
*/
|
||||
inline T *allocateInsteadAndReset(int32_t newCapacity=1);
|
||||
inline T* allocateInsteadAndReset(int32_t newCapacity = 1) U_LIFETIME_BOUND;
|
||||
/**
|
||||
* Deletes the array it owns and allocates a new one, copying length T items.
|
||||
* Returns the new array pointer.
|
||||
@@ -264,18 +271,18 @@ public:
|
||||
* which the caller must track because the LocalMemory does not track it
|
||||
* @return the allocated array pointer, or nullptr if the allocation failed
|
||||
*/
|
||||
inline T *allocateInsteadAndCopy(int32_t newCapacity=1, int32_t length=0);
|
||||
inline T* allocateInsteadAndCopy(int32_t newCapacity = 1, int32_t length = 0) U_LIFETIME_BOUND;
|
||||
/**
|
||||
* Array item access (writable).
|
||||
* No index bounds check.
|
||||
* @param i array index
|
||||
* @return reference to the array item
|
||||
*/
|
||||
T &operator[](ptrdiff_t i) const { return LocalPointerBase<T>::ptr[i]; }
|
||||
T& operator[](ptrdiff_t i) const U_LIFETIME_BOUND { return LocalPointerBase<T>::ptr[i]; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline T *LocalMemory<T>::allocateInsteadAndReset(int32_t newCapacity) {
|
||||
template <typename T>
|
||||
inline T* LocalMemory<T>::allocateInsteadAndReset(int32_t newCapacity) U_LIFETIME_BOUND {
|
||||
if(newCapacity>0) {
|
||||
T *p=(T *)uprv_malloc(newCapacity*sizeof(T));
|
||||
if(p!=nullptr) {
|
||||
@@ -289,9 +296,9 @@ inline T *LocalMemory<T>::allocateInsteadAndReset(int32_t newCapacity) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline T *LocalMemory<T>::allocateInsteadAndCopy(int32_t newCapacity, int32_t length) {
|
||||
template <typename T>
|
||||
inline T* LocalMemory<T>::allocateInsteadAndCopy(int32_t newCapacity,
|
||||
int32_t length) U_LIFETIME_BOUND {
|
||||
if(newCapacity>0) {
|
||||
T *p=(T *)uprv_malloc(newCapacity*sizeof(T));
|
||||
if(p!=nullptr) {
|
||||
@@ -366,7 +373,8 @@ public:
|
||||
/**
|
||||
* Move assignment: transfers ownership or copies the stack array.
|
||||
*/
|
||||
MaybeStackArray<T, stackCapacity> &operator=(MaybeStackArray<T, stackCapacity> &&src) noexcept;
|
||||
MaybeStackArray<T, stackCapacity>&
|
||||
operator=(MaybeStackArray<T, stackCapacity>&& src) noexcept U_LIFETIME_BOUND;
|
||||
/**
|
||||
* Returns the array capacity (number of T items).
|
||||
* @return array capacity
|
||||
@@ -376,12 +384,12 @@ public:
|
||||
* Access without ownership change.
|
||||
* @return the array pointer
|
||||
*/
|
||||
T *getAlias() const { return ptr; }
|
||||
T* getAlias() const U_LIFETIME_BOUND { return ptr; }
|
||||
/**
|
||||
* Returns the array limit. Simple convenience method.
|
||||
* @return getAlias()+getCapacity()
|
||||
*/
|
||||
T *getArrayLimit() const { return getAlias()+capacity; }
|
||||
T* getArrayLimit() const U_LIFETIME_BOUND { return getAlias() + capacity; }
|
||||
// No "operator T *() const" because that can make
|
||||
// expressions like mbs[index] ambiguous for some compilers.
|
||||
/**
|
||||
@@ -390,14 +398,14 @@ public:
|
||||
* @param i array index
|
||||
* @return reference to the array item
|
||||
*/
|
||||
const T &operator[](ptrdiff_t i) const { return ptr[i]; }
|
||||
const T& operator[](ptrdiff_t i) const U_LIFETIME_BOUND { return ptr[i]; }
|
||||
/**
|
||||
* Array item access (writable).
|
||||
* No index bounds check.
|
||||
* @param i array index
|
||||
* @return reference to the array item
|
||||
*/
|
||||
T &operator[](ptrdiff_t i) { return ptr[i]; }
|
||||
T& operator[](ptrdiff_t i) U_LIFETIME_BOUND { return ptr[i]; }
|
||||
/**
|
||||
* Deletes the array (if owned) and aliases another one, no transfer of ownership.
|
||||
* If the arguments are illegal, then the current array is unchanged.
|
||||
@@ -422,7 +430,7 @@ public:
|
||||
* @param length number of T items to be copied from the old array to the new one
|
||||
* @return the allocated array pointer, or nullptr if the allocation failed
|
||||
*/
|
||||
inline T *resize(int32_t newCapacity, int32_t length=0);
|
||||
inline T* resize(int32_t newCapacity, int32_t length = 0) U_LIFETIME_BOUND;
|
||||
/**
|
||||
* Gives up ownership of the array if owned, or else clones it,
|
||||
* copying length T items; resets itself to the internal stack array.
|
||||
@@ -483,9 +491,9 @@ icu::MaybeStackArray<T, stackCapacity>::MaybeStackArray(
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, int32_t stackCapacity>
|
||||
inline MaybeStackArray <T, stackCapacity>&
|
||||
MaybeStackArray<T, stackCapacity>::operator=(MaybeStackArray <T, stackCapacity>&& src) noexcept {
|
||||
template <typename T, int32_t stackCapacity>
|
||||
inline MaybeStackArray<T, stackCapacity>& MaybeStackArray<T, stackCapacity>::operator=(
|
||||
MaybeStackArray<T, stackCapacity>&& src) noexcept U_LIFETIME_BOUND {
|
||||
releaseArray(); // in case this instance had its own memory allocated
|
||||
capacity = src.capacity;
|
||||
needToRelease = src.needToRelease;
|
||||
@@ -499,8 +507,9 @@ MaybeStackArray<T, stackCapacity>::operator=(MaybeStackArray <T, stackCapacity>&
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T, int32_t stackCapacity>
|
||||
inline T *MaybeStackArray<T, stackCapacity>::resize(int32_t newCapacity, int32_t length) {
|
||||
template <typename T, int32_t stackCapacity>
|
||||
inline T* MaybeStackArray<T, stackCapacity>::resize(int32_t newCapacity,
|
||||
int32_t length) U_LIFETIME_BOUND {
|
||||
if(newCapacity>0) {
|
||||
#if U_DEBUG && defined(UPRV_MALLOC_COUNT)
|
||||
::fprintf(::stderr, "MaybeStackArray (resize) alloc %d * %lu\n", newCapacity, sizeof(T));
|
||||
@@ -587,30 +596,30 @@ public:
|
||||
* Access without ownership change.
|
||||
* @return the header pointer
|
||||
*/
|
||||
H *getAlias() const { return ptr; }
|
||||
H* getAlias() const U_LIFETIME_BOUND { return ptr; }
|
||||
/**
|
||||
* Returns the array start.
|
||||
* @return array start, same address as getAlias()+1
|
||||
*/
|
||||
T *getArrayStart() const { return reinterpret_cast<T *>(getAlias()+1); }
|
||||
T* getArrayStart() const U_LIFETIME_BOUND { return reinterpret_cast<T*>(getAlias() + 1); }
|
||||
/**
|
||||
* Returns the array limit.
|
||||
* @return array limit
|
||||
*/
|
||||
T *getArrayLimit() const { return getArrayStart()+capacity; }
|
||||
T* getArrayLimit() const U_LIFETIME_BOUND { return getArrayStart() + capacity; }
|
||||
/**
|
||||
* Access without ownership change. Same as getAlias().
|
||||
* A class instance can be used directly in expressions that take a T *.
|
||||
* @return the header pointer
|
||||
*/
|
||||
operator H *() const { return ptr; }
|
||||
operator H*() const U_LIFETIME_BOUND { return ptr; }
|
||||
/**
|
||||
* Array item access (writable).
|
||||
* No index bounds check.
|
||||
* @param i array index
|
||||
* @return reference to the array item
|
||||
*/
|
||||
T &operator[](ptrdiff_t i) { return getArrayStart()[i]; }
|
||||
T& operator[](ptrdiff_t i) U_LIFETIME_BOUND { return getArrayStart()[i]; }
|
||||
/**
|
||||
* 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.
|
||||
@@ -636,7 +645,7 @@ public:
|
||||
* @param length number of T items to be copied from the old array to the new one
|
||||
* @return the allocated pointer, or nullptr if the allocation failed
|
||||
*/
|
||||
inline H *resize(int32_t newCapacity, int32_t length=0);
|
||||
inline H* resize(int32_t newCapacity, int32_t length = 0) U_LIFETIME_BOUND;
|
||||
/**
|
||||
* 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.
|
||||
@@ -668,9 +677,9 @@ private:
|
||||
void operator=(const MaybeStackHeaderAndArray & /*other*/) {}
|
||||
};
|
||||
|
||||
template<typename H, typename T, int32_t stackCapacity>
|
||||
inline H *MaybeStackHeaderAndArray<H, T, stackCapacity>::resize(int32_t newCapacity,
|
||||
int32_t length) {
|
||||
template <typename H, typename T, int32_t stackCapacity>
|
||||
inline H* MaybeStackHeaderAndArray<H, T, stackCapacity>::resize(int32_t newCapacity,
|
||||
int32_t length) U_LIFETIME_BOUND {
|
||||
if(newCapacity>=0) {
|
||||
#if U_DEBUG && defined(UPRV_MALLOC_COUNT)
|
||||
::fprintf(::stderr,"MaybeStackHeaderAndArray alloc %d + %d * %ul\n", sizeof(H),newCapacity,sizeof(T));
|
||||
@@ -769,7 +778,7 @@ public:
|
||||
other.fCount = 0;
|
||||
}
|
||||
|
||||
MemoryPool& operator=(MemoryPool&& other) noexcept {
|
||||
MemoryPool& operator=(MemoryPool&& other) noexcept U_LIFETIME_BOUND {
|
||||
// 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
|
||||
@@ -788,8 +797,8 @@ public:
|
||||
* @param args Arguments to be forwarded to the typename T constructor.
|
||||
* @return A pointer to the newly created object, or nullptr on error.
|
||||
*/
|
||||
template<typename... Args>
|
||||
T* create(Args&&... args) {
|
||||
template <typename... Args>
|
||||
T* create(Args&&... args) U_LIFETIME_BOUND {
|
||||
int32_t capacity = fPool.getCapacity();
|
||||
if (fCount == capacity &&
|
||||
fPool.resize(capacity == stackCapacity ? 4 * capacity : 2 * capacity,
|
||||
@@ -800,7 +809,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
T* createAndCheckErrorCode(UErrorCode &status, Args &&... args) {
|
||||
T* createAndCheckErrorCode(UErrorCode& status, Args&&... args) U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -846,13 +855,13 @@ protected:
|
||||
template<typename T, int32_t stackCapacity = 8>
|
||||
class MaybeStackVector : protected MemoryPool<T, stackCapacity> {
|
||||
public:
|
||||
template<typename... Args>
|
||||
T* emplaceBack(Args&&... args) {
|
||||
template <typename... Args>
|
||||
T* emplaceBack(Args&&... args) U_LIFETIME_BOUND {
|
||||
return this->create(args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
T *emplaceBackAndCheckErrorCode(UErrorCode &status, Args &&... args) {
|
||||
T* emplaceBackAndCheckErrorCode(UErrorCode& status, Args&&... args) U_LIFETIME_BOUND {
|
||||
return this->createAndCheckErrorCode(status, args...);
|
||||
}
|
||||
|
||||
@@ -860,11 +869,11 @@ public:
|
||||
return this->fCount;
|
||||
}
|
||||
|
||||
T** getAlias() {
|
||||
T** getAlias() U_LIFETIME_BOUND {
|
||||
return this->fPool.getAlias();
|
||||
}
|
||||
|
||||
const T *const *getAlias() const {
|
||||
const T* const* getAlias() const U_LIFETIME_BOUND {
|
||||
return this->fPool.getAlias();
|
||||
}
|
||||
|
||||
@@ -874,7 +883,7 @@ public:
|
||||
* @param i array index
|
||||
* @return reference to the array item
|
||||
*/
|
||||
const T* operator[](ptrdiff_t i) const {
|
||||
const T* operator[](ptrdiff_t i) const U_LIFETIME_BOUND {
|
||||
return this->fPool[i];
|
||||
}
|
||||
|
||||
@@ -884,11 +893,270 @@ public:
|
||||
* @param i array index
|
||||
* @return reference to the array item
|
||||
*/
|
||||
T* operator[](ptrdiff_t i) {
|
||||
T* operator[](ptrdiff_t i) U_LIFETIME_BOUND {
|
||||
return this->fPool[i];
|
||||
}
|
||||
};
|
||||
|
||||
namespace prv {
|
||||
|
||||
#if U_OVERRIDE_CXX_ALLOCATION
|
||||
|
||||
/**
|
||||
* A deleter (as used by std::unique_ptr) that deallocates using `deallocate`.
|
||||
* @internal
|
||||
*/
|
||||
template <typename T, void deallocate(void *), typename = void> class Deleter {
|
||||
public:
|
||||
Deleter() = default;
|
||||
void operator()(T *const ptr) const {
|
||||
if constexpr (!std::is_trivially_destructible_v<T>) {
|
||||
ptr->~T();
|
||||
}
|
||||
deallocate(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A deleter (as used by std::unique_ptr) that deallocates using `deallocate`: specialization for
|
||||
* arrays of trivially destructible objects, e.g., int32_t[].
|
||||
* @internal
|
||||
*/
|
||||
template <typename T, void deallocate(void *)>
|
||||
class Deleter<T[], deallocate, std::enable_if_t<std::is_trivially_destructible_v<T>>> {
|
||||
public:
|
||||
Deleter() = default;
|
||||
void operator()(T *const ptr) const { deallocate(ptr); }
|
||||
};
|
||||
|
||||
/**
|
||||
* A deleter (as used by std::unique_ptr) that deallocates using `deallocate`: specialization for
|
||||
* arrays of nontrivially destructible objects, e.g., UnicodeString[].
|
||||
* @internal
|
||||
*/
|
||||
template <typename T, void deallocate(void *)>
|
||||
class Deleter<T[], deallocate, std::enable_if_t<!std::is_trivially_destructible_v<T>>> {
|
||||
public:
|
||||
Deleter(const std::size_t size) : size_(size) {}
|
||||
void operator()(T *const ptr) const {
|
||||
for (std::ptrdiff_t i = static_cast<std::ptrdiff_t>(size_) - 1; i >= 0; --i) {
|
||||
ptr[i]->~T();
|
||||
}
|
||||
deallocate(ptr);
|
||||
}
|
||||
private:
|
||||
const std::size_t size_;
|
||||
};
|
||||
|
||||
/**
|
||||
* An std::unique_ptr that deallocates using uprv_free.
|
||||
* @internal
|
||||
*/
|
||||
template <typename T> using unique_ptr = std::unique_ptr<T, Deleter<T, uprv_free>>;
|
||||
|
||||
#else
|
||||
|
||||
using std::unique_ptr;
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Helper for make_unique<T, Args...>; forwards all but the last of args to the constructor of
|
||||
* T, uses the last of args as the error code for allocation errors.
|
||||
*
|
||||
* As usual, does nothing if the incoming UErrorCode already is U_FAILURE.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
template <typename T, typename... Args, std::size_t... i>
|
||||
unique_ptr<T> make_unique_impl(std::tuple<Args...> args,
|
||||
std::index_sequence<i...> constructor_arg_indices) {
|
||||
static_assert(std::is_same_v<decltype(constructor_arg_indices),
|
||||
std::make_index_sequence<sizeof...(Args) - 1>>);
|
||||
auto &&error = std::get<sizeof...(Args) - 1>(args);
|
||||
static_assert(std::is_same_v<decltype(error), UErrorCode &>);
|
||||
if (U_FAILURE(error)) {
|
||||
return nullptr;
|
||||
}
|
||||
#if U_OVERRIDE_CXX_ALLOCATION
|
||||
void *const buffer = uprv_malloc(sizeof(T));
|
||||
if (buffer == nullptr) {
|
||||
error = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
return unique_ptr<T>(new (buffer) T(std::get<i>(args)...));
|
||||
#else
|
||||
return std::make_unique<T>(std::get<i>(args)...);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of std::make_unique<T> that is compatible with ICU allocation error handling.
|
||||
* If U_OVERRIDE_CXX_ALLOCATION, allocates using uprv_malloc, and sets a UErrorCode on failure.
|
||||
* Otherwise, equivalent to std::make_unique<T>.
|
||||
* prv::make_unique<T>(Args... args, UErrorCode& status)
|
||||
* corresponds to
|
||||
* std::make_unique<T>(Args... args)
|
||||
* and
|
||||
* new T(Args... args).
|
||||
*
|
||||
* As usual, does nothing if the incoming UErrorCode already is U_FAILURE.
|
||||
*
|
||||
* With empty args, this corresponds to new T(), and the allocated object is value-initialized; in
|
||||
* particular, scalar types are zero-initialized; cf. make_unique_for_overwrite which
|
||||
* corresponds to new T.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
template <typename T, typename... Args, typename = std::enable_if_t<!std::is_array_v<T>>>
|
||||
unique_ptr<T> make_unique(Args &&...args) {
|
||||
return make_unique_impl<T>(std::forward_as_tuple(args...),
|
||||
std::make_index_sequence<sizeof...(Args) - 1>());
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of std::make_unique<T[]> that is compatible with ICU allocation error handling.
|
||||
* If U_OVERRIDE_CXX_ALLOCATION, allocates using uprv_malloc, and sets a UErrorCode on failure.
|
||||
* Otherwise, equivalent to std::make_unique<T[]>.
|
||||
* prv::make_unique<T[]>(std::size_t n, UErrorCode& status)
|
||||
* corresponds to
|
||||
* std::make_unique<T[]>(std::size_t n)
|
||||
* and
|
||||
* new T[std::size_t n]().
|
||||
*
|
||||
* As usual, does nothing if the incoming UErrorCode already is U_FAILURE.
|
||||
*
|
||||
* The allocated objects are value-initialized; in particular, scalar types are zero-initialized;
|
||||
* cf. make_unique_for_overwrite which corresponds to new T[n].
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
template <typename T,
|
||||
// In C++20, this could require is_unbounded_array_v<T>.
|
||||
typename = std::enable_if_t<std::is_same_v<std::remove_extent_t<T>[], T>>>
|
||||
unique_ptr<T> make_unique(const std::size_t n, UErrorCode &error) {
|
||||
if (U_FAILURE(error)) {
|
||||
return nullptr;
|
||||
}
|
||||
// In C23/C++26, we could use ckd_mul.
|
||||
constexpr std::size_t maxSize = SIZE_MAX / sizeof(std::remove_extent_t<T>);
|
||||
if (n > maxSize) {
|
||||
error = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
#if U_OVERRIDE_CXX_ALLOCATION
|
||||
void *const buffer = uprv_malloc(sizeof(std::remove_extent_t<T>) * n);
|
||||
if (buffer == nullptr) {
|
||||
error = U_MEMORY_ALLOCATION_ERROR;
|
||||
if constexpr (std::is_trivially_destructible_v<std::remove_extent_t<T>>) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return unique_ptr<T>(nullptr, Deleter<T, uprv_free>(0));
|
||||
}
|
||||
}
|
||||
if constexpr (std::is_trivially_destructible_v<std::remove_extent_t<T>>) {
|
||||
return unique_ptr<T>(new (buffer) std::remove_extent_t<T>[n]());
|
||||
} else {
|
||||
return unique_ptr<T>(new (buffer) std::remove_extent_t<T>[n](), Deleter<T, uprv_free>(n));
|
||||
}
|
||||
#else
|
||||
return std::make_unique<T>(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of std::make_unique_for_overwrite<T> that is compatible with ICU allocation error
|
||||
* handling.
|
||||
* If U_OVERRIDE_CXX_ALLOCATION, allocates using uprv_malloc, and sets a UErrorCode on failure.
|
||||
* Otherwise, equivalent to std::make_unique_for_overwrite<T>.
|
||||
* prv::make_unique_for_overwrite<T>(UErrorCode& status)
|
||||
* corresponds to
|
||||
* std::make_unique_for_overwrite<T>()
|
||||
* and
|
||||
* new T.
|
||||
*
|
||||
* As usual, does nothing if the incoming UErrorCode already is U_FAILURE.
|
||||
*
|
||||
* The allocated object is default-initialized. For some types, e.g., scalar types, this means it
|
||||
* has an indeterminate value, or an erroneous value since C++26 (in plain English, the memory is
|
||||
* uninitialized).
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
template <typename T, typename = std::enable_if_t<!std::is_array_v<T>>>
|
||||
unique_ptr<T> make_unique_for_overwrite(UErrorCode &error) {
|
||||
if (U_FAILURE(error)) {
|
||||
return nullptr;
|
||||
}
|
||||
#if U_OVERRIDE_CXX_ALLOCATION
|
||||
void *const buffer = uprv_malloc(sizeof(T));
|
||||
if (buffer == nullptr) {
|
||||
error = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
return unique_ptr<T>(new (buffer) T);
|
||||
#elif U_CPLUSPLUS_VERSION >= 20
|
||||
return std::make_unique_for_overwrite<T>();
|
||||
#else
|
||||
return unique_ptr<T>(new T);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of std::make_unique_for_overwrite<T[]> that is compatible with ICU allocation error
|
||||
* handling.
|
||||
* If U_OVERRIDE_CXX_ALLOCATION, allocates using uprv_malloc, and sets a UErrorCode on failure.
|
||||
* Otherwise, equivalent to std::make_unique_for_overwrite<T[]>.
|
||||
* prv::make_unique_for_overwrite<T[]>(std::size_t n, UErrorCode& status)
|
||||
* corresponds to
|
||||
* std::make_unique_for_overwrite<T[]>(std::size_t n)
|
||||
* and
|
||||
* new T[std::size_t n].
|
||||
*
|
||||
* As usual, does nothing if the incoming UErrorCode already is U_FAILURE.
|
||||
*
|
||||
* The allocated objects are default-initialized. For some types, e.g., scalar types, this means
|
||||
* they have indeterminate values, or erroneous values since C++26 (in plain English, the memory is
|
||||
* uninitialized).
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
template <typename T,
|
||||
// In C++20, this could require is_unbounded_array_v<T>.
|
||||
typename = std::enable_if_t<std::is_same_v<std::remove_extent_t<T>[], T>>>
|
||||
unique_ptr<T> make_unique_for_overwrite(const std::size_t n, UErrorCode &error) {
|
||||
if (U_FAILURE(error)) {
|
||||
return nullptr;
|
||||
}
|
||||
// In C23/C++26, we could use ckd_mul.
|
||||
constexpr std::size_t maxSize = SIZE_MAX / sizeof(std::remove_extent_t<T>);
|
||||
if (n > maxSize) {
|
||||
error = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
#if U_OVERRIDE_CXX_ALLOCATION
|
||||
void *const buffer = uprv_malloc(sizeof(std::remove_extent_t<T>) * n);
|
||||
if (buffer == nullptr) {
|
||||
error = U_MEMORY_ALLOCATION_ERROR;
|
||||
if constexpr (std::is_trivially_destructible_v<std::remove_extent_t<T>>) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return unique_ptr<T>(nullptr, Deleter<T, uprv_free>(0));
|
||||
}
|
||||
}
|
||||
if constexpr (std::is_trivially_destructible_v<std::remove_extent_t<T>>) {
|
||||
return unique_ptr<T>(new (buffer) std::remove_extent_t<T>[n]);
|
||||
} else {
|
||||
return unique_ptr<T>(new (buffer) std::remove_extent_t<T>[n], Deleter<T, uprv_free>(n));
|
||||
}
|
||||
#elif U_CPLUSPLUS_VERSION >= 20
|
||||
return std::make_unique_for_overwrite<T>(n);
|
||||
#else
|
||||
return unique_ptr<T>(new std::remove_extent_t<T>[n]);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace prv
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ DateInterval::DateInterval(const DateInterval& other)
|
||||
|
||||
|
||||
DateInterval&
|
||||
DateInterval::operator=(const DateInterval& other) {
|
||||
DateInterval::operator=(const DateInterval& other) U_LIFETIME_BOUND {
|
||||
if ( this != &other ) {
|
||||
fromDate = other.fromDate;
|
||||
toDate = other.toDate;
|
||||
|
||||
+9
-7
@@ -41,7 +41,7 @@ void Edits::releaseArray() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
Edits &Edits::copyArray(const Edits &other) {
|
||||
Edits& Edits::copyArray(const Edits& other) U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode_)) {
|
||||
length = delta = numChanges = 0;
|
||||
return *this;
|
||||
@@ -63,7 +63,7 @@ Edits &Edits::copyArray(const Edits &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Edits &Edits::moveArray(Edits &src) noexcept {
|
||||
Edits& Edits::moveArray(Edits& src) noexcept U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode_)) {
|
||||
length = delta = numChanges = 0;
|
||||
return *this;
|
||||
@@ -85,7 +85,7 @@ Edits &Edits::moveArray(Edits &src) noexcept {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Edits &Edits::operator=(const Edits &other) {
|
||||
Edits& Edits::operator=(const Edits& other) U_LIFETIME_BOUND {
|
||||
if (this == &other) { return *this; } // self-assignment: no-op
|
||||
length = other.length;
|
||||
delta = other.delta;
|
||||
@@ -94,7 +94,7 @@ Edits &Edits::operator=(const Edits &other) {
|
||||
return copyArray(other);
|
||||
}
|
||||
|
||||
Edits &Edits::operator=(Edits &&src) noexcept {
|
||||
Edits& Edits::operator=(Edits&& src) noexcept U_LIFETIME_BOUND {
|
||||
length = src.length;
|
||||
delta = src.delta;
|
||||
numChanges = src.numChanges;
|
||||
@@ -251,7 +251,9 @@ UBool Edits::copyErrorTo(UErrorCode &outErrorCode) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
Edits &Edits::mergeAndAppend(const Edits &ab, const Edits &bc, UErrorCode &errorCode) {
|
||||
Edits& Edits::mergeAndAppend(const Edits& ab,
|
||||
const Edits& bc,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
if (copyErrorTo(errorCode)) { return *this; }
|
||||
// Picture string a --(Edits ab)--> string b --(Edits bc)--> string c.
|
||||
// Parallel iteration over both Edits.
|
||||
@@ -397,7 +399,7 @@ Edits &Edits::mergeAndAppend(const Edits &ab, const Edits &bc, UErrorCode &error
|
||||
return *this;
|
||||
}
|
||||
|
||||
Edits::Iterator::Iterator(const uint16_t *a, int32_t len, UBool oc, UBool crs) :
|
||||
Edits::Iterator::Iterator(const uint16_t* a U_LIFETIME_BOUND, int32_t len, UBool oc, UBool crs) :
|
||||
array(a), index(0), length(len), remaining(0),
|
||||
onlyChanges_(oc), coarse(crs),
|
||||
dir(0), changed(false), oldLength_(0), newLength_(0),
|
||||
@@ -776,7 +778,7 @@ int32_t Edits::Iterator::sourceIndexFromDestinationIndex(int32_t i, UErrorCode &
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeString& Edits::Iterator::toString(UnicodeString& sb) const {
|
||||
UnicodeString& Edits::Iterator::toString(UnicodeString& sb U_LIFETIME_BOUND) const {
|
||||
sb.append(u"{ src[", -1);
|
||||
ICU_Utility::appendNumber(sb, srcIndex);
|
||||
sb.append(u"..", -1);
|
||||
|
||||
+17
-7
@@ -75,7 +75,7 @@ class UStringSet : public UVector {
|
||||
/**
|
||||
* Return the ith UnicodeString alias
|
||||
*/
|
||||
inline const UnicodeString* getStringAt(int32_t i) const {
|
||||
inline const UnicodeString* getStringAt(int32_t i) const U_LIFETIME_BOUND {
|
||||
return static_cast<const UnicodeString*>(elementAt(i));
|
||||
}
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ class SimpleFilteredSentenceBreakData : public UMemory {
|
||||
public:
|
||||
SimpleFilteredSentenceBreakData(UCharsTrie *forwards, UCharsTrie *backwards )
|
||||
: fForwardsPartialTrie(forwards), fBackwardsTrie(backwards), refcount(1) { }
|
||||
SimpleFilteredSentenceBreakData *incr() {
|
||||
SimpleFilteredSentenceBreakData* incr() U_LIFETIME_BOUND {
|
||||
umtx_atomic_inc(&refcount);
|
||||
return this;
|
||||
}
|
||||
@@ -154,8 +154,10 @@ public:
|
||||
bool hasForwardsPartialTrie() const { return fForwardsPartialTrie.isValid(); }
|
||||
bool hasBackwardsTrie() const { return fBackwardsTrie.isValid(); }
|
||||
|
||||
const UCharsTrie &getForwardsPartialTrie() const { return *fForwardsPartialTrie; }
|
||||
const UCharsTrie &getBackwardsTrie() const { return *fBackwardsTrie; }
|
||||
const UCharsTrie& getForwardsPartialTrie() const U_LIFETIME_BOUND {
|
||||
return *fForwardsPartialTrie;
|
||||
}
|
||||
const UCharsTrie& getBackwardsTrie() const U_LIFETIME_BOUND { return *fBackwardsTrie; }
|
||||
|
||||
private:
|
||||
// These tries own their data arrays.
|
||||
@@ -196,13 +198,21 @@ public:
|
||||
|
||||
/* -- text modifying -- */
|
||||
virtual void setText(UText *text, UErrorCode &status) override { fDelegate->setText(text,status); }
|
||||
virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) override { fDelegate->refreshInputText(input,status); return *this; }
|
||||
virtual BreakIterator& refreshInputText(UText* input,
|
||||
UErrorCode& status) U_LIFETIME_BOUND override {
|
||||
fDelegate->refreshInputText(input, status);
|
||||
return *this;
|
||||
}
|
||||
virtual void adoptText(CharacterIterator* it) override { fDelegate->adoptText(it); }
|
||||
virtual void setText(const UnicodeString &text) override { fDelegate->setText(text); }
|
||||
|
||||
/* -- other functions that are just delegated -- */
|
||||
virtual UText *getUText(UText *fillIn, UErrorCode &status) const override { return fDelegate->getUText(fillIn,status); }
|
||||
virtual CharacterIterator& getText() const override { return fDelegate->getText(); }
|
||||
virtual UText* getUText(UText* fillIn U_LIFETIME_BOUND, UErrorCode& status) const override {
|
||||
return fDelegate->getUText(fillIn, status);
|
||||
}
|
||||
virtual CharacterIterator& getText() const U_LIFETIME_BOUND override {
|
||||
return fDelegate->getText();
|
||||
}
|
||||
|
||||
/* -- ITERATION -- */
|
||||
virtual int32_t first() override;
|
||||
|
||||
+24
-22
@@ -32,10 +32,10 @@ U_NAMESPACE_BEGIN
|
||||
|
||||
FilteredNormalizer2::~FilteredNormalizer2() {}
|
||||
|
||||
UnicodeString &
|
||||
FilteredNormalizer2::normalize(const UnicodeString &src,
|
||||
UnicodeString &dest,
|
||||
UErrorCode &errorCode) const {
|
||||
UnicodeString&
|
||||
FilteredNormalizer2::normalize(const UnicodeString& src,
|
||||
UnicodeString& dest U_LIFETIME_BOUND,
|
||||
UErrorCode& errorCode) const {
|
||||
uprv_checkCanGetBuffer(src, errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
dest.setToBogus();
|
||||
@@ -56,11 +56,11 @@ FilteredNormalizer2::normalize(const UnicodeString &src,
|
||||
// USET_SPAN_SIMPLE should be passed in for the start of src
|
||||
// and USET_SPAN_NOT_CONTAINED should be passed in if we continue after
|
||||
// an in-filter prefix.
|
||||
UnicodeString &
|
||||
FilteredNormalizer2::normalize(const UnicodeString &src,
|
||||
UnicodeString &dest,
|
||||
UnicodeString&
|
||||
FilteredNormalizer2::normalize(const UnicodeString& src,
|
||||
UnicodeString& dest U_LIFETIME_BOUND,
|
||||
USetSpanCondition spanCondition,
|
||||
UErrorCode &errorCode) const {
|
||||
UErrorCode& errorCode) const {
|
||||
UnicodeString tempDest; // Don't throw away destination buffer between iterations.
|
||||
for(int32_t prevSpanLimit=0; prevSpanLimit<src.length();) {
|
||||
int32_t spanLimit=set.span(src, prevSpanLimit, spanCondition);
|
||||
@@ -133,25 +133,25 @@ FilteredNormalizer2::normalizeUTF8(uint32_t options, const char *src, int32_t le
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
FilteredNormalizer2::normalizeSecondAndAppend(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const {
|
||||
UnicodeString&
|
||||
FilteredNormalizer2::normalizeSecondAndAppend(UnicodeString& first U_LIFETIME_BOUND,
|
||||
const UnicodeString& second,
|
||||
UErrorCode& errorCode) const {
|
||||
return normalizeSecondAndAppend(first, second, true, errorCode);
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
FilteredNormalizer2::append(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const {
|
||||
UnicodeString&
|
||||
FilteredNormalizer2::append(UnicodeString& first U_LIFETIME_BOUND,
|
||||
const UnicodeString& second,
|
||||
UErrorCode& errorCode) const {
|
||||
return normalizeSecondAndAppend(first, second, false, errorCode);
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
FilteredNormalizer2::normalizeSecondAndAppend(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UnicodeString&
|
||||
FilteredNormalizer2::normalizeSecondAndAppend(UnicodeString& first U_LIFETIME_BOUND,
|
||||
const UnicodeString& second,
|
||||
UBool doNormalize,
|
||||
UErrorCode &errorCode) const {
|
||||
UErrorCode& errorCode) const {
|
||||
uprv_checkCanGetBuffer(first, errorCode);
|
||||
uprv_checkCanGetBuffer(second, errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
@@ -343,8 +343,10 @@ U_NAMESPACE_END
|
||||
|
||||
U_NAMESPACE_USE
|
||||
|
||||
U_CAPI UNormalizer2 * U_EXPORT2
|
||||
unorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode *pErrorCode) {
|
||||
U_CAPI UNormalizer2* U_EXPORT2
|
||||
unorm2_openFiltered(const UNormalizer2* norm2 U_LIFETIME_BOUND,
|
||||
const USet* filterSet U_LIFETIME_BOUND,
|
||||
UErrorCode* pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+7
-7
@@ -462,19 +462,19 @@ uplug_setPlugName(UPlugData *data, const char *name) {
|
||||
}
|
||||
|
||||
|
||||
U_CAPI const char * U_EXPORT2
|
||||
uplug_getPlugName(UPlugData *data) {
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uplug_getPlugName(UPlugData* data U_LIFETIME_BOUND) {
|
||||
return data->name;
|
||||
}
|
||||
|
||||
|
||||
U_CAPI const char * U_EXPORT2
|
||||
uplug_getSymbolName(UPlugData *data) {
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uplug_getSymbolName(UPlugData* data U_LIFETIME_BOUND) {
|
||||
return data->sym;
|
||||
}
|
||||
|
||||
U_CAPI const char * U_EXPORT2
|
||||
uplug_getLibraryName(UPlugData *data, UErrorCode *status) {
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uplug_getLibraryName(UPlugData* data U_LIFETIME_BOUND, UErrorCode* status) {
|
||||
if(data->libName[0]) {
|
||||
return data->libName;
|
||||
} else {
|
||||
@@ -503,7 +503,7 @@ uplug_setContext(UPlugData *data, void *context) {
|
||||
}
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uplug_getConfiguration(UPlugData *data) {
|
||||
uplug_getConfiguration(UPlugData* data U_LIFETIME_BOUND) {
|
||||
return data->config;
|
||||
}
|
||||
|
||||
|
||||
+13
-15
@@ -51,7 +51,7 @@ LocaleBuilder::~LocaleBuilder()
|
||||
delete extensions_;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::setLocale(const Locale& locale)
|
||||
LocaleBuilder& LocaleBuilder::setLocale(const Locale& locale) U_LIFETIME_BOUND
|
||||
{
|
||||
clear();
|
||||
setLanguage(locale.getLanguage());
|
||||
@@ -65,7 +65,7 @@ LocaleBuilder& LocaleBuilder::setLocale(const Locale& locale)
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::setLanguageTag(StringPiece tag)
|
||||
LocaleBuilder& LocaleBuilder::setLanguageTag(StringPiece tag) U_LIFETIME_BOUND
|
||||
{
|
||||
Locale l = Locale::forLanguageTag(tag, status_);
|
||||
if (U_FAILURE(status_)) { return *this; }
|
||||
@@ -92,19 +92,19 @@ void setField(StringPiece input, char* dest, UErrorCode& errorCode,
|
||||
|
||||
} // namespace
|
||||
|
||||
LocaleBuilder& LocaleBuilder::setLanguage(StringPiece language)
|
||||
LocaleBuilder& LocaleBuilder::setLanguage(StringPiece language) U_LIFETIME_BOUND
|
||||
{
|
||||
setField(language, language_, status_, &ultag_isLanguageSubtag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::setScript(StringPiece script)
|
||||
LocaleBuilder& LocaleBuilder::setScript(StringPiece script) U_LIFETIME_BOUND
|
||||
{
|
||||
setField(script, script_, status_, &ultag_isScriptSubtag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::setRegion(StringPiece region)
|
||||
LocaleBuilder& LocaleBuilder::setRegion(StringPiece region) U_LIFETIME_BOUND
|
||||
{
|
||||
setField(region, region_, status_, &ultag_isRegionSubtag);
|
||||
return *this;
|
||||
@@ -124,7 +124,7 @@ void transform(char* data, int32_t len) {
|
||||
|
||||
} // namespace
|
||||
|
||||
LocaleBuilder& LocaleBuilder::setVariant(StringPiece variant)
|
||||
LocaleBuilder& LocaleBuilder::setVariant(StringPiece variant) U_LIFETIME_BOUND
|
||||
{
|
||||
if (U_FAILURE(status_)) { return *this; }
|
||||
if (variant.empty()) {
|
||||
@@ -233,7 +233,7 @@ _setUnicodeExtensions(Locale& locale, const CharString& value, UErrorCode& error
|
||||
|
||||
} // namespace
|
||||
|
||||
LocaleBuilder& LocaleBuilder::setExtension(char key, StringPiece value)
|
||||
LocaleBuilder& LocaleBuilder::setExtension(char key, StringPiece value) U_LIFETIME_BOUND
|
||||
{
|
||||
if (U_FAILURE(status_)) { return *this; }
|
||||
if (!UPRV_ISALPHANUM(key)) {
|
||||
@@ -269,8 +269,8 @@ LocaleBuilder& LocaleBuilder::setExtension(char key, StringPiece value)
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::setUnicodeLocaleKeyword(
|
||||
StringPiece key, StringPiece type)
|
||||
LocaleBuilder& LocaleBuilder::setUnicodeLocaleKeyword(StringPiece key,
|
||||
StringPiece type) U_LIFETIME_BOUND
|
||||
{
|
||||
if (U_FAILURE(status_)) { return *this; }
|
||||
if (!ultag_isUnicodeLocaleKey(key.data(), key.length()) ||
|
||||
@@ -290,8 +290,7 @@ LocaleBuilder& LocaleBuilder::setUnicodeLocaleKeyword(
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::addUnicodeLocaleAttribute(
|
||||
StringPiece value)
|
||||
LocaleBuilder& LocaleBuilder::addUnicodeLocaleAttribute(StringPiece value) U_LIFETIME_BOUND
|
||||
{
|
||||
CharString value_str(value, status_);
|
||||
if (U_FAILURE(status_)) { return *this; }
|
||||
@@ -351,8 +350,7 @@ LocaleBuilder& LocaleBuilder::addUnicodeLocaleAttribute(
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::removeUnicodeLocaleAttribute(
|
||||
StringPiece value)
|
||||
LocaleBuilder& LocaleBuilder::removeUnicodeLocaleAttribute(StringPiece value) U_LIFETIME_BOUND
|
||||
{
|
||||
CharString value_str(value, status_);
|
||||
if (U_FAILURE(status_)) { return *this; }
|
||||
@@ -398,7 +396,7 @@ LocaleBuilder& LocaleBuilder::removeUnicodeLocaleAttribute(
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::clear()
|
||||
LocaleBuilder& LocaleBuilder::clear() U_LIFETIME_BOUND
|
||||
{
|
||||
status_ = U_ZERO_ERROR;
|
||||
language_[0] = 0;
|
||||
@@ -410,7 +408,7 @@ LocaleBuilder& LocaleBuilder::clear()
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleBuilder& LocaleBuilder::clearExtensions()
|
||||
LocaleBuilder& LocaleBuilder::clearExtensions() U_LIFETIME_BOUND
|
||||
{
|
||||
delete extensions_;
|
||||
extensions_ = nullptr;
|
||||
|
||||
+1078
-1060
File diff suppressed because it is too large.
Load diff
+35
-23
@@ -72,7 +72,8 @@ LocaleMatcher::Result::~Result() {
|
||||
}
|
||||
}
|
||||
|
||||
LocaleMatcher::Result &LocaleMatcher::Result::operator=(LocaleMatcher::Result &&src) noexcept {
|
||||
LocaleMatcher::Result&
|
||||
LocaleMatcher::Result::operator=(LocaleMatcher::Result&& src) noexcept U_LIFETIME_BOUND {
|
||||
this->~Result();
|
||||
|
||||
desiredLocale = src.desiredLocale;
|
||||
@@ -144,7 +145,8 @@ LocaleMatcher::Builder::~Builder() {
|
||||
delete maxDistanceSupported_;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::operator=(LocaleMatcher::Builder &&src) noexcept {
|
||||
LocaleMatcher::Builder&
|
||||
LocaleMatcher::Builder::operator=(LocaleMatcher::Builder&& src) noexcept U_LIFETIME_BOUND {
|
||||
this->~Builder();
|
||||
|
||||
errorCode_ = src.errorCode_;
|
||||
@@ -176,8 +178,8 @@ bool LocaleMatcher::Builder::ensureSupportedLocaleVector() {
|
||||
return true;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::setSupportedLocalesFromListString(
|
||||
StringPiece locales) {
|
||||
LocaleMatcher::Builder&
|
||||
LocaleMatcher::Builder::setSupportedLocalesFromListString(StringPiece locales) U_LIFETIME_BOUND {
|
||||
LocalePriorityList list(locales, errorCode_);
|
||||
if (U_FAILURE(errorCode_)) { return *this; }
|
||||
clearSupportedLocales();
|
||||
@@ -194,7 +196,8 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::setSupportedLocalesFromListStrin
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::setSupportedLocales(Locale::Iterator &locales) {
|
||||
LocaleMatcher::Builder&
|
||||
LocaleMatcher::Builder::setSupportedLocales(Locale::Iterator& locales) U_LIFETIME_BOUND {
|
||||
if (ensureSupportedLocaleVector()) {
|
||||
clearSupportedLocales();
|
||||
while (locales.hasNext() && U_SUCCESS(errorCode_)) {
|
||||
@@ -206,7 +209,8 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::setSupportedLocales(Locale::Iter
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::addSupportedLocale(const Locale &locale) {
|
||||
LocaleMatcher::Builder&
|
||||
LocaleMatcher::Builder::addSupportedLocale(const Locale& locale) U_LIFETIME_BOUND {
|
||||
if (ensureSupportedLocaleVector()) {
|
||||
LocalPointer<Locale> clone(locale.clone(), errorCode_);
|
||||
supportedLocales_->adoptElement(clone.orphan(), errorCode_);
|
||||
@@ -214,7 +218,7 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::addSupportedLocale(const Locale
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::setNoDefaultLocale() {
|
||||
LocaleMatcher::Builder& LocaleMatcher::Builder::setNoDefaultLocale() U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode_)) { return *this; }
|
||||
delete defaultLocale_;
|
||||
defaultLocale_ = nullptr;
|
||||
@@ -222,7 +226,8 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::setNoDefaultLocale() {
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::setDefaultLocale(const Locale *defaultLocale) {
|
||||
LocaleMatcher::Builder&
|
||||
LocaleMatcher::Builder::setDefaultLocale(const Locale* defaultLocale) U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode_)) { return *this; }
|
||||
Locale *clone = nullptr;
|
||||
if (defaultLocale != nullptr) {
|
||||
@@ -238,20 +243,23 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::setDefaultLocale(const Locale *d
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::setFavorSubtag(ULocMatchFavorSubtag subtag) {
|
||||
LocaleMatcher::Builder&
|
||||
LocaleMatcher::Builder::setFavorSubtag(ULocMatchFavorSubtag subtag) U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode_)) { return *this; }
|
||||
favor_ = subtag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::setDemotionPerDesiredLocale(ULocMatchDemotion demotion) {
|
||||
LocaleMatcher::Builder&
|
||||
LocaleMatcher::Builder::setDemotionPerDesiredLocale(ULocMatchDemotion demotion) U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode_)) { return *this; }
|
||||
demotion_ = demotion;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LocaleMatcher::Builder &LocaleMatcher::Builder::setMaxDistance(const Locale &desired,
|
||||
const Locale &supported) {
|
||||
LocaleMatcher::Builder&
|
||||
LocaleMatcher::Builder::setMaxDistance(const Locale& desired,
|
||||
const Locale& supported) U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode_)) { return *this; }
|
||||
Locale *desiredClone = desired.clone();
|
||||
Locale *supportedClone = supported.clone();
|
||||
@@ -522,7 +530,7 @@ LocaleMatcher::~LocaleMatcher() {
|
||||
delete ownedDefaultLocale;
|
||||
}
|
||||
|
||||
LocaleMatcher &LocaleMatcher::operator=(LocaleMatcher &&src) noexcept {
|
||||
LocaleMatcher& LocaleMatcher::operator=(LocaleMatcher&& src) noexcept U_LIFETIME_BOUND {
|
||||
this->~LocaleMatcher();
|
||||
|
||||
thresholdDistance = src.thresholdDistance;
|
||||
@@ -605,7 +613,8 @@ private:
|
||||
int32_t bestDesiredIndex = -1;
|
||||
};
|
||||
|
||||
const Locale *LocaleMatcher::getBestMatch(const Locale &desiredLocale, UErrorCode &errorCode) const {
|
||||
const Locale* LocaleMatcher::getBestMatch(const Locale& desiredLocale,
|
||||
UErrorCode& errorCode) const U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode)) { return nullptr; }
|
||||
std::optional<int32_t> suppIndex = getBestSuppIndex(
|
||||
getMaximalLsrOrUnd(likelySubtags, desiredLocale, errorCode),
|
||||
@@ -614,8 +623,8 @@ const Locale *LocaleMatcher::getBestMatch(const Locale &desiredLocale, UErrorCod
|
||||
: defaultLocale;
|
||||
}
|
||||
|
||||
const Locale *LocaleMatcher::getBestMatch(Locale::Iterator &desiredLocales,
|
||||
UErrorCode &errorCode) const {
|
||||
const Locale* LocaleMatcher::getBestMatch(Locale::Iterator& desiredLocales,
|
||||
UErrorCode& errorCode) const U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode)) { return nullptr; }
|
||||
if (!desiredLocales.hasNext()) {
|
||||
return defaultLocale;
|
||||
@@ -626,16 +635,18 @@ const Locale *LocaleMatcher::getBestMatch(Locale::Iterator &desiredLocales,
|
||||
: defaultLocale;
|
||||
}
|
||||
|
||||
const Locale *LocaleMatcher::getBestMatchForListString(
|
||||
StringPiece desiredLocaleList, UErrorCode &errorCode) const {
|
||||
const Locale*
|
||||
LocaleMatcher::getBestMatchForListString(StringPiece desiredLocaleList,
|
||||
UErrorCode& errorCode) const U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode)) { return nullptr; }
|
||||
LocalePriorityList list(desiredLocaleList, errorCode);
|
||||
LocalePriorityList::Iterator iter = list.iterator();
|
||||
return getBestMatch(iter, errorCode);
|
||||
}
|
||||
|
||||
LocaleMatcher::Result LocaleMatcher::getBestMatchResult(
|
||||
const Locale &desiredLocale, UErrorCode &errorCode) const {
|
||||
LocaleMatcher::Result
|
||||
LocaleMatcher::getBestMatchResult(const Locale& desiredLocale U_LIFETIME_BOUND,
|
||||
UErrorCode& errorCode) const U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return Result(nullptr, defaultLocale, -1, -1, false);
|
||||
}
|
||||
@@ -649,8 +660,9 @@ LocaleMatcher::Result LocaleMatcher::getBestMatchResult(
|
||||
}
|
||||
}
|
||||
|
||||
LocaleMatcher::Result LocaleMatcher::getBestMatchResult(
|
||||
Locale::Iterator &desiredLocales, UErrorCode &errorCode) const {
|
||||
LocaleMatcher::Result
|
||||
LocaleMatcher::getBestMatchResult(Locale::Iterator& desiredLocales,
|
||||
UErrorCode& errorCode) const U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(errorCode) || !desiredLocales.hasNext()) {
|
||||
return Result(nullptr, defaultLocale, -1, -1, false);
|
||||
}
|
||||
@@ -749,7 +761,7 @@ namespace {
|
||||
class LocaleFromTag {
|
||||
public:
|
||||
LocaleFromTag() : locale(Locale::getRoot()) {}
|
||||
const Locale &operator()(const char *tag) { return locale = Locale(tag); }
|
||||
const Locale& operator()(const char* tag) U_LIFETIME_BOUND { return locale = Locale(tag); }
|
||||
|
||||
private:
|
||||
// Store the locale in the converter, rather than return a reference to a temporary,
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ class AvailableLocalesStringEnumeration : public StringEnumeration {
|
||||
AvailableLocalesStringEnumeration(ULocAvailableType type) : fType(type) {
|
||||
}
|
||||
|
||||
const char* next(int32_t *resultLength, UErrorCode &status) override {
|
||||
const char* next(int32_t* resultLength, UErrorCode& status) U_LIFETIME_BOUND override {
|
||||
if (U_FAILURE(status)) { return nullptr; }
|
||||
ULocAvailableType actualType = fType;
|
||||
int32_t actualIndex = fIndex++;
|
||||
|
||||
+4
-2
@@ -15,8 +15,10 @@
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
const Locale& LocaleBased::getLocale(const Locale& valid, const Locale& actual,
|
||||
ULocDataLocaleType type, UErrorCode& status) {
|
||||
const Locale& LocaleBased::getLocale(const Locale& valid U_LIFETIME_BOUND,
|
||||
const Locale& actual U_LIFETIME_BOUND,
|
||||
ULocDataLocaleType type,
|
||||
UErrorCode& status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return Locale::getRoot();
|
||||
}
|
||||
|
||||
+4
-2
@@ -40,8 +40,10 @@ class U_COMMON_API LocaleBased : public UMemory {
|
||||
* @return the indicated locale
|
||||
*/
|
||||
static const Locale& getLocale(
|
||||
const Locale& valid, const Locale& actual,
|
||||
ULocDataLocaleType type, UErrorCode& status);
|
||||
const Locale& valid U_LIFETIME_BOUND,
|
||||
const Locale& actual U_LIFETIME_BOUND,
|
||||
ULocDataLocaleType type,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Return the locale ID for the service object wrapped by this
|
||||
|
||||
+18
-18
@@ -42,7 +42,7 @@
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayLanguage(UnicodeString& dispLang) const
|
||||
Locale::getDisplayLanguage(UnicodeString& dispLang U_LIFETIME_BOUND) const
|
||||
{
|
||||
return this->getDisplayLanguage(getDefault(), dispLang);
|
||||
}
|
||||
@@ -54,8 +54,8 @@ Locale::getDisplayLanguage(UnicodeString& dispLang) const
|
||||
* the exact buffer we need copy it to the UnicodeString and delete it*/
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayLanguage(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
Locale::getDisplayLanguage(const Locale& displayLocale,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
@@ -88,14 +88,14 @@ Locale::getDisplayLanguage(const Locale &displayLocale,
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayScript(UnicodeString& dispScript) const
|
||||
Locale::getDisplayScript(UnicodeString& dispScript U_LIFETIME_BOUND) const
|
||||
{
|
||||
return this->getDisplayScript(getDefault(), dispScript);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayScript(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
Locale::getDisplayScript(const Locale& displayLocale,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
@@ -128,14 +128,14 @@ Locale::getDisplayScript(const Locale &displayLocale,
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayCountry(UnicodeString& dispCntry) const
|
||||
Locale::getDisplayCountry(UnicodeString& dispCntry U_LIFETIME_BOUND) const
|
||||
{
|
||||
return this->getDisplayCountry(getDefault(), dispCntry);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayCountry(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
Locale::getDisplayCountry(const Locale& displayLocale,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
@@ -168,14 +168,14 @@ Locale::getDisplayCountry(const Locale &displayLocale,
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayVariant(UnicodeString& dispVar) const
|
||||
Locale::getDisplayVariant(UnicodeString& dispVar U_LIFETIME_BOUND) const
|
||||
{
|
||||
return this->getDisplayVariant(getDefault(), dispVar);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayVariant(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
Locale::getDisplayVariant(const Locale& displayLocale,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
@@ -208,14 +208,14 @@ Locale::getDisplayVariant(const Locale &displayLocale,
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayName( UnicodeString& name ) const
|
||||
Locale::getDisplayName(UnicodeString& name U_LIFETIME_BOUND) const
|
||||
{
|
||||
return this->getDisplayName(getDefault(), name);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
Locale::getDisplayName(const Locale &displayLocale,
|
||||
UnicodeString &result) const {
|
||||
Locale::getDisplayName(const Locale& displayLocale,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
char16_t *buffer;
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
int32_t length;
|
||||
@@ -253,7 +253,7 @@ Locale::getDisplayName(const Locale &displayLocale,
|
||||
// Gets the objectLocale display name in the default locale language.
|
||||
UnicodeString& U_EXPORT2
|
||||
BreakIterator::getDisplayName(const Locale& objectLocale,
|
||||
UnicodeString& name)
|
||||
UnicodeString& name U_LIFETIME_BOUND)
|
||||
{
|
||||
return objectLocale.getDisplayName(name);
|
||||
}
|
||||
@@ -262,8 +262,8 @@ BreakIterator::getDisplayName(const Locale& objectLocale,
|
||||
// Gets the objectLocale display name in the displayLocale language.
|
||||
UnicodeString& U_EXPORT2
|
||||
BreakIterator::getDisplayName(const Locale& objectLocale,
|
||||
const Locale& displayLocale,
|
||||
UnicodeString& name)
|
||||
const Locale& displayLocale,
|
||||
UnicodeString& name U_LIFETIME_BOUND)
|
||||
{
|
||||
return objectLocale.getDisplayName(displayLocale, name);
|
||||
}
|
||||
|
||||
+85
-77
@@ -44,26 +44,26 @@ public:
|
||||
ICUDataTable(const char* path, const Locale& locale);
|
||||
~ICUDataTable() = default;
|
||||
|
||||
const Locale& getLocale();
|
||||
const Locale& getLocale() U_LIFETIME_BOUND;
|
||||
|
||||
UnicodeString& get(const char* tableKey, const char* itemKey,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
UnicodeString& get(const char* tableKey, const char* subTableKey, const char* itemKey,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
|
||||
UnicodeString& getNoFallback(const char* tableKey, const char* itemKey,
|
||||
UnicodeString &result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
UnicodeString& getNoFallback(const char* tableKey, const char* subTableKey, const char* itemKey,
|
||||
UnicodeString &result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
};
|
||||
|
||||
inline UnicodeString &
|
||||
ICUDataTable::get(const char* tableKey, const char* itemKey, UnicodeString& result) const {
|
||||
inline UnicodeString& ICUDataTable::get(const char* tableKey, const char* itemKey,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return get(tableKey, nullptr, itemKey, result);
|
||||
}
|
||||
|
||||
inline UnicodeString &
|
||||
ICUDataTable::getNoFallback(const char* tableKey, const char* itemKey, UnicodeString& result) const {
|
||||
inline UnicodeString& ICUDataTable::getNoFallback(const char* tableKey, const char* itemKey,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return getNoFallback(tableKey, nullptr, itemKey, result);
|
||||
}
|
||||
|
||||
@@ -74,13 +74,13 @@ ICUDataTable::ICUDataTable(const char* path, const Locale& locale)
|
||||
}
|
||||
|
||||
const Locale&
|
||||
ICUDataTable::getLocale() {
|
||||
ICUDataTable::getLocale() U_LIFETIME_BOUND {
|
||||
return locale;
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
UnicodeString&
|
||||
ICUDataTable::get(const char* tableKey, const char* subTableKey, const char* itemKey,
|
||||
UnicodeString &result) const {
|
||||
UnicodeString &result U_LIFETIME_BOUND) const {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t len = 0;
|
||||
|
||||
@@ -93,9 +93,9 @@ ICUDataTable::get(const char* tableKey, const char* subTableKey, const char* ite
|
||||
return result.setTo(UnicodeString(itemKey, -1, US_INV));
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
UnicodeString&
|
||||
ICUDataTable::getNoFallback(const char* tableKey, const char* subTableKey, const char* itemKey,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t len = 0;
|
||||
|
||||
@@ -127,28 +127,28 @@ public:
|
||||
|
||||
virtual ~DefaultLocaleDisplayNames();
|
||||
|
||||
virtual const Locale& getLocale() const;
|
||||
virtual const Locale& getLocale() const U_LIFETIME_BOUND;
|
||||
virtual UDialectHandling getDialectHandling() const;
|
||||
|
||||
virtual UnicodeString& localeDisplayName(const Locale& locale,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
virtual UnicodeString& localeDisplayName(const char* localeId,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
virtual UnicodeString& languageDisplayName(const char* lang,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
virtual UnicodeString& scriptDisplayName(const char* script,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
virtual UnicodeString& scriptDisplayName(UScriptCode scriptCode,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
virtual UnicodeString& regionDisplayName(const char* region,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
virtual UnicodeString& variantDisplayName(const char* variant,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
virtual UnicodeString& keyDisplayName(const char* key,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
virtual UnicodeString& keyValueDisplayName(const char* key,
|
||||
const char* value,
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
};
|
||||
|
||||
DefaultLocaleDisplayNames::DefaultLocaleDisplayNames(UDialectHandling dialectHandling)
|
||||
@@ -159,7 +159,7 @@ DefaultLocaleDisplayNames::~DefaultLocaleDisplayNames() {
|
||||
}
|
||||
|
||||
const Locale&
|
||||
DefaultLocaleDisplayNames::getLocale() const {
|
||||
DefaultLocaleDisplayNames::getLocale() const U_LIFETIME_BOUND {
|
||||
return Locale::getRoot();
|
||||
}
|
||||
|
||||
@@ -170,31 +170,31 @@ DefaultLocaleDisplayNames::getDialectHandling() const {
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::localeDisplayName(const Locale& locale,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return result = UnicodeString(locale.getName(), -1, US_INV);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::localeDisplayName(const char* localeId,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return result = UnicodeString(localeId, -1, US_INV);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::languageDisplayName(const char* lang,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return result = UnicodeString(lang, -1, US_INV);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::scriptDisplayName(const char* script,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return result = UnicodeString(script, -1, US_INV);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::scriptDisplayName(UScriptCode scriptCode,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
const char* name = uscript_getName(scriptCode);
|
||||
if (name) {
|
||||
return result = UnicodeString(name, -1, US_INV);
|
||||
@@ -204,26 +204,26 @@ DefaultLocaleDisplayNames::scriptDisplayName(UScriptCode scriptCode,
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::regionDisplayName(const char* region,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return result = UnicodeString(region, -1, US_INV);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::variantDisplayName(const char* variant,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return result = UnicodeString(variant, -1, US_INV);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::keyDisplayName(const char* key,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return result = UnicodeString(key, -1, US_INV);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
DefaultLocaleDisplayNames::keyValueDisplayName(const char* /* key */,
|
||||
const char* value,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return result = UnicodeString(value, -1, US_INV);
|
||||
}
|
||||
|
||||
@@ -272,40 +272,48 @@ public:
|
||||
LocaleDisplayNamesImpl(const Locale& locale, UDisplayContext *contexts, int32_t length);
|
||||
virtual ~LocaleDisplayNamesImpl();
|
||||
|
||||
virtual const Locale& getLocale() const override;
|
||||
virtual const Locale& getLocale() const U_LIFETIME_BOUND override;
|
||||
virtual UDialectHandling getDialectHandling() const override;
|
||||
virtual UDisplayContext getContext(UDisplayContextType type) const override;
|
||||
|
||||
virtual UnicodeString& localeDisplayName(const Locale& locale,
|
||||
UnicodeString& result) const override;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
virtual UnicodeString& localeDisplayName(const char* localeId,
|
||||
UnicodeString& result) const override;
|
||||
virtual UnicodeString& languageDisplayName(const char* lang,
|
||||
UnicodeString& result) const override;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
virtual UnicodeString&
|
||||
languageDisplayName(const char* lang, UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
virtual UnicodeString& scriptDisplayName(const char* script,
|
||||
UnicodeString& result) const override;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
virtual UnicodeString& scriptDisplayName(UScriptCode scriptCode,
|
||||
UnicodeString& result) const override;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
virtual UnicodeString& regionDisplayName(const char* region,
|
||||
UnicodeString& result) const override;
|
||||
virtual UnicodeString& variantDisplayName(const char* variant,
|
||||
UnicodeString& result) const override;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
virtual UnicodeString&
|
||||
variantDisplayName(const char* variant, UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
virtual UnicodeString& keyDisplayName(const char* key,
|
||||
UnicodeString& result) const override;
|
||||
virtual UnicodeString& keyValueDisplayName(const char* key,
|
||||
const char* value,
|
||||
UnicodeString& result) const override;
|
||||
UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
virtual UnicodeString&
|
||||
keyValueDisplayName(const char* key, const char* value,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const override;
|
||||
|
||||
private:
|
||||
UnicodeString& localeIdName(const char* localeId,
|
||||
UnicodeString& result, bool substitute) const;
|
||||
UnicodeString& appendWithSep(UnicodeString& buffer, const UnicodeString& src) const;
|
||||
UnicodeString& adjustForUsageAndContext(CapContextUsage usage, UnicodeString& result) const;
|
||||
UnicodeString& scriptDisplayName(const char* script, UnicodeString& result, bool skipAdjust) const;
|
||||
UnicodeString& regionDisplayName(const char* region, UnicodeString& result, bool skipAdjust) const;
|
||||
UnicodeString& variantDisplayName(const char* variant, UnicodeString& result, bool skipAdjust) const;
|
||||
UnicodeString& keyDisplayName(const char* key, UnicodeString& result, bool skipAdjust) const;
|
||||
UnicodeString& localeIdName(const char* localeId, UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool substitute) const;
|
||||
UnicodeString& appendWithSep(UnicodeString& buffer U_LIFETIME_BOUND,
|
||||
const UnicodeString& src) const;
|
||||
UnicodeString& adjustForUsageAndContext(CapContextUsage usage,
|
||||
UnicodeString& result U_LIFETIME_BOUND) const;
|
||||
UnicodeString& scriptDisplayName(const char* script, UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const;
|
||||
UnicodeString& regionDisplayName(const char* region, UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const;
|
||||
UnicodeString& variantDisplayName(const char* variant, UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const;
|
||||
UnicodeString& keyDisplayName(const char* key, UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const;
|
||||
UnicodeString& keyValueDisplayName(const char* key, const char* value,
|
||||
UnicodeString& result, bool skipAdjust) const;
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const;
|
||||
void initialize();
|
||||
|
||||
struct CapitalizationContextSink;
|
||||
@@ -483,7 +491,7 @@ LocaleDisplayNamesImpl::~LocaleDisplayNamesImpl() {
|
||||
}
|
||||
|
||||
const Locale&
|
||||
LocaleDisplayNamesImpl::getLocale() const {
|
||||
LocaleDisplayNamesImpl::getLocale() const U_LIFETIME_BOUND {
|
||||
return locale;
|
||||
}
|
||||
|
||||
@@ -511,7 +519,7 @@ LocaleDisplayNamesImpl::getContext(UDisplayContextType type) const {
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::adjustForUsageAndContext(CapContextUsage usage,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) 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!= nullptr &&
|
||||
@@ -527,7 +535,7 @@ LocaleDisplayNamesImpl::adjustForUsageAndContext(CapContextUsage usage,
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
if (loc.isBogus()) {
|
||||
result.setToBogus();
|
||||
return result;
|
||||
@@ -669,7 +677,7 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& loc,
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::appendWithSep(UnicodeString& buffer, const UnicodeString& src) const {
|
||||
LocaleDisplayNamesImpl::appendWithSep(UnicodeString& buffer U_LIFETIME_BOUND, const UnicodeString& src) const {
|
||||
if (buffer.isEmpty()) {
|
||||
buffer.setTo(src);
|
||||
} else {
|
||||
@@ -682,14 +690,14 @@ LocaleDisplayNamesImpl::appendWithSep(UnicodeString& buffer, const UnicodeString
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::localeDisplayName(const char* localeId,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return localeDisplayName(Locale(localeId), result);
|
||||
}
|
||||
|
||||
// private
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::localeIdName(const char* localeId,
|
||||
UnicodeString& result, bool substitute) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND, bool substitute) const {
|
||||
if (nameLength == UDISPCTX_LENGTH_SHORT) {
|
||||
langData.getNoFallback("Languages%short", localeId, result);
|
||||
if (!result.isBogus()) {
|
||||
@@ -719,7 +727,7 @@ LocaleDisplayNamesImpl::localeIdName(const char* localeId,
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::languageDisplayName(const char* lang,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
if (uprv_strcmp("root", lang) == 0 || uprv_strchr(lang, '_') != nullptr) {
|
||||
return result = UnicodeString(lang, -1, US_INV);
|
||||
}
|
||||
@@ -751,7 +759,7 @@ LocaleDisplayNamesImpl::languageDisplayName(const char* lang,
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::scriptDisplayName(const char* script,
|
||||
UnicodeString& result,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const {
|
||||
if (nameLength == UDISPCTX_LENGTH_SHORT) {
|
||||
langData.getNoFallback("Scripts%short", script, result);
|
||||
@@ -769,19 +777,19 @@ LocaleDisplayNamesImpl::scriptDisplayName(const char* script,
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::scriptDisplayName(const char* script,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return scriptDisplayName(script, result, false);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::scriptDisplayName(UScriptCode scriptCode,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return scriptDisplayName(uscript_getName(scriptCode), result, false);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::regionDisplayName(const char* region,
|
||||
UnicodeString& result,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const {
|
||||
if (nameLength == UDISPCTX_LENGTH_SHORT) {
|
||||
regionData.getNoFallback("Countries%short", region, result);
|
||||
@@ -799,14 +807,14 @@ LocaleDisplayNamesImpl::regionDisplayName(const char* region,
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::regionDisplayName(const char* region,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return regionDisplayName(region, result, false);
|
||||
}
|
||||
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::variantDisplayName(const char* variant,
|
||||
UnicodeString& result,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const {
|
||||
// don't have a resource for short variant names
|
||||
if (substitute == UDISPCTX_SUBSTITUTE) {
|
||||
@@ -819,13 +827,13 @@ LocaleDisplayNamesImpl::variantDisplayName(const char* variant,
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::variantDisplayName(const char* variant,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return variantDisplayName(variant, result, false);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::keyDisplayName(const char* key,
|
||||
UnicodeString& result,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const {
|
||||
// don't have a resource for short key names
|
||||
if (substitute == UDISPCTX_SUBSTITUTE) {
|
||||
@@ -838,14 +846,14 @@ LocaleDisplayNamesImpl::keyDisplayName(const char* key,
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::keyDisplayName(const char* key,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return keyDisplayName(key, result, false);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::keyValueDisplayName(const char* key,
|
||||
const char* value,
|
||||
UnicodeString& result,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
bool skipAdjust) const {
|
||||
if (uprv_strcmp(key, "currency") == 0) {
|
||||
// ICU4C does not have ICU4J CurrencyDisplayInfo equivalent for now.
|
||||
@@ -880,7 +888,7 @@ LocaleDisplayNamesImpl::keyValueDisplayName(const char* key,
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::keyValueDisplayName(const char* key,
|
||||
const char* value,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result U_LIFETIME_BOUND) const {
|
||||
return keyValueDisplayName(key, value, result, false);
|
||||
}
|
||||
|
||||
@@ -939,8 +947,8 @@ uldn_close(ULocaleDisplayNames *ldn) {
|
||||
delete (LocaleDisplayNames *)ldn;
|
||||
}
|
||||
|
||||
U_CAPI const char * U_EXPORT2
|
||||
uldn_getLocale(const ULocaleDisplayNames *ldn) {
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uldn_getLocale(const ULocaleDisplayNames* ldn U_LIFETIME_BOUND) {
|
||||
if (ldn) {
|
||||
return ((const LocaleDisplayNames *)ldn)->getLocale().getName();
|
||||
}
|
||||
|
||||
+64
-51
@@ -63,6 +63,10 @@
|
||||
#include "ustr_imp.h"
|
||||
#include "uvector.h"
|
||||
|
||||
#if UPRV_HAS_FEATURE(memory_sanitizer)
|
||||
#include <sanitizer/msan_interface.h>
|
||||
#endif
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
static Locale *gLocaleCache = nullptr;
|
||||
@@ -272,6 +276,10 @@ Locale::Nest::Nest(Heap&& heap, uint8_t variantBegin) {
|
||||
static_assert(offsetof(Nest, region) <= offsetof(Heap, script));
|
||||
static_assert(offsetof(Nest, variantBegin) <= offsetof(Heap, region));
|
||||
U_ASSERT(this == reinterpret_cast<Nest*>(&heap));
|
||||
#if UPRV_HAS_FEATURE(memory_sanitizer)
|
||||
// Tell the sanitizer that we know that this memory really is OK to access.
|
||||
__msan_unpoison(&heap, sizeof(Heap));
|
||||
#endif
|
||||
copyToArray<&Nest::script>(heap.script, this);
|
||||
copyToArray<&Nest::region>(heap.region, this);
|
||||
this->variantBegin = variantBegin;
|
||||
@@ -283,9 +291,11 @@ struct Locale::Heap::Alloc : public UMemory {
|
||||
FixedString baseName;
|
||||
int32_t variantBegin;
|
||||
|
||||
const char* getVariant() const { return variantBegin == 0 ? "" : getBaseName() + variantBegin; }
|
||||
const char* getFullName() const { return fullName.data(); }
|
||||
const char* getBaseName() const {
|
||||
const char* getVariant() const U_LIFETIME_BOUND {
|
||||
return variantBegin == 0 ? "" : getBaseName() + variantBegin;
|
||||
}
|
||||
const char* getFullName() const U_LIFETIME_BOUND { return fullName.data(); }
|
||||
const char* getBaseName() const U_LIFETIME_BOUND {
|
||||
if (baseName.isEmpty()) {
|
||||
if (const char* name = fullName.data(); *name != '@') {
|
||||
return name;
|
||||
@@ -321,9 +331,9 @@ struct Locale::Heap::Alloc : public UMemory {
|
||||
~Alloc() = default;
|
||||
};
|
||||
|
||||
const char* Locale::Heap::getVariant() const { return ptr->getVariant(); }
|
||||
const char* Locale::Heap::getFullName() const { return ptr->getFullName(); }
|
||||
const char* Locale::Heap::getBaseName() const { return ptr->getBaseName(); }
|
||||
const char* Locale::Heap::getVariant() const U_LIFETIME_BOUND { return ptr->getVariant(); }
|
||||
const char* Locale::Heap::getFullName() const U_LIFETIME_BOUND { return ptr->getFullName(); }
|
||||
const char* Locale::Heap::getBaseName() const U_LIFETIME_BOUND { return ptr->getBaseName(); }
|
||||
|
||||
Locale::Heap::Heap(std::string_view language,
|
||||
std::string_view script,
|
||||
@@ -345,7 +355,7 @@ Locale::Heap::~Heap() {
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
Locale::Heap& Locale::Heap::operator=(const Heap& other) {
|
||||
Locale::Heap& Locale::Heap::operator=(const Heap& other) U_LIFETIME_BOUND {
|
||||
U_ASSERT(type == eBOGUS);
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ptr = new Alloc(*other.ptr, status);
|
||||
@@ -360,7 +370,7 @@ Locale::Heap& Locale::Heap::operator=(const Heap& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Locale::Heap& Locale::Heap::operator=(Heap&& other) noexcept {
|
||||
Locale::Heap& Locale::Heap::operator=(Heap&& other) noexcept U_LIFETIME_BOUND {
|
||||
U_ASSERT(type == eBOGUS);
|
||||
ptr = other.ptr;
|
||||
type = eHEAP;
|
||||
@@ -407,7 +417,7 @@ Locale::Payload::~Payload() {
|
||||
Locale::Payload::Payload(const Payload& other) : type{eBOGUS} { copy(other); }
|
||||
Locale::Payload::Payload(Payload&& other) noexcept : type{eBOGUS} { move(std::move(other)); }
|
||||
|
||||
Locale::Payload& Locale::Payload::operator=(const Payload& other) {
|
||||
Locale::Payload& Locale::Payload::operator=(const Payload& other) U_LIFETIME_BOUND {
|
||||
if (this != &other) {
|
||||
setToBogus();
|
||||
copy(other);
|
||||
@@ -415,7 +425,7 @@ Locale::Payload& Locale::Payload::operator=(const Payload& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Locale::Payload& Locale::Payload::operator=(Payload&& other) noexcept {
|
||||
Locale::Payload& Locale::Payload::operator=(Payload&& other) noexcept U_LIFETIME_BOUND {
|
||||
if (this != &other) {
|
||||
setToBogus();
|
||||
move(std::move(other));
|
||||
@@ -428,7 +438,7 @@ void Locale::Payload::setToBogus() {
|
||||
type = eBOGUS;
|
||||
}
|
||||
|
||||
template <typename T, typename... Args> T& Locale::Payload::emplace(Args&&... args) {
|
||||
template <typename T, typename... Args> T& Locale::Payload::emplace(Args&&... args) U_LIFETIME_BOUND {
|
||||
if constexpr (std::is_same_v<T, Nest>) {
|
||||
this->~Payload();
|
||||
::new (&nest) Nest(std::forward<Args>(args)...);
|
||||
@@ -441,8 +451,12 @@ template <typename T, typename... Args> T& Locale::Payload::emplace(Args&&... ar
|
||||
}
|
||||
}
|
||||
|
||||
template <> Locale::Nest* Locale::Payload::get() { return type == eNEST ? &nest : nullptr; }
|
||||
template <> Locale::Heap* Locale::Payload::get() { return type == eHEAP ? &heap : nullptr; }
|
||||
template <> Locale::Nest* Locale::Payload::get() U_LIFETIME_BOUND {
|
||||
return type == eNEST ? &nest : nullptr;
|
||||
}
|
||||
template <> Locale::Heap* Locale::Payload::get() U_LIFETIME_BOUND {
|
||||
return type == eHEAP ? &heap : nullptr;
|
||||
}
|
||||
|
||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Locale)
|
||||
|
||||
@@ -586,8 +600,8 @@ Locale::Locale( const char * newLanguage,
|
||||
Locale::Locale(const Locale&) = default;
|
||||
Locale::Locale(Locale&&) noexcept = default;
|
||||
|
||||
Locale& Locale::operator=(const Locale&) = default;
|
||||
Locale& Locale::operator=(Locale&&) noexcept = default;
|
||||
Locale& Locale::operator=(const Locale&) U_LIFETIME_BOUND = default;
|
||||
Locale& Locale::operator=(Locale&&) noexcept U_LIFETIME_BOUND = default;
|
||||
|
||||
Locale *
|
||||
Locale::clone() const {
|
||||
@@ -749,11 +763,11 @@ public:
|
||||
return gSingleton;
|
||||
}
|
||||
|
||||
const CharStringMap& languageMap() const { return language; }
|
||||
const CharStringMap& scriptMap() const { return script; }
|
||||
const CharStringMap& territoryMap() const { return territory; }
|
||||
const CharStringMap& variantMap() const { return variant; }
|
||||
const CharStringMap& subdivisionMap() const { return subdivision; }
|
||||
const CharStringMap& languageMap() const U_LIFETIME_BOUND { return language; }
|
||||
const CharStringMap& scriptMap() const U_LIFETIME_BOUND { return script; }
|
||||
const CharStringMap& territoryMap() const U_LIFETIME_BOUND { return territory; }
|
||||
const CharStringMap& variantMap() const U_LIFETIME_BOUND { return variant; }
|
||||
const CharStringMap& subdivisionMap() const U_LIFETIME_BOUND { return subdivision; }
|
||||
|
||||
static void U_CALLCONV loadData(UErrorCode &status);
|
||||
static UBool U_CALLCONV cleanup();
|
||||
@@ -1224,8 +1238,9 @@ private:
|
||||
* nullptr || "" CCC nullptr CCC
|
||||
* nullptr || "" * DDD nullptr
|
||||
*/
|
||||
inline const char* deleteOrReplace(
|
||||
const char* input, const char* type, const char* replacement) {
|
||||
inline const char* deleteOrReplace(const char* input U_LIFETIME_BOUND,
|
||||
const char* type,
|
||||
const char* replacement U_LIFETIME_BOUND) {
|
||||
return notEmpty(replacement) ?
|
||||
((input == nullptr) ? replacement : input) :
|
||||
((type == nullptr) ? input : nullptr);
|
||||
@@ -1243,11 +1258,11 @@ private:
|
||||
}
|
||||
|
||||
// Gather fields and generate locale ID into out.
|
||||
CharString& outputToString(CharString& out, UErrorCode& status);
|
||||
CharString& outputToString(CharString& out U_LIFETIME_BOUND, UErrorCode& status);
|
||||
|
||||
// Generate the lookup key.
|
||||
CharString& generateKey(const char* language, const char* region,
|
||||
const char* variant, CharString& out,
|
||||
const char* variant, CharString& out U_LIFETIME_BOUND,
|
||||
UErrorCode& status);
|
||||
|
||||
void parseLanguageReplacement(const char* replacement,
|
||||
@@ -1285,7 +1300,7 @@ private:
|
||||
CharString&
|
||||
AliasReplacer::generateKey(
|
||||
const char* language, const char* region, const char* variant,
|
||||
CharString& out, UErrorCode& status)
|
||||
CharString& out U_LIFETIME_BOUND, UErrorCode& status)
|
||||
{
|
||||
if (U_FAILURE(status)) { return out; }
|
||||
out.append(language, status);
|
||||
@@ -1322,14 +1337,13 @@ AliasReplacer::parseLanguageReplacement(
|
||||
return;
|
||||
}
|
||||
// We have multiple field so we have to allocate and parse
|
||||
CharString* str =
|
||||
new CharString(replacement, static_cast<int32_t>(uprv_strlen(replacement)), status);
|
||||
LocalPointer<CharString> lpStr(str, status);
|
||||
toBeFreed.adoptElement(lpStr.orphan(), status);
|
||||
auto str = prv::make_unique<CharString>(
|
||||
replacement, static_cast<int32_t>(uprv_strlen(replacement)), status, status);
|
||||
char* data = str->data();
|
||||
toBeFreed.adoptElement(str.release(), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
char* data = str->data();
|
||||
replacedLanguage = (const char*) data;
|
||||
char* endOfField = uprv_strchr(data, '_');
|
||||
*endOfField = '\0'; // null terminiate it.
|
||||
@@ -1515,7 +1529,7 @@ AliasReplacer::replaceTerritory(UVector& toBeFreed, UErrorCode& status)
|
||||
.build(status);
|
||||
l.addLikelySubtags(status);
|
||||
const char* likelyRegion = l.getCountry();
|
||||
LocalPointer<CharString> item;
|
||||
prv::unique_ptr<CharString> item;
|
||||
if (likelyRegion != nullptr && uprv_strlen(likelyRegion) > 0) {
|
||||
size_t len = uprv_strlen(likelyRegion);
|
||||
const char* foundInReplacement = uprv_strstr(replacement,
|
||||
@@ -1527,18 +1541,17 @@ AliasReplacer::replaceTerritory(UVector& toBeFreed, UErrorCode& status)
|
||||
*(foundInReplacement-1) == ' ');
|
||||
U_ASSERT(foundInReplacement[len] == ' ' ||
|
||||
foundInReplacement[len] == '\0');
|
||||
item.adoptInsteadAndCheckErrorCode(
|
||||
new CharString(foundInReplacement, static_cast<int32_t>(len), status), status);
|
||||
item = prv::make_unique<CharString>(
|
||||
foundInReplacement, static_cast<int32_t>(len), status, status);
|
||||
}
|
||||
}
|
||||
if (item.isNull() && U_SUCCESS(status)) {
|
||||
item.adoptInsteadAndCheckErrorCode(
|
||||
new CharString(replacement,
|
||||
static_cast<int32_t>(firstSpace - replacement), status), status);
|
||||
if (!item && U_SUCCESS(status)) {
|
||||
item = prv::make_unique<CharString>(
|
||||
replacement, static_cast<int32_t>(firstSpace - replacement), status, status);
|
||||
}
|
||||
if (U_FAILURE(status)) { return false; }
|
||||
replacedRegion = item->data();
|
||||
toBeFreed.adoptElement(item.orphan(), status);
|
||||
toBeFreed.adoptElement(item.release(), status);
|
||||
if (U_FAILURE(status)) { return false; }
|
||||
}
|
||||
U_ASSERT(!same(region, replacedRegion));
|
||||
@@ -1704,7 +1717,7 @@ AliasReplacer::replaceTransformedExtensions(
|
||||
|
||||
CharString&
|
||||
AliasReplacer::outputToString(
|
||||
CharString& out, UErrorCode& status)
|
||||
CharString& out U_LIFETIME_BOUND, UErrorCode& status)
|
||||
{
|
||||
if (U_FAILURE(status)) { return out; }
|
||||
out.append(language, status);
|
||||
@@ -1948,13 +1961,13 @@ ulocimp_isCanonicalizedLocaleForTest(const char* localeName)
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
Locale& Locale::init(const char* localeID, UBool canonicalize)
|
||||
Locale& Locale::init(const char* localeID, UBool canonicalize) U_LIFETIME_BOUND
|
||||
{
|
||||
return localeID == nullptr ? *this = getDefault() : init(StringPiece{localeID}, canonicalize);
|
||||
}
|
||||
|
||||
/*This function initializes a Locale from a C locale ID*/
|
||||
Locale& Locale::init(StringPiece localeID, UBool canonicalize)
|
||||
Locale& Locale::init(StringPiece localeID, UBool canonicalize) U_LIFETIME_BOUND
|
||||
{
|
||||
/* Free our current storage */
|
||||
Nest& nest = payload.emplace<Nest>();
|
||||
@@ -2579,7 +2592,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual const char* next(int32_t* resultLength, UErrorCode& status) override {
|
||||
virtual const char* next(int32_t* resultLength, UErrorCode& status) U_LIFETIME_BOUND override {
|
||||
const char* result;
|
||||
int32_t len;
|
||||
if(U_SUCCESS(status) && *current != 0) {
|
||||
@@ -2598,7 +2611,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual const UnicodeString* snext(UErrorCode& status) override {
|
||||
virtual const UnicodeString* snext(UErrorCode& status) U_LIFETIME_BOUND override {
|
||||
if (U_FAILURE(status)) { return nullptr; }
|
||||
int32_t resultLength = 0;
|
||||
const char *s = next(&resultLength, status);
|
||||
@@ -2623,7 +2636,7 @@ public:
|
||||
using KeywordEnumeration::KeywordEnumeration;
|
||||
virtual ~UnicodeKeywordEnumeration();
|
||||
|
||||
virtual const char* next(int32_t* resultLength, UErrorCode& status) override {
|
||||
virtual const char* next(int32_t* resultLength, UErrorCode& status) U_LIFETIME_BOUND override {
|
||||
const char* legacy_key = KeywordEnumeration::next(nullptr, status);
|
||||
while (U_SUCCESS(status) && legacy_key != nullptr) {
|
||||
const char* key = uloc_toUnicodeLocaleKey(legacy_key);
|
||||
@@ -2877,38 +2890,38 @@ Locale::setUnicodeKeywordValue(StringPiece keywordName,
|
||||
}
|
||||
|
||||
const char*
|
||||
Locale::getCountry() const {
|
||||
Locale::getCountry() const U_LIFETIME_BOUND {
|
||||
return getField<&Nest::getRegion, &Heap::getRegion>();
|
||||
}
|
||||
|
||||
const char*
|
||||
Locale::getLanguage() const {
|
||||
Locale::getLanguage() const U_LIFETIME_BOUND {
|
||||
return getField<&Nest::getLanguage, &Heap::getLanguage>();
|
||||
}
|
||||
|
||||
const char*
|
||||
Locale::getScript() const {
|
||||
Locale::getScript() const U_LIFETIME_BOUND {
|
||||
return getField<&Nest::getScript, &Heap::getScript>();
|
||||
}
|
||||
|
||||
const char*
|
||||
Locale::getVariant() const {
|
||||
Locale::getVariant() const U_LIFETIME_BOUND {
|
||||
return getField<&Nest::getVariant, &Heap::getVariant>();
|
||||
}
|
||||
|
||||
const char*
|
||||
Locale::getName() const {
|
||||
Locale::getName() const U_LIFETIME_BOUND {
|
||||
return getField<&Nest::getBaseName, &Heap::getFullName>();
|
||||
}
|
||||
|
||||
const char*
|
||||
Locale::getBaseName() const {
|
||||
Locale::getBaseName() const U_LIFETIME_BOUND {
|
||||
return getField<&Nest::getBaseName, &Heap::getBaseName>();
|
||||
}
|
||||
|
||||
template <const char* (Locale::Nest::*const NEST)() const,
|
||||
const char* (Locale::Heap::*const HEAP)() const>
|
||||
const char* Locale::getField() const {
|
||||
const char* Locale::getField() const U_LIFETIME_BOUND {
|
||||
return payload.visit([] { return ""; },
|
||||
[](const Nest& nest) { return (nest.*NEST)(); },
|
||||
[](const Heap& heap) { return (heap.*HEAP)(); });
|
||||
|
||||
+1
-1
@@ -418,7 +418,7 @@ GetRegionFromKey(const char* localeID, std::string_view key, UErrorCode& status)
|
||||
if (U_SUCCESS(status) && len >= 3 && len <= 6 &&
|
||||
uprv_isASCIILetter(kw[0]) && uprv_isASCIILetter(kw[1])) {
|
||||
// Additional Check
|
||||
static icu::RegionValidateMap valid;
|
||||
icu::RegionValidateMap valid;
|
||||
const char region[] = {kw[0], kw[1], '\0'};
|
||||
if (valid.isSet(region)) {
|
||||
result.append(uprv_toupper(kw[0]), status);
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public:
|
||||
UErrorCode &errorCode) const;
|
||||
|
||||
// visible for LocaleDistance
|
||||
const LocaleDistanceData &getDistanceData() const { return distanceData; }
|
||||
const LocaleDistanceData& getDistanceData() const U_LIFETIME_BOUND { return distanceData; }
|
||||
|
||||
private:
|
||||
LikelySubtags(LikelySubtagsData &data);
|
||||
|
||||
-1
@@ -1173,7 +1173,6 @@ uprv_convertToLCIDPlatform(const char* localeID, UErrorCode* status)
|
||||
// The purpose of this function is to leverage the Windows platform name->lcid
|
||||
// conversion functionality when available.
|
||||
#if U_PLATFORM_HAS_WIN32_API && UCONFIG_USE_WINDOWS_LCID_MAPPING_API
|
||||
int32_t len;
|
||||
icu::CharString baseName;
|
||||
const char * mylocaleID = localeID;
|
||||
|
||||
|
||||
+2
-2
@@ -50,9 +50,9 @@ public:
|
||||
* Appends the sub-message to the result string.
|
||||
* Omits SKIP_SYNTAX and appends whole arguments using appendReducedApostrophes().
|
||||
*/
|
||||
static UnicodeString &appendSubMessageWithoutSkipSyntax(const MessagePattern &msgPattern,
|
||||
static UnicodeString& appendSubMessageWithoutSkipSyntax(const MessagePattern& msgPattern,
|
||||
int32_t msgStart,
|
||||
UnicodeString &result);
|
||||
UnicodeString& result U_LIFETIME_BOUND);
|
||||
|
||||
private:
|
||||
MessageImpl() = delete; // no constructor: all static methods
|
||||
|
||||
+21
-16
@@ -195,8 +195,8 @@ MessagePattern::MessagePattern(const MessagePattern &other)
|
||||
}
|
||||
}
|
||||
|
||||
MessagePattern &
|
||||
MessagePattern::operator=(const MessagePattern &other) {
|
||||
MessagePattern&
|
||||
MessagePattern::operator=(const MessagePattern& other) U_LIFETIME_BOUND {
|
||||
if(this==&other) {
|
||||
return *this;
|
||||
}
|
||||
@@ -264,35 +264,40 @@ MessagePattern::~MessagePattern() {
|
||||
|
||||
// MessagePattern API ------------------------------------------------------ ***
|
||||
|
||||
MessagePattern &
|
||||
MessagePattern::parse(const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode) {
|
||||
MessagePattern&
|
||||
MessagePattern::parse(const UnicodeString& pattern,
|
||||
UParseError* parseError,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
preParse(pattern, parseError, errorCode);
|
||||
parseMessage(0, 0, 0, UMSGPAT_ARG_TYPE_NONE, parseError, errorCode);
|
||||
postParse();
|
||||
return *this;
|
||||
}
|
||||
|
||||
MessagePattern &
|
||||
MessagePattern::parseChoiceStyle(const UnicodeString &pattern,
|
||||
UParseError *parseError, UErrorCode &errorCode) {
|
||||
MessagePattern&
|
||||
MessagePattern::parseChoiceStyle(const UnicodeString& pattern,
|
||||
UParseError* parseError,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
preParse(pattern, parseError, errorCode);
|
||||
parseChoiceStyle(0, 0, parseError, errorCode);
|
||||
postParse();
|
||||
return *this;
|
||||
}
|
||||
|
||||
MessagePattern &
|
||||
MessagePattern::parsePluralStyle(const UnicodeString &pattern,
|
||||
UParseError *parseError, UErrorCode &errorCode) {
|
||||
MessagePattern&
|
||||
MessagePattern::parsePluralStyle(const UnicodeString& pattern,
|
||||
UParseError* parseError,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
preParse(pattern, parseError, errorCode);
|
||||
parsePluralOrSelectStyle(UMSGPAT_ARG_TYPE_PLURAL, 0, 0, parseError, errorCode);
|
||||
postParse();
|
||||
return *this;
|
||||
}
|
||||
|
||||
MessagePattern &
|
||||
MessagePattern::parseSelectStyle(const UnicodeString &pattern,
|
||||
UParseError *parseError, UErrorCode &errorCode) {
|
||||
MessagePattern&
|
||||
MessagePattern::parseSelectStyle(const UnicodeString& pattern,
|
||||
UParseError* parseError,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
preParse(pattern, parseError, errorCode);
|
||||
parsePluralOrSelectStyle(UMSGPAT_ARG_TYPE_SELECT, 0, 0, parseError, errorCode);
|
||||
postParse();
|
||||
@@ -1202,10 +1207,10 @@ MessageImpl::appendReducedApostrophes(const UnicodeString &s, int32_t start, int
|
||||
}
|
||||
|
||||
// Ported from second half of ICU4J SelectFormat.format(String).
|
||||
UnicodeString &
|
||||
MessageImpl::appendSubMessageWithoutSkipSyntax(const MessagePattern &msgPattern,
|
||||
UnicodeString&
|
||||
MessageImpl::appendSubMessageWithoutSkipSyntax(const MessagePattern& msgPattern,
|
||||
int32_t msgStart,
|
||||
UnicodeString &result) {
|
||||
UnicodeString& result U_LIFETIME_BOUND) {
|
||||
const UnicodeString &msgString=msgPattern.getPatternString();
|
||||
int32_t prevIndex=msgPattern.getPart(msgStart).getLimit();
|
||||
for(int32_t i=msgStart;;) {
|
||||
|
||||
+88
-84
@@ -10,14 +10,14 @@
|
||||
#ifdef INCLUDED_FROM_NORMALIZER2_CPP
|
||||
|
||||
static const UVersionInfo norm2_nfc_data_formatVersion={5,0,0,0};
|
||||
static const UVersionInfo norm2_nfc_data_dataVersion={0x11,0,0,0};
|
||||
static const UVersionInfo norm2_nfc_data_dataVersion={0x12,0,0,0};
|
||||
|
||||
static const int32_t norm2_nfc_data_indexes[Normalizer2Impl::IX_COUNT]={
|
||||
0x58,0x4eec,0x8cc8,0x8dc8,0x8dc8,0x8dc8,0x8dc8,0x8dc8,0xc0,0x300,0xb0c,0x2a6a,0x3cf0,0xfbc4,0x12c2,0x3c26,
|
||||
0x58,0x4f50,0x8d2c,0x8e2c,0x8e2c,0x8e2c,0x8e2c,0x8e2c,0xc0,0x300,0xb0c,0x2a6a,0x3cf0,0xfbc4,0x12c2,0x3c26,
|
||||
0x3cbe,0x3cf0,0x300,0,0xfb10,0xfb9e
|
||||
};
|
||||
|
||||
static const uint16_t norm2_nfc_data_trieIndex[1888]={
|
||||
static const uint16_t norm2_nfc_data_trieIndex[1891]={
|
||||
0,0x40,0x7b,0xbb,0xfb,0x13a,0x17a,0x1b2,0x1f2,0x226,0x254,0x226,0x294,0x2d4,0x313,0x353,
|
||||
0x393,0x3d2,0x40f,0x44e,0x226,0x226,0x488,0x4c8,0x4f8,0x530,0x226,0x570,0x59f,0x5de,0x226,0x5f3,
|
||||
0x631,0x65f,0x688,0x6be,0x6fe,0x73b,0x75b,0x79a,0x7d9,0x816,0x835,0x872,0x75b,0x8ab,0x8d9,0x918,
|
||||
@@ -82,7 +82,7 @@ static const uint16_t norm2_nfc_data_trieIndex[1888]={
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x1881,0x18c1,0x1901,0x1941,0x1981,0x19c1,0x1a01,0x1a41,0x1a64,0x1aa4,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1ac4,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x6e2,0x6f2,0x70a,0x729,0x73e,0x73e,0x73e,0x742,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x6e5,0x6f5,0x70d,0x72c,0x741,0x741,0x741,0x745,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0xc0c,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x54f,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x40c,
|
||||
@@ -91,54 +91,55 @@ static const uint16_t norm2_nfc_data_trieIndex[1888]={
|
||||
0x1b1a,0x226,0x226,0x1b2a,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0xdf8,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x1b3a,0x226,0x226,0x226,0x1b42,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x1608,0x226,0x226,0x226,0x226,0x1b50,0x226,0x226,0x226,0x226,0x1b60,0x54f,0x226,0x226,0x1b70,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x81d,0x226,0x226,0x1b80,0x226,0x1b90,0x1b9d,0x1ba9,0x226,0x226,
|
||||
0x226,0x226,0x414,0x226,0x1bb4,0x1bc4,0x226,0x226,0x226,0x812,0x226,0x226,0x226,0x226,0x1bd4,0x226,
|
||||
0x226,0x226,0x1bdf,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1be6,0x226,0x226,
|
||||
0x226,0x226,0x1bf1,0x1c00,0x928,0x1c0e,0x412,0x1c1c,0x1c2c,0x226,0x1c34,0x1c42,0x87f,0x226,0x226,0x226,
|
||||
0x226,0x1c52,0x7ca,0x226,0x226,0x226,0x226,0x226,0x1c62,0x1c71,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x908,0x1c79,0x1c89,0x226,0x226,0x226,0x9ec,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x1c93,0x226,0x226,0x226,0x226,0x226,0x226,0x818,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1c90,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1ca3,0x812,0x226,0x226,0x226,0x226,
|
||||
0x1608,0x226,0x1b50,0x226,0x226,0x1b60,0x226,0x226,0x226,0x226,0x1b70,0x54f,0x226,0x226,0x1b80,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x81d,0x226,0x226,0x1b90,0x226,0x1ba0,0x1bad,0x1bb9,0x226,0x226,
|
||||
0x226,0x226,0x414,0x226,0x1bc4,0x1bd4,0x226,0x226,0x226,0x812,0x226,0x226,0x226,0x226,0x1be4,0x226,
|
||||
0x226,0x226,0x1bef,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1bf6,0x226,0x226,
|
||||
0x226,0x226,0x1c01,0x1c10,0x928,0x1c1e,0x412,0x1c2c,0x1c3c,0x226,0x1c44,0x1c52,0x87f,0x226,0x226,0x226,
|
||||
0x226,0x1c62,0x7ca,0x226,0x226,0x226,0x226,0x226,0x1c72,0x1c81,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x908,0x1c89,0x1c99,0x226,0x226,0x226,0x9ec,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x1ca3,0x226,0x226,0x226,0x226,0x226,0x226,0x818,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1ca0,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1cb3,0x812,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x87f,0x226,0x226,0x226,0x81f,0x81c,0x226,0x226,0x226,0x226,0x81a,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x9ec,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0xc06,0x226,0x226,0x226,0x226,0x81c,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0xc09,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x1cb2,0x1cc1,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x1cd1,0x226,0x226,0x226,0xf2d,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1cde,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x1cc2,0x1cd1,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x1ce1,0x226,0x226,0x226,0xf2d,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1cee,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1cf0,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x1cff,0x1d0f,0x1d1d,0x1d2a,0x226,0x1d36,0x1d44,0x1d54,0x226,0x226,0x226,0x226,0xd1c,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1cfe,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1d00,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1d64,0x1d6c,0x1d7a,0x226,0x226,0x226,0x226,0x226,
|
||||
0x4f9,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0xf2d,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x7ca,0x226,0x226,0x226,0x4fc,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1d85,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x5c1,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1d95,0x7d3,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1da5,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x1db1,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x1dc1,0x1dd1,0x1de1,0x1df1,0x1e01,0x1e11,0x1e21,0x1e31,0x1e41,0x1e51,0x1e61,0x1e71,0x1e81,0x1e91,
|
||||
0x1ea1,0x1eb1,0x1ec1,0x1ed1,0x1ee1,0x1ef1,0x1f01,0x1f11,0x1f21,0x1f31,0x1f41,0x1f51,0x1f61,0x1f71,0x1f81,0x1f91,
|
||||
0x1fa1,0x1fb1,0x1fc1,0x1fd1,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0xb10,0x226,0x226,0x1d0f,0x1d1f,0x1d2d,0x1d3a,0x226,0x1d46,0x1d54,0x1d64,0x226,0x226,0x226,0x226,0xd1c,
|
||||
0x1d74,0x226,0x226,0x1d83,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x1d93,0x1d9b,0x1da9,0x226,0x226,
|
||||
0x226,0x226,0x226,0x4f9,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0xf2d,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x7ca,0x226,0x226,0x226,0x4fc,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x408,0x428,0x440,0xc4,0xc4,0x460,0x46f,0x486,0x4a2,0x4bf,0x4dd,0x4fa,0x517,0x536,
|
||||
0x553,0x56d,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,
|
||||
0xc4,0xc4,0x582,0xc4,0xc4,0xc4,0xc4,0x595,0x5a9,0x5c0,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,
|
||||
0x226,0x1db4,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x5c1,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x1dc4,0x7d3,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x1dd4,0x226,0x226,0x226,0x226,0x226,0x226,0x1de0,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x1df0,0x1e00,0x1e10,0x1e20,0x1e30,0x1e40,0x1e50,0x1e60,0x1e70,0x1e80,0x1e90,
|
||||
0x1ea0,0x1eb0,0x1ec0,0x1ed0,0x1ee0,0x1ef0,0x1f00,0x1f10,0x1f20,0x1f30,0x1f40,0x1f50,0x1f60,0x1f70,0x1f80,0x1f90,
|
||||
0x1fa0,0x1fb0,0x1fc0,0x1fd0,0x1fe0,0x1ff0,0x2000,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,0x226,
|
||||
0x226,0x226,0x226,0x226,0x226,0x408,0x428,0x440,0xc4,0xc4,0x460,0x46f,0x486,0x4a2,0x4bf,0x4dd,
|
||||
0x4fa,0x517,0x536,0x553,0x56d,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,
|
||||
0xc4,0xc4,0xc4,0xc4,0xc4,0x582,0xc4,0xc4,0xc4,0xc4,0x595,0x5a9,0x5c0,0xc4,0xc4,0xc4,
|
||||
0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,
|
||||
0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0x5e0,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,
|
||||
0xc4,0x5eb,0x608,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0x628,0x63e,0x650,0x66f,0x682,0xc4,0xc4,
|
||||
0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0x5e0,0xc4,0xc4,0xc4,0xc4,
|
||||
0xc4,0xc4,0xc4,0xc4,0x5ee,0x60b,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0x62b,0x641,0x653,0x672,
|
||||
0x685,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,
|
||||
0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,
|
||||
0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0x6a2,0x6c2
|
||||
0xc4,0x6a5,0x6c5
|
||||
};
|
||||
|
||||
static const uint16_t norm2_nfc_data_trieData[8162]={
|
||||
static const uint16_t norm2_nfc_data_trieData[8209]={
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
@@ -216,7 +217,7 @@ static const uint16_t norm2_nfc_data_trieData[8162]={
|
||||
0xffcc,0xffcc,0xffbc,0xffb8,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,
|
||||
0xffcc,0xffcc,0xffb8,0xffcc,0xffcc,0xffbc,0xffc8,0xffcc,0xfe14,0xfe16,0xfe18,0xfe1a,0xfe1c,0xfe1e,0xfe20,0xfe22,
|
||||
0xfe24,0xfe26,0xfe26,0xfe28,0xfe2a,0xfe2c,1,0xfe2e,1,0xfe30,0xfe32,1,0xffcc,0xffb8,1,0xfe24,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
0xfe14,0xfe2a,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,
|
||||
@@ -373,8 +374,8 @@ static const uint16_t norm2_nfc_data_trieData[8162]={
|
||||
1,1,1,1,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,
|
||||
0xffb8,0xffcc,0xffcc,0xffb8,1,0xffb8,0xffcc,0xffcc,0xffb8,0xffb8,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffb8,
|
||||
0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,
|
||||
0xffcc,0xffcc,0xffb8,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffb8,0xffcc,0xffcc,0xffcc,0xffcc,
|
||||
0xffd4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
0xffcc,0xffcc,0xffb8,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffb8,0xffcc,0xffcc,0xffcc,0xffcc,
|
||||
0xffd4,0xffcc,0xffcc,0xffb8,0xffb8,0xffcc,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,0x8c4,0x1a65,0x8c8,0x1a6b,0x8cc,0x1a71,0x8d0,0x1a77,0x8d4,0x1a7d,1,
|
||||
1,0x8d8,0x1a83,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
@@ -576,7 +577,8 @@ static const uint16_t norm2_nfc_data_trieData[8162]={
|
||||
1,1,1,1,1,1,1,0xffb8,1,0xffcc,1,1,1,1,1,1,
|
||||
1,1,0xffcc,0xfe02,0xffb8,1,1,1,1,0xfe12,1,1,1,1,0xffcc,0xffcc,
|
||||
0xffcc,0xffcc,1,1,1,1,1,1,1,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,
|
||||
1,1,1,1,1,1,1,1,1,1,0xffb8,0xffb8,1,0xffb8,0xffb8,0xffb8,
|
||||
1,1,1,1,1,1,1,1,1,1,1,0xffcc,0xffb8,0xffb8,0xffcc,0xffcc,
|
||||
0xffb8,0xffb8,0xffb8,0xffcc,0xffb8,0xffcc,0xffb8,0xffcc,0xffcc,0xffcc,0xffb8,0xffb8,1,0xffb8,0xffb8,0xffb8,
|
||||
1,1,1,1,1,1,0xffb8,0xffb8,0xffcc,0xffcc,0xffcc,0xffb8,0xffcc,0xffb8,0xffb8,0xffb8,
|
||||
1,1,0xffcc,0xffb8,0xffcc,0xffb8,1,1,1,1,1,1,1,1,1,1,
|
||||
0xfe12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0xfe12,
|
||||
@@ -609,53 +611,55 @@ static const uint16_t norm2_nfc_data_trieData[8162]={
|
||||
0xffcc,0xffcc,0xffcc,0xffcc,0xffb8,0xffb8,1,1,1,1,1,1,1,1,1,1,
|
||||
0xffcc,0xffcc,0xffcc,0xffcc,1,1,1,1,1,1,1,1,1,1,1,0x3370,
|
||||
0x337a,0x338e,0x33a6,0x33be,0x33d6,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,1,0xffcc,0xffcc,0xffcc,0xffcc,
|
||||
0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,1,0xffcc,0xffcc,1,
|
||||
0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,0xffd0,0xffd0,0xffb8,0xffcc,1,1,1,0xffcc,1,1,0xffcc,1,1,1,1,
|
||||
1,1,1,0xffcc,0xffcc,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,1,1,1,1,
|
||||
1,1,1,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xfe0e,1,1,1,1,
|
||||
1,0x33e5,0x33e9,0x33ed,0x33f1,0x33f7,0x2fd7,0x33fb,0x33ff,0x3403,0x3407,0x2fdb,0x340b,0x340f,0x3413,0x2fdf,
|
||||
0x3419,0x341d,0x3421,0x3425,0x342b,0x342f,0x3433,0x3437,0x343d,0x3441,0x3445,0x3449,0x30c9,0x344d,0x3453,0x3457,
|
||||
0x345b,0x345f,0x3463,0x3467,0x346b,0x346f,0x30dd,0x2fe3,0x2fe7,0x30e1,0x3473,0x3477,0x2ce3,0x347b,0x2feb,0x347f,
|
||||
0x3483,0x3487,0x348b,0x348b,0x348b,0x348f,0x3495,0x3499,0x349d,0x34a1,0x34a7,0x34ab,0x34af,0x34b3,0x34b7,0x34bb,
|
||||
0x34bf,0x34c3,0x34c7,0x34cb,0x34cf,0x34d3,0x34d7,0x34d7,0x30e9,0x34db,0x34df,0x34e3,0x34e7,0x2ff3,0x34eb,0x34ef,
|
||||
0x34f3,0x2f47,0x34f7,0x34fb,0x34ff,0x3503,0x3507,0x350b,0x350f,0x3513,0x3517,0x351d,0x3521,0x3525,0x3529,0x352d,
|
||||
0x3531,0x3535,0x353b,0x3541,0x3545,0x3549,0x354d,0x3551,0x3555,0x3559,0x355d,0x3561,0x3561,0x3565,0x356b,0x356f,
|
||||
0x2cd3,0x3573,0x3577,0x357d,0x3581,0x3585,0x3589,0x358d,0x3591,0x3007,0x3595,0x3599,0x359d,0x35a3,0x35a7,0x35ad,
|
||||
0x35b1,0x35b5,0x35b9,0x35bd,0x35c1,0x35c5,0x35c9,0x35cd,0x35d1,0x35d5,0x35d9,0x35df,0x35e3,0x35e7,0x35eb,0x2bfb,
|
||||
0x35ef,0x35f5,0x35f9,0x35f9,0x35ff,0x3603,0x3603,0x3607,0x360b,0x3611,0x3617,0x361b,0x361f,0x3623,0x3627,0x362b,
|
||||
0x362f,0x3633,0x3637,0x363b,0x300b,0x363f,0x3645,0x3649,0x364d,0x3119,0x364d,0x3651,0x3013,0x3655,0x3659,0x365d,
|
||||
0x3661,0x3017,0x2b8f,0x3665,0x3669,0x366d,0x3671,0x3675,0x3679,0x367d,0x3683,0x3687,0x368b,0x368f,0x3693,0x3697,
|
||||
0x369d,0x36a1,0x36a5,0x36a9,0x36ad,0x36b1,0x36b5,0x36b9,0x36bd,0x301b,0x36c1,0x36c5,0x36cb,0x36cf,0x36d3,0x36d7,
|
||||
0x3023,0x36db,0x36df,0x36e3,0x36e7,0x36eb,0x36ef,0x36f3,0x36f7,0x2bff,0x3139,0x36fb,0x36ff,0x3703,0x3707,0x370d,
|
||||
0x3711,0x3715,0x3719,0x3027,0x371d,0x3723,0x3727,0x372b,0x31eb,0x372f,0x3733,0x3737,0x373b,0x373f,0x3745,0x3749,
|
||||
0x374d,0x3751,0x3757,0x375b,0x375f,0x3763,0x2d17,0x3767,0x376b,0x3771,0x3777,0x377d,0x3781,0x3787,0x378b,0x378f,
|
||||
0x3793,0x3797,0x302b,0x2e73,0x379b,0x379f,0x37a3,0x37a7,0x37ad,0x37b1,0x37b5,0x37b9,0x3149,0x37bd,0x37c1,0x37c7,
|
||||
0x37cb,0x37cf,0x37d5,0x37db,0x37df,0x314d,0x37e3,0x37e7,0x37eb,0x37ef,0x37f3,0x37f7,0x37fb,0x3801,0x3805,0x380b,
|
||||
0x380f,0x3815,0x3155,0x3819,0x381d,0x3823,0x3827,0x382b,0x3831,0x3837,0x383b,0x383f,0x3843,0x3847,0x3847,0x384b,
|
||||
0x384f,0x315d,0x3853,0x3857,0x385b,0x385f,0x3863,0x3869,0x386d,0x2cdf,0x3873,0x3879,0x387d,0x3883,0x3889,0x388f,
|
||||
0x3893,0x3175,0x3897,0x389d,0x38a3,0x38a9,0x38af,0x38b3,0x38b3,0x3179,0x31f3,0x38b7,0x38bb,0x38bf,0x38c3,0x38c9,
|
||||
0x2c47,0x3181,0x38cd,0x38d1,0x3057,0x38d7,0x38dd,0x2f9f,0x38e3,0x38e7,0x3067,0x38eb,0x38ef,0x38f3,0x38f9,0x38f9,
|
||||
0x38ff,0x3903,0x3907,0x390d,0x3911,0x3915,0x3919,0x391f,0x3923,0x3927,0x392b,0x392f,0x3933,0x3939,0x393d,0x3941,
|
||||
0x3945,0x3949,0x394d,0x3951,0x3957,0x395d,0x3961,0x3967,0x396b,0x3971,0x3975,0x307f,0x3979,0x397f,0x3985,0x3989,
|
||||
0x398f,0x3993,0x3999,0x399d,0x39a1,0x39a5,0x39a9,0x39ad,0x39b1,0x39b7,0x39bd,0x39c3,0x35ff,0x39c9,0x39cd,0x39d1,
|
||||
0x39d5,0x39d9,0x39dd,0x39e1,0x39e5,0x39e9,0x39ed,0x39f1,0x39f5,0x2d27,0x39fb,0x39ff,0x3a03,0x3a07,0x3a0b,0x3a0f,
|
||||
0x308b,0x3a13,0x3a17,0x3a1b,0x3a1f,0x3a23,0x3a29,0x3a2f,0x3a35,0x3a39,0x3a3d,0x3a41,0x3a45,0x3a4b,0x3a4f,0x3a55,
|
||||
0x3a59,0x3a5d,0x3a63,0x3a69,0x3a6d,0x2c33,0x3a71,0x3a75,0x3a79,0x3a7d,0x3a81,0x3a85,0x319d,0x3a89,0x3a8d,0x3a91,
|
||||
0x3a95,0x3a99,0x3a9d,0x3aa1,0x3aa5,0x3aa9,0x3aad,0x3ab3,0x3ab7,0x3abb,0x3abf,0x3ac3,0x3ac7,0x3acd,0x3ad3,0x3ad7,
|
||||
0x3adb,0x31b1,0x31b5,0x3adf,0x3ae3,0x3ae9,0x3aed,0x3af1,0x3af5,0x3af9,0x3aff,0x3b05,0x3b09,0x3b0d,0x3b11,0x3b17,
|
||||
0x31b9,0x3b1b,0x3b21,0x3b27,0x3b2b,0x3b2f,0x3b33,0x3b39,0x3b3d,0x3b41,0x3b45,0x3b49,0x3b4d,0x3b51,0x3b55,0x3b5b,
|
||||
0x3b5f,0x3b63,0x3b67,0x3b6d,0x3b71,0x3b75,0x3b79,0x3b7d,0x3b83,0x3b89,0x3b8d,0x3b91,0x3b95,0x3b9b,0x3b9f,0x31d1,
|
||||
0x31d1,0x3ba5,0x3ba9,0x3baf,0x3bb3,0x3bb7,0x3bbb,0x3bbf,0x3bc3,0x3bc7,0x3bcb,0x31d5,0x3bd1,0x3bd5,0x3bd9,0x3bdd,
|
||||
0x3be1,0x3be5,0x3beb,0x3bef,0x3bf5,0x3bfb,0x3c01,0x3c05,0x3c09,0x3c0d,0x3c11,0x3c15,0x3c19,0x3c1d,0x3c21,1,
|
||||
1,1
|
||||
1,1,1,1,0xffb0,0xffb0,0xffb0,1,1,1,1,1,1,1,1,0xfe02,
|
||||
0xfe02,1,1,0xffb0,0xffb0,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,
|
||||
0xffcc,0xffcc,0xffcc,0xffcc,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,1,0xffcc,0xffcc,1,0xffcc,
|
||||
0xffcc,0xffcc,0xffcc,0xffcc,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
0xffd0,0xffd0,0xffb8,0xffcc,1,1,1,0xffcc,1,1,0xffcc,1,1,1,1,1,
|
||||
1,1,0xffcc,0xffcc,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,0xffb8,1,1,1,1,1,
|
||||
1,1,1,1,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xffcc,0xfe0e,1,1,1,1,1,
|
||||
0x33e5,0x33e9,0x33ed,0x33f1,0x33f7,0x2fd7,0x33fb,0x33ff,0x3403,0x3407,0x2fdb,0x340b,0x340f,0x3413,0x2fdf,0x3419,
|
||||
0x341d,0x3421,0x3425,0x342b,0x342f,0x3433,0x3437,0x343d,0x3441,0x3445,0x3449,0x30c9,0x344d,0x3453,0x3457,0x345b,
|
||||
0x345f,0x3463,0x3467,0x346b,0x346f,0x30dd,0x2fe3,0x2fe7,0x30e1,0x3473,0x3477,0x2ce3,0x347b,0x2feb,0x347f,0x3483,
|
||||
0x3487,0x348b,0x348b,0x348b,0x348f,0x3495,0x3499,0x349d,0x34a1,0x34a7,0x34ab,0x34af,0x34b3,0x34b7,0x34bb,0x34bf,
|
||||
0x34c3,0x34c7,0x34cb,0x34cf,0x34d3,0x34d7,0x34d7,0x30e9,0x34db,0x34df,0x34e3,0x34e7,0x2ff3,0x34eb,0x34ef,0x34f3,
|
||||
0x2f47,0x34f7,0x34fb,0x34ff,0x3503,0x3507,0x350b,0x350f,0x3513,0x3517,0x351d,0x3521,0x3525,0x3529,0x352d,0x3531,
|
||||
0x3535,0x353b,0x3541,0x3545,0x3549,0x354d,0x3551,0x3555,0x3559,0x355d,0x3561,0x3561,0x3565,0x356b,0x356f,0x2cd3,
|
||||
0x3573,0x3577,0x357d,0x3581,0x3585,0x3589,0x358d,0x3591,0x3007,0x3595,0x3599,0x359d,0x35a3,0x35a7,0x35ad,0x35b1,
|
||||
0x35b5,0x35b9,0x35bd,0x35c1,0x35c5,0x35c9,0x35cd,0x35d1,0x35d5,0x35d9,0x35df,0x35e3,0x35e7,0x35eb,0x2bfb,0x35ef,
|
||||
0x35f5,0x35f9,0x35f9,0x35ff,0x3603,0x3603,0x3607,0x360b,0x3611,0x3617,0x361b,0x361f,0x3623,0x3627,0x362b,0x362f,
|
||||
0x3633,0x3637,0x363b,0x300b,0x363f,0x3645,0x3649,0x364d,0x3119,0x364d,0x3651,0x3013,0x3655,0x3659,0x365d,0x3661,
|
||||
0x3017,0x2b8f,0x3665,0x3669,0x366d,0x3671,0x3675,0x3679,0x367d,0x3683,0x3687,0x368b,0x368f,0x3693,0x3697,0x369d,
|
||||
0x36a1,0x36a5,0x36a9,0x36ad,0x36b1,0x36b5,0x36b9,0x36bd,0x301b,0x36c1,0x36c5,0x36cb,0x36cf,0x36d3,0x36d7,0x3023,
|
||||
0x36db,0x36df,0x36e3,0x36e7,0x36eb,0x36ef,0x36f3,0x36f7,0x2bff,0x3139,0x36fb,0x36ff,0x3703,0x3707,0x370d,0x3711,
|
||||
0x3715,0x3719,0x3027,0x371d,0x3723,0x3727,0x372b,0x31eb,0x372f,0x3733,0x3737,0x373b,0x373f,0x3745,0x3749,0x374d,
|
||||
0x3751,0x3757,0x375b,0x375f,0x3763,0x2d17,0x3767,0x376b,0x3771,0x3777,0x377d,0x3781,0x3787,0x378b,0x378f,0x3793,
|
||||
0x3797,0x302b,0x2e73,0x379b,0x379f,0x37a3,0x37a7,0x37ad,0x37b1,0x37b5,0x37b9,0x3149,0x37bd,0x37c1,0x37c7,0x37cb,
|
||||
0x37cf,0x37d5,0x37db,0x37df,0x314d,0x37e3,0x37e7,0x37eb,0x37ef,0x37f3,0x37f7,0x37fb,0x3801,0x3805,0x380b,0x380f,
|
||||
0x3815,0x3155,0x3819,0x381d,0x3823,0x3827,0x382b,0x3831,0x3837,0x383b,0x383f,0x3843,0x3847,0x3847,0x384b,0x384f,
|
||||
0x315d,0x3853,0x3857,0x385b,0x385f,0x3863,0x3869,0x386d,0x2cdf,0x3873,0x3879,0x387d,0x3883,0x3889,0x388f,0x3893,
|
||||
0x3175,0x3897,0x389d,0x38a3,0x38a9,0x38af,0x38b3,0x38b3,0x3179,0x31f3,0x38b7,0x38bb,0x38bf,0x38c3,0x38c9,0x2c47,
|
||||
0x3181,0x38cd,0x38d1,0x3057,0x38d7,0x38dd,0x2f9f,0x38e3,0x38e7,0x3067,0x38eb,0x38ef,0x38f3,0x38f9,0x38f9,0x38ff,
|
||||
0x3903,0x3907,0x390d,0x3911,0x3915,0x3919,0x391f,0x3923,0x3927,0x392b,0x392f,0x3933,0x3939,0x393d,0x3941,0x3945,
|
||||
0x3949,0x394d,0x3951,0x3957,0x395d,0x3961,0x3967,0x396b,0x3971,0x3975,0x307f,0x3979,0x397f,0x3985,0x3989,0x398f,
|
||||
0x3993,0x3999,0x399d,0x39a1,0x39a5,0x39a9,0x39ad,0x39b1,0x39b7,0x39bd,0x39c3,0x35ff,0x39c9,0x39cd,0x39d1,0x39d5,
|
||||
0x39d9,0x39dd,0x39e1,0x39e5,0x39e9,0x39ed,0x39f1,0x39f5,0x2d27,0x39fb,0x39ff,0x3a03,0x3a07,0x3a0b,0x3a0f,0x308b,
|
||||
0x3a13,0x3a17,0x3a1b,0x3a1f,0x3a23,0x3a29,0x3a2f,0x3a35,0x3a39,0x3a3d,0x3a41,0x3a45,0x3a4b,0x3a4f,0x3a55,0x3a59,
|
||||
0x3a5d,0x3a63,0x3a69,0x3a6d,0x2c33,0x3a71,0x3a75,0x3a79,0x3a7d,0x3a81,0x3a85,0x319d,0x3a89,0x3a8d,0x3a91,0x3a95,
|
||||
0x3a99,0x3a9d,0x3aa1,0x3aa5,0x3aa9,0x3aad,0x3ab3,0x3ab7,0x3abb,0x3abf,0x3ac3,0x3ac7,0x3acd,0x3ad3,0x3ad7,0x3adb,
|
||||
0x31b1,0x31b5,0x3adf,0x3ae3,0x3ae9,0x3aed,0x3af1,0x3af5,0x3af9,0x3aff,0x3b05,0x3b09,0x3b0d,0x3b11,0x3b17,0x31b9,
|
||||
0x3b1b,0x3b21,0x3b27,0x3b2b,0x3b2f,0x3b33,0x3b39,0x3b3d,0x3b41,0x3b45,0x3b49,0x3b4d,0x3b51,0x3b55,0x3b5b,0x3b5f,
|
||||
0x3b63,0x3b67,0x3b6d,0x3b71,0x3b75,0x3b79,0x3b7d,0x3b83,0x3b89,0x3b8d,0x3b91,0x3b95,0x3b9b,0x3b9f,0x31d1,0x31d1,
|
||||
0x3ba5,0x3ba9,0x3baf,0x3bb3,0x3bb7,0x3bbb,0x3bbf,0x3bc3,0x3bc7,0x3bcb,0x31d5,0x3bd1,0x3bd5,0x3bd9,0x3bdd,0x3be1,
|
||||
0x3be5,0x3beb,0x3bef,0x3bf5,0x3bfb,0x3c01,0x3c05,0x3c09,0x3c0d,0x3c11,0x3c15,0x3c19,0x3c1d,0x3c21,1,1,
|
||||
1
|
||||
};
|
||||
|
||||
static const UCPTrie norm2_nfc_data_trie={
|
||||
norm2_nfc_data_trieIndex,
|
||||
{ norm2_nfc_data_trieData },
|
||||
1888, 8162,
|
||||
1891, 8209,
|
||||
0x2fc00, 0x30,
|
||||
0, 0,
|
||||
0, 0,
|
||||
|
||||
+40
-25
@@ -24,6 +24,7 @@
|
||||
#include "unicode/unistr.h"
|
||||
#include "cpputils.h"
|
||||
#include "normalizer2impl.h"
|
||||
#include "putilimp.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
@@ -35,10 +36,10 @@ public:
|
||||
virtual ~Normalizer2WithImpl();
|
||||
|
||||
// normalize
|
||||
virtual UnicodeString &
|
||||
normalize(const UnicodeString &src,
|
||||
UnicodeString &dest,
|
||||
UErrorCode &errorCode) const override {
|
||||
virtual UnicodeString&
|
||||
normalize(const UnicodeString& src,
|
||||
UnicodeString& dest U_LIFETIME_BOUND,
|
||||
UErrorCode& errorCode) const override {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
dest.setToBogus();
|
||||
return dest;
|
||||
@@ -61,23 +62,23 @@ public:
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const = 0;
|
||||
|
||||
// normalize and append
|
||||
virtual UnicodeString &
|
||||
normalizeSecondAndAppend(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const override {
|
||||
virtual UnicodeString&
|
||||
normalizeSecondAndAppend(UnicodeString& first U_LIFETIME_BOUND,
|
||||
const UnicodeString& second,
|
||||
UErrorCode& errorCode) const override {
|
||||
return normalizeSecondAndAppend(first, second, true, errorCode);
|
||||
}
|
||||
virtual UnicodeString &
|
||||
append(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const override {
|
||||
virtual UnicodeString&
|
||||
append(UnicodeString& first U_LIFETIME_BOUND,
|
||||
const UnicodeString& second,
|
||||
UErrorCode& errorCode) const override {
|
||||
return normalizeSecondAndAppend(first, second, false, errorCode);
|
||||
}
|
||||
UnicodeString &
|
||||
normalizeSecondAndAppend(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UnicodeString&
|
||||
normalizeSecondAndAppend(UnicodeString& first U_LIFETIME_BOUND,
|
||||
const UnicodeString& second,
|
||||
UBool doNormalize,
|
||||
UErrorCode &errorCode) const {
|
||||
UErrorCode& errorCode) const {
|
||||
uprv_checkCanGetBuffer(first, errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return first;
|
||||
@@ -90,8 +91,14 @@ public:
|
||||
int32_t firstLength=first.length();
|
||||
UnicodeString safeMiddle;
|
||||
{
|
||||
int32_t destCapacity;
|
||||
if(uprv_add32_overflow(firstLength, second.length(), &destCapacity)) {
|
||||
first.setToBogus();
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return first;
|
||||
}
|
||||
ReorderingBuffer buffer(impl, first);
|
||||
if(buffer.init(firstLength+second.length(), errorCode)) {
|
||||
if(buffer.init(destCapacity, errorCode)) {
|
||||
normalizeAndAppend(secondArray, secondArray+second.length(), doNormalize,
|
||||
safeMiddle, buffer, errorCode);
|
||||
}
|
||||
@@ -176,8 +183,10 @@ public:
|
||||
}
|
||||
return static_cast<int32_t>(spanQuickCheckYes(sArray, sArray + s.length(), errorCode) - sArray);
|
||||
}
|
||||
virtual const char16_t *
|
||||
spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const = 0;
|
||||
virtual const char16_t*
|
||||
spanQuickCheckYes(const char16_t* src U_LIFETIME_BOUND,
|
||||
const char16_t* limit,
|
||||
UErrorCode& errorCode) const = 0;
|
||||
|
||||
virtual UNormalizationCheckResult getQuickCheck(UChar32) const {
|
||||
return UNORM_YES;
|
||||
@@ -228,8 +237,10 @@ private:
|
||||
return sLimit == impl.decomposeUTF8(0, s, sLimit, nullptr, nullptr, errorCode);
|
||||
}
|
||||
|
||||
virtual const char16_t *
|
||||
spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const override {
|
||||
virtual const char16_t*
|
||||
spanQuickCheckYes(const char16_t* src U_LIFETIME_BOUND,
|
||||
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.
|
||||
@@ -322,8 +333,10 @@ private:
|
||||
impl.composeQuickCheck(sArray, sArray+s.length(), onlyContiguous, &qcResult);
|
||||
return qcResult;
|
||||
}
|
||||
virtual const char16_t *
|
||||
spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &) const override {
|
||||
virtual const char16_t*
|
||||
spanQuickCheckYes(const char16_t* src U_LIFETIME_BOUND,
|
||||
const char16_t* limit,
|
||||
UErrorCode&) const override {
|
||||
return impl.composeQuickCheck(src, limit, onlyContiguous, nullptr);
|
||||
}
|
||||
using Normalizer2WithImpl::spanQuickCheckYes; // Avoid warning about hiding base class function.
|
||||
@@ -361,8 +374,10 @@ private:
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const override {
|
||||
impl.makeFCDAndAppend(src, limit, doNormalize, safeMiddle, buffer, errorCode);
|
||||
}
|
||||
virtual const char16_t *
|
||||
spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const override {
|
||||
virtual const char16_t*
|
||||
spanQuickCheckYes(const char16_t* src U_LIFETIME_BOUND,
|
||||
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.
|
||||
|
||||
+21
-15
@@ -29,6 +29,7 @@
|
||||
#include "mutex.h"
|
||||
#include "norm2allmodes.h"
|
||||
#include "normalizer2impl.h"
|
||||
#include "putilimp.h"
|
||||
#include "uassert.h"
|
||||
#include "ucln_cmn.h"
|
||||
|
||||
@@ -84,10 +85,10 @@ Normalizer2::isNormalizedUTF8(StringPiece s, UErrorCode &errorCode) const {
|
||||
class NoopNormalizer2 : public Normalizer2 {
|
||||
virtual ~NoopNormalizer2();
|
||||
|
||||
virtual UnicodeString &
|
||||
normalize(const UnicodeString &src,
|
||||
UnicodeString &dest,
|
||||
UErrorCode &errorCode) const override {
|
||||
virtual UnicodeString&
|
||||
normalize(const UnicodeString& src,
|
||||
UnicodeString& dest U_LIFETIME_BOUND,
|
||||
UErrorCode& errorCode) const override {
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
if(&dest!=&src) {
|
||||
dest=src;
|
||||
@@ -114,10 +115,10 @@ class NoopNormalizer2 : public Normalizer2 {
|
||||
}
|
||||
}
|
||||
|
||||
virtual UnicodeString &
|
||||
normalizeSecondAndAppend(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const override {
|
||||
virtual UnicodeString&
|
||||
normalizeSecondAndAppend(UnicodeString& first U_LIFETIME_BOUND,
|
||||
const UnicodeString& second,
|
||||
UErrorCode& errorCode) const override {
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
if(&first!=&second) {
|
||||
first.append(second);
|
||||
@@ -127,10 +128,10 @@ class NoopNormalizer2 : public Normalizer2 {
|
||||
}
|
||||
return first;
|
||||
}
|
||||
virtual UnicodeString &
|
||||
append(UnicodeString &first,
|
||||
const UnicodeString &second,
|
||||
UErrorCode &errorCode) const override {
|
||||
virtual UnicodeString&
|
||||
append(UnicodeString& first U_LIFETIME_BOUND,
|
||||
const UnicodeString& second,
|
||||
UErrorCode& errorCode) const override {
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
if(&first!=&second) {
|
||||
first.append(second);
|
||||
@@ -203,8 +204,8 @@ const Normalizer2 *Normalizer2Factory::getNoopInstance(UErrorCode &errorCode) {
|
||||
return noopSingleton;
|
||||
}
|
||||
|
||||
const Normalizer2Impl *
|
||||
Normalizer2Factory::getImpl(const Normalizer2 *norm2) {
|
||||
const Normalizer2Impl*
|
||||
Normalizer2Factory::getImpl(const Normalizer2* norm2 U_LIFETIME_BOUND) {
|
||||
return &((Normalizer2WithImpl *)norm2)->impl;
|
||||
}
|
||||
|
||||
@@ -386,8 +387,13 @@ normalizeSecondAndAppend(const UNormalizer2 *norm2,
|
||||
// Avoid duplicate argument checking and support NUL-terminated src.
|
||||
UnicodeString safeMiddle;
|
||||
{
|
||||
int32_t destCapacity;
|
||||
ReorderingBuffer buffer(n2wi->impl, firstString);
|
||||
if(buffer.init(firstLength+secondLength+1, *pErrorCode)) { // destCapacity>=-1
|
||||
if(uprv_add32_overflow(firstLength, secondLength, &destCapacity) ||
|
||||
uprv_add32_overflow(destCapacity, 1, &destCapacity)) {
|
||||
firstString.setToBogus();
|
||||
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
} else if(buffer.init(destCapacity, *pErrorCode)) { // destCapacity>=-1
|
||||
n2wi->normalizeAndAppend(second, secondLength>=0 ? second+secondLength : nullptr,
|
||||
doNormalize, safeMiddle, buffer, *pErrorCode);
|
||||
}
|
||||
|
||||
+14
-3
@@ -353,9 +353,16 @@ UBool ReorderingBuffer::resize(int32_t appendLength, UErrorCode &errorCode) {
|
||||
int32_t reorderStartIndex = static_cast<int32_t>(reorderStart - start);
|
||||
int32_t length = static_cast<int32_t>(limit - start);
|
||||
str.releaseBuffer(length);
|
||||
int32_t newCapacity=length+appendLength;
|
||||
int32_t doubleCapacity=2*str.getCapacity();
|
||||
if(newCapacity<doubleCapacity) {
|
||||
int32_t newCapacity;
|
||||
if(uprv_add32_overflow(length, appendLength, &newCapacity)) {
|
||||
str.setToBogus();
|
||||
start=nullptr;
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
int32_t doubleCapacity;
|
||||
if(!uprv_mul32_overflow(2, str.getCapacity(), &doubleCapacity) &&
|
||||
newCapacity<doubleCapacity) {
|
||||
newCapacity=doubleCapacity;
|
||||
}
|
||||
if(newCapacity<256) {
|
||||
@@ -585,6 +592,10 @@ const char16_t *
|
||||
Normalizer2Impl::decompose(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer *buffer,
|
||||
UErrorCode &errorCode) const {
|
||||
if(src==nullptr) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return src;
|
||||
}
|
||||
UChar32 minNoCP=minDecompNoCP;
|
||||
if(limit==nullptr) {
|
||||
src=copyLowPrefixFromNulTerminated(src, minNoCP, buffer, errorCode);
|
||||
|
||||
+1
-1
@@ -806,7 +806,7 @@ public:
|
||||
|
||||
// Get the Impl instance of the Normalizer2.
|
||||
// Must be used only when it is known that norm2 is a Normalizer2WithImpl instance.
|
||||
static const Normalizer2Impl *getImpl(const Normalizer2 *norm2);
|
||||
static const Normalizer2Impl* getImpl(const Normalizer2* norm2 U_LIFETIME_BOUND);
|
||||
private:
|
||||
Normalizer2Factory() = delete; // No instantiation.
|
||||
};
|
||||
|
||||
+8
-6
@@ -46,7 +46,7 @@ Normalizer::Normalizer(const UnicodeString& str, UNormalizationMode mode) :
|
||||
init();
|
||||
}
|
||||
|
||||
Normalizer::Normalizer(ConstChar16Ptr str, int32_t length, UNormalizationMode mode) :
|
||||
Normalizer::Normalizer(ConstChar16Ptr str U_LIFETIME_BOUND, int32_t length, UNormalizationMode mode) :
|
||||
UObject(), fFilteredNorm2(nullptr), fNorm2(nullptr), fUMode(mode), fOptions(0),
|
||||
text(new UCharCharacterIterator(str, length)),
|
||||
currentIndex(0), nextIndex(0),
|
||||
@@ -209,11 +209,13 @@ Normalizer::isNormalized(const UnicodeString& source,
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeString & U_EXPORT2
|
||||
Normalizer::concatenate(const UnicodeString &left, const UnicodeString &right,
|
||||
UnicodeString &result,
|
||||
UNormalizationMode mode, int32_t options,
|
||||
UErrorCode &errorCode) {
|
||||
UnicodeString& U_EXPORT2
|
||||
Normalizer::concatenate(const UnicodeString& left,
|
||||
const UnicodeString& right,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
UNormalizationMode mode,
|
||||
int32_t options,
|
||||
UErrorCode& errorCode) {
|
||||
if(left.isBogus() || right.isBogus() || U_FAILURE(errorCode)) {
|
||||
result.setToBogus();
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
|
||||
+861
-825
File diff suppressed because it is too large.
Load diff
+33
-15
@@ -885,7 +885,6 @@ typedef struct DefaultTZInfo {
|
||||
char* defaultTZBuffer;
|
||||
int64_t defaultTZFileSize;
|
||||
FILE* defaultTZFilePtr;
|
||||
UBool defaultTZstatus;
|
||||
int32_t defaultTZPosition;
|
||||
} DefaultTZInfo;
|
||||
|
||||
@@ -893,7 +892,7 @@ typedef struct DefaultTZInfo {
|
||||
* This method compares the two files given to see if they are a match.
|
||||
* It is currently use to compare two TZ files.
|
||||
*/
|
||||
static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFileName, DefaultTZInfo* tzInfo) {
|
||||
static UBool compareBinaryFiles(const char* TZFileName, DefaultTZInfo* tzInfo) {
|
||||
FILE* file;
|
||||
int64_t sizeFile;
|
||||
int64_t sizeFileLeft;
|
||||
@@ -902,21 +901,26 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
|
||||
char bufferFile[MAX_READ_SIZE];
|
||||
UBool result = true;
|
||||
|
||||
if (tzInfo->defaultTZFilePtr == nullptr) {
|
||||
tzInfo->defaultTZFilePtr = fopen(defaultTZFileName, "r");
|
||||
}
|
||||
U_ASSERT(tzInfo->defaultTZFilePtr != nullptr);
|
||||
file = fopen(TZFileName, "r");
|
||||
|
||||
tzInfo->defaultTZPosition = 0; /* reset position to begin search */
|
||||
|
||||
if (file != nullptr && tzInfo->defaultTZFilePtr != nullptr) {
|
||||
if (file != nullptr) {
|
||||
/* First check that the file size are equal. */
|
||||
if (tzInfo->defaultTZFileSize == 0) {
|
||||
fseek(tzInfo->defaultTZFilePtr, 0, SEEK_END);
|
||||
tzInfo->defaultTZFileSize = ftell(tzInfo->defaultTZFilePtr);
|
||||
}
|
||||
fseek(file, 0, SEEK_END);
|
||||
if (fseek(file, 0, SEEK_END) != 0) {
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
sizeFile = ftell(file);
|
||||
if (sizeFile == -1) {
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
sizeFileLeft = sizeFile;
|
||||
|
||||
if (sizeFile != tzInfo->defaultTZFileSize) {
|
||||
@@ -926,16 +930,26 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
|
||||
* compare each byte to determine equality.
|
||||
*/
|
||||
if (tzInfo->defaultTZBuffer == nullptr) {
|
||||
rewind(tzInfo->defaultTZFilePtr);
|
||||
if (fseek(tzInfo->defaultTZFilePtr, 0, SEEK_SET) != 0) {
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
tzInfo->defaultTZBuffer = static_cast<char*>(uprv_malloc(sizeof(char) * tzInfo->defaultTZFileSize));
|
||||
sizeFileRead = fread(tzInfo->defaultTZBuffer, 1, tzInfo->defaultTZFileSize, tzInfo->defaultTZFilePtr);
|
||||
}
|
||||
rewind(file);
|
||||
if (fseek(file, 0, SEEK_SET) != 0) {
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
while(sizeFileLeft > 0) {
|
||||
uprv_memset(bufferFile, 0, MAX_READ_SIZE);
|
||||
sizeFileToRead = sizeFileLeft < MAX_READ_SIZE ? sizeFileLeft : MAX_READ_SIZE;
|
||||
|
||||
sizeFileRead = fread(bufferFile, 1, sizeFileToRead, file);
|
||||
if (sizeFileRead == -1) {
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
if (memcmp(tzInfo->defaultTZBuffer + tzInfo->defaultTZPosition, bufferFile, sizeFileRead) != 0) {
|
||||
result = false;
|
||||
break;
|
||||
@@ -972,6 +986,11 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
||||
char* result = nullptr;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
/* There is no reference file to compare against, so do not traverse the zoneinfo tree. */
|
||||
if (tzInfo->defaultTZFilePtr == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Save the current path */
|
||||
CharString curpath(path, -1, status);
|
||||
if (U_FAILURE(status)) {
|
||||
@@ -1023,7 +1042,7 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
||||
if (result != nullptr)
|
||||
break;
|
||||
} else {
|
||||
if(compareBinaryFiles(TZDEFAULT, newpath.data(), tzInfo)) {
|
||||
if(compareBinaryFiles(newpath.data(), tzInfo)) {
|
||||
int32_t amountToSkip = sizeof(TZZONEINFO) - 1;
|
||||
if (amountToSkip > newpath.length()) {
|
||||
amountToSkip = newpath.length();
|
||||
@@ -1198,8 +1217,7 @@ uprv_tzname(int n)
|
||||
if (tzInfo != nullptr) {
|
||||
tzInfo->defaultTZBuffer = nullptr;
|
||||
tzInfo->defaultTZFileSize = 0;
|
||||
tzInfo->defaultTZFilePtr = nullptr;
|
||||
tzInfo->defaultTZstatus = false;
|
||||
tzInfo->defaultTZFilePtr = fopen(TZDEFAULT, "r");
|
||||
tzInfo->defaultTZPosition = 0;
|
||||
|
||||
gTimeZoneBufferPtr = searchForTZFile(TZZONEINFO, tzInfo);
|
||||
@@ -1430,9 +1448,6 @@ static void U_CALLCONV dataDirectoryInitFn() {
|
||||
}
|
||||
|
||||
const char *path = nullptr;
|
||||
#if defined(ICU_DATA_DIR_PREFIX_ENV_VAR)
|
||||
char datadir_path_buffer[PATH_MAX];
|
||||
#endif
|
||||
|
||||
/*
|
||||
When ICU_NO_USER_DATA_OVERRIDE is defined, users aren't allowed to
|
||||
@@ -1462,6 +1477,9 @@ static void U_CALLCONV dataDirectoryInitFn() {
|
||||
* set their own path.
|
||||
*/
|
||||
#if defined(ICU_DATA_DIR) || defined(U_ICU_DATA_DEFAULT_DIR)
|
||||
# if defined(ICU_DATA_DIR_PREFIX_ENV_VAR)
|
||||
char datadir_path_buffer[PATH_MAX];
|
||||
# endif
|
||||
if(path==nullptr || *path==0) {
|
||||
# if defined(ICU_DATA_DIR_PREFIX_ENV_VAR)
|
||||
const char *prefix = getenv(ICU_DATA_DIR_PREFIX_ENV_VAR);
|
||||
|
||||
+6
@@ -107,6 +107,8 @@ typedef size_t uintptr_t;
|
||||
/* not defined */
|
||||
#elif U_PLATFORM == U_PF_HAIKU
|
||||
/* not defined */
|
||||
#elif defined(__wasi__)
|
||||
/* not defined */
|
||||
#else
|
||||
# define U_TZSET tzset
|
||||
#endif
|
||||
@@ -132,6 +134,8 @@ typedef size_t uintptr_t;
|
||||
/* not defined */
|
||||
#elif U_PLATFORM == U_PF_IPHONE
|
||||
/* not defined */
|
||||
#elif defined(__wasi__)
|
||||
/* not defined */
|
||||
#else
|
||||
# define U_TIMEZONE timezone
|
||||
#endif
|
||||
@@ -147,6 +151,8 @@ typedef size_t uintptr_t;
|
||||
/* not defined */
|
||||
#elif U_PLATFORM == U_PF_HAIKU
|
||||
/* not defined, (well it is but a loop back to icu) */
|
||||
#elif defined(__wasi__)
|
||||
/* not defined */
|
||||
#else
|
||||
# define U_TZNAME tzname
|
||||
#endif
|
||||
|
||||
+12
-13
@@ -277,7 +277,7 @@ RuleBasedBreakIterator::~RuleBasedBreakIterator() {
|
||||
* TODO: needs better handling of memory allocation errors.
|
||||
*/
|
||||
RuleBasedBreakIterator&
|
||||
RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
|
||||
RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) U_LIFETIME_BOUND {
|
||||
if (this == &that) {
|
||||
return *this;
|
||||
}
|
||||
@@ -326,6 +326,7 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
|
||||
fPosition = that.fPosition;
|
||||
fRuleStatusIndex = that.fRuleStatusIndex;
|
||||
fDone = that.fDone;
|
||||
fIsPhraseBreaking = that.fIsPhraseBreaking;
|
||||
|
||||
// TODO: both the dictionary and the main cache need to be copied.
|
||||
// Current position could be within a dictionary range. Trying to continue
|
||||
@@ -377,7 +378,8 @@ RuleBasedBreakIterator::operator==(const BreakIterator& that) const {
|
||||
|
||||
if (!(fPosition == that2.fPosition &&
|
||||
fRuleStatusIndex == that2.fRuleStatusIndex &&
|
||||
fDone == that2.fDone)) {
|
||||
fDone == that2.fDone &&
|
||||
fIsPhraseBreaking == that2.fIsPhraseBreaking)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -429,7 +431,7 @@ void RuleBasedBreakIterator::setText(UText *ut, UErrorCode &status) {
|
||||
}
|
||||
|
||||
|
||||
UText *RuleBasedBreakIterator::getUText(UText *fillIn, UErrorCode &status) const {
|
||||
UText* RuleBasedBreakIterator::getUText(UText* fillIn U_LIFETIME_BOUND, UErrorCode& status) const {
|
||||
UText *result = utext_clone(fillIn, &fText, false, true, &status);
|
||||
return result;
|
||||
}
|
||||
@@ -443,7 +445,7 @@ UText *RuleBasedBreakIterator::getUText(UText *fillIn, UErrorCode &status) const
|
||||
* Return a CharacterIterator over the text being analyzed.
|
||||
*/
|
||||
CharacterIterator&
|
||||
RuleBasedBreakIterator::getText() const {
|
||||
RuleBasedBreakIterator::getText() const U_LIFETIME_BOUND {
|
||||
return *fCharIter;
|
||||
}
|
||||
|
||||
@@ -508,7 +510,8 @@ RuleBasedBreakIterator::setText(const UnicodeString& newText) {
|
||||
* Intended for use with text data originating in Java (garbage collected) environments
|
||||
* where the data may be moved in memory at arbitrary times.
|
||||
*/
|
||||
RuleBasedBreakIterator &RuleBasedBreakIterator::refreshInputText(UText *input, UErrorCode &status) {
|
||||
RuleBasedBreakIterator&
|
||||
RuleBasedBreakIterator::refreshInputText(UText* input, UErrorCode& status) U_LIFETIME_BOUND {
|
||||
if (U_FAILURE(status)) {
|
||||
return *this;
|
||||
}
|
||||
@@ -820,10 +823,6 @@ int32_t RuleBasedBreakIterator::handleNext() {
|
||||
|
||||
|
||||
mode = RBBI_RUN;
|
||||
if (statetable->fFlags & RBBI_BOF_REQUIRED) {
|
||||
category = 2;
|
||||
mode = RBBI_START;
|
||||
}
|
||||
|
||||
|
||||
// loop until we reach the end of the text or transition to state 0
|
||||
@@ -1086,7 +1085,7 @@ int32_t RuleBasedBreakIterator::getRuleStatusVec(
|
||||
// for standard iterator types.
|
||||
//
|
||||
//-------------------------------------------------------------------------------
|
||||
const uint8_t *RuleBasedBreakIterator::getBinaryRules(uint32_t &length) {
|
||||
const uint8_t* RuleBasedBreakIterator::getBinaryRules(uint32_t& length) U_LIFETIME_BOUND {
|
||||
const uint8_t *retPtr = nullptr;
|
||||
length = 0;
|
||||
|
||||
@@ -1203,8 +1202,8 @@ getLanguageBreakEngineFromFactory(UChar32 c, const char* locale)
|
||||
// the character c.
|
||||
//
|
||||
//-------------------------------------------------------------------------------
|
||||
const LanguageBreakEngine *
|
||||
RuleBasedBreakIterator::getLanguageBreakEngine(UChar32 c, const char* locale) {
|
||||
const LanguageBreakEngine*
|
||||
RuleBasedBreakIterator::getLanguageBreakEngine(UChar32 c, const char* locale) U_LIFETIME_BOUND {
|
||||
const LanguageBreakEngine *lbe = nullptr;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
@@ -1289,7 +1288,7 @@ void RuleBasedBreakIterator::dumpTables() {
|
||||
*/
|
||||
|
||||
const UnicodeString&
|
||||
RuleBasedBreakIterator::getRules() const {
|
||||
RuleBasedBreakIterator::getRules() const U_LIFETIME_BOUND {
|
||||
if (fData != nullptr) {
|
||||
return fData->getRuleSourceString();
|
||||
} else {
|
||||
|
||||
+13
-4
@@ -40,6 +40,11 @@ void RuleBasedBreakIterator::DictionaryCache::reset() {
|
||||
fFirstRuleStatusIndex = 0;
|
||||
fOtherRuleStatusIndex = 0;
|
||||
fBreaks.removeAllElements();
|
||||
int32_t maxStatus = 0;
|
||||
for (int32_t i = 0; i < fBI->fData->fStatusMaxIdx; ++i) {
|
||||
maxStatus = std::max(maxStatus, fBI->fData->fRuleStatusTable[i]);
|
||||
}
|
||||
isWordLike = maxStatus > 100;
|
||||
}
|
||||
|
||||
UBool RuleBasedBreakIterator::DictionaryCache::following(int32_t fromPos, int32_t *result, int32_t *statusIndex) {
|
||||
@@ -60,7 +65,7 @@ UBool RuleBasedBreakIterator::DictionaryCache::following(int32_t fromPos, int32_
|
||||
r = fBreaks.elementAti(fPositionInCache);
|
||||
U_ASSERT(r > fromPos);
|
||||
*result = r;
|
||||
*statusIndex = fOtherRuleStatusIndex;
|
||||
*statusIndex = isWordLike || r == fLimit ? fOtherRuleStatusIndex : 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -70,7 +75,7 @@ UBool RuleBasedBreakIterator::DictionaryCache::following(int32_t fromPos, int32_
|
||||
r= fBreaks.elementAti(fPositionInCache);
|
||||
if (r > fromPos) {
|
||||
*result = r;
|
||||
*statusIndex = fOtherRuleStatusIndex;
|
||||
*statusIndex = isWordLike || r == fLimit ? fOtherRuleStatusIndex : 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -97,7 +102,9 @@ UBool RuleBasedBreakIterator::DictionaryCache::preceding(int32_t fromPos, int32_
|
||||
r = fBreaks.elementAti(fPositionInCache);
|
||||
U_ASSERT(r < fromPos);
|
||||
*result = r;
|
||||
*statusIndex = ( r== fStart) ? fFirstRuleStatusIndex : fOtherRuleStatusIndex;
|
||||
*statusIndex = (r == fStart) ? fFirstRuleStatusIndex
|
||||
: isWordLike ? fOtherRuleStatusIndex
|
||||
: 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -110,7 +117,9 @@ UBool RuleBasedBreakIterator::DictionaryCache::preceding(int32_t fromPos, int32_
|
||||
r = fBreaks.elementAti(fPositionInCache);
|
||||
if (r < fromPos) {
|
||||
*result = r;
|
||||
*statusIndex = ( r == fStart) ? fFirstRuleStatusIndex : fOtherRuleStatusIndex;
|
||||
*statusIndex = (r == fStart) ? fFirstRuleStatusIndex
|
||||
: isWordLike ? fOtherRuleStatusIndex
|
||||
: 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -64,6 +64,13 @@ class RuleBasedBreakIterator::DictionaryCache: public UMemory {
|
||||
// text segment being handled by the dictionary.
|
||||
int32_t fFirstRuleStatusIndex; // Rule status info for first boundary.
|
||||
int32_t fOtherRuleStatusIndex; // Rule status info for 2nd through last boundaries.
|
||||
|
||||
// If `this->isWordLike`, the status of dictionary breaks is equal to the status of the final
|
||||
// break of the rule-based segment they refine (fOtherRuleStatusIndex); otherwise, dictionary
|
||||
// breaks have status 0.
|
||||
// For compatibility, this property is determined by the largest status value used by `*fBI`:
|
||||
// rules that have a largest status greater than 100 are considered word-like.
|
||||
bool isWordLike;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-2
@@ -234,10 +234,9 @@ void RBBIDataWrapper::printTable(const char *heading, const RBBIStateTable *tab
|
||||
|
||||
RBBIDebugPrintf(" fDictCategoriesStart: %d\n", table->fDictCategoriesStart);
|
||||
RBBIDebugPrintf(" fLookAheadResultsSize: %d\n", table->fLookAheadResultsSize);
|
||||
RBBIDebugPrintf(" Flags: %4x RBBI_LOOKAHEAD_HARD_BREAK=%s RBBI_BOF_REQUIRED=%s RBBI_8BITS_ROWS=%s\n",
|
||||
RBBIDebugPrintf(" Flags: %4x RBBI_LOOKAHEAD_HARD_BREAK=%s RBBI_8BITS_ROWS=%s\n",
|
||||
table->fFlags,
|
||||
table->fFlags & RBBI_LOOKAHEAD_HARD_BREAK ? "T" : "F",
|
||||
table->fFlags & RBBI_BOF_REQUIRED ? "T" : "F",
|
||||
table->fFlags & RBBI_8BITS_ROWS ? "T" : "F");
|
||||
RBBIDebugPrintf("\nState | Acc LA TagIx");
|
||||
for (c=0; c<fHeader->fCatCount; c++) {RBBIDebugPrintf("%3d ", c);}
|
||||
|
||||
+3
-2
@@ -59,7 +59,7 @@ ubrk_swap(const UDataSwapper *ds,
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// The current RBBI data format version.
|
||||
static const uint8_t RBBI_DATA_FORMAT_VERSION[] = {6, 0, 0, 0};
|
||||
static const uint8_t RBBI_DATA_FORMAT_VERSION[] = {7, 0, 0, 0};
|
||||
|
||||
/*
|
||||
* The following structs map exactly onto the raw data from ICU common data file.
|
||||
@@ -148,7 +148,8 @@ struct RBBIStateTable {
|
||||
};
|
||||
|
||||
constexpr uint32_t RBBI_LOOKAHEAD_HARD_BREAK = 1;
|
||||
constexpr uint32_t RBBI_BOF_REQUIRED = 2;
|
||||
// No longer used since ICU 79:
|
||||
// constexpr uint32_t RBBI_BOF_REQUIRED = 2;
|
||||
constexpr uint32_t RBBI_8BITS_ROWS = 4;
|
||||
|
||||
|
||||
|
||||
+5
-3
@@ -337,13 +337,15 @@ RBBIDataHeader *RBBIRuleBuilder::build(UErrorCode &status) {
|
||||
|
||||
void RBBIRuleBuilder::optimizeTables() {
|
||||
bool didSomething;
|
||||
fForwardTable->minimizeLookaheads();
|
||||
do {
|
||||
didSomething = false;
|
||||
|
||||
// Begin looking for duplicates with char class 3.
|
||||
// Classes 0, 1 and 2 are special; they are unused, {bof} and {eof} respectively,
|
||||
// and should not have other categories merged into them.
|
||||
IntPair duplPair = {3, 0};
|
||||
// Class 0 is unused and should not have other categories merged into
|
||||
// it. We allow merging categories *into* class 1 {eof} (but not the
|
||||
// reverse, so that eof remains in class 1).
|
||||
IntPair duplPair = {1, 0};
|
||||
while (fForwardTable->findDuplCharClassFrom(&duplPair)) {
|
||||
fSetBuilder->mergeCategories(duplPair);
|
||||
fForwardTable->removeColumn(duplPair.second);
|
||||
|
||||
+3
-8
@@ -65,15 +65,10 @@ private:
|
||||
UHashtable *fHashTable;
|
||||
RBBIRuleScanner *fRuleScanner;
|
||||
|
||||
// These next two fields are part of the mechanism for passing references to
|
||||
// already-constructed UnicodeSets back to the UnicodeSet constructor
|
||||
// when the pattern includes $variable references.
|
||||
const UnicodeString ffffString; // = "/uffff"
|
||||
UnicodeSet *fCachedSetLookup;
|
||||
|
||||
public:
|
||||
// API inherited from class SymbolTable
|
||||
virtual const UnicodeString* lookup(const UnicodeString& s) const override;
|
||||
virtual const UnicodeSet* lookupSet(const UnicodeString& s) const override;
|
||||
virtual const UnicodeFunctor* lookupMatcher(UChar32 ch) const override;
|
||||
virtual UnicodeString parseReference(const UnicodeString& text,
|
||||
ParsePosition& pos, int32_t limit) const override;
|
||||
@@ -91,7 +86,7 @@ public:
|
||||
// A do-nothing inline function for non-debug builds. Member funcs can't be empty
|
||||
// or the call sites won't compile.
|
||||
int32_t fFakeField;
|
||||
#define rbbiSymtablePrint() fFakeField=0;
|
||||
#define rbbiSymtablePrint() fFakeField=0;
|
||||
#endif
|
||||
|
||||
private:
|
||||
@@ -220,7 +215,7 @@ typedef std::pair<int32_t, int32_t> IntPair;
|
||||
#define RBBIDebugPrintf printf
|
||||
#define RBBIDebugPuts puts
|
||||
#else
|
||||
#undef RBBIDebugPrintf
|
||||
#undef RBBIDebugPrintf
|
||||
#define RBBIDebugPuts(arg)
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -1258,7 +1258,7 @@ void RBBIRuleScanner::scanSet() {
|
||||
// Use tempSet to handle the case that the UnicodeSet contains
|
||||
// only string element, such as [{ab}] and treat it as empty set.
|
||||
tempSet.removeAllStrings();
|
||||
if (tempSet.isEmpty()) {
|
||||
if (tempSet.isEmpty() && !uset->contains(UnicodeString::readOnlyAlias(u"eof"))) {
|
||||
// This set is empty.
|
||||
// Make it an error, because it almost certainly is not what the user wanted.
|
||||
// Also, avoids having to think about corner cases in the tree manipulation code
|
||||
|
||||
+3
-22
@@ -60,7 +60,6 @@ RBBISetBuilder::RBBISetBuilder(RBBIRuleBuilder *rb)
|
||||
fTrie = nullptr;
|
||||
fTrieSize = 0;
|
||||
fGroupCount = 0;
|
||||
fSawBOF = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -240,16 +239,12 @@ void RBBISetBuilder::buildRanges() {
|
||||
|
||||
// Handle input sets that contain the special string {eof}.
|
||||
// Column 1 of the state table is reserved for EOF on input.
|
||||
// Column 2 is reserved for before-the-start-input.
|
||||
// (This column can be optimized away later if there are no rule
|
||||
// references to {bof}.)
|
||||
// Add this column value (1 or 2) to the equivalent expression
|
||||
// Add this column value (1) to the equivalent expression
|
||||
// subtree for each UnicodeSet that contains the string {eof}
|
||||
// Because {bof} and {eof} are not characters in the normal sense,
|
||||
// they don't affect the computation of the ranges or TRIE.
|
||||
// Because {eof} is not a character in the normal sense,
|
||||
// it doesn’t affect the computation of ranges or TRIE.
|
||||
|
||||
UnicodeString eofString(u"eof");
|
||||
UnicodeString bofString(u"bof");
|
||||
for (ni=0; ; ni++) { // Loop over each of the UnicodeSets encountered in the input rules
|
||||
usetNode = static_cast<RBBINode*>(this->fRB->fUSetNodes->elementAt(ni));
|
||||
if (usetNode==nullptr) {
|
||||
@@ -259,10 +254,6 @@ void RBBISetBuilder::buildRanges() {
|
||||
if (inputSet->contains(eofString)) {
|
||||
addValToSet(usetNode, 1);
|
||||
}
|
||||
if (inputSet->contains(bofString)) {
|
||||
addValToSet(usetNode, 2);
|
||||
fSawBOF = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -432,16 +423,6 @@ int32_t RBBISetBuilder::getDictCategoriesStart() const {
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// sawBOF
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
UBool RBBISetBuilder::sawBOF() const {
|
||||
return fSawBOF;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// getFirstChar Given a runtime RBBI character category, find
|
||||
|
||||
+1
-4
@@ -96,8 +96,7 @@ public:
|
||||
int32_t getTrieSize() /*const*/; // Size in bytes of the serialized Trie.
|
||||
void serializeTrie(uint8_t *where); // write out the serialized Trie.
|
||||
UChar32 getFirstChar(int32_t val) const;
|
||||
UBool sawBOF() const; // Indicate whether any references to the {bof} pseudo
|
||||
// character were encountered.
|
||||
|
||||
/**
|
||||
* Merge two character categories that have been identified as having equivalent behavior.
|
||||
* The ranges belonging to the second category (table column) will be added to the first.
|
||||
@@ -132,8 +131,6 @@ private:
|
||||
// If there are no Dictionary categories, set to the last category + 1.
|
||||
int32_t fDictCategoriesStart;
|
||||
|
||||
UBool fSawBOF;
|
||||
|
||||
RBBISetBuilder(const RBBISetBuilder &other) = delete; // forbid copying of this class
|
||||
RBBISetBuilder &operator=(const RBBISetBuilder &other) = delete; // forbid copying of this class
|
||||
};
|
||||
|
||||
+33
-47
@@ -41,11 +41,10 @@ U_CDECL_END
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
RBBISymbolTable::RBBISymbolTable(RBBIRuleScanner *rs, const UnicodeString &rules, UErrorCode &status)
|
||||
: fRules(rules), fRuleScanner(rs), ffffString(static_cast<char16_t>(0xffff))
|
||||
: fRules(rules), fRuleScanner(rs)
|
||||
{
|
||||
fHashTable = nullptr;
|
||||
fCachedSetLookup = nullptr;
|
||||
|
||||
|
||||
fHashTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, nullptr, &status);
|
||||
// uhash_open checks status
|
||||
if (U_FAILURE(status)) {
|
||||
@@ -71,60 +70,47 @@ RBBISymbolTable::~RBBISymbolTable()
|
||||
//
|
||||
const UnicodeString *RBBISymbolTable::lookup(const UnicodeString& s) const
|
||||
{
|
||||
RBBISymbolTableEntry *el;
|
||||
RBBINode *varRefNode;
|
||||
RBBINode *exprNode;
|
||||
RBBINode *usetNode;
|
||||
const UnicodeString *retString;
|
||||
RBBISymbolTable *This = const_cast<RBBISymbolTable*>(this); // cast off const
|
||||
|
||||
el = static_cast<RBBISymbolTableEntry*>(uhash_get(fHashTable, &s));
|
||||
const RBBISymbolTableEntry* const el =
|
||||
static_cast<const RBBISymbolTableEntry*>(uhash_get(fHashTable, &s));
|
||||
if (el == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const RBBINode& exprNode = *el->val->fLeftChild; // Root node of expression for variable
|
||||
// Return the original source string for the expression.
|
||||
// Note that for set-valued variables used in UnicodeSet expressions, this would be rejected by
|
||||
// the UnicodeSet parser if the source itself contains variable references. For instance, with
|
||||
// $CaseIgnorable = [[:Mn:][:Me:][:Cf:][:Lm:][:Sk:] \u0027 \u00AD \u2019];
|
||||
// $Cased = [[:Upper_Case:][:Lower_Case:][:Lt:] - $CaseIgnorable];
|
||||
// If lookupSet were not overridden, when parsing the right-hand side of
|
||||
// $NotCased = [[^ $Cased] - $CaseIgnorable];
|
||||
// there would be a call to lookup("Cased") which would return
|
||||
// "[[:Upper_Case:][:Lower_Case:][:Lt:]-$CaseIgnorable]". This contains a variable, which is
|
||||
// disallowed by the UnicodeSet parser inside a variable expansion.
|
||||
// However, set-valued variables are pre-parsed, and returned by lookupSet instead, so this call
|
||||
// to lookup() never happens; instead, lookupSet("CaseIgnorable") is called when computing
|
||||
// $Cased and returns the non-null value of $CaseIgnorable, and then when computing $NotCased,
|
||||
// lookupSet("Cased") returns the value computed for $Cased.
|
||||
return &exprNode.fText;
|
||||
}
|
||||
|
||||
varRefNode = el->val;
|
||||
exprNode = varRefNode->fLeftChild; // Root node of expression for variable
|
||||
if (exprNode->fType == RBBINode::setRef) {
|
||||
// The $variable refers to a single UnicodeSet
|
||||
// return the ffffString, which will subsequently be interpreted as a
|
||||
// stand-in character for the set by RBBISymbolTable::lookupMatcher()
|
||||
usetNode = exprNode->fLeftChild;
|
||||
This->fCachedSetLookup = usetNode->fInputSet;
|
||||
retString = &ffffString;
|
||||
const UnicodeSet* RBBISymbolTable::lookupSet(const UnicodeString& s) const {
|
||||
const RBBISymbolTableEntry* const el = static_cast<const RBBISymbolTableEntry*>(uhash_get(fHashTable, &s));
|
||||
if (el == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The variable refers to something other than just a set.
|
||||
// return the original source string for the expression
|
||||
retString = &exprNode->fText;
|
||||
This->fCachedSetLookup = nullptr;
|
||||
const RBBINode& exprNode = *el->val->fLeftChild;
|
||||
if (exprNode.fType == RBBINode::setRef) {
|
||||
return exprNode.fLeftChild->fInputSet;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
return retString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// RBBISymbolTable::lookupMatcher This function from the abstract symbol table
|
||||
// interface maps a single stand-in character to a
|
||||
// pointer to a Unicode Set. The Unicode Set code uses this
|
||||
// mechanism to get all references to the same $variable
|
||||
// name to refer to a single common Unicode Set instance.
|
||||
//
|
||||
// This implementation cheats a little, and does not maintain a map of stand-in chars
|
||||
// to sets. Instead, it takes advantage of the fact that the UnicodeSet
|
||||
// constructor will always call this function right after calling lookup(),
|
||||
// and we just need to remember what set to return between these two calls.
|
||||
const UnicodeFunctor *RBBISymbolTable::lookupMatcher(UChar32 ch) const
|
||||
{
|
||||
UnicodeSet *retVal = nullptr;
|
||||
RBBISymbolTable *This = const_cast<RBBISymbolTable*>(this); // cast off const
|
||||
if (ch == 0xffff) {
|
||||
retVal = fCachedSetLookup;
|
||||
This->fCachedSetLookup = nullptr;
|
||||
}
|
||||
return retVal;
|
||||
// No longer used, see ICU-23297.
|
||||
const UnicodeFunctor* RBBISymbolTable::lookupMatcher(UChar32 /*ch*/) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
+642
-134
@@ -10,6 +10,7 @@
|
||||
// rbbitblb.cpp
|
||||
//
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
@@ -28,6 +29,53 @@
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
namespace {
|
||||
|
||||
// Given the `RBBITableBuilder::fDStates` vector of `RBBIStateDescriptor`s, returns
|
||||
// true if a state for which `isSink` returns true is reachable from state `source` by following
|
||||
// transitions without going through any state for which `excludedState` returns true.
|
||||
// Note that “going through” is distinct from “reaching”, and means entering and then leaving: A
|
||||
// state can be both a sink and excluded, and can still be reachable.
|
||||
bool reachableByTransitions(const UVector &states, const int32_t source,
|
||||
const std::function<bool(int32_t)> isSink,
|
||||
const std::function<bool(int32_t)> excludedState, UErrorCode &status) {
|
||||
UStack boundary(status);
|
||||
{
|
||||
UVector32 &transitionsFromSource =
|
||||
*static_cast<RBBIStateDescriptor *>(states.elementAt(source))->fDtran;
|
||||
// We do not initialize boundary to `{source}`, but instead to the set of states one
|
||||
// transition away from `source`; if `source` sets lookahead l and accepts lookahead k, we
|
||||
// only need k and l to occupy distinct slots if there is a `source`-to-`source` path.
|
||||
for (int32_t symbol = 0; symbol < transitionsFromSource.size(); ++symbol) {
|
||||
const int32_t state = transitionsFromSource.elementAti(symbol);
|
||||
if (state != 0) {
|
||||
boundary.push(state, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
const auto visited = prv::make_unique<bool[]>(states.size(), status);
|
||||
while (U_SUCCESS(status) && !boundary.empty()) {
|
||||
const int32_t s = boundary.popi();
|
||||
if (isSink(s)) {
|
||||
return true;
|
||||
}
|
||||
if (excludedState(s) || visited[s]) {
|
||||
continue;
|
||||
}
|
||||
visited[s] = true;
|
||||
UVector32 &transitions = *static_cast<RBBIStateDescriptor *>(states.elementAt(s))->fDtran;
|
||||
for (int32_t symbol = 0; symbol < transitions.size(); ++symbol) {
|
||||
const int32_t t = transitions.elementAti(symbol);
|
||||
if (t != 0 && !visited[t]) {
|
||||
boundary.push(t, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const int32_t kMaxStateFor8BitsTable = 255;
|
||||
|
||||
RBBITableBuilder::RBBITableBuilder(RBBIRuleBuilder *rb, RBBINode **rootNode, UErrorCode &status) :
|
||||
@@ -92,38 +140,6 @@ void RBBITableBuilder::buildForwardTable() {
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// If the rules contained any references to {bof}
|
||||
// add a {bof} <cat> <former root of tree> to the
|
||||
// tree. Means that all matches must start out with the
|
||||
// {bof} fake character.
|
||||
//
|
||||
if (fRB->fSetBuilder->sawBOF()) {
|
||||
RBBINode *bofTop = new RBBINode(RBBINode::opCat, *fStatus);
|
||||
if (bofTop == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
delete bofTop;
|
||||
return;
|
||||
}
|
||||
RBBINode *bofLeaf = new RBBINode(RBBINode::leafChar, *fStatus);
|
||||
// Delete and exit if memory allocation failed.
|
||||
if (bofLeaf == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
delete bofLeaf;
|
||||
delete bofTop;
|
||||
return;
|
||||
}
|
||||
bofTop->fLeftChild = bofLeaf;
|
||||
bofTop->fRightChild = fTree;
|
||||
bofLeaf->fParent = bofTop;
|
||||
bofLeaf->fVal = 2; // Reserved value for {bof}.
|
||||
fTree = bofTop;
|
||||
}
|
||||
|
||||
//
|
||||
// Add a unique right-end marker to the expression.
|
||||
// Appears as a cat-node, left child being the original tree,
|
||||
@@ -157,6 +173,9 @@ void RBBITableBuilder::buildForwardTable() {
|
||||
// expression.
|
||||
//
|
||||
fTree->flattenSets(*fStatus, 0);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
#ifdef RBBI_DEBUG
|
||||
if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "stree")) {
|
||||
RBBIDebugPuts("\nParse tree after flattening Unicode Set references.");
|
||||
@@ -188,13 +207,6 @@ void RBBITableBuilder::buildForwardTable() {
|
||||
calcChainedFollowPos(fTree, endMarkerNode);
|
||||
}
|
||||
|
||||
//
|
||||
// BOF (start of input) test fixup.
|
||||
//
|
||||
if (fRB->fSetBuilder->sawBOF()) {
|
||||
bofFixup();
|
||||
}
|
||||
|
||||
//
|
||||
// Build the DFA state transition tables.
|
||||
//
|
||||
@@ -561,7 +573,7 @@ void RBBITableBuilder::bofFixup() {
|
||||
// transition tables for these states, by the algorithm
|
||||
// of fig. 3.44 in Aho.
|
||||
//
|
||||
// Most of the comments are quotes of Aho's psuedo-code.
|
||||
// Most of the comments are quotes of Aho's pseudo-code.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void RBBITableBuilder::buildStateTable() {
|
||||
@@ -1001,6 +1013,247 @@ void RBBITableBuilder::mergeRuleStatusVals() {
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// minimizeStates Minimize the number of states of the DFA, by Algorithm
|
||||
// 3.6 in Aho. The one twist is that instead of starting
|
||||
// from a partition in two groups (accepting and non-
|
||||
// accepting states), we partition according to all
|
||||
// relevant properties of the states, namely the values of:
|
||||
// - fAccepting—which may be non-accepting,
|
||||
// unconditionally accepting, or the index of a
|
||||
// lookahead—;
|
||||
// - fLookAhead;
|
||||
// - fTagsIdx.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void RBBITableBuilder::minimizeStates() {
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if UPRV_HAS_SANITIZER
|
||||
if (fDStates->size() > 512) {
|
||||
// This algorithm is sluggish on large state machines, and even more sluggish with
|
||||
// sanitizers, which leads the fuzzer into the weeds, see
|
||||
// https://github.com/unicode-org/icu/pull/3948#issuecomment-4335461360.
|
||||
*fStatus = U_REGEX_PATTERN_TOO_BIG;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
struct StateType {
|
||||
uint32_t fAccepting;
|
||||
uint32_t fLookAhead;
|
||||
int32_t fTagsIdx;
|
||||
bool operator==(StateType const &other) const {
|
||||
return fAccepting == other.fAccepting &&
|
||||
fLookAhead == other.fLookAhead &&
|
||||
fTagsIdx == other.fTagsIdx;
|
||||
}
|
||||
};
|
||||
// We wrap `UVector`s in `unique_ptr``s throughout so we can move them,
|
||||
// including into `UVector`s (by releasing them from the `unique_ptr`
|
||||
// and having the enclosing `UVector` adopt them).
|
||||
// Group the states by types (but we have no maps so this is verbose).
|
||||
// If there are no lookaheads and no tags, there are only two types
|
||||
// (accepting and non-accepting) in which case this is exactly step 1
|
||||
// of Algorithm 3.6.
|
||||
struct TypeToStates : UMemory {
|
||||
TypeToStates(const StateType &type, UErrorCode &status)
|
||||
: type(type), states(prv::make_unique<UVector>(status, status)) {}
|
||||
StateType type;
|
||||
prv::unique_ptr<UVector> states;
|
||||
};
|
||||
UVector initialPartition(*fStatus);
|
||||
initialPartition.setDeleter(
|
||||
[](void *p) { delete static_cast<TypeToStates *>(p); });
|
||||
for (int32_t i = 0; i < fDStates->size(); ++i) {
|
||||
const RBBIStateDescriptor &state =
|
||||
*static_cast<RBBIStateDescriptor *>(fDStates->elementAt(i));
|
||||
const StateType type{state.fAccepting,
|
||||
state.fLookAhead,
|
||||
state.fTagsIdx};
|
||||
int32_t j = 0;
|
||||
for (; j < initialPartition.size(); ++j) {
|
||||
auto &[type_j, states] =
|
||||
*static_cast<TypeToStates *>(initialPartition.elementAt(j));
|
||||
if (type_j == type) {
|
||||
states->addElement(i, *fStatus);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == initialPartition.size()) {
|
||||
auto newEntry = prv::make_unique<TypeToStates>(type, *fStatus, *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
newEntry->states->addElement(i, *fStatus);
|
||||
initialPartition.adoptElement(newEntry.release(), *fStatus);
|
||||
}
|
||||
}
|
||||
// The partition Π from Algorithm 3.6.
|
||||
// (We could call it Π, but some member companies that integrate the ICU
|
||||
// code base prohibit non-ASCII identifiers…).
|
||||
auto partition = prv::make_unique<UVector>(*fStatus, *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
partition->setDeleter(
|
||||
[](void *p) { delete static_cast<UVector*>(p); });
|
||||
|
||||
for (int32_t i = 0; i < initialPartition.size(); ++i) {
|
||||
partition->adoptElement(
|
||||
static_cast<TypeToStates*>(initialPartition.elementAt(i))->states.release(),
|
||||
*fStatus);
|
||||
}
|
||||
// Given the index of a state 𝑠 in `fDStates`, returns a UVector of integers
|
||||
// σ(𝑠) such that 𝑠.fDtran[i] (the index of the state reached by the
|
||||
// transition from 𝑠 on the character class with index i) is in Π[σ(𝑠)[i]].
|
||||
// We then have σ(𝑠) == σ(𝑡) if and only if “for all input symbols 𝑎, states
|
||||
// 𝑠 and 𝑡 have transitions on 𝑎 to states in the same group of Π” (which is
|
||||
// what defines the refinement of 𝐺 in Fig. 3.45).
|
||||
auto partition_signature = [&partition, this](int32_t stateIndex) -> prv::unique_ptr<UVector> {
|
||||
const RBBIStateDescriptor &state =
|
||||
*static_cast<RBBIStateDescriptor *>(fDStates->elementAt(stateIndex));
|
||||
auto result = prv::make_unique<UVector>(state.fDtran->size(), *fStatus, *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return nullptr;
|
||||
}
|
||||
for (int32_t i = 0; i < state.fDtran->size(); ++i) {
|
||||
int32_t toState = state.fDtran->elementAti(i);
|
||||
for (int32_t partIndex = 0; partIndex < partition->size(); ++partIndex) {
|
||||
const UVector &part = *static_cast<UVector *>(partition->elementAt(partIndex));
|
||||
if (part.contains(toState)) {
|
||||
result->addElement(partIndex, *fStatus);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
result->setComparer([](const UElement left, const UElement right) -> UBool {
|
||||
return left.integer == right.integer;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
// The loop between steps 2. and 3. of Algorithm 3.6.
|
||||
for (;;) {
|
||||
// Π_new.
|
||||
auto partitionNew = prv::make_unique<UVector>(*fStatus, *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
partitionNew->setDeleter(
|
||||
[](void *p) { delete static_cast<UVector*>(p); });
|
||||
// The procedure from Figure 3.45, Construction of Π_new.
|
||||
bool refined = false;
|
||||
for (int32_t i = 0; i < partition->size(); ++i) {
|
||||
// Group 𝐺 in Π (=`partition`).
|
||||
const UVector &group = *static_cast<UVector*>(partition->elementAt(i));
|
||||
// Partition 𝐺 based on the signature, see above.
|
||||
struct SignatureToStates : UMemory {
|
||||
SignatureToStates(prv::unique_ptr<UVector> signature, UErrorCode &status)
|
||||
: signature(std::move(signature)), states(prv::make_unique<UVector>(status, status)) {
|
||||
}
|
||||
prv::unique_ptr<UVector> signature;
|
||||
prv::unique_ptr<UVector> states;
|
||||
};
|
||||
UVector groupRefinement(*fStatus);
|
||||
groupRefinement.setDeleter([](void *p) { delete static_cast<SignatureToStates*>(p); });
|
||||
for (int32_t j = 0; j < group.size(); ++j) {
|
||||
// Index of a state in the group.
|
||||
const int32_t s = group.elementAti(j);
|
||||
auto signature = partition_signature(s);
|
||||
int32_t k = 0;
|
||||
for (; k < groupRefinement.size(); ++k) {
|
||||
const auto &[subgroupSignature, subgroup] =
|
||||
*static_cast<SignatureToStates*>(groupRefinement.elementAt(k));
|
||||
if (*subgroupSignature == *signature) {
|
||||
subgroup->addElement(s, *fStatus);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (k == groupRefinement.size()) {
|
||||
const auto newEntry =
|
||||
new SignatureToStates(std::move(signature), *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
if (newEntry == nullptr) {
|
||||
*fStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
newEntry->states->addElement(s, *fStatus);
|
||||
groupRefinement.adoptElement(newEntry, *fStatus);
|
||||
}
|
||||
}
|
||||
refined |= groupRefinement.size() > 1;
|
||||
for (int32_t j = 0; j < groupRefinement.size(); ++j) {
|
||||
auto &[_, subgroup] = *static_cast<SignatureToStates*>(
|
||||
groupRefinement.elementAt(j));
|
||||
partitionNew->adoptElement(subgroup.release(), *fStatus);
|
||||
}
|
||||
}
|
||||
if (refined) {
|
||||
partition = std::move(partitionNew);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// We will use the indices in `partition` as the new state indices. Make
|
||||
// sure that the start (1) and stop (0) states remain in their correct
|
||||
// places; everything else can merrily be scrambled.
|
||||
for (int i = 0; i < partition->size(); ++i) {
|
||||
UVector *const part_i = static_cast<UVector *>(partition->elementAt(i));
|
||||
if (part_i->contains(0)) {
|
||||
void *const part_0 = partition->elementAt(0);
|
||||
// No swap on UVector, so we briefly remove the deleter.
|
||||
const auto deleter = partition->setDeleter(nullptr);
|
||||
partition->setElementAt(part_i, 0);
|
||||
partition->setElementAt(part_0, i);
|
||||
partition->setDeleter(deleter);
|
||||
} else if (part_i->contains(1)) {
|
||||
void *const part_1 = partition->elementAt(1);
|
||||
const auto deleter = partition->setDeleter(nullptr);
|
||||
partition->setElementAt(part_i, 1);
|
||||
partition->setElementAt(part_1, i);
|
||||
partition->setDeleter(deleter);
|
||||
}
|
||||
}
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
auto oldStateToPart = prv::make_unique_for_overwrite<uint16_t[]>(fDStates->size(), *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < partition->size(); ++i) {
|
||||
const UVector &part = *static_cast<UVector*>(partition->elementAt(i));
|
||||
for (int j = 0; j < part.size(); ++j) {
|
||||
oldStateToPart[part.elementAti(j)] = i;
|
||||
}
|
||||
}
|
||||
auto const oldStates = prv::unique_ptr<UVector>(fDStates);
|
||||
fDStates = prv::make_unique<UVector>(*fStatus, *fStatus).release();
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < partition->size(); ++i) {
|
||||
const UVector &part = *static_cast<UVector*>(partition->elementAt(i));
|
||||
RBBIStateDescriptor *const state =
|
||||
static_cast<RBBIStateDescriptor*>(oldStates->elementAt(part.elementAti(0)));
|
||||
fDStates->addElement(state, *fStatus);
|
||||
for (int j = 0; j < state->fDtran->size(); ++j) {
|
||||
state->fDtran->setElementAt(oldStateToPart[state->fDtran->elementAti(j)], j);
|
||||
}
|
||||
oldStates->setElementAt(nullptr, part.elementAti(0));
|
||||
}
|
||||
oldStates->setDeleter([](void *p) { delete static_cast<RBBIStateDescriptor*>(p); });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1196,41 +1449,6 @@ void RBBITableBuilder::removeColumn(int32_t column) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* findDuplicateState
|
||||
*/
|
||||
bool RBBITableBuilder::findDuplicateState(IntPair *states) {
|
||||
int32_t numStates = fDStates->size();
|
||||
int32_t numCols = fRB->fSetBuilder->getNumCharCategories();
|
||||
|
||||
for (; states->first<numStates-1; states->first++) {
|
||||
RBBIStateDescriptor* firstSD = static_cast<RBBIStateDescriptor*>(fDStates->elementAt(states->first));
|
||||
for (states->second=states->first+1; states->second<numStates; states->second++) {
|
||||
RBBIStateDescriptor* duplSD = static_cast<RBBIStateDescriptor*>(fDStates->elementAt(states->second));
|
||||
if (firstSD->fAccepting != duplSD->fAccepting ||
|
||||
firstSD->fLookAhead != duplSD->fLookAhead ||
|
||||
firstSD->fTagsIdx != duplSD->fTagsIdx) {
|
||||
continue;
|
||||
}
|
||||
bool rowsMatch = true;
|
||||
for (int32_t col=0; col < numCols; ++col) {
|
||||
int32_t firstVal = firstSD->fDtran->elementAti(col);
|
||||
int32_t duplVal = duplSD->fDtran->elementAti(col);
|
||||
if (!((firstVal == duplVal) ||
|
||||
((firstVal == states->first || firstVal == states->second) &&
|
||||
(duplVal == states->first || duplVal == states->second)))) {
|
||||
rowsMatch = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rowsMatch) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool RBBITableBuilder::findDuplicateSafeState(IntPair *states) {
|
||||
int32_t numStates = fSafeTable->size();
|
||||
@@ -1259,34 +1477,6 @@ bool RBBITableBuilder::findDuplicateSafeState(IntPair *states) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void RBBITableBuilder::removeState(IntPair duplStates) {
|
||||
const int32_t keepState = duplStates.first;
|
||||
const int32_t duplState = duplStates.second;
|
||||
U_ASSERT(keepState < duplState);
|
||||
U_ASSERT(duplState < fDStates->size());
|
||||
|
||||
RBBIStateDescriptor* duplSD = static_cast<RBBIStateDescriptor*>(fDStates->elementAt(duplState));
|
||||
fDStates->removeElementAt(duplState);
|
||||
delete duplSD;
|
||||
|
||||
int32_t numStates = fDStates->size();
|
||||
int32_t numCols = fRB->fSetBuilder->getNumCharCategories();
|
||||
for (int32_t state=0; state<numStates; ++state) {
|
||||
RBBIStateDescriptor* sd = static_cast<RBBIStateDescriptor*>(fDStates->elementAt(state));
|
||||
for (int32_t col=0; col<numCols; col++) {
|
||||
int32_t existingVal = sd->fDtran->elementAti(col);
|
||||
int32_t newVal = existingVal;
|
||||
if (existingVal == duplState) {
|
||||
newVal = keepState;
|
||||
} else if (existingVal > duplState) {
|
||||
newVal = existingVal - 1;
|
||||
}
|
||||
sd->fDtran->setElementAt(newVal, col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RBBITableBuilder::removeSafeState(IntPair duplStates) {
|
||||
const int32_t keepState = duplStates.first;
|
||||
const int32_t duplState = duplStates.second;
|
||||
@@ -1317,15 +1507,160 @@ void RBBITableBuilder::removeSafeState(IntPair duplStates) {
|
||||
* RemoveDuplicateStates
|
||||
*/
|
||||
int32_t RBBITableBuilder::removeDuplicateStates() {
|
||||
IntPair dupls = {3, 0};
|
||||
int32_t numStatesRemoved = 0;
|
||||
const int32_t oldStateCount = fDStates->size();
|
||||
minimizeStates();
|
||||
return fDStates->size() - oldStateCount;
|
||||
}
|
||||
|
||||
while (findDuplicateState(&dupls)) {
|
||||
// printf("Removing duplicate states (%d, %d)\n", dupls.first, dupls.second);
|
||||
removeState(dupls);
|
||||
++numStatesRemoved;
|
||||
|
||||
/*
|
||||
* Minimizes the number of slots used by the lookaheads.
|
||||
*
|
||||
* When the state machine is first generated, every lookahead rule occupies a different slot, for instance,
|
||||
* given
|
||||
* x / z; # Lookahead 1 below.
|
||||
* y / z; # Lookahead 2 below.
|
||||
* [xyz]*;
|
||||
* the following state machine is produced,
|
||||
* x
|
||||
* x ⮏ z
|
||||
* → 𝑠₁ → 𝑎₁
|
||||
* START x⇅y
|
||||
* ↻z → 𝑠₂ → 𝑎₂
|
||||
* y ↻ z
|
||||
* y
|
||||
*
|
||||
* where 𝑠ᵢ sets the current position for lookahead i (assigning pᵢ=p_current), and 𝑎ᵢ accepts
|
||||
* lookahead i if set, i.e., on state 𝑎ᵢ,the break iterator returns pᵢ if set. Because they accept
|
||||
* different lookaheads, states 𝑎₁ and 𝑎₂ are distinct in the initial partition constructed by
|
||||
* `minimizeStates`, and cannot be merged, and the state machine cannot be simplified.
|
||||
*
|
||||
* However, there is no need for lookaheads 1 and 2 to occupy different slots, i.e., there is no
|
||||
* need for the state machine to separately store the positions set by 𝑠₁ and 𝑠₂ (for p₁ and p₂ to
|
||||
* be distinct variables). Indeed, if state 𝑠₁ is encountered, state 𝑎₂ cannot be reached without
|
||||
* going through state 𝑠₂, and vice versa, so if p₁ and p₂ are backed by the same variable p, the
|
||||
* value set by p=p₁=p_current on 𝑠₁ will have been overriden by p=p₂=p_current on 𝑠₂, so that the
|
||||
* p₁-p₂ merger has no effect.
|
||||
*
|
||||
* If the lookaheads are merged, states 𝑎₁ and 𝑎₂ are no longer initially distinct in
|
||||
* `minimizeStates` (they both accept the only lookahead), and indeed the whole state machine
|
||||
* simplifies to
|
||||
* [xy] z
|
||||
* START → 𝑠 → 𝑎
|
||||
* ↻z ↻
|
||||
* [xy]
|
||||
*
|
||||
* Lookaheads i and j can be merged if:
|
||||
* 1. From any state that sets lookahead i, no state that accepts lookahead j can be reached without
|
||||
* going through a state that sets lookahead j; and
|
||||
* 2. From any state that sets lookahead j, no state that accepts lookahead i can be reached without
|
||||
* going through a state that sets lookahead i.
|
||||
* This reachability relation defines a directed graph of lookaheads, and an optimal merging of
|
||||
* lookaheads is then a colouring of that graph. (In the example above, the graph of lookaheads has
|
||||
* no edges, and is thus 1-colourable; more interesting examples can be found in the test
|
||||
* TestLookaheadPolychromy.)
|
||||
*
|
||||
* This function first computes the adjacency matrix of lookahead reachability, and then colours the
|
||||
* graph of lookaheads and reassigns lookahead slots accordingly.
|
||||
*/
|
||||
void RBBITableBuilder::minimizeLookaheads() {
|
||||
if (fLASlotsInUse == ACCEPTING_UNCONDITIONAL) {
|
||||
return;
|
||||
}
|
||||
const int32_t lookaheadCount = fLASlotsInUse - ACCEPTING_UNCONDITIONAL;
|
||||
// The last lookahead is fLASlotsInUse.
|
||||
const int32_t firstLookahead = ACCEPTING_UNCONDITIONAL + 1;
|
||||
const auto stateDescriptor = [this](const int32_t state) -> RBBIStateDescriptor & {
|
||||
return *static_cast<RBBIStateDescriptor *>(fDStates->elementAt(state));
|
||||
};
|
||||
|
||||
const auto lookaheadReachability =
|
||||
prv::make_unique<bool[]>(lookaheadCount * lookaheadCount, *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
for (int32_t l = firstLookahead; l <= fLASlotsInUse; ++l) {
|
||||
for (int32_t k = firstLookahead; k <= fLASlotsInUse; ++k) {
|
||||
if (k != l) {
|
||||
for (int32_t source = 1; source < fDStates->size(); ++source) {
|
||||
if (static_cast<int32_t>(stateDescriptor(source).fLookAhead) != l) {
|
||||
continue;
|
||||
}
|
||||
if (reachableByTransitions(
|
||||
*fDStates, source, /*isSink=*/
|
||||
[&](const int32_t state) {
|
||||
return static_cast<int32_t>(stateDescriptor(state).fAccepting) == k;
|
||||
},
|
||||
/*excludedState=*/
|
||||
[&](const int32_t state) {
|
||||
return static_cast<int32_t>(stateDescriptor(state).fLookAhead) == k;
|
||||
},
|
||||
*fStatus)) {
|
||||
lookaheadReachability[(l - firstLookahead) * lookaheadCount + k -
|
||||
firstLookahead] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto colours = prv::make_unique_for_overwrite<int32_t[]>(lookaheadCount, *fStatus);
|
||||
if (U_FAILURE(*fStatus)) {
|
||||
return;
|
||||
}
|
||||
// Brute-force colouring: the number of lookaheads is in practice small, and the chromatic
|
||||
// number is in practice 1, so this usually terminates in one iteration of the first two loops.
|
||||
// Of course the worst case is exponential, but exponentials are everywhere in regular
|
||||
// expressions anyway.
|
||||
// The outer loop terminates after at most `lookaheadCount` iterations
|
||||
// (when the chromatic number equals the number of lookaheads being coloured).
|
||||
for (int32_t chromaticNumber = 1;; ++chromaticNumber) {
|
||||
uprv_memset(colours.get(), 0, sizeof(int32_t) * lookaheadCount);
|
||||
// This loop terminates after at most chromaticNumber ** lookaheadCount iterations.
|
||||
for (;;) {
|
||||
// Here `source` and `sink` correspond to lookaheads, not states.
|
||||
for (int source = 0; source < lookaheadCount; ++source) {
|
||||
for (int sink = 0; sink < lookaheadCount; ++sink) {
|
||||
if (lookaheadReachability[source * lookaheadCount + sink] &&
|
||||
colours[source] == colours[sink]) {
|
||||
goto nextColouring;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We have found a valid colouring of the graph of lookaheads. Assign lookahead slots
|
||||
// accordingly.
|
||||
for (int i = 0; i < fDStates->size(); ++i) {
|
||||
if (stateDescriptor(i).fAccepting > ACCEPTING_UNCONDITIONAL) {
|
||||
stateDescriptor(i).fAccepting =
|
||||
firstLookahead +
|
||||
colours[stateDescriptor(i).fAccepting - firstLookahead];
|
||||
}
|
||||
if (stateDescriptor(i).fLookAhead != 0) {
|
||||
stateDescriptor(i).fLookAhead =
|
||||
ACCEPTING_UNCONDITIONAL + 1 +
|
||||
colours[stateDescriptor(i).fLookAhead - firstLookahead];
|
||||
}
|
||||
}
|
||||
fLASlotsInUse = ACCEPTING_UNCONDITIONAL + chromaticNumber;
|
||||
return;
|
||||
|
||||
nextColouring:
|
||||
// Increment the colour of the first lookahead, and then carry if we reach
|
||||
// `chromaticNumber` (which is one more than the greatest colour).
|
||||
++colours[0];
|
||||
for (int32_t i = 0; i < lookaheadCount - 1 && colours[i] == chromaticNumber;
|
||||
++i) {
|
||||
colours[i] = 0;
|
||||
++colours[i + 1];
|
||||
}
|
||||
if (colours[lookaheadCount - 1] == chromaticNumber) {
|
||||
// We tried all assignments of colours in {0, …, chromaticNumber - 1},
|
||||
// we need more colours.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return numStatesRemoved;
|
||||
}
|
||||
|
||||
|
||||
@@ -1399,9 +1734,6 @@ void RBBITableBuilder::exportTable(void *where) {
|
||||
if (fRB->fLookAheadHardBreak) {
|
||||
table->fFlags |= RBBI_LOOKAHEAD_HARD_BREAK;
|
||||
}
|
||||
if (fRB->fSetBuilder->sawBOF()) {
|
||||
table->fFlags |= RBBI_BOF_REQUIRED;
|
||||
}
|
||||
|
||||
for (state=0; state<table->fNumStates; state++) {
|
||||
RBBIStateDescriptor* sd = static_cast<RBBIStateDescriptor*>(fDStates->elementAt(state));
|
||||
@@ -1442,8 +1774,15 @@ void RBBITableBuilder::buildSafeReverseTable(UErrorCode &status) {
|
||||
// 1. Identify pairs of character classes that are "safe." Safe means that boundaries
|
||||
// following the pair do not depend on context or state before the pair. To test
|
||||
// whether a pair is safe, run it through the main forward state table, starting
|
||||
// from each state. If the final state is the same, no matter what the starting state,
|
||||
// the pair is safe.
|
||||
// from each possible configuration. If the final configuration is the same, no matter what the
|
||||
// starting configuration, the pair is safe.
|
||||
// Note that the configuration includes not only the state, but also the last accepting position
|
||||
// and the lookaheads. Some differences in final lookaheads can be ignored when it can be shown
|
||||
// that they do not affect breaks after the pair: this happens when we come back out of the pair
|
||||
// with a matching configuration when the lookahead matches.
|
||||
// TODO(egg): It is possible for pairs to be safe even if the outgoing states differ depending
|
||||
// on the state before the pair; this would require a more thorough analysis to handle, probably
|
||||
// in the style of what happens in minimizeStates.
|
||||
//
|
||||
// 2. Build a state table that recognizes the safe pairs. It's similar to their
|
||||
// forward table, with a column for each input character [class], and a row for
|
||||
@@ -1467,31 +1806,200 @@ void RBBITableBuilder::buildSafeReverseTable(UErrorCode &status) {
|
||||
|
||||
int32_t numCharClasses = fRB->fSetBuilder->getNumCharCategories();
|
||||
int32_t numStates = fDStates->size();
|
||||
|
||||
for (int32_t c1=0; c1<numCharClasses; ++c1) {
|
||||
for (int32_t c2=0; c2 < numCharClasses; ++c2) {
|
||||
// The elements at indices 0 and ACCEPTING_UNCONDITIONAL (1) are never used.
|
||||
const auto lookaheadPositions =
|
||||
prv::make_unique_for_overwrite<int8_t[]>(fLASlotsInUse + 1, status);
|
||||
const auto wantedLookaheadsInPair =
|
||||
prv::make_unique_for_overwrite<int8_t[]>(fLASlotsInUse + 1, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
// Same as in rbbi.cpp.
|
||||
// TODO(egg): Maybe this should move to rbbidata.h like ACCEPTING_UNCONDITIONAL?
|
||||
constexpr int32_t START_STATE = 1;
|
||||
// Index -2 is used to signify a text position before the pair (c1, c2).
|
||||
constexpr int32_t BEFORE_PAIR = -2;
|
||||
// In lookaheadPositions, index -1 is used to signify that the lookahead has not been set.
|
||||
constexpr int8_t LOOKAHEAD_NOT_SET = -1;
|
||||
for (int32_t c1 = 1; c1 < numCharClasses; ++c1) {
|
||||
if (fRB->fSetBuilder->getFirstChar(c1) < 0) {
|
||||
continue;
|
||||
}
|
||||
for (int32_t c2 = 1; c2 < numCharClasses; ++c2) {
|
||||
if (fRB->fSetBuilder->getFirstChar(c2) < 0) {
|
||||
continue;
|
||||
}
|
||||
int32_t wantedEndState = -1;
|
||||
int32_t endState = 0;
|
||||
for (int32_t startState = 1; startState < numStates; ++startState) {
|
||||
RBBIStateDescriptor *startStateD = static_cast<RBBIStateDescriptor *>(fDStates->elementAt(startState));
|
||||
int32_t s2 = startStateD->fDtran->elementAti(c1);
|
||||
RBBIStateDescriptor *s2StateD = static_cast<RBBIStateDescriptor *>(fDStates->elementAt(s2));
|
||||
endState = s2StateD->fDtran->elementAti(c2);
|
||||
if (wantedEndState < 0) {
|
||||
wantedEndState = endState;
|
||||
} else {
|
||||
if (wantedEndState != endState) {
|
||||
break;
|
||||
int32_t wantedLastAcceptingPosition;
|
||||
bool mustCheckConsistentWithStartC2 = false;
|
||||
const int32_t text[2] = {c1, c2};
|
||||
for (int32_t injectedState = START_STATE; injectedState < numStates; ++injectedState) {
|
||||
for (int32_t injectedLookahead = ACCEPTING_UNCONDITIONAL;
|
||||
injectedLookahead <= fLASlotsInUse; ++injectedLookahead) {
|
||||
int32_t lastBreak = BEFORE_PAIR;
|
||||
int32_t lastAcceptingPosition = BEFORE_PAIR;
|
||||
uprv_memset(lookaheadPositions.get(), LOOKAHEAD_NOT_SET, fLASlotsInUse + 1);
|
||||
if (injectedLookahead != ACCEPTING_UNCONDITIONAL) {
|
||||
lookaheadPositions[injectedLookahead] = BEFORE_PAIR;
|
||||
}
|
||||
{
|
||||
const RBBIStateDescriptor &injectedStateDescriptor =
|
||||
*static_cast<RBBIStateDescriptor *>(fDStates->elementAt(injectedState));
|
||||
if (injectedStateDescriptor.fAccepting == ACCEPTING_UNCONDITIONAL) {
|
||||
lastAcceptingPosition = 0;
|
||||
} else if (static_cast<int32_t>(injectedStateDescriptor.fAccepting) ==
|
||||
injectedLookahead) {
|
||||
continue;
|
||||
}
|
||||
if (injectedStateDescriptor.fLookAhead != 0) {
|
||||
lookaheadPositions[injectedStateDescriptor.fLookAhead] = 0;
|
||||
}
|
||||
}
|
||||
int32_t s = injectedState;
|
||||
int32_t i = 0;
|
||||
goto dfaStep;
|
||||
// Loop Run_DFA in L2/26-135, without the termination condition (we do not need
|
||||
// to simulate the end of text).
|
||||
for (;;) {
|
||||
s = START_STATE;
|
||||
uprv_memset(lookaheadPositions.get(), LOOKAHEAD_NOT_SET, fLASlotsInUse + 1);
|
||||
i = lastBreak;
|
||||
// Loop Find_Next_Break in L2/26-135.
|
||||
for (;;) {
|
||||
dfaStep:
|
||||
if (i == BEFORE_PAIR || i == 2) {
|
||||
goto inspectFinalState;
|
||||
}
|
||||
const int32_t symbolAhead = text[i];
|
||||
++i;
|
||||
const RBBIStateDescriptor *sDescriptor =
|
||||
static_cast<RBBIStateDescriptor *>(fDStates->elementAt(s));
|
||||
if (sDescriptor->fDtran->elementAti(symbolAhead) != 0) {
|
||||
s = sDescriptor->fDtran->elementAti(symbolAhead);
|
||||
sDescriptor =
|
||||
static_cast<RBBIStateDescriptor *>(fDStates->elementAt(s));
|
||||
} else {
|
||||
if (lastBreak != BEFORE_PAIR &&
|
||||
lastAcceptingPosition == lastBreak) {
|
||||
// The pair (c1, c2) puts us in an infinite loop from the
|
||||
// current configuration, presumably because some one-character
|
||||
// strings are not in the language recognized by the rules).
|
||||
// This should never happen for a segmentation algorithm. The
|
||||
// RBBI implementation forcefully advances the iterator in that
|
||||
// case; let’s just say the pair is unsafe and move on.
|
||||
goto nextSymbolPair;
|
||||
}
|
||||
lastBreak = lastAcceptingPosition;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sDescriptor->fAccepting == ACCEPTING_UNCONDITIONAL) {
|
||||
lastAcceptingPosition = i;
|
||||
} else if (sDescriptor->fAccepting > ACCEPTING_UNCONDITIONAL &&
|
||||
lookaheadPositions[sDescriptor->fAccepting] !=
|
||||
LOOKAHEAD_NOT_SET) {
|
||||
lastBreak = lookaheadPositions[sDescriptor->fAccepting];
|
||||
break;
|
||||
}
|
||||
if (sDescriptor->fLookAhead != 0) {
|
||||
lookaheadPositions[sDescriptor->fLookAhead] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
inspectFinalState:
|
||||
if (i == BEFORE_PAIR) {
|
||||
// Starting on `injectedState` with `injectedLookahead` set, with the pair
|
||||
// (c1, c2) ahead, the state machine finds a break before the pair; it will
|
||||
// thus come back to the pair in a different configuration, which is covered
|
||||
// by some other iteration of the loop over `injectedState` and
|
||||
// `injectedLookahead`.
|
||||
continue;
|
||||
}
|
||||
if (wantedEndState < 0) {
|
||||
wantedEndState = s;
|
||||
wantedLastAcceptingPosition = lastAcceptingPosition;
|
||||
for (int32_t l = ACCEPTING_UNCONDITIONAL + 1; l <= fLASlotsInUse; ++l) {
|
||||
if (lookaheadPositions[l] != LOOKAHEAD_NOT_SET &&
|
||||
lookaheadPositions[l] != BEFORE_PAIR &&
|
||||
lookaheadPositions[l] != 0) {
|
||||
wantedLookaheadsInPair[l] = lookaheadPositions[i];
|
||||
} else {
|
||||
wantedLookaheadsInPair[l] = LOOKAHEAD_NOT_SET;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (wantedEndState != s) {
|
||||
// We can get out of the pair on different states depending on the
|
||||
// initial configuration.
|
||||
goto nextSymbolPair;
|
||||
}
|
||||
if (wantedLastAcceptingPosition != lastAcceptingPosition) {
|
||||
goto nextSymbolPair;
|
||||
}
|
||||
}
|
||||
// A lookahead some distance before the pair (set to BEFORE_PAIR) means we
|
||||
// will come back to the pair in a different configuration if it matches, a
|
||||
// lookahead at position 0 means we get back to the pair on the start state
|
||||
// if it matches; either way, this is covered by other iterations of the
|
||||
// loop over injected states and lookaheads.
|
||||
// For lookaheads at position 1 (in the middle of the pair) and 2 (after the
|
||||
// pair), these have two ways of being safe: either they are always set, or it
|
||||
// does not matter if they are set, because if they match we come back with the
|
||||
// same state.
|
||||
for (int32_t l = ACCEPTING_UNCONDITIONAL + 1; l <= fLASlotsInUse; ++l) {
|
||||
if (lookaheadPositions[l] == BEFORE_PAIR || lookaheadPositions[l] == 0 ||
|
||||
lookaheadPositions[l] == wantedLookaheadsInPair[l]) {
|
||||
continue;
|
||||
}
|
||||
if (lookaheadPositions[l] == 2 || wantedLookaheadsInPair[l] == 2) {
|
||||
// A lookahead after the pair means we will come back to the end of the
|
||||
// pair on the start state if it matches, so in order for the pair to be
|
||||
// safe if that lookahead is not consistently set, we must have left it
|
||||
// on the start state.
|
||||
if (wantedEndState != START_STATE) {
|
||||
goto nextSymbolPair;
|
||||
}
|
||||
}
|
||||
if (lookaheadPositions[l] == 1 || wantedLookaheadsInPair[l] == 1) {
|
||||
// If a lookahead in the middle of the pair matches, we will come back
|
||||
// to c2 on the start state.
|
||||
mustCheckConsistentWithStartC2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wantedEndState == endState) {
|
||||
safePairs.append(static_cast<char16_t>(c1));
|
||||
safePairs.append(static_cast<char16_t>(c2));
|
||||
// printf("(%d, %d) ", c1, c2);
|
||||
if (mustCheckConsistentWithStartC2) {
|
||||
const RBBIStateDescriptor& startDescriptor =
|
||||
*static_cast<RBBIStateDescriptor *>(fDStates->elementAt(START_STATE));
|
||||
const auto c2State = startDescriptor.fDtran->elementAti(c2);
|
||||
if (c2State != wantedEndState) {
|
||||
goto nextSymbolPair;
|
||||
}
|
||||
const RBBIStateDescriptor& c2StateDescriptor =
|
||||
*static_cast<RBBIStateDescriptor *>(fDStates->elementAt(c2State));
|
||||
// In a segmentation algorithm, any single symbol transitions to an
|
||||
// accepting state from the start state (a single character is a
|
||||
// possible segment), so we know c2State is accepting.
|
||||
U_ASSERT(c2StateDescriptor.fAccepting == ACCEPTING_UNCONDITIONAL);
|
||||
if (wantedLastAcceptingPosition != 2) {
|
||||
goto nextSymbolPair;
|
||||
}
|
||||
// If that in turn sets a lookahead, we have a lookahead after the
|
||||
// pair. If we consistently have that the pair is safe. Otherwise, if we match
|
||||
// that lookahead, we end up on the start state.
|
||||
for (int32_t l = ACCEPTING_UNCONDITIONAL + 1; l <= fLASlotsInUse; ++l) {
|
||||
if (((wantedLookaheadsInPair[l] == 2) !=
|
||||
(static_cast<int32_t>(c2StateDescriptor.fLookAhead) == l)) &&
|
||||
wantedEndState != START_STATE) {
|
||||
goto nextSymbolPair;
|
||||
}
|
||||
}
|
||||
}
|
||||
safePairs.append(static_cast<char16_t>(c1));
|
||||
safePairs.append(static_cast<char16_t>(c2));
|
||||
nextSymbolPair:
|
||||
continue;
|
||||
}
|
||||
// printf("\n");
|
||||
}
|
||||
|
||||
// Populate the initial safe table.
|
||||
|
||||
+8
-17
@@ -79,6 +79,13 @@ public:
|
||||
*/
|
||||
int32_t removeDuplicateStates();
|
||||
|
||||
/**
|
||||
* Minimizes the number of slots used by the lookaheads.
|
||||
* This must be called before `removeDuplicateStates`: by merging lookaheads, it removes
|
||||
* distinctions between states that would be preserved by `removeDuplicateStates`.
|
||||
*/
|
||||
void minimizeLookaheads();
|
||||
|
||||
/** Build the safe reverse table from the already-constructed forward table. */
|
||||
void buildSafeReverseTable(UErrorCode &status);
|
||||
|
||||
@@ -105,6 +112,7 @@ private:
|
||||
void flagLookAheadStates();
|
||||
void flagTaggedStates();
|
||||
void mergeRuleStatusVals();
|
||||
void minimizeStates();
|
||||
|
||||
/**
|
||||
* Merge redundant state table columns, eliminating character classes with identical behavior.
|
||||
@@ -114,23 +122,6 @@ private:
|
||||
|
||||
void addRuleRootNodes(UVector *dest, RBBINode *node);
|
||||
|
||||
/**
|
||||
* Find duplicate (redundant) states, beginning at the specified pair,
|
||||
* within this state table. This is an iterator-like function, used to
|
||||
* identify states (state table rows) that can be eliminated.
|
||||
* @param states in/out parameter, specifies where to start looking for duplicates,
|
||||
* and returns the first pair of duplicates found, if any.
|
||||
* @return true if duplicate states were found, false otherwise.
|
||||
*/
|
||||
bool findDuplicateState(IntPair *states);
|
||||
|
||||
/** Remove a duplicate state.
|
||||
* @param duplStates The duplicate states. The first is kept, the second is removed.
|
||||
* All references to the second in the state table are retargeted
|
||||
* to the first.
|
||||
*/
|
||||
void removeState(IntPair duplStates);
|
||||
|
||||
/** Find the next duplicate state in the safe reverse table. An iterator function.
|
||||
* @param states in/out parameter, specifies where to start looking for duplicates,
|
||||
* and returns the first pair of duplicates found, if any.
|
||||
|
||||
+16
-14
@@ -213,7 +213,7 @@ ResourceBundle::ResourceBundle(const char* path, const Locale& locale, UErrorCod
|
||||
}
|
||||
|
||||
|
||||
ResourceBundle& ResourceBundle::operator=(const ResourceBundle& other)
|
||||
ResourceBundle& ResourceBundle::operator=(const ResourceBundle& other) U_LIFETIME_BOUND
|
||||
{
|
||||
if(this == &other) {
|
||||
return *this;
|
||||
@@ -249,17 +249,18 @@ ResourceBundle::clone() const {
|
||||
return new ResourceBundle(*this);
|
||||
}
|
||||
|
||||
UnicodeString ResourceBundle::getString(UErrorCode& status) const {
|
||||
UnicodeString ResourceBundle::getString(UErrorCode& status) const U_LIFETIME_BOUND {
|
||||
int32_t len = 0;
|
||||
const char16_t *r = ures_getString(fResource, &len, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
const uint8_t *ResourceBundle::getBinary(int32_t& len, UErrorCode& status) const {
|
||||
const uint8_t* ResourceBundle::getBinary(int32_t& len, UErrorCode& status) const U_LIFETIME_BOUND {
|
||||
return ures_getBinary(fResource, &len, &status);
|
||||
}
|
||||
|
||||
const int32_t *ResourceBundle::getIntVector(int32_t& len, UErrorCode& status) const {
|
||||
const int32_t* ResourceBundle::getIntVector(int32_t& len,
|
||||
UErrorCode& status) const U_LIFETIME_BOUND {
|
||||
return ures_getIntVector(fResource, &len, &status);
|
||||
}
|
||||
|
||||
@@ -271,11 +272,11 @@ int32_t ResourceBundle::getInt(UErrorCode& status) const {
|
||||
return ures_getInt(fResource, &status);
|
||||
}
|
||||
|
||||
const char *ResourceBundle::getName() const {
|
||||
const char* ResourceBundle::getName() const U_LIFETIME_BOUND {
|
||||
return ures_getName(fResource);
|
||||
}
|
||||
|
||||
const char *ResourceBundle::getKey() const {
|
||||
const char* ResourceBundle::getKey() const U_LIFETIME_BOUND {
|
||||
return ures_getKey(fResource);
|
||||
}
|
||||
|
||||
@@ -307,13 +308,13 @@ ResourceBundle ResourceBundle::getNext(UErrorCode& status) {
|
||||
return res;
|
||||
}
|
||||
|
||||
UnicodeString ResourceBundle::getNextString(UErrorCode& status) {
|
||||
UnicodeString ResourceBundle::getNextString(UErrorCode& status) U_LIFETIME_BOUND {
|
||||
int32_t len = 0;
|
||||
const char16_t* r = ures_getNextString(fResource, &len, nullptr, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
UnicodeString ResourceBundle::getNextString(const char ** key, UErrorCode& status) {
|
||||
UnicodeString ResourceBundle::getNextString(const char** key, UErrorCode& status) U_LIFETIME_BOUND {
|
||||
int32_t len = 0;
|
||||
const char16_t* r = ures_getNextString(fResource, &len, key, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
@@ -331,7 +332,8 @@ ResourceBundle ResourceBundle::get(int32_t indexR, UErrorCode& status) const {
|
||||
return res;
|
||||
}
|
||||
|
||||
UnicodeString ResourceBundle::getStringEx(int32_t indexS, UErrorCode& status) const {
|
||||
UnicodeString ResourceBundle::getStringEx(int32_t indexS,
|
||||
UErrorCode& status) const U_LIFETIME_BOUND {
|
||||
int32_t len = 0;
|
||||
const char16_t* r = ures_getStringByIndex(fResource, indexS, &len, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
@@ -359,15 +361,15 @@ ResourceBundle ResourceBundle::getWithFallback(const char* key, UErrorCode& stat
|
||||
}
|
||||
return res;
|
||||
}
|
||||
UnicodeString ResourceBundle::getStringEx(const char* key, UErrorCode& status) const {
|
||||
|
||||
UnicodeString ResourceBundle::getStringEx(const char* key,
|
||||
UErrorCode& status) const U_LIFETIME_BOUND {
|
||||
int32_t len = 0;
|
||||
const char16_t* r = ures_getStringByKey(fResource, key, &len, &status);
|
||||
return UnicodeString(true, r, len);
|
||||
}
|
||||
|
||||
const char*
|
||||
ResourceBundle::getVersionNumber() const
|
||||
{
|
||||
const char* ResourceBundle::getVersionNumber() const U_LIFETIME_BOUND {
|
||||
return ures_getVersionNumberInternal(fResource);
|
||||
}
|
||||
|
||||
@@ -375,7 +377,7 @@ void ResourceBundle::getVersion(UVersionInfo versionInfo) const {
|
||||
ures_getVersion(fResource, versionInfo);
|
||||
}
|
||||
|
||||
const Locale &ResourceBundle::getLocale() const {
|
||||
const Locale& ResourceBundle::getLocale() const U_LIFETIME_BOUND {
|
||||
static UMutex gLocaleLock;
|
||||
Mutex lock(&gLocaleLock);
|
||||
if (fLocale != nullptr) {
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ StringCharacterIterator::~StringCharacterIterator() {
|
||||
}
|
||||
|
||||
StringCharacterIterator&
|
||||
StringCharacterIterator::operator=(const StringCharacterIterator& that) {
|
||||
StringCharacterIterator::operator=(const StringCharacterIterator& that) U_LIFETIME_BOUND {
|
||||
UCharCharacterIterator::operator=(that);
|
||||
text = that.text;
|
||||
// we had set the input parameter's array, now we need to set our copy's array
|
||||
|
||||
+1
-1
@@ -518,7 +518,7 @@ class U_COMMON_API_CLASS ICULocaleService : public ICUService
|
||||
* Convenience method for callers using locales. This returns the standard
|
||||
* service ID enumeration.
|
||||
*/
|
||||
U_COMMON_API virtual StringEnumeration* getAvailableLocales() const;
|
||||
U_COMMON_API virtual StringEnumeration* getAvailableLocales() const U_LIFETIME_BOUND;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
+4
-4
@@ -159,7 +159,7 @@ private:
|
||||
int32_t _pos;
|
||||
|
||||
private:
|
||||
ServiceEnumeration(const ICULocaleService* service, UErrorCode &status)
|
||||
ServiceEnumeration(const ICULocaleService* service U_LIFETIME_BOUND, UErrorCode& status)
|
||||
: _service(service)
|
||||
, _timestamp(service->getTimestamp())
|
||||
, _ids(uprv_deleteUObject, nullptr, status)
|
||||
@@ -190,7 +190,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
static ServiceEnumeration* create(const ICULocaleService* service) {
|
||||
static ServiceEnumeration* create(const ICULocaleService* service U_LIFETIME_BOUND) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ServiceEnumeration* result = new ServiceEnumeration(service, status);
|
||||
if (U_SUCCESS(status)) {
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
return upToDate(status) ? _ids.size() : 0;
|
||||
}
|
||||
|
||||
virtual const UnicodeString* snext(UErrorCode& status) override {
|
||||
virtual const UnicodeString* snext(UErrorCode& status) U_LIFETIME_BOUND override {
|
||||
if (upToDate(status) && (_pos < _ids.size())) {
|
||||
return static_cast<const UnicodeString*>(_ids[_pos++]);
|
||||
}
|
||||
@@ -254,7 +254,7 @@ ServiceEnumeration::~ServiceEnumeration() {}
|
||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ServiceEnumeration)
|
||||
|
||||
StringEnumeration*
|
||||
ICULocaleService::getAvailableLocales() const
|
||||
ICULocaleService::getAvailableLocales() const U_LIFETIME_BOUND
|
||||
{
|
||||
return ServiceEnumeration::create(this);
|
||||
}
|
||||
|
||||
+36
-23
@@ -50,7 +50,7 @@ inline UBool isInvalidArray(const void *array, int32_t length) {
|
||||
|
||||
} // namespace
|
||||
|
||||
SimpleFormatter &SimpleFormatter::operator=(const SimpleFormatter& other) {
|
||||
SimpleFormatter& SimpleFormatter::operator=(const SimpleFormatter& other) U_LIFETIME_BOUND {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
@@ -156,33 +156,39 @@ UBool SimpleFormatter::applyPatternMinMaxArguments(
|
||||
}
|
||||
|
||||
UnicodeString& SimpleFormatter::format(
|
||||
const UnicodeString &value0,
|
||||
UnicodeString &appendTo, UErrorCode &errorCode) const {
|
||||
const UnicodeString& value0,
|
||||
UnicodeString& appendTo U_LIFETIME_BOUND,
|
||||
UErrorCode& errorCode) const {
|
||||
const UnicodeString *values[] = { &value0 };
|
||||
return formatAndAppend(values, 1, appendTo, nullptr, 0, errorCode);
|
||||
}
|
||||
|
||||
UnicodeString& SimpleFormatter::format(
|
||||
const UnicodeString &value0,
|
||||
const UnicodeString &value1,
|
||||
UnicodeString &appendTo, UErrorCode &errorCode) const {
|
||||
const UnicodeString& value0,
|
||||
const UnicodeString& value1,
|
||||
UnicodeString& appendTo U_LIFETIME_BOUND,
|
||||
UErrorCode& errorCode) const {
|
||||
const UnicodeString *values[] = { &value0, &value1 };
|
||||
return formatAndAppend(values, 2, appendTo, nullptr, 0, errorCode);
|
||||
}
|
||||
|
||||
UnicodeString& SimpleFormatter::format(
|
||||
const UnicodeString &value0,
|
||||
const UnicodeString &value1,
|
||||
const UnicodeString &value2,
|
||||
UnicodeString &appendTo, UErrorCode &errorCode) const {
|
||||
const UnicodeString& value0,
|
||||
const UnicodeString& value1,
|
||||
const UnicodeString& value2,
|
||||
UnicodeString& appendTo U_LIFETIME_BOUND,
|
||||
UErrorCode& errorCode) const {
|
||||
const UnicodeString *values[] = { &value0, &value1, &value2 };
|
||||
return formatAndAppend(values, 3, appendTo, nullptr, 0, errorCode);
|
||||
}
|
||||
|
||||
UnicodeString& SimpleFormatter::formatAndAppend(
|
||||
const UnicodeString *const *values, int32_t valuesLength,
|
||||
UnicodeString &appendTo,
|
||||
int32_t *offsets, int32_t offsetsLength, UErrorCode &errorCode) const {
|
||||
const UnicodeString* const* values,
|
||||
int32_t valuesLength,
|
||||
UnicodeString& appendTo U_LIFETIME_BOUND,
|
||||
int32_t* offsets,
|
||||
int32_t offsetsLength,
|
||||
UErrorCode& errorCode) const {
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return appendTo;
|
||||
}
|
||||
@@ -196,10 +202,13 @@ UnicodeString& SimpleFormatter::formatAndAppend(
|
||||
offsets, offsetsLength, errorCode);
|
||||
}
|
||||
|
||||
UnicodeString &SimpleFormatter::formatAndReplace(
|
||||
const UnicodeString *const *values, int32_t valuesLength,
|
||||
UnicodeString &result,
|
||||
int32_t *offsets, int32_t offsetsLength, UErrorCode &errorCode) const {
|
||||
UnicodeString& SimpleFormatter::formatAndReplace(
|
||||
const UnicodeString* const* values,
|
||||
int32_t valuesLength,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
int32_t* offsets,
|
||||
int32_t offsetsLength,
|
||||
UErrorCode& errorCode) const {
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return result;
|
||||
}
|
||||
@@ -271,12 +280,16 @@ UnicodeString SimpleFormatter::getTextWithNoArguments(
|
||||
return sb;
|
||||
}
|
||||
|
||||
UnicodeString &SimpleFormatter::format(
|
||||
const char16_t *compiledPattern, int32_t compiledPatternLength,
|
||||
const UnicodeString *const *values,
|
||||
UnicodeString &result, const UnicodeString *resultCopy, UBool forbidResultAsValue,
|
||||
int32_t *offsets, int32_t offsetsLength,
|
||||
UErrorCode &errorCode) {
|
||||
UnicodeString& SimpleFormatter::format(
|
||||
const char16_t* compiledPattern,
|
||||
int32_t compiledPatternLength,
|
||||
const UnicodeString* const* values,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
const UnicodeString* resultCopy,
|
||||
UBool forbidResultAsValue,
|
||||
int32_t* offsets,
|
||||
int32_t offsetsLength,
|
||||
UErrorCode& errorCode) {
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
StringPiece::StringPiece(const char* str)
|
||||
StringPiece::StringPiece(const char* str U_LIFETIME_BOUND)
|
||||
: ptr_(str), length_((str == nullptr) ? 0 : static_cast<int32_t>(uprv_strlen(str))) { }
|
||||
|
||||
StringPiece::StringPiece(const StringPiece& x, int32_t pos) {
|
||||
StringPiece::StringPiece(const StringPiece& x U_LIFETIME_BOUND, int32_t pos) {
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
} else if (pos > x.length_) {
|
||||
@@ -28,7 +28,7 @@ StringPiece::StringPiece(const StringPiece& x, int32_t pos) {
|
||||
length_ = x.length_ - pos;
|
||||
}
|
||||
|
||||
StringPiece::StringPiece(const StringPiece& x, int32_t pos, int32_t len) {
|
||||
StringPiece::StringPiece(const StringPiece& x U_LIFETIME_BOUND, int32_t pos, int32_t len) {
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
} else if (pos > x.length_) {
|
||||
|
||||
+15
-9
@@ -204,8 +204,11 @@ StringTrieBuilder::writeBranchSubNode(int32_t start, int32_t limit, int32_t unit
|
||||
// Requires start<limit,
|
||||
// and all strings of the [start..limit[ elements must be sorted and
|
||||
// have a common prefix of length unitIndex.
|
||||
StringTrieBuilder::Node *
|
||||
StringTrieBuilder::makeNode(int32_t start, int32_t limit, int32_t unitIndex, UErrorCode &errorCode) {
|
||||
StringTrieBuilder::Node*
|
||||
StringTrieBuilder::makeNode(int32_t start,
|
||||
int32_t limit,
|
||||
int32_t unitIndex,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -256,9 +259,12 @@ StringTrieBuilder::makeNode(int32_t start, int32_t limit, int32_t unitIndex, UEr
|
||||
|
||||
// start<limit && all strings longer than unitIndex &&
|
||||
// length different units at unitIndex
|
||||
StringTrieBuilder::Node *
|
||||
StringTrieBuilder::makeBranchSubNode(int32_t start, int32_t limit, int32_t unitIndex,
|
||||
int32_t length, UErrorCode &errorCode) {
|
||||
StringTrieBuilder::Node*
|
||||
StringTrieBuilder::makeBranchSubNode(int32_t start,
|
||||
int32_t limit,
|
||||
int32_t unitIndex,
|
||||
int32_t length,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -315,8 +321,8 @@ StringTrieBuilder::makeBranchSubNode(int32_t start, int32_t limit, int32_t unitI
|
||||
return node;
|
||||
}
|
||||
|
||||
StringTrieBuilder::Node *
|
||||
StringTrieBuilder::registerNode(Node *newNode, UErrorCode &errorCode) {
|
||||
StringTrieBuilder::Node*
|
||||
StringTrieBuilder::registerNode(Node* newNode, UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
delete newNode;
|
||||
return nullptr;
|
||||
@@ -344,8 +350,8 @@ StringTrieBuilder::registerNode(Node *newNode, UErrorCode &errorCode) {
|
||||
return newNode;
|
||||
}
|
||||
|
||||
StringTrieBuilder::Node *
|
||||
StringTrieBuilder::registerFinalValue(int32_t value, UErrorCode &errorCode) {
|
||||
StringTrieBuilder::Node*
|
||||
StringTrieBuilder::registerFinalValue(int32_t value, UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+126
-7
@@ -17,7 +17,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "cmemory.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/uchar.h"
|
||||
@@ -196,19 +199,25 @@ ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode)
|
||||
* is this the best way to do this??
|
||||
*/
|
||||
U_CFUNC UBool
|
||||
ubidi_getMemory(BidiMemoryForAllocation *bidiMem, int32_t *pSize, UBool mayAllocate, int32_t sizeNeeded) {
|
||||
ubidi_getMemory(BidiMemoryForAllocation *bidiMem, int32_t *pSize, UBool mayAllocate, size_t sizeNeeded) {
|
||||
if (sizeNeeded > std::numeric_limits<int32_t>::max()) {
|
||||
// TODO(egg): Ugly guard for ICU-23397. A cleaner fix would be to change the pSize to size_t*
|
||||
// and update callers throughout to use size_t for sizes (just like uprv_malloc already does).
|
||||
// Not that anyone should be running the UBA on text with that many runs…
|
||||
return false;
|
||||
}
|
||||
void **pMemory = (void **)bidiMem;
|
||||
/* check for existing memory */
|
||||
if(*pMemory==nullptr) {
|
||||
/* we need to allocate memory */
|
||||
if(mayAllocate && (*pMemory=uprv_malloc(sizeNeeded))!=nullptr) {
|
||||
*pSize=sizeNeeded;
|
||||
*pSize=static_cast<int32_t>(sizeNeeded);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(sizeNeeded<=*pSize) {
|
||||
if(sizeNeeded<=static_cast<size_t>(*pSize)) {
|
||||
/* there is already enough memory */
|
||||
return true;
|
||||
}
|
||||
@@ -224,7 +233,7 @@ ubidi_getMemory(BidiMemoryForAllocation *bidiMem, int32_t *pSize, UBool mayAlloc
|
||||
*/
|
||||
if((memory=uprv_realloc(*pMemory, sizeNeeded))!=nullptr) {
|
||||
*pMemory=memory;
|
||||
*pSize=sizeNeeded;
|
||||
*pSize=static_cast<int32_t>(sizeNeeded);
|
||||
return true;
|
||||
} else {
|
||||
/* we failed to grow */
|
||||
@@ -2417,9 +2426,16 @@ setParaRunsOnly(UBiDi *pBiDi, const char16_t *text, int32_t length,
|
||||
* to ubidi_setPara (but must make provision for possible removal of
|
||||
* BiDi controls. Alternatively, only use the dirProps array via
|
||||
* customized classifier callback.
|
||||
*
|
||||
* Note: We pass UBIDI_INTERNAL_RUNS_ONLY so that if mirroring changes code point
|
||||
* length (e.g., U+1DB10 contracting back to U+221D), doWriteReverse() uses legacy
|
||||
* 1-to-1 code unit stepping (j += k) rather than character stepping (j += origBaseLen).
|
||||
* This ensures visualLength remains synchronized with pBiDi->length and allows the
|
||||
* trailing surrogate half (Bidi class LTR) to act as a run boundary splitter in the
|
||||
* subsequent ubidi_setPara call.
|
||||
*/
|
||||
visualLength=ubidi_writeReordered(pBiDi, visualText, length,
|
||||
UBIDI_DO_MIRRORING, pErrorCode);
|
||||
(saveOptions & UBIDI_DO_MIRRORING) | UBIDI_INTERNAL_RUNS_ONLY, pErrorCode);
|
||||
ubidi_getVisualMap(pBiDi, visualMap, pErrorCode);
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
goto cleanup2;
|
||||
@@ -2471,6 +2487,7 @@ setParaRunsOnly(UBiDi *pBiDi, const char16_t *text, int32_t length,
|
||||
runs=pBiDi->runs=pBiDi->runsMemory;
|
||||
pBiDi->runCount+=addedRuns;
|
||||
} else {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanup1;
|
||||
}
|
||||
}
|
||||
@@ -2879,8 +2896,8 @@ ubidi_getDirection(const UBiDi *pBiDi) {
|
||||
}
|
||||
}
|
||||
|
||||
U_CAPI const char16_t * U_EXPORT2
|
||||
ubidi_getText(const UBiDi *pBiDi) {
|
||||
U_CAPI const char16_t* U_EXPORT2
|
||||
ubidi_getText(const UBiDi* pBiDi) {
|
||||
if(IS_VALID_PARA_OR_LINE(pBiDi)) {
|
||||
return pBiDi->text;
|
||||
} else {
|
||||
@@ -3034,3 +3051,105 @@ ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c)
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
/* Utilities for MessageFormat ------------------------------------------------*/
|
||||
|
||||
#if U_SHOW_CPLUSPLUS_API
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
U_CAPI UMFBidiOption U_EXPORT2
|
||||
ubidi_getMFOption(const UnicodeString& s) {
|
||||
if (s == u"ltr") {
|
||||
return U_MF_BIDI_OPTION_LTR;
|
||||
}
|
||||
if (s == u"rtl") {
|
||||
return U_MF_BIDI_OPTION_RTL;
|
||||
}
|
||||
if (s == u"auto") {
|
||||
return U_MF_BIDI_OPTION_AUTO;
|
||||
}
|
||||
return U_MF_BIDI_OPTION_INHERIT; // inherit is default
|
||||
}
|
||||
|
||||
// BiDi isolation
|
||||
// --------------
|
||||
// `uDirOption` is the directionality from a u:dir annotation on the expression
|
||||
// that produced this formatted value, if present.
|
||||
// `dir` is the directionality of `fmt`. This is determined from the resolved
|
||||
// value that `fmt` is part of; that is, each function can set the directionality
|
||||
// of the resolved value of its result.
|
||||
U_CAPI UnicodeString* U_EXPORT2
|
||||
ubidi_isolate(UMFBidiIsolationStrategy bidiIsolationStrategy,
|
||||
UMFDirectionality msgdir,
|
||||
UMFBidiIsolationStyle bidiIsolationStyle,
|
||||
UMFBidiOption uDirOption,
|
||||
UMFDirectionality dir,
|
||||
UnicodeString& fmt) {
|
||||
// See "The Default Bidi Strategy" at:
|
||||
// https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#handling-bidirectional-text
|
||||
|
||||
// If strategy is 'none', just return the string
|
||||
if (bidiIsolationStrategy == U_MF_BIDI_OFF)
|
||||
return &fmt;
|
||||
|
||||
/* 1. Let msgdir be the directionality of the whole message, one of « 'LTR', 'RTL', 'unknown' ». These correspond to the message having left-to-right directionality, right-to-left directionality, and to the message's directionality not being known. */
|
||||
|
||||
// 2i Let fmt be the formatted string representation of the resolved value of exp.
|
||||
// (Passed as argument)
|
||||
|
||||
// 2ii Let dir be the directionality of fmt, one of « 'LTR', 'RTL', 'unknown' », with the same meanings as for msgdir
|
||||
// (Passed as argument)
|
||||
|
||||
// 2iii. Let the boolean value isolate be True if the u:dir option of the resolved value of exp has a value other than 'inherit', or False otherwise.
|
||||
bool isolate = uDirOption != U_MF_BIDI_OPTION_INHERIT;
|
||||
|
||||
UnicodeString bdiOpen("<bdi>");
|
||||
UnicodeString bdiClose("</bdi>");
|
||||
|
||||
// 2iv. If dir is 'LTR'
|
||||
switch (dir) {
|
||||
case U_MF_DIRECTIONALITY_LTR:
|
||||
if (msgdir == U_MF_DIRECTIONALITY_LTR && !isolate) {
|
||||
// 2iv(a). If msgdir is 'LTR' in the formatted output, let fmt be itself
|
||||
return &fmt;
|
||||
}
|
||||
// 2iii(b) Else, in the formatted output, prefix fmt with U+2066 LEFT-TO-RIGHT ISOLATE and postfix it with U+2069 POP DIRECTIONAL ISOLATE.
|
||||
if (bidiIsolationStyle == U_MF_BIDI_STYLE_CONTROL) {
|
||||
fmt.insert(0, LRI_CHAR);
|
||||
fmt.insert(fmt.length(), PDI_CHAR);
|
||||
} else {
|
||||
fmt.insert(0, bdiOpen);
|
||||
fmt.insert(fmt.length(), bdiClose);
|
||||
}
|
||||
break; // End of 2iii
|
||||
// 2iv. Else, if dir is 'RTL':
|
||||
case U_MF_DIRECTIONALITY_RTL:
|
||||
// 2iv(a). In the formatted output, prefix fmt with U+2067 RIGHT-TO-LEFT ISOLATE and postfix it with U+2069 POP DIRECTIONAL ISOLATE.
|
||||
if (bidiIsolationStyle == U_MF_BIDI_STYLE_CONTROL) {
|
||||
fmt.insert(0, RLI_CHAR);
|
||||
fmt.insert(fmt.length(), PDI_CHAR);
|
||||
} else {
|
||||
fmt.insert(0, bdiOpen);
|
||||
fmt.insert(fmt.length(), bdiClose);
|
||||
}
|
||||
break; // End of 2iv.
|
||||
// 2v. Else:
|
||||
default:
|
||||
// 2v(a). In the formatted output, prefix fmt with U+2068 FIRST STRONG ISOLATE and postfix it with U+2069 POP DIRECTIONAL ISOLATE.
|
||||
if (bidiIsolationStyle == U_MF_BIDI_STYLE_CONTROL) {
|
||||
fmt.insert(0, FSI_CHAR);
|
||||
fmt.insert(fmt.length(), PDI_CHAR);
|
||||
} else {
|
||||
fmt.insert(0, bdiOpen);
|
||||
fmt.insert(fmt.length(), bdiClose);
|
||||
}
|
||||
break; // End of 2v
|
||||
} // `fmt` now contains the isolated string
|
||||
return &fmt;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // #if SHOW_CPLUSPLUS_API
|
||||
|
||||
+499
-497
File diff suppressed because it is too large.
Load diff
+15
-1
@@ -25,6 +25,20 @@
|
||||
#include "ubidi_props.h"
|
||||
|
||||
/* miscellaneous definitions ---------------------------------------------- */
|
||||
/*
|
||||
* Internal option bit for ubidi_writeReordered() and doWriteReverse():
|
||||
* Used exclusively by setParaRunsOnly() during Scheme 9 (LOGICAL, RTL => LOGICAL, LTR)
|
||||
* BidiTransform transformations. When mirroring changes code point length (e.g., U+1DB10
|
||||
* contracting back to U+221D), setParaRunsOnly() requires that the temporary visualText
|
||||
* buffer maintain 1-to-1 code unit synchronization with pBiDi->length (4) to prevent
|
||||
* array desynchronization in the subsequent ubidi_setPara call.
|
||||
*
|
||||
* When this flag is set, doWriteReverse() steps source indices by destination code unit
|
||||
* length (j += k) instead of original base character length (j += origBaseLen), preserving
|
||||
* legacy ICU behavior where the trailing surrogate half (which has Bidi class LTR) is copied
|
||||
* into visualText, allowing ubidi_setPara to correctly split the run for reordering.
|
||||
*/
|
||||
#define UBIDI_INTERNAL_RUNS_ONLY 64
|
||||
|
||||
// ICU-20853=ICU-20935 Solaris #defines CS and ES in sys/regset.h
|
||||
#ifdef CS
|
||||
@@ -441,7 +455,7 @@ typedef union {
|
||||
|
||||
/* helper function to (re)allocate memory if allowed */
|
||||
U_CFUNC UBool
|
||||
ubidi_getMemory(BidiMemoryForAllocation *pMemory, int32_t *pSize, UBool mayAllocate, int32_t sizeNeeded);
|
||||
ubidi_getMemory(BidiMemoryForAllocation *pMemory, int32_t *pSize, UBool mayAllocate, size_t sizeNeeded);
|
||||
|
||||
/* helper macros for each allocated array in UBiDi */
|
||||
#define getDirPropsMemory(pBiDi, length) \
|
||||
|
||||
+4
-3
@@ -258,8 +258,8 @@ ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
U_CAPI const UBiDiLevel * U_EXPORT2
|
||||
ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode) {
|
||||
U_CAPI const UBiDiLevel* U_EXPORT2
|
||||
ubidi_getLevels(UBiDi* pBiDi, UErrorCode* pErrorCode) {
|
||||
int32_t start, length;
|
||||
|
||||
RETURN_IF_NULL_OR_FAILING_ERRCODE(pErrorCode, nullptr);
|
||||
@@ -544,7 +544,7 @@ static int32_t getRunFromLogicalIndex(UBiDi *pBiDi, int32_t logicalIndex) {
|
||||
* negative number of BiDi control characters within this run.
|
||||
*/
|
||||
U_CFUNC UBool
|
||||
ubidi_getRuns(UBiDi *pBiDi, UErrorCode*) {
|
||||
ubidi_getRuns(UBiDi *pBiDi, UErrorCode* pErrorCode) {
|
||||
/*
|
||||
* This method returns immediately if the runs are already set. This
|
||||
* includes the case of length==0 (handled in setPara)..
|
||||
@@ -607,6 +607,7 @@ ubidi_getRuns(UBiDi *pBiDi, UErrorCode*) {
|
||||
if(getRunsMemory(pBiDi, runCount)) {
|
||||
runs=pBiDi->runsMemory;
|
||||
} else {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+15
-7
@@ -308,17 +308,25 @@ action_mirror(UBiDiTransform *pTransform, UErrorCode *pErrorCode)
|
||||
if (0 == (pTransform->reorderingOptions & UBIDI_DO_MIRRORING)) {
|
||||
return false;
|
||||
}
|
||||
if (pTransform->destSize < pTransform->srcLength) {
|
||||
*pErrorCode = U_BUFFER_OVERFLOW_ERROR;
|
||||
return false;
|
||||
}
|
||||
do {
|
||||
UBool isOdd = ubidi_getLevelAt(pTransform->pBidi, i) & 1;
|
||||
U16_NEXT(pTransform->src, i, pTransform->srcLength, c);
|
||||
U16_APPEND_UNSAFE(pTransform->dest, j, isOdd ? u_charMirror(c) : c);
|
||||
if (isOdd) {
|
||||
c = u_charMirror(c);
|
||||
}
|
||||
uint32_t k = U16_LENGTH(c);
|
||||
if (j + k <= pTransform->destSize) {
|
||||
U16_APPEND_UNSAFE(pTransform->dest, j, c);
|
||||
} else {
|
||||
j += k;
|
||||
}
|
||||
} while (i < pTransform->srcLength);
|
||||
|
||||
*pTransform->pDestLength = pTransform->srcLength;
|
||||
*pTransform->pDestLength = j;
|
||||
if (pTransform->destSize < j) {
|
||||
*pErrorCode = U_BUFFER_OVERFLOW_ERROR;
|
||||
return false;
|
||||
}
|
||||
pTransform->reorderingOptions = UBIDI_REORDER_DEFAULT;
|
||||
return true;
|
||||
}
|
||||
@@ -526,5 +534,5 @@ cleanup:
|
||||
pBiDiTransform->srcLength = 0;
|
||||
pBiDiTransform->destSize = 0;
|
||||
}
|
||||
return U_FAILURE(*pErrorCode) ? 0 : destLength;
|
||||
return (U_FAILURE(*pErrorCode) && *pErrorCode != U_BUFFER_OVERFLOW_ERROR) ? 0 : destLength;
|
||||
}
|
||||
+144
-68
@@ -37,8 +37,7 @@
|
||||
* ("minimum-length-problem" of UTF-8)
|
||||
* - The BiDi control characters need only one code unit each
|
||||
*
|
||||
* Further assumptions for all UTFs:
|
||||
* - u_charMirror(c) needs the same number of code units as c
|
||||
* Note: Since Unicode 18, u_charMirror(c) may change the number of code units.
|
||||
*/
|
||||
#if defined(UTF_SIZE) && UTF_SIZE==8
|
||||
# error reimplement ubidi_writeReordered() for UTF-8, see comment above
|
||||
@@ -60,6 +59,10 @@ doWriteForward(const char16_t *src, int32_t srcLength,
|
||||
char16_t *dest, int32_t destSize,
|
||||
uint16_t options,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (srcLength<=0) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
/* optimize for several combinations of options */
|
||||
switch(options&(UBIDI_REMOVE_BIDI_CONTROLS|UBIDI_DO_MIRRORING)) {
|
||||
case 0: {
|
||||
@@ -78,16 +81,30 @@ doWriteForward(const char16_t *src, int32_t srcLength,
|
||||
/* do mirroring */
|
||||
int32_t i=0, j=0;
|
||||
UChar32 c;
|
||||
|
||||
if(destSize<srcLength) {
|
||||
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
|
||||
return srcLength;
|
||||
}
|
||||
do {
|
||||
U16_NEXT(src, i, srcLength, c);
|
||||
c=u_charMirror(c);
|
||||
U16_APPEND_UNSAFE(dest, j, c);
|
||||
int32_t charLen = U16_LENGTH(c);
|
||||
if(j + charLen <= destSize) {
|
||||
int32_t temp = j;
|
||||
U16_APPEND_UNSAFE(dest, temp, c);
|
||||
}
|
||||
j += charLen;
|
||||
} while(i<srcLength);
|
||||
if(destSize < j) {
|
||||
*pErrorCode = U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
if(j > srcLength) {
|
||||
return j;
|
||||
}
|
||||
/* If mirroring caused code unit contraction (e.g., U+1DB10 contracting to U+221D),
|
||||
* pad trailing array slots up to srcLength to avoid leaving uninitialized memory.
|
||||
* If j > 0, repeat the preceding code unit; if j == 0, fallback to 0x0020 (ASCII space).
|
||||
*/
|
||||
while(j < srcLength && j < destSize) {
|
||||
dest[j] = j > 0 ? dest[j - 1] : 0x0020;
|
||||
j++;
|
||||
}
|
||||
return srcLength;
|
||||
}
|
||||
case UBIDI_REMOVE_BIDI_CONTROLS: {
|
||||
@@ -116,7 +133,6 @@ doWriteForward(const char16_t *src, int32_t srcLength,
|
||||
}
|
||||
default: {
|
||||
/* remove BiDi control characters and do mirroring */
|
||||
int32_t remaining=destSize;
|
||||
int32_t i, j=0;
|
||||
UChar32 c;
|
||||
do {
|
||||
@@ -125,24 +141,18 @@ doWriteForward(const char16_t *src, int32_t srcLength,
|
||||
src+=i;
|
||||
srcLength-=i;
|
||||
if(!IS_BIDI_CONTROL_CHAR(c)) {
|
||||
remaining-=i;
|
||||
if(remaining<0) {
|
||||
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
|
||||
|
||||
/* preflight the length */
|
||||
while(srcLength>0) {
|
||||
c=*src++;
|
||||
if(!IS_BIDI_CONTROL_CHAR(c)) {
|
||||
--remaining;
|
||||
}
|
||||
--srcLength;
|
||||
}
|
||||
return destSize-remaining;
|
||||
}
|
||||
c=u_charMirror(c);
|
||||
U16_APPEND_UNSAFE(dest, j, c);
|
||||
int32_t charLen = U16_LENGTH(c);
|
||||
if(j + charLen <= destSize) {
|
||||
int32_t temp = j;
|
||||
U16_APPEND_UNSAFE(dest, temp, c);
|
||||
}
|
||||
j += charLen;
|
||||
}
|
||||
} while(srcLength>0);
|
||||
if(destSize < j) {
|
||||
*pErrorCode = U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
} /* end of switch */
|
||||
@@ -174,6 +184,11 @@ doWriteReverse(const char16_t *src, int32_t srcLength,
|
||||
int32_t i, j;
|
||||
UChar32 c;
|
||||
|
||||
if(srcLength<=0) {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* optimize for several combinations of options */
|
||||
switch(options&(UBIDI_REMOVE_BIDI_CONTROLS|UBIDI_DO_MIRRORING|UBIDI_KEEP_BASE_COMBINING)) {
|
||||
case 0:
|
||||
@@ -195,7 +210,7 @@ doWriteReverse(const char16_t *src, int32_t srcLength,
|
||||
i=srcLength;
|
||||
|
||||
/* collect code units for one base character */
|
||||
U16_BACK_1(src, 0, srcLength);
|
||||
U16_PREV(src, 0, srcLength, c);
|
||||
|
||||
/* copy this base character */
|
||||
j=srcLength;
|
||||
@@ -234,74 +249,133 @@ doWriteReverse(const char16_t *src, int32_t srcLength,
|
||||
} while(j<i);
|
||||
} while(srcLength>0);
|
||||
break;
|
||||
default:
|
||||
default: {
|
||||
/*
|
||||
* With several "complicated" options set, this is the most
|
||||
* general and the slowest copying of an RTL run.
|
||||
* We will do mirroring, remove BiDi controls, and
|
||||
* keep combining characters with their base characters
|
||||
* as requested.
|
||||
* Note on UBIDI_INTERNAL_RUNS_ONLY:
|
||||
* This internal flag is passed exclusively by setParaRunsOnly() in ubidi.cpp during
|
||||
* Scheme 9 (LOGICAL, RTL => LOGICAL, LTR) BidiTransform transformations.
|
||||
* When mirroring contracts a code point (e.g., U+1DB10 contracting to U+221D),
|
||||
* setParaRunsOnly() requires legacy ICU 1-to-1 code unit stepping (j += k) and
|
||||
* returning destSize (which equals srcLength). This prevents array desynchronization
|
||||
* between visualLength and pBiDi->length, and allows the trailing surrogate half
|
||||
* of U+1DB10 (which has Bidi class LTR) to be copied into visualText to split
|
||||
* the run for reordering.
|
||||
*
|
||||
* For all other calls (direct user API calls to ubidi_writeReverse, or normal
|
||||
* reordering), we use character stepping (j += origBaseLen) and return destLength,
|
||||
* which correctly handles expansion and contraction without leaking broken surrogates.
|
||||
*/
|
||||
if(!(options&UBIDI_REMOVE_BIDI_CONTROLS)) {
|
||||
i=srcLength;
|
||||
} else {
|
||||
/* we need to find out the destination length of the run,
|
||||
which will not include the BiDi control characters */
|
||||
int32_t length=srcLength;
|
||||
char16_t ch;
|
||||
|
||||
i=0;
|
||||
if(options&UBIDI_INTERNAL_RUNS_ONLY) {
|
||||
if(!(options&UBIDI_REMOVE_BIDI_CONTROLS)) {
|
||||
i=srcLength;
|
||||
} else {
|
||||
int32_t length=srcLength;
|
||||
char16_t ch;
|
||||
i=0;
|
||||
/* Loop over all code units in the source run to count those that are not Bidi control characters,
|
||||
* determining the required destination buffer length for preflighting when UBIDI_REMOVE_BIDI_CONTROLS is set.
|
||||
*/
|
||||
do {
|
||||
ch=*src++;
|
||||
if(!IS_BIDI_CONTROL_CHAR(ch)) {
|
||||
++i;
|
||||
}
|
||||
} while(--length>0);
|
||||
src-=srcLength;
|
||||
}
|
||||
if(destSize<i) {
|
||||
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
|
||||
return i;
|
||||
}
|
||||
char16_t *saveDest=dest;
|
||||
int32_t destLength=0;
|
||||
/* Loop backward across the source run segment by segment, using legacy 1-to-1 code unit stepping
|
||||
* to extract and reverse character clusters for internal setPara classification.
|
||||
*/
|
||||
do {
|
||||
ch=*src++;
|
||||
if(!IS_BIDI_CONTROL_CHAR(ch)) {
|
||||
++i;
|
||||
i=srcLength;
|
||||
U16_PREV(src, 0, srcLength, c);
|
||||
if(options&UBIDI_KEEP_BASE_COMBINING) {
|
||||
/* Loop backward over any combining marks attached to the base character so that the combining
|
||||
* sequence remains attached after its base character when reversed.
|
||||
*/
|
||||
while(srcLength>0 && IS_COMBINING(u_charType(c))) {
|
||||
U16_PREV(src, 0, srcLength, c);
|
||||
}
|
||||
}
|
||||
} while(--length>0);
|
||||
src-=srcLength;
|
||||
if(options&UBIDI_REMOVE_BIDI_CONTROLS && IS_BIDI_CONTROL_CHAR(c)) {
|
||||
continue;
|
||||
}
|
||||
int32_t origBaseLen=U16_LENGTH(c);
|
||||
j=srcLength;
|
||||
if(options&UBIDI_DO_MIRRORING) {
|
||||
c=u_charMirror(c);
|
||||
int32_t k=U16_LENGTH(c);
|
||||
if(destLength+k<=destSize) {
|
||||
int32_t temp=destLength;
|
||||
U16_APPEND_UNSAFE(saveDest, temp, c);
|
||||
}
|
||||
destLength+=k;
|
||||
j+=origBaseLen;
|
||||
}
|
||||
/* Loop forward from the current segment index to copy any unmirrored code units (such as combining marks
|
||||
* or surrogate halves) into dest in forward visual order.
|
||||
*/
|
||||
while(j<i) {
|
||||
if(destLength<destSize) {
|
||||
saveDest[destLength]=src[j];
|
||||
}
|
||||
destLength++;
|
||||
j++;
|
||||
}
|
||||
} while(srcLength>0);
|
||||
if(destSize<destLength) {
|
||||
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
return destLength;
|
||||
}
|
||||
|
||||
if(destSize<i) {
|
||||
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
|
||||
return i;
|
||||
}
|
||||
destSize=i;
|
||||
|
||||
/* preserve character integrity */
|
||||
int32_t destLength=0;
|
||||
do {
|
||||
/* i is always after the last code unit known to need to be kept in this segment */
|
||||
i=srcLength;
|
||||
|
||||
/* collect code units for one base character */
|
||||
U16_PREV(src, 0, srcLength, c);
|
||||
if(options&UBIDI_KEEP_BASE_COMBINING) {
|
||||
/* collect modifier letters for this base character */
|
||||
while(srcLength>0 && IS_COMBINING(u_charType(c))) {
|
||||
U16_PREV(src, 0, srcLength, c);
|
||||
}
|
||||
}
|
||||
|
||||
if(options&UBIDI_REMOVE_BIDI_CONTROLS && IS_BIDI_CONTROL_CHAR(c)) {
|
||||
/* do not copy this BiDi control character */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* copy this "user character" */
|
||||
int32_t origBaseLen=U16_LENGTH(c);
|
||||
j=srcLength;
|
||||
if(options&UBIDI_DO_MIRRORING) {
|
||||
/* mirror only the base character */
|
||||
int32_t k=0;
|
||||
c=u_charMirror(c);
|
||||
U16_APPEND_UNSAFE(dest, k, c);
|
||||
dest+=k;
|
||||
j+=k;
|
||||
int32_t k=U16_LENGTH(c);
|
||||
if(destLength+k<=destSize) {
|
||||
int32_t temp=destLength;
|
||||
U16_APPEND_UNSAFE(dest, temp, c);
|
||||
}
|
||||
destLength+=k;
|
||||
j+=origBaseLen;
|
||||
}
|
||||
while(j<i) {
|
||||
*dest++=src[j++];
|
||||
if(destLength<destSize) {
|
||||
dest[destLength]=src[j];
|
||||
}
|
||||
destLength++;
|
||||
j++;
|
||||
}
|
||||
} while(srcLength>0);
|
||||
break;
|
||||
} /* end of switch */
|
||||
|
||||
|
||||
if(destSize<destLength) {
|
||||
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
return destLength;
|
||||
}
|
||||
} /* end of switch */
|
||||
return destSize;
|
||||
}
|
||||
|
||||
@@ -398,6 +472,7 @@ ubidi_writeReordered(UBiDi *pBiDi,
|
||||
/* destSize shrinks, later destination length=destCapacity-destSize */
|
||||
saveDest=dest;
|
||||
destCapacity=destSize;
|
||||
runLength = 0;
|
||||
|
||||
/*
|
||||
* Option "insert marks" implies UBIDI_INSERT_LRM_FOR_NUMERIC if the
|
||||
@@ -627,6 +702,7 @@ ubidi_writeReordered(UBiDi *pBiDi,
|
||||
--destSize;
|
||||
}
|
||||
|
||||
int32_t originalRunLength = runLength;
|
||||
runLength=doWriteForward(src, runLength,
|
||||
dest, destSize,
|
||||
options, pErrorCode);
|
||||
@@ -638,7 +714,7 @@ ubidi_writeReordered(UBiDi *pBiDi,
|
||||
if(/*run>0 &&*/
|
||||
runLength > 0 && // doWriteForward may return 0 if src
|
||||
// only include bidi control chars
|
||||
!(MASK_R_AL&DIRPROP_FLAG(dirProps[logicalStart+runLength-1]))) {
|
||||
!(MASK_R_AL&DIRPROP_FLAG(dirProps[logicalStart+originalRunLength-1]))) {
|
||||
if(destSize>0) {
|
||||
*dest++=RLM_CHAR;
|
||||
}
|
||||
|
||||
+1
-1
@@ -300,7 +300,7 @@ ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity,
|
||||
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
ubrk_getLocaleByType(const UBreakIterator *bi,
|
||||
ubrk_getLocaleByType(const UBreakIterator* bi U_LIFETIME_BOUND,
|
||||
ULocDataLocaleType type,
|
||||
UErrorCode* status)
|
||||
{
|
||||
|
||||
+431
-410
File diff suppressed because it is too large.
Load diff
+34
-23
@@ -46,26 +46,33 @@ U_NAMESPACE_USE
|
||||
|
||||
/* UCaseMap service object -------------------------------------------------- */
|
||||
|
||||
UCaseMap::UCaseMap(const char *localeID, uint32_t opts, UErrorCode *pErrorCode) :
|
||||
// The public type, unicode/ucasemap.h struct UCaseMap, is an opaque C type.
|
||||
// We define a parallel C++ type in the ICU namespace for entry point renaming.
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
UCaseMapImpl::UCaseMapImpl(const char *localeID, uint32_t opts, UErrorCode *pErrorCode) :
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
iter(nullptr),
|
||||
#endif
|
||||
caseLocale(UCASE_LOC_UNKNOWN), options(opts) {
|
||||
ucasemap_setLocale(this, localeID, pErrorCode);
|
||||
ucasemap_setLocale(reinterpret_cast<UCaseMap *>(this), localeID, pErrorCode);
|
||||
}
|
||||
|
||||
UCaseMap::~UCaseMap() {
|
||||
UCaseMapImpl::~UCaseMapImpl() {
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
delete iter;
|
||||
#endif
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
U_CAPI UCaseMap * U_EXPORT2
|
||||
ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return nullptr;
|
||||
}
|
||||
UCaseMap *csm = new UCaseMap(locale, options, pErrorCode);
|
||||
UCaseMapImpl *csm = new UCaseMapImpl(locale, options, pErrorCode);
|
||||
if(csm==nullptr) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
@@ -73,22 +80,22 @@ ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode) {
|
||||
delete csm;
|
||||
return nullptr;
|
||||
}
|
||||
return csm;
|
||||
return reinterpret_cast<UCaseMap *>(csm);
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
ucasemap_close(UCaseMap *csm) {
|
||||
delete csm;
|
||||
delete reinterpret_cast<UCaseMapImpl *>(csm);
|
||||
}
|
||||
|
||||
U_CAPI const char * U_EXPORT2
|
||||
ucasemap_getLocale(const UCaseMap *csm) {
|
||||
return csm->locale;
|
||||
U_CAPI const char* U_EXPORT2
|
||||
ucasemap_getLocale(const UCaseMap* csm U_LIFETIME_BOUND) {
|
||||
return reinterpret_cast<const UCaseMapImpl *>(csm)->locale;
|
||||
}
|
||||
|
||||
U_CAPI uint32_t U_EXPORT2
|
||||
ucasemap_getOptions(const UCaseMap *csm) {
|
||||
return csm->options;
|
||||
return reinterpret_cast<const UCaseMapImpl *>(csm)->options;
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
@@ -96,29 +103,30 @@ ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return;
|
||||
}
|
||||
auto *impl = reinterpret_cast<UCaseMapImpl *>(csm);
|
||||
if (locale != nullptr && *locale == 0) {
|
||||
csm->locale[0] = 0;
|
||||
csm->caseLocale = UCASE_LOC_ROOT;
|
||||
impl->locale[0] = 0;
|
||||
impl->caseLocale = UCASE_LOC_ROOT;
|
||||
return;
|
||||
}
|
||||
|
||||
UErrorCode bufferStatus = U_ZERO_ERROR;
|
||||
int32_t length=uloc_getName(locale, csm->locale, (int32_t)sizeof(csm->locale), &bufferStatus);
|
||||
if(bufferStatus==U_BUFFER_OVERFLOW_ERROR || (U_SUCCESS(bufferStatus) && length==sizeof(csm->locale))) {
|
||||
int32_t length=uloc_getName(locale, impl->locale, (int32_t)sizeof(impl->locale), &bufferStatus);
|
||||
if(bufferStatus==U_BUFFER_OVERFLOW_ERROR || (U_SUCCESS(bufferStatus) && length==sizeof(impl->locale))) {
|
||||
bufferStatus = U_ZERO_ERROR;
|
||||
/* we only really need the language code for case mappings */
|
||||
length=uloc_getLanguage(locale, csm->locale, (int32_t)sizeof(csm->locale), &bufferStatus);
|
||||
length=uloc_getLanguage(locale, impl->locale, (int32_t)sizeof(impl->locale), &bufferStatus);
|
||||
}
|
||||
if(U_FAILURE(bufferStatus)) {
|
||||
*pErrorCode=bufferStatus;
|
||||
} else if(length==sizeof(csm->locale)) {
|
||||
} else if(length==sizeof(impl->locale)) {
|
||||
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
if(U_SUCCESS(*pErrorCode)) {
|
||||
csm->caseLocale = ucase_getCaseLocale(csm->locale);
|
||||
impl->caseLocale = ucase_getCaseLocale(impl->locale);
|
||||
} else {
|
||||
csm->locale[0]=0;
|
||||
csm->caseLocale = UCASE_LOC_ROOT;
|
||||
impl->locale[0]=0;
|
||||
impl->caseLocale = UCASE_LOC_ROOT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +135,7 @@ ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode) {
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return;
|
||||
}
|
||||
csm->options=options;
|
||||
reinterpret_cast<UCaseMapImpl *>(csm)->options=options;
|
||||
}
|
||||
|
||||
/* UTF-8 string case mappings ----------------------------------------------- */
|
||||
@@ -942,8 +950,9 @@ ucasemap_utf8ToLower(const UCaseMap *csm,
|
||||
char *dest, int32_t destCapacity,
|
||||
const char *src, int32_t srcLength,
|
||||
UErrorCode *pErrorCode) {
|
||||
auto *impl = reinterpret_cast<const UCaseMapImpl *>(csm);
|
||||
return ucasemap_mapUTF8(
|
||||
csm->caseLocale, csm->options, UCASEMAP_BREAK_ITERATOR_NULL
|
||||
impl->caseLocale, impl->options, UCASEMAP_BREAK_ITERATOR_NULL
|
||||
dest, destCapacity,
|
||||
src, srcLength,
|
||||
ucasemap_internalUTF8ToLower, nullptr, *pErrorCode);
|
||||
@@ -954,8 +963,9 @@ ucasemap_utf8ToUpper(const UCaseMap *csm,
|
||||
char *dest, int32_t destCapacity,
|
||||
const char *src, int32_t srcLength,
|
||||
UErrorCode *pErrorCode) {
|
||||
auto *impl = reinterpret_cast<const UCaseMapImpl *>(csm);
|
||||
return ucasemap_mapUTF8(
|
||||
csm->caseLocale, csm->options, UCASEMAP_BREAK_ITERATOR_NULL
|
||||
impl->caseLocale, impl->options, UCASEMAP_BREAK_ITERATOR_NULL
|
||||
dest, destCapacity,
|
||||
src, srcLength,
|
||||
ucasemap_internalUTF8ToUpper, nullptr, *pErrorCode);
|
||||
@@ -966,8 +976,9 @@ ucasemap_utf8FoldCase(const UCaseMap *csm,
|
||||
char *dest, int32_t destCapacity,
|
||||
const char *src, int32_t srcLength,
|
||||
UErrorCode *pErrorCode) {
|
||||
auto *impl = reinterpret_cast<const UCaseMapImpl *>(csm);
|
||||
return ucasemap_mapUTF8(
|
||||
UCASE_LOC_ROOT, csm->options, UCASEMAP_BREAK_ITERATOR_NULL
|
||||
UCASE_LOC_ROOT, impl->options, UCASEMAP_BREAK_ITERATOR_NULL
|
||||
dest, destCapacity,
|
||||
src, srcLength,
|
||||
ucasemap_internalUTF8Fold, nullptr, *pErrorCode);
|
||||
|
||||
+12
-11
@@ -10,6 +10,7 @@
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucasemap.h"
|
||||
#include "unicode/uchar.h"
|
||||
#include "unicode/unistr.h" // for UStringCaseMapper
|
||||
#include "ucase.h"
|
||||
|
||||
/**
|
||||
@@ -92,25 +93,24 @@ inline UBool ustrcase_isLNS(UChar32 c) {
|
||||
|
||||
/** Returns nullptr if error. Pass in either locale or locID, not both. */
|
||||
U_CFUNC
|
||||
BreakIterator *ustrcase_getTitleBreakIterator(
|
||||
const Locale *locale, const char *locID, uint32_t options, BreakIterator *iter,
|
||||
LocalPointer<BreakIterator> &ownedIter, UErrorCode &errorCode);
|
||||
BreakIterator* ustrcase_getTitleBreakIterator(const Locale* locale,
|
||||
const char* locID,
|
||||
uint32_t options,
|
||||
BreakIterator* iter U_LIFETIME_BOUND,
|
||||
LocalPointer<BreakIterator>& ownedIter,
|
||||
UErrorCode& errorCode);
|
||||
|
||||
#endif
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#include "unicode/unistr.h" // for UStringCaseMapper
|
||||
|
||||
/*
|
||||
* Internal string casing functions implementing
|
||||
* ustring.h/ustrcase.cpp and UnicodeString case mapping functions.
|
||||
*/
|
||||
|
||||
struct UCaseMap : public icu::UMemory {
|
||||
struct UCaseMapImpl : public icu::UMemory {
|
||||
/** Implements most of ucasemap_open(). */
|
||||
UCaseMap(const char *localeID, uint32_t opts, UErrorCode *pErrorCode);
|
||||
~UCaseMap();
|
||||
UCaseMapImpl(const char *localeID, uint32_t opts, UErrorCode *pErrorCode);
|
||||
~UCaseMapImpl();
|
||||
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
icu::BreakIterator *iter; /* We adopt the iterator, so we own it. */
|
||||
@@ -120,6 +120,8 @@ struct UCaseMap : public icu::UMemory {
|
||||
uint32_t options;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#if UCONFIG_NO_BREAK_ITERATION
|
||||
# define UCASEMAP_BREAK_ITERATOR_PARAM
|
||||
# define UCASEMAP_BREAK_ITERATOR_UNUSED
|
||||
@@ -201,7 +203,6 @@ ustrcase_mapWithOverlap(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITE
|
||||
* UTF-8 string case mapping function type, used by ucasemap_mapUTF8().
|
||||
* UTF-8 version of UStringCaseMapper.
|
||||
* All error checking must be done.
|
||||
* The UCaseMap must be fully initialized, with locale and/or iter set as needed.
|
||||
*/
|
||||
typedef void U_CALLCONV
|
||||
UTF8CaseMapper(int32_t caseLocale, uint32_t options,
|
||||
|
||||
+13
-10
@@ -84,9 +84,10 @@ U_NAMESPACE_END
|
||||
|
||||
U_NAMESPACE_USE
|
||||
|
||||
U_CAPI const UBreakIterator * U_EXPORT2
|
||||
ucasemap_getBreakIterator(const UCaseMap *csm) {
|
||||
return reinterpret_cast<UBreakIterator *>(csm->iter);
|
||||
U_CAPI const UBreakIterator* U_EXPORT2
|
||||
ucasemap_getBreakIterator(const UCaseMap* csm U_LIFETIME_BOUND) {
|
||||
auto *impl = reinterpret_cast<const UCaseMapImpl *>(csm);
|
||||
return reinterpret_cast<UBreakIterator *>(impl->iter);
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
@@ -94,8 +95,9 @@ ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
return;
|
||||
}
|
||||
delete csm->iter;
|
||||
csm->iter=reinterpret_cast<BreakIterator *>(iterToAdopt);
|
||||
auto *impl = reinterpret_cast<UCaseMapImpl *>(csm);
|
||||
delete impl->iter;
|
||||
impl->iter=reinterpret_cast<BreakIterator *>(iterToAdopt);
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
@@ -111,19 +113,20 @@ ucasemap_utf8ToTitle(UCaseMap *csm,
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if(csm->iter==nullptr) {
|
||||
auto *impl = reinterpret_cast<UCaseMapImpl *>(csm);
|
||||
if(impl->iter==nullptr) {
|
||||
LocalPointer<BreakIterator> ownedIter;
|
||||
BreakIterator *iter = ustrcase_getTitleBreakIterator(
|
||||
nullptr, csm->locale, csm->options, nullptr, ownedIter, *pErrorCode);
|
||||
nullptr, impl->locale, impl->options, nullptr, ownedIter, *pErrorCode);
|
||||
if (iter == nullptr) {
|
||||
utext_close(&utext);
|
||||
return 0;
|
||||
}
|
||||
csm->iter = ownedIter.orphan();
|
||||
impl->iter = ownedIter.orphan();
|
||||
}
|
||||
csm->iter->setText(&utext, *pErrorCode);
|
||||
impl->iter->setText(&utext, *pErrorCode);
|
||||
int32_t length=ucasemap_mapUTF8(
|
||||
csm->caseLocale, csm->options, csm->iter,
|
||||
impl->caseLocale, impl->options, impl->iter,
|
||||
dest, destCapacity,
|
||||
src, srcLength,
|
||||
ucasemap_internalUTF8ToTitle, nullptr, *pErrorCode);
|
||||
|
||||
+7
-4
@@ -28,7 +28,7 @@ static const char SEPARATOR = '%';
|
||||
* MAX_KEY_LEN or more.
|
||||
*/
|
||||
static char*
|
||||
_catkey(char* buffer, int32_t set_num, int32_t msg_num) {
|
||||
_catkey(char* buffer U_LIFETIME_BOUND, int32_t set_num, int32_t msg_num) {
|
||||
int32_t i = 0;
|
||||
i = T_CString_integerToString(buffer, set_num, 10);
|
||||
buffer[i++] = SEPARATOR;
|
||||
@@ -47,9 +47,12 @@ u_catclose(u_nl_catd catd) {
|
||||
}
|
||||
|
||||
U_CAPI const char16_t* U_EXPORT2
|
||||
u_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num,
|
||||
const char16_t* s,
|
||||
int32_t* len, UErrorCode* ec) {
|
||||
u_catgets(u_nl_catd catd U_LIFETIME_BOUND,
|
||||
int32_t set_num,
|
||||
int32_t msg_num,
|
||||
const char16_t* s U_LIFETIME_BOUND,
|
||||
int32_t* len,
|
||||
UErrorCode* ec) {
|
||||
|
||||
char key[MAX_KEY_LEN];
|
||||
const char16_t* result;
|
||||
|
||||
+4294
-4189
File diff suppressed because it is too large.
Load diff
+5
-3
@@ -282,9 +282,11 @@ UCharsTrie::next(ConstChar16Ptr ptr, int32_t sLength) {
|
||||
}
|
||||
}
|
||||
|
||||
const char16_t *
|
||||
UCharsTrie::findUniqueValueFromBranch(const char16_t *pos, int32_t length,
|
||||
UBool haveUniqueValue, int32_t &uniqueValue) {
|
||||
const char16_t*
|
||||
UCharsTrie::findUniqueValueFromBranch(const char16_t* pos U_LIFETIME_BOUND,
|
||||
int32_t length,
|
||||
UBool haveUniqueValue,
|
||||
int32_t& uniqueValue) {
|
||||
while(length>kMaxBranchLinearSubNodeLength) {
|
||||
++pos; // ignore the comparison unit
|
||||
if(nullptr==findUniqueValueFromBranch(jumpByDelta(pos), length>>1, haveUniqueValue, uniqueValue)) {
|
||||
|
||||
+9
-6
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
void setTo(const UnicodeString &s, int32_t val, UnicodeString &strings, UErrorCode &errorCode);
|
||||
|
||||
UnicodeString getString(const UnicodeString &strings) const {
|
||||
UnicodeString getString(const UnicodeString& strings U_LIFETIME_BOUND) const {
|
||||
int32_t length=strings[stringOffset];
|
||||
return strings.tempSubString(stringOffset+1, length);
|
||||
}
|
||||
@@ -94,8 +94,10 @@ UCharsTrieBuilder::~UCharsTrieBuilder() {
|
||||
uprv_free(uchars);
|
||||
}
|
||||
|
||||
UCharsTrieBuilder &
|
||||
UCharsTrieBuilder::add(const UnicodeString &s, int32_t value, UErrorCode &errorCode) {
|
||||
UCharsTrieBuilder&
|
||||
UCharsTrieBuilder::add(const UnicodeString& s,
|
||||
int32_t value,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
@@ -158,9 +160,10 @@ UCharsTrieBuilder::build(UStringTrieBuildOption buildOption, UErrorCode &errorCo
|
||||
return newTrie;
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
UCharsTrieBuilder::buildUnicodeString(UStringTrieBuildOption buildOption, UnicodeString &result,
|
||||
UErrorCode &errorCode) {
|
||||
UnicodeString&
|
||||
UCharsTrieBuilder::buildUnicodeString(UStringTrieBuildOption buildOption,
|
||||
UnicodeString& result U_LIFETIME_BOUND,
|
||||
UErrorCode& errorCode) U_LIFETIME_BOUND {
|
||||
buildUChars(buildOption, errorCode);
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
result.setTo(false, uchars+(ucharsCapacity-ucharsLength), ucharsLength);
|
||||
|
||||
+7
-5
@@ -21,7 +21,7 @@
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
UCharsTrie::Iterator::Iterator(ConstChar16Ptr trieUChars, int32_t maxStringLength,
|
||||
UCharsTrie::Iterator::Iterator(ConstChar16Ptr trieUChars U_LIFETIME_BOUND, int32_t maxStringLength,
|
||||
UErrorCode &errorCode)
|
||||
: uchars_(trieUChars),
|
||||
pos_(uchars_), initialPos_(uchars_),
|
||||
@@ -78,8 +78,8 @@ UCharsTrie::Iterator::~Iterator() {
|
||||
delete stack_;
|
||||
}
|
||||
|
||||
UCharsTrie::Iterator &
|
||||
UCharsTrie::Iterator::reset() {
|
||||
UCharsTrie::Iterator&
|
||||
UCharsTrie::Iterator::reset() U_LIFETIME_BOUND {
|
||||
pos_=initialPos_;
|
||||
remainingMatchLength_=initialRemainingMatchLength_;
|
||||
skipValue_=false;
|
||||
@@ -182,8 +182,10 @@ UCharsTrie::Iterator::next(UErrorCode &errorCode) {
|
||||
}
|
||||
|
||||
// Branch node, needs to take the first outbound edge and push state for the rest.
|
||||
const char16_t *
|
||||
UCharsTrie::Iterator::branchNext(const char16_t *pos, int32_t length, UErrorCode &errorCode) {
|
||||
const char16_t*
|
||||
UCharsTrie::Iterator::branchNext(const char16_t* pos U_LIFETIME_BOUND,
|
||||
int32_t length,
|
||||
UErrorCode& errorCode) {
|
||||
while(length>kMaxBranchLinearSubNodeLength) {
|
||||
++pos; // ignore the comparison unit
|
||||
// Push state for the greater-or-equal edge.
|
||||
|
||||
+4
-4
@@ -25,14 +25,14 @@ UCharCharacterIterator::UCharCharacterIterator()
|
||||
// never default construct!
|
||||
}
|
||||
|
||||
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
|
||||
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr U_LIFETIME_BOUND,
|
||||
int32_t length)
|
||||
: CharacterIterator(textPtr != nullptr ? (length >= 0 ? length : u_strlen(textPtr)) : 0),
|
||||
text(textPtr)
|
||||
{
|
||||
}
|
||||
|
||||
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
|
||||
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr U_LIFETIME_BOUND,
|
||||
int32_t length,
|
||||
int32_t position)
|
||||
: CharacterIterator(textPtr != nullptr ? (length >= 0 ? length : u_strlen(textPtr)) : 0, position),
|
||||
@@ -40,7 +40,7 @@ UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
|
||||
{
|
||||
}
|
||||
|
||||
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
|
||||
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr U_LIFETIME_BOUND,
|
||||
int32_t length,
|
||||
int32_t textBegin,
|
||||
int32_t textEnd,
|
||||
@@ -58,7 +58,7 @@ UCharCharacterIterator::UCharCharacterIterator(const UCharCharacterIterator& tha
|
||||
}
|
||||
|
||||
UCharCharacterIterator&
|
||||
UCharCharacterIterator::operator=(const UCharCharacterIterator& that) {
|
||||
UCharCharacterIterator::operator=(const UCharCharacterIterator& that) U_LIFETIME_BOUND {
|
||||
CharacterIterator::operator=(that);
|
||||
text = that.text;
|
||||
return *this;
|
||||
|
||||
+14
-4
@@ -155,7 +155,10 @@ and created from a converter that is shared across threads.
|
||||
*/
|
||||
|
||||
U_CAPI UConverter* U_EXPORT2
|
||||
ucnv_safeClone(const UConverter* cnv, void *stackBuffer, int32_t *pBufferSize, UErrorCode *status)
|
||||
ucnv_safeClone(const UConverter* cnv,
|
||||
void* stackBuffer U_LIFETIME_BOUND,
|
||||
int32_t* pBufferSize,
|
||||
UErrorCode* status)
|
||||
{
|
||||
UConverter *localConverter, *allocatedConverter;
|
||||
int32_t stackBufferSize;
|
||||
@@ -660,9 +663,8 @@ ucnv_getMinCharSize (const UConverter * converter)
|
||||
return converter->sharedData->staticData->minBytesPerChar;
|
||||
}
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
ucnv_getName (const UConverter * converter, UErrorCode * err)
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
ucnv_getName(const UConverter* converter U_LIFETIME_BOUND, UErrorCode* err)
|
||||
{
|
||||
if (U_FAILURE (*err))
|
||||
return nullptr;
|
||||
@@ -877,6 +879,10 @@ _fromUnicodeWithCallback(UConverterFromUnicodeArgs *pArgs, UErrorCode *err) {
|
||||
* and failed to consume all of them.
|
||||
* We need to "replay" them from a temporary buffer and convert them first.
|
||||
*/
|
||||
if (!pArgs->source) {
|
||||
*err=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
realSource=pArgs->source;
|
||||
realSourceLimit=pArgs->sourceLimit;
|
||||
realFlush=pArgs->flush;
|
||||
@@ -1322,6 +1328,10 @@ _toUnicodeWithCallback(UConverterToUnicodeArgs *pArgs, UErrorCode *err) {
|
||||
* and failed to consume all of them.
|
||||
* We need to "replay" them from a temporary buffer and convert them first.
|
||||
*/
|
||||
if (!pArgs->source) {
|
||||
*err=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
realSource=pArgs->source;
|
||||
realSourceLimit=pArgs->sourceLimit;
|
||||
realFlush=pArgs->flush;
|
||||
|
||||
+13
-10
@@ -824,8 +824,10 @@ ucnv_loadSharedData(const char *converterName,
|
||||
return mySharedConverterData;
|
||||
}
|
||||
|
||||
U_CAPI UConverter *
|
||||
ucnv_createConverter(UConverter *myUConverter, const char *converterName, UErrorCode * err)
|
||||
U_CAPI UConverter*
|
||||
ucnv_createConverter(UConverter* myUConverter U_LIFETIME_BOUND,
|
||||
const char* converterName,
|
||||
UErrorCode* err)
|
||||
{
|
||||
UConverterNamePieces stackPieces;
|
||||
UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
|
||||
@@ -879,11 +881,12 @@ ucnv_canCreateConverter(const char *converterName, UErrorCode *err) {
|
||||
return U_SUCCESS(*err);
|
||||
}
|
||||
|
||||
UConverter *
|
||||
ucnv_createAlgorithmicConverter(UConverter *myUConverter,
|
||||
UConverter*
|
||||
ucnv_createAlgorithmicConverter(UConverter* myUConverter U_LIFETIME_BOUND,
|
||||
UConverterType type,
|
||||
const char *locale, uint32_t options,
|
||||
UErrorCode *err) {
|
||||
const char* locale,
|
||||
uint32_t options,
|
||||
UErrorCode* err) {
|
||||
UConverter *cnv;
|
||||
const UConverterSharedData *sharedData;
|
||||
UConverterLoadArgs stackArgs=UCNV_LOAD_ARGS_INITIALIZER;
|
||||
@@ -969,10 +972,10 @@ ucnv_createConverterFromPackage(const char *packageName, const char *converterNa
|
||||
|
||||
|
||||
U_CFUNC UConverter*
|
||||
ucnv_createConverterFromSharedData(UConverter *myUConverter,
|
||||
UConverterSharedData *mySharedConverterData,
|
||||
UConverterLoadArgs *pArgs,
|
||||
UErrorCode *err)
|
||||
ucnv_createConverterFromSharedData(UConverter* myUConverter U_LIFETIME_BOUND,
|
||||
UConverterSharedData* mySharedConverterData,
|
||||
UConverterLoadArgs* pArgs,
|
||||
UErrorCode* err)
|
||||
{
|
||||
UBool isCopyLocal;
|
||||
|
||||
|
||||
+14
-11
@@ -58,8 +58,10 @@ ucnv_canCreateConverter(const char *converterName, UErrorCode *err);
|
||||
* @param err The error code
|
||||
* @return the newly created converter
|
||||
*/
|
||||
U_CAPI UConverter *
|
||||
ucnv_createConverter(UConverter *myUConverter, const char *converterName, UErrorCode * err);
|
||||
U_CAPI UConverter*
|
||||
ucnv_createConverter(UConverter* myUConverter U_LIFETIME_BOUND,
|
||||
const char* converterName,
|
||||
UErrorCode* err);
|
||||
|
||||
/*
|
||||
* Open a purely algorithmic converter, specified by a type constant.
|
||||
@@ -72,11 +74,12 @@ ucnv_createConverter(UConverter *myUConverter, const char *converterName, UError
|
||||
* because this is an internal function
|
||||
* @internal
|
||||
*/
|
||||
U_CFUNC UConverter *
|
||||
ucnv_createAlgorithmicConverter(UConverter *myUConverter,
|
||||
U_CFUNC UConverter*
|
||||
ucnv_createAlgorithmicConverter(UConverter* myUConverter U_LIFETIME_BOUND,
|
||||
UConverterType type,
|
||||
const char *locale, uint32_t options,
|
||||
UErrorCode *err);
|
||||
const char* locale,
|
||||
uint32_t options,
|
||||
UErrorCode* err);
|
||||
|
||||
/*
|
||||
* Creates a converter from shared data.
|
||||
@@ -84,11 +87,11 @@ ucnv_createAlgorithmicConverter(UConverter *myUConverter,
|
||||
* unload mySharedConverterData, except via ucnv_close(return value)
|
||||
* if this function is successful.
|
||||
*/
|
||||
U_CFUNC UConverter *
|
||||
ucnv_createConverterFromSharedData(UConverter *myUConverter,
|
||||
UConverterSharedData *mySharedConverterData,
|
||||
UConverterLoadArgs *pArgs,
|
||||
UErrorCode *err);
|
||||
U_CFUNC UConverter*
|
||||
ucnv_createConverterFromSharedData(UConverter* myUConverter U_LIFETIME_BOUND,
|
||||
UConverterSharedData* mySharedConverterData,
|
||||
UConverterLoadArgs* pArgs,
|
||||
UErrorCode* err);
|
||||
|
||||
U_CFUNC UConverter *
|
||||
ucnv_createConverterFromPackage(const char *packageName, const char *converterName, UErrorCode *err);
|
||||
|
||||
+8
-7
@@ -249,14 +249,15 @@ static void U_CALLCONV initAliasData(UErrorCode &errCode) {
|
||||
|
||||
sectionSizes = static_cast<const uint32_t*>(udata_getMemory(data));
|
||||
int32_t dataLength = udata_getLength(data); // This is the length minus the UDataInfo size
|
||||
if (dataLength <= int32_t(sizeof(sectionSizes[0]))) {
|
||||
UBool isDataLengthKnown = dataLength >= 0; // Only false when using a pointer table of contents (not files nor a common data archive)
|
||||
if (isDataLengthKnown && dataLength <= int32_t(sizeof(sectionSizes[0]))) {
|
||||
// We don't even have a TOC!
|
||||
goto invalidFormat;
|
||||
}
|
||||
table = reinterpret_cast<const uint16_t*>(sectionSizes);
|
||||
tableStart = sectionSizes[0];
|
||||
sizeOfTOC = int32_t((tableStart + 1) * sizeof(sectionSizes[0]));
|
||||
if (tableStart < minTocLength || dataLength <= sizeOfTOC) {
|
||||
if (tableStart < minTocLength || (isDataLengthKnown && dataLength <= sizeOfTOC)) {
|
||||
// We don't have a whole TOC!
|
||||
goto invalidFormat;
|
||||
}
|
||||
@@ -279,7 +280,7 @@ static void U_CALLCONV initAliasData(UErrorCode &errCode) {
|
||||
for (uint32_t section = 1; section <= tableStart; section++) {
|
||||
sizeOfData += sectionSizes[section] * sizeof(table[0]);
|
||||
}
|
||||
if (dataLength < sizeOfData) {
|
||||
if (isDataLengthKnown && dataLength < sizeOfData) {
|
||||
// Truncated file!
|
||||
goto invalidFormat;
|
||||
}
|
||||
@@ -406,8 +407,8 @@ static const uint8_t ebcdicTypes[128] = {
|
||||
|
||||
|
||||
/* @see ucnv_compareNames */
|
||||
U_CAPI char * U_CALLCONV
|
||||
ucnv_io_stripASCIIForCompare(char *dst, const char *name) {
|
||||
U_CAPI char* U_CALLCONV
|
||||
ucnv_io_stripASCIIForCompare(char* dst U_LIFETIME_BOUND, const char* name) {
|
||||
char *dstItr = dst;
|
||||
uint8_t type, nextType;
|
||||
char c1;
|
||||
@@ -441,8 +442,8 @@ ucnv_io_stripASCIIForCompare(char *dst, const char *name) {
|
||||
return dst;
|
||||
}
|
||||
|
||||
U_CAPI char * U_CALLCONV
|
||||
ucnv_io_stripEBCDICForCompare(char *dst, const char *name) {
|
||||
U_CAPI char* U_CALLCONV
|
||||
ucnv_io_stripEBCDICForCompare(char* dst U_LIFETIME_BOUND, const char* name) {
|
||||
char *dstItr = dst;
|
||||
uint8_t type, nextType;
|
||||
char c1;
|
||||
|
||||
+4
-4
@@ -77,11 +77,11 @@ typedef struct UConverterAlias {
|
||||
# error U_CHARSET_FAMILY is not valid
|
||||
#endif
|
||||
|
||||
U_CAPI char * U_CALLCONV
|
||||
ucnv_io_stripASCIIForCompare(char *dst, const char *name);
|
||||
U_CAPI char* U_CALLCONV
|
||||
ucnv_io_stripASCIIForCompare(char* dst U_LIFETIME_BOUND, const char* name);
|
||||
|
||||
U_CAPI char * U_CALLCONV
|
||||
ucnv_io_stripEBCDICForCompare(char *dst, const char *name);
|
||||
U_CAPI char* U_CALLCONV
|
||||
ucnv_io_stripEBCDICForCompare(char* dst U_LIFETIME_BOUND, const char* name);
|
||||
|
||||
/**
|
||||
* Map a converter alias name to a canonical converter name.
|
||||
|
||||
+17
-9
@@ -463,7 +463,9 @@ ucnvsel_swap(const UDataSwapper *ds,
|
||||
|
||||
/* unserialize a selector */
|
||||
U_CAPI UConverterSelector* U_EXPORT2
|
||||
ucnvsel_openFromSerialized(const void* buffer, int32_t length, UErrorCode* status) {
|
||||
ucnvsel_openFromSerialized(const void* buffer U_LIFETIME_BOUND,
|
||||
int32_t length,
|
||||
UErrorCode* status) {
|
||||
// check if already failed
|
||||
if (U_FAILURE(*status)) {
|
||||
return nullptr;
|
||||
@@ -690,8 +692,10 @@ static int16_t countOnes(uint32_t* mask, int32_t len) {
|
||||
|
||||
|
||||
/* internal function! */
|
||||
static UEnumeration *selectForMask(const UConverterSelector* sel,
|
||||
uint32_t *theMask, UErrorCode *status) {
|
||||
static UEnumeration*
|
||||
selectForMask(const UConverterSelector* sel U_LIFETIME_BOUND,
|
||||
uint32_t* theMask,
|
||||
UErrorCode* status) {
|
||||
LocalMemory<uint32_t> mask(theMask);
|
||||
// this is the context we will use. Store a table of indices to which
|
||||
// encodings are legit.
|
||||
@@ -739,9 +743,11 @@ static UEnumeration *selectForMask(const UConverterSelector* sel,
|
||||
}
|
||||
|
||||
/* check a string against the selector - UTF16 version */
|
||||
U_CAPI UEnumeration * U_EXPORT2
|
||||
ucnvsel_selectForString(const UConverterSelector* sel,
|
||||
const char16_t *s, int32_t length, UErrorCode *status) {
|
||||
U_CAPI UEnumeration* U_EXPORT2
|
||||
ucnvsel_selectForString(const UConverterSelector* sel U_LIFETIME_BOUND,
|
||||
const char16_t* s,
|
||||
int32_t length,
|
||||
UErrorCode* status) {
|
||||
// check if already failed
|
||||
if (U_FAILURE(*status)) {
|
||||
return nullptr;
|
||||
@@ -781,9 +787,11 @@ ucnvsel_selectForString(const UConverterSelector* sel,
|
||||
}
|
||||
|
||||
/* check a string against the selector - UTF8 version */
|
||||
U_CAPI UEnumeration * U_EXPORT2
|
||||
ucnvsel_selectForUTF8(const UConverterSelector* sel,
|
||||
const char *s, int32_t length, UErrorCode *status) {
|
||||
U_CAPI UEnumeration* U_EXPORT2
|
||||
ucnvsel_selectForUTF8(const UConverterSelector* sel U_LIFETIME_BOUND,
|
||||
const char* s,
|
||||
int32_t length,
|
||||
UErrorCode* status) {
|
||||
// check if already failed
|
||||
if (U_FAILURE(*status)) {
|
||||
return nullptr;
|
||||
|
||||
+7
-4
@@ -18,10 +18,13 @@
|
||||
#include "uassert.h"
|
||||
#include "ucptrie_impl.h"
|
||||
|
||||
U_CAPI UCPTrie * U_EXPORT2
|
||||
ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth,
|
||||
const void *data, int32_t length, int32_t *pActualLength,
|
||||
UErrorCode *pErrorCode) {
|
||||
U_CAPI UCPTrie* U_EXPORT2
|
||||
ucptrie_openFromBinary(UCPTrieType type,
|
||||
UCPTrieValueWidth valueWidth,
|
||||
const void* data U_LIFETIME_BOUND,
|
||||
int32_t length,
|
||||
int32_t* pActualLength,
|
||||
UErrorCode* pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+11
-5
@@ -521,7 +521,7 @@ ucurr_forLocale(const char* locale,
|
||||
return u_terminateUChars(buff, buffCapacity, resLen, ec);
|
||||
}
|
||||
|
||||
// get country or country_variant in `id'
|
||||
// get country or country_variant in `id`
|
||||
CharString id = idForLocale(locale, ec);
|
||||
if (U_FAILURE(*ec)) {
|
||||
return 0;
|
||||
@@ -637,7 +637,7 @@ static UBool fallback(CharString& loc) {
|
||||
|
||||
|
||||
U_CAPI const char16_t* U_EXPORT2
|
||||
ucurr_getName(const char16_t* currency,
|
||||
ucurr_getName(const char16_t* currency U_LIFETIME_BOUND,
|
||||
const char* locale,
|
||||
UCurrNameStyle nameStyle,
|
||||
UBool* isChoiceFormat, // fillin
|
||||
@@ -754,7 +754,7 @@ ucurr_getName(const char16_t* currency,
|
||||
}
|
||||
|
||||
U_CAPI const char16_t* U_EXPORT2
|
||||
ucurr_getPluralName(const char16_t* currency,
|
||||
ucurr_getPluralName(const char16_t* currency U_LIFETIME_BOUND,
|
||||
const char* locale,
|
||||
UBool* isChoiceFormat,
|
||||
const char* pluralCount,
|
||||
@@ -1434,6 +1434,12 @@ getCacheEntry(const char* locale, UErrorCode& ec) {
|
||||
CurrencyNameStruct* currencySymbols = nullptr;
|
||||
CurrencyNameCacheEntry* cacheEntry = nullptr;
|
||||
|
||||
// The cache key is stored in a fixed-size buffer.
|
||||
if (uprv_strlen(locale) >= ULOC_FULLNAME_CAPACITY) {
|
||||
ec = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
umtx_lock(&gCurrencyCacheMutex);
|
||||
// in order to handle racing correctly,
|
||||
// not putting 'search' in a separate function.
|
||||
@@ -2291,7 +2297,7 @@ ucurr_countCurrencies(const char* locale,
|
||||
// local variables
|
||||
UErrorCode localStatus = U_ZERO_ERROR;
|
||||
|
||||
// get country or country_variant in `id'
|
||||
// get country or country_variant in `id`
|
||||
CharString id = idForLocale(locale, ec);
|
||||
|
||||
if (U_FAILURE(*ec))
|
||||
@@ -2395,7 +2401,7 @@ ucurr_forLocaleAndDate(const char* locale,
|
||||
// local variables
|
||||
UErrorCode localStatus = U_ZERO_ERROR;
|
||||
|
||||
// get country or country_variant in `id'
|
||||
// get country or country_variant in `id`
|
||||
CharString id = idForLocale(locale, ec);
|
||||
if (U_FAILURE(*ec))
|
||||
{
|
||||
|
||||
+2
-2
@@ -1270,7 +1270,7 @@ doOpenChoice(const char *path, const char *type, const char *name,
|
||||
|
||||
#ifdef UDATA_DEBUG
|
||||
fprintf(stderr, " tocEntryName = %s\n", tocEntryName.data());
|
||||
fprintf(stderr, " tocEntryPath = %s\n", tocEntryName.data());
|
||||
fprintf(stderr, " tocEntryPath = %s\n", tocEntryPath.data());
|
||||
#endif
|
||||
|
||||
#if !defined(ICU_DATA_DIR_WINDOWS)
|
||||
@@ -1291,7 +1291,7 @@ doOpenChoice(const char *path, const char *type, const char *name,
|
||||
dataPath = u_getDataDirectory();
|
||||
|
||||
/**** Time zone individual files override */
|
||||
if (isICUData && isTimeZoneFile(name, type)) {
|
||||
if (isICUData && type != nullptr && isTimeZoneFile(name, type)) {
|
||||
const char *tzFilesDir = u_getTimeZoneFilesDirectory(pErrorCode);
|
||||
if (tzFilesDir[0] != 0) {
|
||||
#ifdef UDATA_DEBUG
|
||||
|
||||
+6
-7
@@ -54,9 +54,8 @@ U_CFUNC UDataMemory *UDataMemory_createNewInstance(UErrorCode *pErr) {
|
||||
return This;
|
||||
}
|
||||
|
||||
|
||||
U_CFUNC const DataHeader *
|
||||
UDataMemory_normalizeDataPointer(const void *p) {
|
||||
U_CFUNC const DataHeader*
|
||||
UDataMemory_normalizeDataPointer(const void* p U_LIFETIME_BOUND) {
|
||||
/* allow the data to be optionally prepended with an alignment-forcing double value */
|
||||
const DataHeader *pdh = (const DataHeader *)p;
|
||||
if(pdh==nullptr || (pdh->dataHeader.magic1==0xda && pdh->dataHeader.magic2==0x27)) {
|
||||
@@ -100,8 +99,8 @@ udata_close(UDataMemory *pData) {
|
||||
}
|
||||
}
|
||||
|
||||
U_CAPI const void * U_EXPORT2
|
||||
udata_getMemory(UDataMemory *pData) {
|
||||
U_CAPI const void* U_EXPORT2
|
||||
udata_getMemory(UDataMemory* pData U_LIFETIME_BOUND) {
|
||||
if(pData!=nullptr && pData->pHeader!=nullptr) {
|
||||
return (char *)(pData->pHeader)+udata_getHeaderSize(pData->pHeader);
|
||||
} else {
|
||||
@@ -147,8 +146,8 @@ udata_getLength(const UDataMemory *pData) {
|
||||
* Used in cintltst/udatatst.c
|
||||
* @internal
|
||||
*/
|
||||
U_CAPI const void * U_EXPORT2
|
||||
udata_getRawMemory(const UDataMemory *pData) {
|
||||
U_CAPI const void* U_EXPORT2
|
||||
udata_getRawMemory(const UDataMemory* pData U_LIFETIME_BOUND) {
|
||||
if(pData!=nullptr && pData->pHeader!=nullptr) {
|
||||
return pData->pHeader;
|
||||
} else {
|
||||
|
||||
+3
-3
@@ -50,12 +50,12 @@ U_CFUNC void UDataMemory_init (UDataMemory *This);
|
||||
U_CFUNC UBool UDataMemory_isLoaded(const UDataMemory *This);
|
||||
U_CFUNC void UDataMemory_setData (UDataMemory *This, const void *dataAddr);
|
||||
|
||||
U_CFUNC const DataHeader *UDataMemory_normalizeDataPointer(const void *p);
|
||||
U_CFUNC const DataHeader* UDataMemory_normalizeDataPointer(const void* p U_LIFETIME_BOUND);
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
udata_getLength(const UDataMemory *pData);
|
||||
|
||||
U_CAPI const void * U_EXPORT2
|
||||
udata_getRawMemory(const UDataMemory *pData);
|
||||
U_CAPI const void* U_EXPORT2
|
||||
udata_getRawMemory(const UDataMemory* pData U_LIFETIME_BOUND);
|
||||
|
||||
#endif
|
||||
+15
-13
@@ -31,7 +31,7 @@ static const int32_t PAD = 8;
|
||||
|
||||
/* Return a pointer to the baseContext buffer, possibly allocating
|
||||
or reallocating it if at least 'capacity' bytes are not available. */
|
||||
static void* _getBuffer(UEnumeration* en, int32_t capacity) {
|
||||
static void* _getBuffer(UEnumeration* en U_LIFETIME_BOUND, int32_t capacity) {
|
||||
|
||||
if (en->baseContext != nullptr) {
|
||||
if (static_cast<_UEnumBuffer*>(en->baseContext)->len < capacity) {
|
||||
@@ -86,9 +86,9 @@ uenum_count(UEnumeration* en, UErrorCode* status)
|
||||
|
||||
/* Don't call this directly. Only uenum_unext should be calling this. */
|
||||
U_CAPI const char16_t* U_EXPORT2
|
||||
uenum_unextDefault(UEnumeration* en,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status)
|
||||
uenum_unextDefault(UEnumeration* en U_LIFETIME_BOUND,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status)
|
||||
{
|
||||
char16_t *ustr = nullptr;
|
||||
int32_t len = 0;
|
||||
@@ -99,7 +99,8 @@ uenum_unextDefault(UEnumeration* en,
|
||||
if (ustr == nullptr) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
} else {
|
||||
u_charsToUChars(cstr, ustr, len+1);
|
||||
u_charsToUChars(cstr, ustr, len);
|
||||
ustr[len] = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -113,9 +114,9 @@ uenum_unextDefault(UEnumeration* en,
|
||||
|
||||
/* Don't call this directly. Only uenum_next should be calling this. */
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uenum_nextDefault(UEnumeration* en,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status)
|
||||
uenum_nextDefault(UEnumeration* en U_LIFETIME_BOUND,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status)
|
||||
{
|
||||
if (en->uNext != nullptr) {
|
||||
char *tempCharVal;
|
||||
@@ -129,7 +130,8 @@ uenum_nextDefault(UEnumeration* en,
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
u_UCharsToChars(tempUCharVal, tempCharVal, *resultLength + 1);
|
||||
u_UCharsToChars(tempUCharVal, tempCharVal, *resultLength);
|
||||
tempCharVal[*resultLength] = 0;
|
||||
return tempCharVal;
|
||||
} else {
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
@@ -138,7 +140,7 @@ uenum_nextDefault(UEnumeration* en,
|
||||
}
|
||||
|
||||
U_CAPI const char16_t* U_EXPORT2
|
||||
uenum_unext(UEnumeration* en,
|
||||
uenum_unext(UEnumeration* en U_LIFETIME_BOUND,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status)
|
||||
{
|
||||
@@ -154,9 +156,9 @@ uenum_unext(UEnumeration* en,
|
||||
}
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uenum_next(UEnumeration* en,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status)
|
||||
uenum_next(UEnumeration* en U_LIFETIME_BOUND,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status)
|
||||
{
|
||||
if (!en || U_FAILURE(*status)) {
|
||||
return nullptr;
|
||||
|
||||
+6
-6
@@ -137,9 +137,9 @@ U_CDECL_END
|
||||
* function.
|
||||
*/
|
||||
U_CAPI const UChar* U_EXPORT2
|
||||
uenum_unextDefault(UEnumeration* en,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status);
|
||||
uenum_unextDefault(UEnumeration* en U_LIFETIME_BOUND,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status);
|
||||
|
||||
/* This is the default implementation for uenum_next().
|
||||
* It automatically converts the UChar * string to char *.
|
||||
@@ -148,8 +148,8 @@ uenum_unextDefault(UEnumeration* en,
|
||||
* function.
|
||||
*/
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uenum_nextDefault(UEnumeration* en,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status);
|
||||
uenum_nextDefault(UEnumeration* en U_LIFETIME_BOUND,
|
||||
int32_t* resultLength,
|
||||
UErrorCode* status);
|
||||
|
||||
#endif
|
||||
+1
@@ -915,6 +915,7 @@ uidna_compare( const char16_t *s1, int32_t length1,
|
||||
|
||||
if (U_FAILURE(bufferStatus)) {
|
||||
*status = bufferStatus;
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
// when toASCII is applied all label separators are replaced with FULL_STOP
|
||||
|
||||
+111
-182
@@ -101,91 +101,55 @@ namespace {
|
||||
/* ISO639 table version is 20150505 */
|
||||
/* Subsequent hand addition of selected languages */
|
||||
constexpr const char* LANGUAGES[] = {
|
||||
"aa", "ab", "ace", "ach", "ada", "ady", "ae", "aeb",
|
||||
"af", "afh", "agq", "ain", "ak", "akk", "akz", "ale",
|
||||
"aln", "alt", "am", "an", "ang", "anp", "ar", "arc",
|
||||
"arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "as",
|
||||
"asa", "ase", "ast", "av", "avk", "awa", "ay", "az",
|
||||
"ba", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj",
|
||||
"be", "bej", "bem", "bew", "bez", "bfd", "bfq", "bg",
|
||||
"bgc", "bgn", "bho", "bi", "bik", "bin", "bjn", "bkm", "bla",
|
||||
"blo", "bm", "bn", "bo", "bpy", "bqi", "br", "bra", "brh",
|
||||
"brx", "bs", "bss", "bua", "bug", "bum", "byn", "byv",
|
||||
"ca", "cad", "car", "cay", "cch", "ccp", "ce", "ceb", "cgg",
|
||||
"ch", "chb", "chg", "chk", "chm", "chn", "cho", "chp",
|
||||
"chr", "chy", "ckb", "co", "cop", "cps", "cr", "crh",
|
||||
"cs", "csb", "csw", "cu", "cv", "cy",
|
||||
"da", "dak", "dar", "dav", "de", "del", "den", "dgr",
|
||||
"din", "dje", "doi", "dsb", "dtp", "dua", "dum", "dv",
|
||||
"dyo", "dyu", "dz", "dzg",
|
||||
"ebu", "ee", "efi", "egl", "egy", "eka", "el", "elx",
|
||||
"en", "enm", "eo", "es", "esu", "et", "eu", "ewo",
|
||||
"ext",
|
||||
"fa", "fan", "fat", "ff", "fi", "fil", "fit", "fj",
|
||||
"fo", "fon", "fr", "frc", "frm", "fro", "frp", "frr",
|
||||
"frs", "fur", "fy",
|
||||
"ga", "gaa", "gag", "gan", "gay", "gba", "gbz", "gd",
|
||||
"gez", "gil", "gl", "glk", "gmh", "gn", "goh", "gom",
|
||||
"gon", "gor", "got", "grb", "grc", "gsw", "gu", "guc",
|
||||
"gur", "guz", "gv", "gwi",
|
||||
"ha", "hai", "hak", "haw", "he", "hi", "hif", "hil",
|
||||
"hit", "hmn", "ho", "hr", "hsb", "hsn", "ht", "hu",
|
||||
"hup", "hy", "hz",
|
||||
"ia", "iba", "ibb", "id", "ie", "ig", "ii", "ik",
|
||||
"ilo", "inh", "io", "is", "it", "iu", "izh",
|
||||
"ja", "jam", "jbo", "jgo", "jmc", "jpr", "jrb", "jut",
|
||||
"jv",
|
||||
"ka", "kaa", "kab", "kac", "kaj", "kam", "kaw", "kbd",
|
||||
"kbl", "kcg", "kde", "kea", "ken", "kfo", "kg", "kgp",
|
||||
"kha", "kho", "khq", "khw", "ki", "kiu", "kj", "kk",
|
||||
"kkj", "kl", "kln", "km", "kmb", "kn", "ko", "koi",
|
||||
"kok", "kos", "kpe", "kr", "krc", "kri", "krj", "krl",
|
||||
"kru", "ks", "ksb", "ksf", "ksh", "ku", "kum", "kut",
|
||||
"kv", "kw", "kxv", "ky",
|
||||
"la", "lad", "lag", "lah", "lam", "lb", "lez", "lfn",
|
||||
"lg", "li", "lij", "liv", "lkt", "lmo", "ln", "lo",
|
||||
"lol", "loz", "lrc", "lt", "ltg", "lu", "lua", "lui",
|
||||
"lun", "luo", "lus", "luy", "lv", "lzh", "lzz",
|
||||
"mad", "maf", "mag", "mai", "mak", "man", "mas", "mde",
|
||||
"mdf", "mdh", "mdr", "men", "mer", "mfe", "mg", "mga",
|
||||
"mgh", "mgo", "mh", "mi", "mic", "min", "mis", "mk",
|
||||
"ml", "mn", "mnc", "mni",
|
||||
"moh", "mos", "mr", "mrj",
|
||||
"ms", "mt", "mua", "mul", "mus", "mwl", "mwr", "mwv",
|
||||
"my", "mye", "myv", "mzn",
|
||||
"na", "nan", "nap", "naq", "nb", "nd", "nds", "ne",
|
||||
"new", "ng", "nia", "niu", "njo", "nl", "nmg", "nn",
|
||||
"nnh", "no", "nog", "non", "nov", "nqo", "nr", "nso",
|
||||
"nus", "nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi",
|
||||
"oc", "oj", "om", "or", "os", "osa", "ota",
|
||||
"pa", "pag", "pal", "pam", "pap", "pau", "pcd", "pcm", "pdc",
|
||||
"pdt", "peo", "pfl", "phn", "pi", "pl", "pms", "pnt",
|
||||
"pon", "prg", "pro", "ps", "pt",
|
||||
"qu", "quc", "qug",
|
||||
"raj", "rap", "rar", "rgn", "rif", "rm", "rn", "ro",
|
||||
"rof", "rom", "rtm", "ru", "rue", "rug", "rup",
|
||||
"rw", "rwk",
|
||||
"sa", "sad", "sah", "sam", "saq", "sas", "sat", "saz",
|
||||
"sba", "sbp", "sc", "scn", "sco", "sd", "sdc", "sdh",
|
||||
"se", "see", "seh", "sei", "sel", "ses", "sg", "sga",
|
||||
"sgs", "shi", "shn", "shu", "si", "sid", "sk",
|
||||
"sl", "sli", "sly", "sm", "sma", "smj", "smn", "sms",
|
||||
"sn", "snk", "so", "sog", "sq", "sr", "srn", "srr",
|
||||
"ss", "ssy", "st", "stq", "su", "suk", "sus", "sux",
|
||||
"sv", "sw", "swb", "syc", "syr", "szl",
|
||||
"ta", "tcy", "te", "tem", "teo", "ter", "tet", "tg",
|
||||
"th", "ti", "tig", "tiv", "tk", "tkl", "tkr",
|
||||
"tlh", "tli", "tly", "tmh", "tn", "to", "tog", "tok", "tpi",
|
||||
"tr", "tru", "trv", "ts", "tsd", "tsi", "tt", "ttt",
|
||||
"tum", "tvl", "tw", "twq", "ty", "tyv", "tzm",
|
||||
"udm", "ug", "uga", "uk", "umb", "und", "ur", "uz",
|
||||
"vai", "ve", "vec", "vep", "vi", "vls", "vmf", "vmw",
|
||||
"vo", "vot", "vro", "vun",
|
||||
"wa", "wae", "wal", "war", "was", "wbp", "wo", "wuu",
|
||||
"xal", "xh", "xmf", "xnr", "xog",
|
||||
"yao", "yap", "yav", "ybb", "yi", "yo", "yrl", "yue",
|
||||
"za", "zap", "zbl", "zea", "zen", "zgh", "zh", "zu",
|
||||
"zun", "zxx", "zza",
|
||||
"aa", "ab", "ace", "ach", "ada", "ady", "ae", "aeb", "af", "afh", "agq", "ain", "ak", "akk",
|
||||
"akz", "ale", "aln", "alt", "am", "an", "ang", "anp", "ar", "arc", "arn", "aro", "arp",
|
||||
"arq", "ars", "arw", "ary", "arz", "as", "asa", "ase", "ast", "av", "avk", "awa", "ay",
|
||||
"az", "ba", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj", "be", "bej", "bem", "bew",
|
||||
"bez", "bfd", "bfq", "bg", "bgc", "bgn", "bho", "bi", "bik", "bin", "bjn", "bkm", "bla",
|
||||
"blo", "bm", "bn", "bo", "bpy", "bqi", "br", "bra", "brh", "brx", "bs", "bss", "bua", "bug",
|
||||
"bum", "byn", "byv", "ca", "cad", "car", "cay", "cch", "ccp", "ce", "ceb", "cgg", "ch",
|
||||
"chb", "chg", "chk", "chm", "chn", "cho", "chp", "chr", "chy", "ckb", "co", "cop", "cps",
|
||||
"cr", "crh", "cs", "csb", "csw", "cu", "cv", "cy", "da", "dak", "dar", "dav", "day", "de",
|
||||
"del", "den", "dgr", "din", "dje", "doi", "dra", "dsb", "dtp", "dua", "dum", "dv", "dyo",
|
||||
"dyu", "dz", "dzg", "ebu", "ee", "efi", "egl", "egy", "eka", "el", "elx", "en", "enm", "eo",
|
||||
"es", "esu", "et", "eu", "ewo", "ext", "fa", "fan", "fat", "ff", "fi", "fil", "fit", "fiu",
|
||||
"fj", "fo", "fon", "fr", "frc", "frm", "fro", "frp", "frr", "frs", "fur", "fy", "ga", "gaa",
|
||||
"gag", "gan", "gay", "gba", "gbz", "gd", "gem", "gez", "gil", "gl", "glk", "gmh", "gn",
|
||||
"goh", "gom", "gon", "gor", "got", "grb", "grc", "gsw", "gu", "guc", "gur", "guz", "gv",
|
||||
"gwi", "ha", "hai", "hak", "haw", "he", "hi", "hif", "hil", "him", "hit", "hmn", "ho", "hr",
|
||||
"hsb", "hsn", "ht", "hu", "hup", "hy", "hz", "ia", "iba", "ibb", "id", "ie", "ig", "ii",
|
||||
"ijo", "ik", "ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it", "iu", "izh", "ja",
|
||||
"jam", "jbo", "jgo", "jmc", "jpr", "jrb", "jut", "jv", "ka", "kaa", "kab", "kac", "kaj",
|
||||
"kam", "kar", "kaw", "kbd", "kbl", "kcg", "kde", "kea", "ken", "kfo", "kg", "kgp", "kha",
|
||||
"khi", "kho", "khq", "khw", "ki", "kiu", "kj", "kk", "kkj", "kl", "kln", "km", "kmb", "kn",
|
||||
"ko", "koi", "kok", "kos", "kpe", "kr", "krc", "kri", "krj", "krl", "kro", "kru", "ks",
|
||||
"ksb", "ksf", "ksh", "ku", "kum", "kut", "kv", "kw", "kxv", "ky", "la", "lad", "lag", "lah",
|
||||
"lam", "lb", "lez", "lfn", "lg", "li", "lij", "liv", "lkt", "lmo", "ln", "lo", "lol", "loz",
|
||||
"lrc", "lt", "ltg", "lu", "lua", "lui", "lun", "luo", "lus", "luy", "lv", "lzh", "lzz",
|
||||
"mad", "maf", "mag", "mai", "mak", "man", "map", "mas", "mde", "mdf", "mdh", "mdr", "men",
|
||||
"mer", "mfe", "mg", "mga", "mgh", "mgo", "mh", "mi", "mic", "min", "mis", "mk", "mkh", "ml",
|
||||
"mn", "mnc", "mni", "mno", "moh", "mos", "mr", "mrj", "ms", "mt", "mua", "mul", "mun",
|
||||
"mus", "mwl", "mwr", "mwv", "my", "mye", "myn", "myv", "mzn", "na", "nah", "nai", "nan",
|
||||
"nap", "naq", "nb", "nd", "nds", "ne", "new", "ng", "nia", "nic", "niu", "njo", "nl", "nmg",
|
||||
"nn", "nnh", "no", "nog", "non", "nov", "nqo", "nr", "nso", "nub", "nus", "nv", "nwc", "ny",
|
||||
"nym", "nyn", "nyo", "nzi", "oc", "oj", "om", "or", "os", "osa", "ota", "oto", "pa", "paa",
|
||||
"pag", "pal", "pam", "pap", "pau", "pcd", "pcm", "pdc", "pdt", "peo", "pfl", "phi", "phn",
|
||||
"pi", "pl", "pms", "pnt", "pon", "pra", "prg", "pro", "ps", "pt", "qu", "quc", "qug", "raj",
|
||||
"rap", "rar", "rgn", "rif", "rm", "rn", "ro", "roa", "rof", "rom", "rtm", "ru", "rue",
|
||||
"rug", "rup", "rw", "rwk", "sa", "sad", "sah", "sai", "sal", "sam", "saq", "sas", "sat",
|
||||
"saz", "sba", "sbp", "sc", "scn", "sco", "sd", "sdc", "sdh", "se", "see", "seh", "sei",
|
||||
"sel", "sem", "ses", "sg", "sga", "sgn", "sgs", "shi", "shn", "shu", "si", "sid", "sio",
|
||||
"sit", "sk", "sl", "sla", "sli", "sly", "sm", "sma", "smi", "smj", "smn", "sms", "sn",
|
||||
"snk", "so", "sog", "son", "sq", "sr", "srn", "srr", "ss", "ssa", "ssy", "st", "stq", "su",
|
||||
"suk", "sus", "sux", "sv", "sw", "swb", "syc", "syr", "szl", "ta", "tai", "tcy", "te",
|
||||
"tem", "teo", "ter", "tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl", "tkr", "tlh",
|
||||
"tli", "tly", "tmh", "tn", "to", "tog", "tok", "tpi", "tr", "tru", "trv", "ts", "tsd",
|
||||
"tsi", "tt", "ttt", "tum", "tup", "tut", "tvl", "tw", "twq", "ty", "tyv", "tzm", "udm",
|
||||
"ug", "uga", "uk", "umb", "und", "ur", "uz", "vai", "ve", "vec", "vep", "vi", "vls", "vmf",
|
||||
"vmw", "vo", "vot", "vro", "vun", "wa", "wae", "wak", "wal", "war", "was", "wbp", "wen",
|
||||
"wo", "wuu", "xal", "xh", "xmf", "xnr", "xog", "yao", "yap", "yav", "ybb", "yi", "yo",
|
||||
"ypk", "yrl", "yue", "za", "zap", "zbl", "zea", "zen", "zgh", "zh", "znd", "zu", "zun",
|
||||
"zxx", "zza",
|
||||
nullptr,
|
||||
"in", "iw", "ji", "jw", "mo", "sh", "swc", "tl", /* obsolete language codes */
|
||||
nullptr
|
||||
@@ -218,91 +182,56 @@ constexpr const char* REPLACEMENT_LANGUAGES[]={
|
||||
/* ISO639 table version is 20150505 */
|
||||
/* Subsequent hand addition of selected languages */
|
||||
constexpr const char* LANGUAGES_3[] = {
|
||||
"aar", "abk", "ace", "ach", "ada", "ady", "ave", "aeb",
|
||||
"afr", "afh", "agq", "ain", "aka", "akk", "akz", "ale",
|
||||
"aln", "alt", "amh", "arg", "ang", "anp", "ara", "arc",
|
||||
"arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "asm",
|
||||
"asa", "ase", "ast", "ava", "avk", "awa", "aym", "aze",
|
||||
"bak", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj",
|
||||
"bel", "bej", "bem", "bew", "bez", "bfd", "bfq", "bul",
|
||||
"bgc", "bgn", "bho", "bis", "bik", "bin", "bjn", "bkm", "bla",
|
||||
"blo", "bam", "ben", "bod", "bpy", "bqi", "bre", "bra", "brh",
|
||||
"brx", "bos", "bss", "bua", "bug", "bum", "byn", "byv",
|
||||
"cat", "cad", "car", "cay", "cch", "ccp", "che", "ceb", "cgg",
|
||||
"cha", "chb", "chg", "chk", "chm", "chn", "cho", "chp",
|
||||
"chr", "chy", "ckb", "cos", "cop", "cps", "cre", "crh",
|
||||
"ces", "csb", "csw", "chu", "chv", "cym",
|
||||
"dan", "dak", "dar", "dav", "deu", "del", "den", "dgr",
|
||||
"din", "dje", "doi", "dsb", "dtp", "dua", "dum", "div",
|
||||
"dyo", "dyu", "dzo", "dzg",
|
||||
"ebu", "ewe", "efi", "egl", "egy", "eka", "ell", "elx",
|
||||
"eng", "enm", "epo", "spa", "esu", "est", "eus", "ewo",
|
||||
"ext",
|
||||
"fas", "fan", "fat", "ful", "fin", "fil", "fit", "fij",
|
||||
"fao", "fon", "fra", "frc", "frm", "fro", "frp", "frr",
|
||||
"frs", "fur", "fry",
|
||||
"gle", "gaa", "gag", "gan", "gay", "gba", "gbz", "gla",
|
||||
"gez", "gil", "glg", "glk", "gmh", "grn", "goh", "gom",
|
||||
"gon", "gor", "got", "grb", "grc", "gsw", "guj", "guc",
|
||||
"gur", "guz", "glv", "gwi",
|
||||
"hau", "hai", "hak", "haw", "heb", "hin", "hif", "hil",
|
||||
"hit", "hmn", "hmo", "hrv", "hsb", "hsn", "hat", "hun",
|
||||
"hup", "hye", "her",
|
||||
"ina", "iba", "ibb", "ind", "ile", "ibo", "iii", "ipk",
|
||||
"ilo", "inh", "ido", "isl", "ita", "iku", "izh",
|
||||
"jpn", "jam", "jbo", "jgo", "jmc", "jpr", "jrb", "jut",
|
||||
"jav",
|
||||
"kat", "kaa", "kab", "kac", "kaj", "kam", "kaw", "kbd",
|
||||
"kbl", "kcg", "kde", "kea", "ken", "kfo", "kon", "kgp",
|
||||
"kha", "kho", "khq", "khw", "kik", "kiu", "kua", "kaz",
|
||||
"kkj", "kal", "kln", "khm", "kmb", "kan", "kor", "koi",
|
||||
"kok", "kos", "kpe", "kau", "krc", "kri", "krj", "krl",
|
||||
"kru", "kas", "ksb", "ksf", "ksh", "kur", "kum", "kut",
|
||||
"kom", "cor", "kxv", "kir",
|
||||
"lat", "lad", "lag", "lah", "lam", "ltz", "lez", "lfn",
|
||||
"lug", "lim", "lij", "liv", "lkt", "lmo", "lin", "lao",
|
||||
"lol", "loz", "lrc", "lit", "ltg", "lub", "lua", "lui",
|
||||
"lun", "luo", "lus", "luy", "lav", "lzh", "lzz",
|
||||
"mad", "maf", "mag", "mai", "mak", "man", "mas", "mde",
|
||||
"mdf", "mdh", "mdr", "men", "mer", "mfe", "mlg", "mga",
|
||||
"mgh", "mgo", "mah", "mri", "mic", "min", "mis", "mkd",
|
||||
"mal", "mon", "mnc", "mni",
|
||||
"moh", "mos", "mar", "mrj",
|
||||
"msa", "mlt", "mua", "mul", "mus", "mwl", "mwr", "mwv",
|
||||
"mya", "mye", "myv", "mzn",
|
||||
"nau", "nan", "nap", "naq", "nob", "nde", "nds", "nep",
|
||||
"new", "ndo", "nia", "niu", "njo", "nld", "nmg", "nno",
|
||||
"nnh", "nor", "nog", "non", "nov", "nqo", "nbl", "nso",
|
||||
"nus", "nav", "nwc", "nya", "nym", "nyn", "nyo", "nzi",
|
||||
"oci", "oji", "orm", "ori", "oss", "osa", "ota",
|
||||
"pan", "pag", "pal", "pam", "pap", "pau", "pcd", "pcm", "pdc",
|
||||
"pdt", "peo", "pfl", "phn", "pli", "pol", "pms", "pnt",
|
||||
"pon", "prg", "pro", "pus", "por",
|
||||
"que", "quc", "qug",
|
||||
"raj", "rap", "rar", "rgn", "rif", "roh", "run", "ron",
|
||||
"rof", "rom", "rtm", "rus", "rue", "rug", "rup",
|
||||
"kin", "rwk",
|
||||
"san", "sad", "sah", "sam", "saq", "sas", "sat", "saz",
|
||||
"sba", "sbp", "srd", "scn", "sco", "snd", "sdc", "sdh",
|
||||
"sme", "see", "seh", "sei", "sel", "ses", "sag", "sga",
|
||||
"sgs", "shi", "shn", "shu", "sin", "sid", "slk",
|
||||
"slv", "sli", "sly", "smo", "sma", "smj", "smn", "sms",
|
||||
"sna", "snk", "som", "sog", "sqi", "srp", "srn", "srr",
|
||||
"ssw", "ssy", "sot", "stq", "sun", "suk", "sus", "sux",
|
||||
"swe", "swa", "swb", "syc", "syr", "szl",
|
||||
"tam", "tcy", "tel", "tem", "teo", "ter", "tet", "tgk",
|
||||
"tha", "tir", "tig", "tiv", "tuk", "tkl", "tkr",
|
||||
"tlh", "tli", "tly", "tmh", "tsn", "ton", "tog", "tok", "tpi",
|
||||
"tur", "tru", "trv", "tso", "tsd", "tsi", "tat", "ttt",
|
||||
"tum", "tvl", "twi", "twq", "tah", "tyv", "tzm",
|
||||
"udm", "uig", "uga", "ukr", "umb", "und", "urd", "uzb",
|
||||
"vai", "ven", "vec", "vep", "vie", "vls", "vmf", "vmw",
|
||||
"vol", "vot", "vro", "vun",
|
||||
"wln", "wae", "wal", "war", "was", "wbp", "wol", "wuu",
|
||||
"xal", "xho", "xmf", "xnr", "xog",
|
||||
"yao", "yap", "yav", "ybb", "yid", "yor", "yrl", "yue",
|
||||
"zha", "zap", "zbl", "zea", "zen", "zgh", "zho", "zul",
|
||||
"zun", "zxx", "zza",
|
||||
"aar", "abk", "ace", "ach", "ada", "ady", "ave", "aeb", "afr", "afh", "agq", "ain", "aka",
|
||||
"akk", "akz", "ale", "aln", "alt", "amh", "arg", "ang", "anp", "ara", "arc", "arn", "aro",
|
||||
"arp", "arq", "ars", "arw", "ary", "arz", "asm", "asa", "ase", "ast", "ava", "avk", "awa",
|
||||
"aym", "aze", "bak", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj", "bel", "bej", "bem",
|
||||
"bew", "bez", "bfd", "bfq", "bul", "bgc", "bgn", "bho", "bis", "bik", "bin", "bjn", "bkm",
|
||||
"bla", "blo", "bam", "ben", "bod", "bpy", "bqi", "bre", "bra", "brh", "brx", "bos", "bss",
|
||||
"bua", "bug", "bum", "byn", "byv", "cat", "cad", "car", "cay", "cch", "ccp", "che", "ceb",
|
||||
"cgg", "cha", "chb", "chg", "chk", "chm", "chn", "cho", "chp", "chr", "chy", "ckb", "cos",
|
||||
"cop", "cps", "cre", "crh", "ces", "csb", "csw", "chu", "chv", "cym", "dan", "dak", "dar",
|
||||
"dav", "day", "deu", "del", "den", "dgr", "din", "dje", "doi", "dra", "dsb", "dtp", "dua",
|
||||
"dum", "div", "dyo", "dyu", "dzo", "dzg", "ebu", "ewe", "efi", "egl", "egy", "eka", "ell",
|
||||
"elx", "eng", "enm", "epo", "spa", "esu", "est", "eus", "ewo", "ext", "fas", "fan", "fat",
|
||||
"ful", "fin", "fil", "fit", "fiu", "fij", "fao", "fon", "fra", "frc", "frm", "fro", "frp",
|
||||
"frr", "frs", "fur", "fry", "gle", "gaa", "gag", "gan", "gay", "gba", "gbz", "gla", "gem",
|
||||
"gez", "gil", "glg", "glk", "gmh", "grn", "goh", "gom", "gon", "gor", "got", "grb", "grc",
|
||||
"gsw", "guj", "guc", "gur", "guz", "glv", "gwi", "hau", "hai", "hak", "haw", "heb", "hin",
|
||||
"hif", "hil", "him", "hit", "hmn", "hmo", "hrv", "hsb", "hsn", "hat", "hun", "hup", "hye",
|
||||
"her", "ina", "iba", "ibb", "ind", "ile", "ibo", "iii", "ijo", "ipk", "ilo", "inc", "ine",
|
||||
"inh", "ido", "ira", "iro", "isl", "ita", "iku", "izh", "jpn", "jam", "jbo", "jgo", "jmc",
|
||||
"jpr", "jrb", "jut", "jav", "kat", "kaa", "kab", "kac", "kaj", "kam", "kar", "kaw", "kbd",
|
||||
"kbl", "kcg", "kde", "kea", "ken", "kfo", "kon", "kgp", "kha", "khi", "kho", "khq", "khw",
|
||||
"kik", "kiu", "kua", "kaz", "kkj", "kal", "kln", "khm", "kmb", "kan", "kor", "koi", "kok",
|
||||
"kos", "kpe", "kau", "krc", "kri", "krj", "krl", "kro", "kru", "kas", "ksb", "ksf", "ksh",
|
||||
"kur", "kum", "kut", "kom", "cor", "kxv", "kir", "lat", "lad", "lag", "lah", "lam", "ltz",
|
||||
"lez", "lfn", "lug", "lim", "lij", "liv", "lkt", "lmo", "lin", "lao", "lol", "loz", "lrc",
|
||||
"lit", "ltg", "lub", "lua", "lui", "lun", "luo", "lus", "luy", "lav", "lzh", "lzz", "mad",
|
||||
"maf", "mag", "mai", "mak", "man", "map", "mas", "mde", "mdf", "mdh", "mdr", "men", "mer",
|
||||
"mfe", "mlg", "mga", "mgh", "mgo", "mah", "mri", "mic", "min", "mis", "mkd", "mkh", "mal",
|
||||
"mon", "mnc", "mni", "mno", "moh", "mos", "mar", "mrj", "msa", "mlt", "mua", "mul", "mun",
|
||||
"mus", "mwl", "mwr", "mwv", "mya", "mye", "myn", "myv", "mzn", "nau", "nah", "nai", "nan",
|
||||
"nap", "naq", "nob", "nde", "nds", "nep", "new", "ndo", "nia", "nic", "niu", "njo", "nld",
|
||||
"nmg", "nno", "nnh", "nor", "nog", "non", "nov", "nqo", "nbl", "nso", "nub", "nus", "nav",
|
||||
"nwc", "nya", "nym", "nyn", "nyo", "nzi", "oci", "oji", "orm", "ori", "oss", "osa", "ota",
|
||||
"oto", "pan", "paa", "pag", "pal", "pam", "pap", "pau", "pcd", "pcm", "pdc", "pdt", "peo",
|
||||
"pfl", "phi", "phn", "pli", "pol", "pms", "pnt", "pon", "pra", "prg", "pro", "pus", "por",
|
||||
"que", "quc", "qug", "raj", "rap", "rar", "rgn", "rif", "roh", "run", "ron", "roa", "rof",
|
||||
"rom", "rtm", "rus", "rue", "rug", "rup", "kin", "rwk", "san", "sad", "sah", "sai", "sal",
|
||||
"sam", "saq", "sas", "sat", "saz", "sba", "sbp", "srd", "scn", "sco", "snd", "sdc", "sdh",
|
||||
"sme", "see", "seh", "sei", "sel", "sem", "ses", "sag", "sga", "sgn", "sgs", "shi", "shn",
|
||||
"shu", "sin", "sid", "sio", "sit", "slk", "slv", "sla", "sli", "sly", "smo", "sma", "smi",
|
||||
"smj", "smn", "sms", "sna", "snk", "som", "sog", "son", "sqi", "srp", "srn", "srr", "ssw",
|
||||
"ssa", "ssy", "sot", "stq", "sun", "suk", "sus", "sux", "swe", "swa", "swb", "syc", "syr",
|
||||
"szl", "tam", "tai", "tcy", "tel", "tem", "teo", "ter", "tet", "tgk", "tha", "tir", "tig",
|
||||
"tiv", "tuk", "tkl", "tkr", "tlh", "tli", "tly", "tmh", "tsn", "ton", "tog", "tok", "tpi",
|
||||
"tur", "tru", "trv", "tso", "tsd", "tsi", "tat", "ttt", "tum", "tup", "tut", "tvl", "twi",
|
||||
"twq", "tah", "tyv", "tzm", "udm", "uig", "uga", "ukr", "umb", "und", "urd", "uzb", "vai",
|
||||
"ven", "vec", "vep", "vie", "vls", "vmf", "vmw", "vol", "vot", "vro", "vun", "wln", "wae",
|
||||
"wak", "wal", "war", "was", "wbp", "wen", "wol", "wuu", "xal", "xho", "xmf", "xnr", "xog",
|
||||
"yao", "yap", "yav", "ybb", "yid", "yor", "ypk", "yrl", "yue", "zha", "zap", "zbl", "zea",
|
||||
"zen", "zgh", "zho", "znd", "zul", "zun", "zxx", "zza",
|
||||
nullptr,
|
||||
/* "in", "iw", "ji", "jw", "mo", "sh", "swc", "tl", */
|
||||
"ind", "heb", "yid", "jaw", "mol", "srp", "swc", "tgl",
|
||||
@@ -522,8 +451,8 @@ inline bool UPRV_OK_VALUE_PUNCTUATION(char c) { return c == '_' || c == '-' || c
|
||||
#define ULOC_KEYWORD_BUFFER_LEN 25
|
||||
#define ULOC_MAX_NO_KEYWORDS 25
|
||||
|
||||
U_CAPI const char * U_EXPORT2
|
||||
locale_getKeywordsStart(std::string_view localeID) {
|
||||
U_CAPI const char* U_EXPORT2
|
||||
locale_getKeywordsStart(std::string_view localeID U_LIFETIME_BOUND) {
|
||||
if (size_t pos = localeID.find('@'); pos != std::string_view::npos) {
|
||||
return localeID.data() + pos;
|
||||
}
|
||||
@@ -1195,12 +1124,12 @@ std::optional<int16_t> _findIndex(const char* const* list, const char* key)
|
||||
} // namespace
|
||||
|
||||
U_CFUNC const char*
|
||||
uloc_getCurrentCountryID(const char* oldID){
|
||||
uloc_getCurrentCountryID(const char* oldID U_LIFETIME_BOUND) {
|
||||
std::optional<int16_t> offset = _findIndex(DEPRECATED_COUNTRIES, oldID);
|
||||
return offset.has_value() ? REPLACEMENT_COUNTRIES[*offset] : oldID;
|
||||
}
|
||||
U_CFUNC const char*
|
||||
uloc_getCurrentLanguageID(const char* oldID){
|
||||
uloc_getCurrentLanguageID(const char* oldID U_LIFETIME_BOUND) {
|
||||
std::optional<int16_t> offset = _findIndex(DEPRECATED_LANGUAGES, oldID);
|
||||
return offset.has_value() ? REPLACEMENT_LANGUAGES[*offset] : oldID;
|
||||
}
|
||||
@@ -2374,7 +2303,7 @@ uloc_getISOCountries()
|
||||
}
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uloc_toUnicodeLocaleKey(const char* keyword)
|
||||
uloc_toUnicodeLocaleKey(const char* keyword U_LIFETIME_BOUND)
|
||||
{
|
||||
if (keyword == nullptr || *keyword == '\0') { return nullptr; }
|
||||
std::optional<std::string_view> result = ulocimp_toBcpKeyWithFallback(keyword);
|
||||
@@ -2382,7 +2311,7 @@ uloc_toUnicodeLocaleKey(const char* keyword)
|
||||
}
|
||||
|
||||
U_EXPORT std::optional<std::string_view>
|
||||
ulocimp_toBcpKeyWithFallback(std::string_view keyword)
|
||||
ulocimp_toBcpKeyWithFallback(std::string_view keyword U_LIFETIME_BOUND)
|
||||
{
|
||||
std::optional<std::string_view> bcpKey = ulocimp_toBcpKey(keyword);
|
||||
if (!bcpKey.has_value() &&
|
||||
@@ -2394,7 +2323,7 @@ ulocimp_toBcpKeyWithFallback(std::string_view keyword)
|
||||
}
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uloc_toUnicodeLocaleType(const char* keyword, const char* value)
|
||||
uloc_toUnicodeLocaleType(const char* keyword, const char* value U_LIFETIME_BOUND)
|
||||
{
|
||||
if (keyword == nullptr || *keyword == '\0' ||
|
||||
value == nullptr || *value == '\0') { return nullptr; }
|
||||
@@ -2403,7 +2332,7 @@ uloc_toUnicodeLocaleType(const char* keyword, const char* value)
|
||||
}
|
||||
|
||||
U_EXPORT std::optional<std::string_view>
|
||||
ulocimp_toBcpTypeWithFallback(std::string_view keyword, std::string_view value)
|
||||
ulocimp_toBcpTypeWithFallback(std::string_view keyword, std::string_view value U_LIFETIME_BOUND)
|
||||
{
|
||||
std::optional<std::string_view> bcpType = ulocimp_toBcpType(keyword, value);
|
||||
if (!bcpType.has_value() &&
|
||||
@@ -2444,7 +2373,7 @@ isWellFormedLegacyType(std::string_view legacyType)
|
||||
} // namespace
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uloc_toLegacyKey(const char* keyword)
|
||||
uloc_toLegacyKey(const char* keyword U_LIFETIME_BOUND)
|
||||
{
|
||||
if (keyword == nullptr || *keyword == '\0') { return nullptr; }
|
||||
std::optional<std::string_view> result = ulocimp_toLegacyKeyWithFallback(keyword);
|
||||
@@ -2452,7 +2381,7 @@ uloc_toLegacyKey(const char* keyword)
|
||||
}
|
||||
|
||||
U_EXPORT std::optional<std::string_view>
|
||||
ulocimp_toLegacyKeyWithFallback(std::string_view keyword)
|
||||
ulocimp_toLegacyKeyWithFallback(std::string_view keyword U_LIFETIME_BOUND)
|
||||
{
|
||||
std::optional<std::string_view> legacyKey = ulocimp_toLegacyKey(keyword);
|
||||
if (!legacyKey.has_value() && isWellFormedLegacyKey(keyword)) {
|
||||
@@ -2469,7 +2398,7 @@ ulocimp_toLegacyKeyWithFallback(std::string_view keyword)
|
||||
}
|
||||
|
||||
U_CAPI const char* U_EXPORT2
|
||||
uloc_toLegacyType(const char* keyword, const char* value)
|
||||
uloc_toLegacyType(const char* keyword, const char* value U_LIFETIME_BOUND)
|
||||
{
|
||||
if (keyword == nullptr || *keyword == '\0' ||
|
||||
value == nullptr || *value == '\0') { return nullptr; }
|
||||
@@ -2478,7 +2407,7 @@ uloc_toLegacyType(const char* keyword, const char* value)
|
||||
}
|
||||
|
||||
U_EXPORT std::optional<std::string_view>
|
||||
ulocimp_toLegacyTypeWithFallback(std::string_view keyword, std::string_view value)
|
||||
ulocimp_toLegacyTypeWithFallback(std::string_view keyword, std::string_view value U_LIFETIME_BOUND)
|
||||
{
|
||||
std::optional<std::string_view> legacyType = ulocimp_toLegacyType(keyword, value);
|
||||
if (!legacyType.has_value() && isWellFormedLegacyType(value)) {
|
||||
|
||||
+2
-2
@@ -469,7 +469,7 @@ ulocimp_toLegacyKey(std::string_view key) {
|
||||
}
|
||||
|
||||
U_EXPORT std::optional<std::string_view>
|
||||
ulocimp_toBcpType(std::string_view key, std::string_view type) {
|
||||
ulocimp_toBcpType(std::string_view key, std::string_view type U_LIFETIME_BOUND) {
|
||||
if (!init()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -502,7 +502,7 @@ ulocimp_toBcpType(std::string_view key, std::string_view type) {
|
||||
|
||||
|
||||
U_EXPORT std::optional<std::string_view>
|
||||
ulocimp_toLegacyType(std::string_view key, std::string_view type) {
|
||||
ulocimp_toLegacyType(std::string_view key, std::string_view type U_LIFETIME_BOUND) {
|
||||
if (!init()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
+17
-17
@@ -312,7 +312,7 @@ void
|
||||
ultag_close(ULanguageTag* langtag);
|
||||
|
||||
const char*
|
||||
ultag_getLanguage(const ULanguageTag* langtag);
|
||||
ultag_getLanguage(const ULanguageTag* langtag U_LIFETIME_BOUND);
|
||||
|
||||
#if 0
|
||||
const char*
|
||||
@@ -320,34 +320,34 @@ ultag_getJDKLanguage(const ULanguageTag* langtag);
|
||||
#endif
|
||||
|
||||
const char*
|
||||
ultag_getExtlang(const ULanguageTag* langtag, int32_t idx);
|
||||
ultag_getExtlang(const ULanguageTag* langtag U_LIFETIME_BOUND, int32_t idx);
|
||||
|
||||
int32_t
|
||||
ultag_getExtlangSize(const ULanguageTag* langtag);
|
||||
|
||||
const char*
|
||||
ultag_getScript(const ULanguageTag* langtag);
|
||||
ultag_getScript(const ULanguageTag* langtag U_LIFETIME_BOUND);
|
||||
|
||||
const char*
|
||||
ultag_getRegion(const ULanguageTag* langtag);
|
||||
ultag_getRegion(const ULanguageTag* langtag U_LIFETIME_BOUND);
|
||||
|
||||
const char*
|
||||
ultag_getVariant(const ULanguageTag* langtag, int32_t idx);
|
||||
ultag_getVariant(const ULanguageTag* langtag U_LIFETIME_BOUND, int32_t idx);
|
||||
|
||||
int32_t
|
||||
ultag_getVariantsSize(const ULanguageTag* langtag);
|
||||
|
||||
const char*
|
||||
ultag_getExtensionKey(const ULanguageTag* langtag, int32_t idx);
|
||||
ultag_getExtensionKey(const ULanguageTag* langtag U_LIFETIME_BOUND, int32_t idx);
|
||||
|
||||
const char*
|
||||
ultag_getExtensionValue(const ULanguageTag* langtag, int32_t idx);
|
||||
ultag_getExtensionValue(const ULanguageTag* langtag U_LIFETIME_BOUND, int32_t idx);
|
||||
|
||||
int32_t
|
||||
ultag_getExtensionsSize(const ULanguageTag* langtag);
|
||||
|
||||
const char*
|
||||
ultag_getPrivateUse(const ULanguageTag* langtag);
|
||||
ultag_getPrivateUse(const ULanguageTag* langtag U_LIFETIME_BOUND);
|
||||
|
||||
#if 0
|
||||
const char*
|
||||
@@ -677,7 +677,7 @@ _isTKey(const char* s, int32_t len)
|
||||
} // namespace
|
||||
|
||||
const char*
|
||||
ultag_getTKeyStart(const char *localeID) {
|
||||
ultag_getTKeyStart(const char* localeID U_LIFETIME_BOUND) {
|
||||
const char *result = localeID;
|
||||
const char *sep;
|
||||
while((sep = uprv_strchr(result, SEP)) != nullptr) {
|
||||
@@ -2416,7 +2416,7 @@ ultag_close(ULanguageTag* langtag) {
|
||||
}
|
||||
|
||||
const char*
|
||||
ultag_getLanguage(const ULanguageTag* langtag) {
|
||||
ultag_getLanguage(const ULanguageTag* langtag U_LIFETIME_BOUND) {
|
||||
return langtag->language;
|
||||
}
|
||||
|
||||
@@ -2434,7 +2434,7 @@ ultag_getJDKLanguage(const ULanguageTag* langtag) {
|
||||
#endif
|
||||
|
||||
const char*
|
||||
ultag_getExtlang(const ULanguageTag* langtag, int32_t idx) {
|
||||
ultag_getExtlang(const ULanguageTag* langtag U_LIFETIME_BOUND, int32_t idx) {
|
||||
if (idx >= 0 && idx < MAXEXTLANG) {
|
||||
return langtag->extlang[idx];
|
||||
}
|
||||
@@ -2454,17 +2454,17 @@ ultag_getExtlangSize(const ULanguageTag* langtag) {
|
||||
}
|
||||
|
||||
const char*
|
||||
ultag_getScript(const ULanguageTag* langtag) {
|
||||
ultag_getScript(const ULanguageTag* langtag U_LIFETIME_BOUND) {
|
||||
return langtag->script;
|
||||
}
|
||||
|
||||
const char*
|
||||
ultag_getRegion(const ULanguageTag* langtag) {
|
||||
ultag_getRegion(const ULanguageTag* langtag U_LIFETIME_BOUND) {
|
||||
return langtag->region;
|
||||
}
|
||||
|
||||
const char*
|
||||
ultag_getVariant(const ULanguageTag* langtag, int32_t idx) {
|
||||
ultag_getVariant(const ULanguageTag* langtag U_LIFETIME_BOUND, int32_t idx) {
|
||||
const char *var = nullptr;
|
||||
VariantListEntry *cur = langtag->variants;
|
||||
int32_t i = 0;
|
||||
@@ -2494,7 +2494,7 @@ ultag_getVariantsSize(const ULanguageTag* langtag) {
|
||||
}
|
||||
|
||||
const char*
|
||||
ultag_getExtensionKey(const ULanguageTag* langtag, int32_t idx) {
|
||||
ultag_getExtensionKey(const ULanguageTag* langtag U_LIFETIME_BOUND, int32_t idx) {
|
||||
const char *key = nullptr;
|
||||
ExtensionListEntry *cur = langtag->extensions;
|
||||
int32_t i = 0;
|
||||
@@ -2510,7 +2510,7 @@ ultag_getExtensionKey(const ULanguageTag* langtag, int32_t idx) {
|
||||
}
|
||||
|
||||
const char*
|
||||
ultag_getExtensionValue(const ULanguageTag* langtag, int32_t idx) {
|
||||
ultag_getExtensionValue(const ULanguageTag* langtag U_LIFETIME_BOUND, int32_t idx) {
|
||||
const char *val = nullptr;
|
||||
ExtensionListEntry *cur = langtag->extensions;
|
||||
int32_t i = 0;
|
||||
@@ -2540,7 +2540,7 @@ ultag_getExtensionsSize(const ULanguageTag* langtag) {
|
||||
}
|
||||
|
||||
const char*
|
||||
ultag_getPrivateUse(const ULanguageTag* langtag) {
|
||||
ultag_getPrivateUse(const ULanguageTag* langtag U_LIFETIME_BOUND) {
|
||||
return langtag->privateuse;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ ulocale_close(ULocale* locale) {
|
||||
}
|
||||
|
||||
#define IMPL_ULOCALE_STRING_GETTER(N1, N2) \
|
||||
const char* ulocale_get ## N1(const ULocale* locale) { \
|
||||
const char* ulocale_get ## N1(const ULocale* locale U_LIFETIME_BOUND) { \
|
||||
if (locale == nullptr) return nullptr; \
|
||||
return CONST_INTERNAL(locale)->get ## N2(); \
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,8 +7,8 @@
|
||||
#include "unicode/localebuilder.h"
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/stringpiece.h"
|
||||
#include "unicode/umachine.h"
|
||||
#include "unicode/ulocbuilder.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "bytesinkutil.h"
|
||||
#include "cstring.h"
|
||||
#include "ustr_imp.h"
|
||||
|
||||
Loaded 100 of 356 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user