| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c440f3f commit 0cb7720
453 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | 1 | ICU sources - auto generated by shrink-icu-src.py | |
| 2 | 2 | ||
| 3 | 3 | This directory contains the ICU subset used by --with-intl=full-icu | |
| 4 | - It is a strict subset of ICU 64 source files with the following exception(s): | ||
| 5 | - * deps/icu-small/source/data/in/icudt64l.dat.bz2 : compressed data file | ||
| 4 | + It is a strict subset of ICU 65 source files with the following exception(s): | ||
| 5 | + * deps/icu-small/source/data/in/icudt65l.dat.bz2 : compressed data file | ||
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | 8 | To rebuild this directory, see ../../tools/icu/README.md | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,7 @@ ICULanguageBreakFactory::getEngineFor(UChar32 c) { | |||
| 129 | 129 | const LanguageBreakEngine *lbe = NULL; | |
| 130 | 130 | UErrorCode status = U_ZERO_ERROR; | |
| 131 | 131 | ||
| 132 | - static UMutex gBreakEngineMutex = U_MUTEX_INITIALIZER; | ||
| 132 | + static UMutex gBreakEngineMutex; | ||
| 133 | 133 | Mutex m(&gBreakEngineMutex); | |
| 134 | 134 | ||
| 135 | 135 | if (fEngines == NULL) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -277,7 +277,7 @@ ICUBreakIteratorService::~ICUBreakIteratorService() {} | |||
| 277 | 277 | // defined in ucln_cmn.h | |
| 278 | 278 | U_NAMESPACE_END | |
| 279 | 279 | ||
| 280 | - static icu::UInitOnce gInitOnceBrkiter; | ||
| 280 | + static icu::UInitOnce gInitOnceBrkiter = U_INITONCE_INITIALIZER; | ||
| 281 | 281 | static icu::ICULocaleService* gService = NULL; | |
| 282 | 282 | ||
| 283 | 283 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,7 +59,7 @@ class U_COMMON_API ByteSinkUtil { | |||
| 59 | 59 | ByteSink &sink, uint32_t options, Edits *edits); | |
| 60 | 60 | }; | |
| 61 | 61 | ||
| 62 | - class CharStringByteSink : public ByteSink { | ||
| 62 | + class U_COMMON_API CharStringByteSink : public ByteSink { | ||
| 63 | 63 | public: | |
| 64 | 64 | CharStringByteSink(CharString* dest); | |
| 65 | 65 | ~CharStringByteSink() override; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,19 +38,16 @@ UBool U_CALLCONV characterproperties_cleanup(); | |||
| 38 | 38 | constexpr int32_t NUM_INCLUSIONS = UPROPS_SRC_COUNT + UCHAR_INT_LIMIT - UCHAR_INT_START; | |
| 39 | 39 | ||
| 40 | 40 | struct Inclusion { | |
| 41 | - UnicodeSet *fSet; | ||
| 42 | - UInitOnce fInitOnce; | ||
| 41 | + UnicodeSet *fSet = nullptr; | ||
| 42 | + UInitOnce fInitOnce = U_INITONCE_INITIALIZER; | ||
| 43 | 43 | }; | |
| 44 | 44 | Inclusion gInclusions[NUM_INCLUSIONS]; // cached getInclusions() | |
| 45 | 45 | ||
| 46 | 46 | UnicodeSet *sets[UCHAR_BINARY_LIMIT] = {}; | |
| 47 | 47 | ||
| 48 | 48 | UCPMap *maps[UCHAR_INT_LIMIT - UCHAR_INT_START] = {}; | |
| 49 | 49 | ||
| 50 | - icu::UMutex *cpMutex() { | ||
| 51 | - static icu::UMutex m = U_MUTEX_INITIALIZER; | ||
| 52 | - return &m; | ||
| 53 | - } | ||
| 50 | + icu::UMutex cpMutex; | ||
| 54 | 51 | ||
| 55 | 52 | //---------------------------------------------------------------- | |
| 56 | 53 | // Inclusions list | |
@@ -361,7 +358,7 @@ u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode) { | |||
| 361 | 358 | *pErrorCode = U_ILLEGAL_ARGUMENT_ERROR; | |
| 362 | 359 | return nullptr; | |
| 363 | 360 | } | |
| 364 | - Mutex m(cpMutex()); | ||
| 361 | + Mutex m(&cpMutex); | ||
| 365 | 362 | UnicodeSet *set = sets[property]; | |
| 366 | 363 | if (set == nullptr) { | |
| 367 | 364 | sets[property] = set = makeSet(property, *pErrorCode); | |
@@ -377,7 +374,7 @@ u_getIntPropertyMap(UProperty property, UErrorCode *pErrorCode) { | |||
| 377 | 374 | *pErrorCode = U_ILLEGAL_ARGUMENT_ERROR; | |
| 378 | 375 | return nullptr; | |
| 379 | 376 | } | |
| 380 | - Mutex m(cpMutex()); | ||
| 377 | + Mutex m(&cpMutex); | ||
| 381 | 378 | UCPMap *map = maps[property - UCHAR_INT_START]; | |
| 382 | 379 | if (map == nullptr) { | |
| 383 | 380 | maps[property - UCHAR_INT_START] = map = makeMap(property, *pErrorCode); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,17 @@ CharString& CharString::operator=(CharString&& src) U_NOEXCEPT { | |||
| 35 | 35 | return *this; | |
| 36 | 36 | } | |
| 37 | 37 | ||
| 38 | + char *CharString::cloneData(UErrorCode &errorCode) const { | ||
| 39 | + if (U_FAILURE(errorCode)) { return nullptr; } | ||
| 40 | + char *p = static_cast<char *>(uprv_malloc(len + 1)); | ||
| 41 | + if (p == nullptr) { | ||
| 42 | + errorCode = U_MEMORY_ALLOCATION_ERROR; | ||
| 43 | + return nullptr; | ||
| 44 | + } | ||
| 45 | + uprv_memcpy(p, buffer.getAlias(), len + 1); | ||
| 46 | + return p; | ||
| 47 | + } | ||
| 48 | + | ||
| 38 | 49 | CharString &CharString::copyFrom(const CharString &s, UErrorCode &errorCode) { | |
| 39 | 50 | if(U_SUCCESS(errorCode) && this!=&s && ensureCapacity(s.len+1, 0, errorCode)) { | |
| 40 | 51 | len=s.len; | |
@@ -52,6 +63,18 @@ int32_t CharString::lastIndexOf(char c) const { | |||
| 52 | 63 | return -1; | |
| 53 | 64 | } | |
| 54 | 65 | ||
| 66 | + bool CharString::contains(StringPiece s) const { | ||
| 67 | + if (s.empty()) { return false; } | ||
| 68 | + const char *p = buffer.getAlias(); | ||
| 69 | + int32_t lastStart = len - s.length(); | ||
| 70 | + for (int32_t i = 0; i <= lastStart; ++i) { | ||
| 71 | + if (uprv_memcmp(p + i, s.data(), s.length()) == 0) { | ||
| 72 | + return true; | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + return false; | ||
| 76 | + } | ||
| 77 | + | ||
| 55 | 78 | CharString &CharString::truncate(int32_t newLength) { | |
| 56 | 79 | if(newLength<0) { | |
| 57 | 80 | newLength=0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,10 +82,24 @@ class U_COMMON_API CharString : public UMemory { | |||
| 82 | 82 | ||
| 83 | 83 | const char *data() const { return buffer.getAlias(); } | |
| 84 | 84 | char *data() { return buffer.getAlias(); } | |
| 85 | + /** | ||
| 86 | + * Allocates length()+1 chars and copies the NUL-terminated data(). | ||
| 87 | + * The caller must uprv_free() the result. | ||
| 88 | + */ | ||
| 89 | + char *cloneData(UErrorCode &errorCode) const; | ||
| 90 | + | ||
| 91 | + bool operator==(StringPiece other) const { | ||
| 92 | + return len == other.length() && (len == 0 || uprv_memcmp(data(), other.data(), len) == 0); | ||
| 93 | + } | ||
| 94 | + bool operator!=(StringPiece other) const { | ||
| 95 | + return !operator==(other); | ||
| 96 | + } | ||
| 85 | 97 | ||
| 86 | 98 | /** @return last index of c, or -1 if c is not in this string */ | |
| 87 | 99 | int32_t lastIndexOf(char c) const; | |
| 88 | 100 | ||
| 101 | + bool contains(StringPiece s) const; | ||
| 102 | + | ||
| 89 | 103 | CharString &clear() { len=0; buffer[0]=0; return *this; } | |
| 90 | 104 | CharString &truncate(int32_t newLength); | |
| 91 | 105 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,38 +64,37 @@ uprv_free(void *mem); | |||
| 64 | 64 | U_CAPI void * U_EXPORT2 | |
| 65 | 65 | uprv_calloc(size_t num, size_t size) U_MALLOC_ATTR U_ALLOC_SIZE_ATTR2(1,2); | |
| 66 | 66 | ||
| 67 | - /** | ||
| 68 | - * This should align the memory properly on any machine. | ||
| 69 | - * This is very useful for the safeClone functions. | ||
| 70 | - */ | ||
| 71 | - typedef union { | ||
| 72 | - long t1; | ||
| 73 | - double t2; | ||
| 74 | - void *t3; | ||
| 75 | - } UAlignedMemory; | ||
| 76 | - | ||
| 77 | 67 | /** | |
| 78 | 68 | * Get the least significant bits of a pointer (a memory address). | |
| 79 | 69 | * For example, with a mask of 3, the macro gets the 2 least significant bits, | |
| 80 | 70 | * which will be 0 if the pointer is 32-bit (4-byte) aligned. | |
| 81 | 71 | * | |
| 82 | - * ptrdiff_t is the most appropriate integer type to cast to. | ||
| 83 | - * size_t should work too, since on most (or all?) platforms it has the same | ||
| 84 | - * width as ptrdiff_t. | ||
| 72 | + * uintptr_t is the most appropriate integer type to cast to. | ||
| 85 | 73 | */ | |
| 86 | - #define U_POINTER_MASK_LSB(ptr, mask) (((ptrdiff_t)(char *)(ptr)) & (mask)) | ||
| 74 | + #define U_POINTER_MASK_LSB(ptr, mask) ((uintptr_t)(ptr) & (mask)) | ||
| 87 | 75 | ||
| 88 | 76 | /** | |
| 89 | - * Get the amount of bytes that a pointer is off by from | ||
| 90 | - * the previous UAlignedMemory-aligned pointer. | ||
| 91 | - */ | ||
| 92 | - #define U_ALIGNMENT_OFFSET(ptr) U_POINTER_MASK_LSB(ptr, sizeof(UAlignedMemory) - 1) | ||
| 93 | - | ||
| 94 | - /** | ||
| 95 | - * Get the amount of bytes to add to a pointer | ||
| 96 | - * in order to get the next UAlignedMemory-aligned address. | ||
| 77 | + * Create & return an instance of "type" in statically allocated storage. | ||
| 78 | + * e.g. | ||
| 79 | + * static std::mutex *myMutex = STATIC_NEW(std::mutex); | ||
| 80 | + * To destroy an object created in this way, invoke the destructor explicitly, e.g. | ||
| 81 | + * myMutex->~mutex(); | ||
| 82 | + * DO NOT use delete. | ||
| 83 | + * DO NOT use with class UMutex, which has specific support for static instances. | ||
| 84 | + * | ||
| 85 | + * STATIC_NEW is intended for use when | ||
| 86 | + * - We want a static (or global) object. | ||
| 87 | + * - We don't want it to ever be destructed, or to explicitly control destruction, | ||
| 88 | + * to avoid use-after-destruction problems. | ||
| 89 | + * - We want to avoid an ordinary heap allocated object, | ||
| 90 | + * to avoid the possibility of memory allocation failures, and | ||
| 91 | + * to avoid memory leak reports, from valgrind, for example. | ||
| 92 | + * This is defined as a macro rather than a template function because each invocation | ||
| 93 | + * must define distinct static storage for the object being returned. | ||
| 97 | 94 | */ | |
| 98 | - #define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr)) | ||
| 95 | + #define STATIC_NEW(type) [] () { \ | ||
| 96 | + alignas(type) static char storage[sizeof(type)]; \ | ||
| 97 | + return new(storage) type();} () | ||
| 99 | 98 | ||
| 100 | 99 | /** | |
| 101 | 100 | * Heap clean up function, called from u_cleanup() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -243,7 +243,7 @@ UBool Edits::growArray() { | |||
| 243 | 243 | return TRUE; | |
| 244 | 244 | } | |
| 245 | 245 | ||
| 246 | - UBool Edits::copyErrorTo(UErrorCode &outErrorCode) { | ||
| 246 | + UBool Edits::copyErrorTo(UErrorCode &outErrorCode) const { | ||
| 247 | 247 | if (U_FAILURE(outErrorCode)) { return TRUE; } | |
| 248 | 248 | if (U_SUCCESS(errorCode_)) { return FALSE; } | |
| 249 | 249 | outErrorCode = errorCode_; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,7 +173,7 @@ class SimpleFilteredSentenceBreakIterator : public BreakIterator { | |||
| 173 | 173 | status = U_SAFECLONE_ALLOCATED_WARNING; | |
| 174 | 174 | return clone(); | |
| 175 | 175 | } | |
| 176 | - virtual BreakIterator* clone(void) const { return new SimpleFilteredSentenceBreakIterator(*this); } | ||
| 176 | + virtual SimpleFilteredSentenceBreakIterator* clone() const { return new SimpleFilteredSentenceBreakIterator(*this); } | ||
| 177 | 177 | virtual UClassID getDynamicClassID(void) const { return NULL; } | |
| 178 | 178 | virtual UBool operator==(const BreakIterator& o) const { if(this==&o) return true; return false; } | |
| 179 | 179 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments