diff options
author | mcheshkov <mcheshkov@yandex-team.ru> | 2022-02-10 16:46:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:15 +0300 |
commit | e9d19cec64684c9c1e6b0c98297e5b895cf904fe (patch) | |
tree | 2768b1223e96a8a0610a93d18425d9647c1123c8 /contrib/libs/icu/common/ubrk.cpp | |
parent | 60040c91ffe701a84689b2c6310ff845e65cff42 (diff) | |
download | ydb-e9d19cec64684c9c1e6b0c98297e5b895cf904fe.tar.gz |
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/common/ubrk.cpp')
-rw-r--r-- | contrib/libs/icu/common/ubrk.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/contrib/libs/icu/common/ubrk.cpp b/contrib/libs/icu/common/ubrk.cpp index f8bdf5a6b6..b2fbd3ea54 100644 --- a/contrib/libs/icu/common/ubrk.cpp +++ b/contrib/libs/icu/common/ubrk.cpp @@ -1,4 +1,4 @@ -// © 2016 and later: Unicode, Inc. and others. +// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************** @@ -20,7 +20,7 @@ #include "unicode/rbbi.h" #include "rbbirb.h" #include "uassert.h" -#include "cmemory.h" +#include "cmemory.h" U_NAMESPACE_USE @@ -120,28 +120,28 @@ ubrk_openRules( const UChar *rules, } -U_CAPI UBreakIterator* U_EXPORT2 -ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength, - const UChar * text, int32_t textLength, - UErrorCode * status) -{ - if (U_FAILURE(*status)) { - return NULL; - } - if (rulesLength < 0) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return NULL; - } - LocalPointer<RuleBasedBreakIterator> lpRBBI(new RuleBasedBreakIterator(binaryRules, rulesLength, *status), *status); - if (U_FAILURE(*status)) { - return NULL; - } - UBreakIterator *uBI = reinterpret_cast<UBreakIterator *>(lpRBBI.orphan()); - if (text != NULL) { - ubrk_setText(uBI, text, textLength, status); - } - return uBI; -} +U_CAPI UBreakIterator* U_EXPORT2 +ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength, + const UChar * text, int32_t textLength, + UErrorCode * status) +{ + if (U_FAILURE(*status)) { + return NULL; + } + if (rulesLength < 0) { + *status = U_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } + LocalPointer<RuleBasedBreakIterator> lpRBBI(new RuleBasedBreakIterator(binaryRules, rulesLength, *status), *status); + if (U_FAILURE(*status)) { + return NULL; + } + UBreakIterator *uBI = reinterpret_cast<UBreakIterator *>(lpRBBI.orphan()); + if (text != NULL) { + ubrk_setText(uBI, text, textLength, status); + } + return uBI; +} U_CAPI UBreakIterator * U_EXPORT2 @@ -310,8 +310,8 @@ ubrk_getLocaleByType(const UBreakIterator *bi, } -U_CAPI void U_EXPORT2 -ubrk_refreshUText(UBreakIterator *bi, +U_CAPI void U_EXPORT2 +ubrk_refreshUText(UBreakIterator *bi, UText *text, UErrorCode *status) { @@ -319,39 +319,39 @@ ubrk_refreshUText(UBreakIterator *bi, bii->refreshInputText(text, *status); } -U_CAPI int32_t U_EXPORT2 -ubrk_getBinaryRules(UBreakIterator *bi, - uint8_t * binaryRules, int32_t rulesCapacity, - UErrorCode * status) -{ - if (U_FAILURE(*status)) { - return 0; - } - if ((binaryRules == NULL && rulesCapacity > 0) || rulesCapacity < 0) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return 0; - } - RuleBasedBreakIterator* rbbi; - if ((rbbi = dynamic_cast<RuleBasedBreakIterator*>(reinterpret_cast<BreakIterator*>(bi))) == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return 0; - } - uint32_t rulesLength; - const uint8_t * returnedRules = rbbi->getBinaryRules(rulesLength); - if (rulesLength > INT32_MAX) { - *status = U_INDEX_OUTOFBOUNDS_ERROR; - return 0; - } - if (binaryRules != NULL) { // if not preflighting - // Here we know rulesLength <= INT32_MAX and rulesCapacity >= 0, can cast safely - if ((int32_t)rulesLength > rulesCapacity) { - *status = U_BUFFER_OVERFLOW_ERROR; - } else { - uprv_memcpy(binaryRules, returnedRules, rulesLength); - } - } - return (int32_t)rulesLength; -} +U_CAPI int32_t U_EXPORT2 +ubrk_getBinaryRules(UBreakIterator *bi, + uint8_t * binaryRules, int32_t rulesCapacity, + UErrorCode * status) +{ + if (U_FAILURE(*status)) { + return 0; + } + if ((binaryRules == NULL && rulesCapacity > 0) || rulesCapacity < 0) { + *status = U_ILLEGAL_ARGUMENT_ERROR; + return 0; + } + RuleBasedBreakIterator* rbbi; + if ((rbbi = dynamic_cast<RuleBasedBreakIterator*>(reinterpret_cast<BreakIterator*>(bi))) == NULL) { + *status = U_ILLEGAL_ARGUMENT_ERROR; + return 0; + } + uint32_t rulesLength; + const uint8_t * returnedRules = rbbi->getBinaryRules(rulesLength); + if (rulesLength > INT32_MAX) { + *status = U_INDEX_OUTOFBOUNDS_ERROR; + return 0; + } + if (binaryRules != NULL) { // if not preflighting + // Here we know rulesLength <= INT32_MAX and rulesCapacity >= 0, can cast safely + if ((int32_t)rulesLength > rulesCapacity) { + *status = U_BUFFER_OVERFLOW_ERROR; + } else { + uprv_memcpy(binaryRules, returnedRules, rulesLength); + } + } + return (int32_t)rulesLength; +} #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ |