aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/common/charstr.cpp
diff options
context:
space:
mode:
authormcheshkov <mcheshkov@yandex-team.ru>2022-02-10 16:46:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:15 +0300
commite9d19cec64684c9c1e6b0c98297e5b895cf904fe (patch)
tree2768b1223e96a8a0610a93d18425d9647c1123c8 /contrib/libs/icu/common/charstr.cpp
parent60040c91ffe701a84689b2c6310ff845e65cff42 (diff)
downloadydb-e9d19cec64684c9c1e6b0c98297e5b895cf904fe.tar.gz
Restoring authorship annotation for <mcheshkov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/common/charstr.cpp')
-rw-r--r--contrib/libs/icu/common/charstr.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/contrib/libs/icu/common/charstr.cpp b/contrib/libs/icu/common/charstr.cpp
index dda29dac632..cd89757a113 100644
--- a/contrib/libs/icu/common/charstr.cpp
+++ b/contrib/libs/icu/common/charstr.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
/*
*******************************************************************************
@@ -6,7 +6,7 @@
* Corporation and others. All Rights Reserved.
*******************************************************************************
* file name: charstr.cpp
-* encoding: UTF-8
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
@@ -15,7 +15,7 @@
*/
#include "unicode/utypes.h"
-#include "unicode/putil.h"
+#include "unicode/putil.h"
#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
@@ -23,29 +23,29 @@
U_NAMESPACE_BEGIN
-CharString::CharString(CharString&& src) U_NOEXCEPT
- : buffer(std::move(src.buffer)), len(src.len) {
- src.len = 0; // not strictly necessary because we make no guarantees on the source string
-}
-
-CharString& CharString::operator=(CharString&& src) U_NOEXCEPT {
- buffer = std::move(src.buffer);
- len = src.len;
- src.len = 0; // not strictly necessary because we make no guarantees on the source string
- return *this;
-}
-
-char *CharString::cloneData(UErrorCode &errorCode) const {
- if (U_FAILURE(errorCode)) { return nullptr; }
- char *p = static_cast<char *>(uprv_malloc(len + 1));
- if (p == nullptr) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
- return nullptr;
- }
- uprv_memcpy(p, buffer.getAlias(), len + 1);
- return p;
-}
-
+CharString::CharString(CharString&& src) U_NOEXCEPT
+ : buffer(std::move(src.buffer)), len(src.len) {
+ src.len = 0; // not strictly necessary because we make no guarantees on the source string
+}
+
+CharString& CharString::operator=(CharString&& src) U_NOEXCEPT {
+ buffer = std::move(src.buffer);
+ len = src.len;
+ src.len = 0; // not strictly necessary because we make no guarantees on the source string
+ return *this;
+}
+
+char *CharString::cloneData(UErrorCode &errorCode) const {
+ if (U_FAILURE(errorCode)) { return nullptr; }
+ char *p = static_cast<char *>(uprv_malloc(len + 1));
+ if (p == nullptr) {
+ errorCode = U_MEMORY_ALLOCATION_ERROR;
+ return nullptr;
+ }
+ uprv_memcpy(p, buffer.getAlias(), len + 1);
+ return p;
+}
+
CharString &CharString::copyFrom(const CharString &s, UErrorCode &errorCode) {
if(U_SUCCESS(errorCode) && this!=&s && ensureCapacity(s.len+1, 0, errorCode)) {
len=s.len;
@@ -63,18 +63,18 @@ int32_t CharString::lastIndexOf(char c) const {
return -1;
}
-bool CharString::contains(StringPiece s) const {
- if (s.empty()) { return false; }
- const char *p = buffer.getAlias();
- int32_t lastStart = len - s.length();
- for (int32_t i = 0; i <= lastStart; ++i) {
- if (uprv_memcmp(p + i, s.data(), s.length()) == 0) {
- return true;
- }
- }
- return false;
-}
-
+bool CharString::contains(StringPiece s) const {
+ if (s.empty()) { return false; }
+ const char *p = buffer.getAlias();
+ int32_t lastStart = len - s.length();
+ for (int32_t i = 0; i <= lastStart; ++i) {
+ if (uprv_memcmp(p + i, s.data(), s.length()) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
CharString &CharString::truncate(int32_t newLength) {
if(newLength<0) {
newLength=0;
@@ -102,7 +102,7 @@ CharString &CharString::append(const char *s, int32_t sLength, UErrorCode &error
return *this;
}
if(sLength<0) {
- sLength= static_cast<int32_t>(uprv_strlen(s));
+ sLength= static_cast<int32_t>(uprv_strlen(s));
}
if(sLength>0) {
if(s==(buffer.getAlias()+len)) {
@@ -149,21 +149,21 @@ char *CharString::getAppendBuffer(int32_t minCapacity,
}
CharString &CharString::appendInvariantChars(const UnicodeString &s, UErrorCode &errorCode) {
- return appendInvariantChars(s.getBuffer(), s.length(), errorCode);
-}
-
-CharString &CharString::appendInvariantChars(const UChar* uchars, int32_t ucharsLen, UErrorCode &errorCode) {
+ return appendInvariantChars(s.getBuffer(), s.length(), errorCode);
+}
+
+CharString &CharString::appendInvariantChars(const UChar* uchars, int32_t ucharsLen, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) {
return *this;
}
- if (!uprv_isInvariantUString(uchars, ucharsLen)) {
+ if (!uprv_isInvariantUString(uchars, ucharsLen)) {
errorCode = U_INVARIANT_CONVERSION_ERROR;
return *this;
}
- if(ensureCapacity(len+ucharsLen+1, 0, errorCode)) {
- u_UCharsToChars(uchars, buffer.getAlias()+len, ucharsLen);
- len += ucharsLen;
- buffer[len] = 0;
+ if(ensureCapacity(len+ucharsLen+1, 0, errorCode)) {
+ u_UCharsToChars(uchars, buffer.getAlias()+len, ucharsLen);
+ len += ucharsLen;
+ buffer[len] = 0;
}
return *this;
}