Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Unified Diff: source/common/charstr.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/common/charstr.h ('k') | source/common/cmemory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/common/charstr.cpp
diff --git a/source/common/charstr.cpp b/source/common/charstr.cpp
index 76723d9790c1f7bdbdaf3a6a8c4ec47411c8c7e0..1b27c683de2f1809ef786043d11bbdb91c69a959 100644
--- a/source/common/charstr.cpp
+++ b/source/common/charstr.cpp
@@ -1,6 +1,6 @@
/*
*******************************************************************************
-* Copyright (C) 2010-2011, International Business Machines
+* Copyright (C) 2010-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* file name: charstr.cpp
@@ -16,6 +16,7 @@
#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
+#include "uinvchar.h"
U_NAMESPACE_BEGIN
@@ -27,6 +28,15 @@ CharString &CharString::copyFrom(const CharString &s, UErrorCode &errorCode) {
return *this;
}
+int32_t CharString::lastIndexOf(char c) const {
+ for(int32_t i=len; i>0;) {
+ if(buffer[--i]==c) {
+ return i;
+ }
+ }
+ return -1;
+}
+
CharString &CharString::truncate(int32_t newLength) {
if(newLength<0) {
newLength=0;
@@ -101,6 +111,13 @@ char *CharString::getAppendBuffer(int32_t minCapacity,
}
CharString &CharString::appendInvariantChars(const UnicodeString &s, UErrorCode &errorCode) {
+ if(U_FAILURE(errorCode)) {
+ return *this;
+ }
+ if (!uprv_isInvariantUnicodeString(s)) {
+ errorCode = U_INVARIANT_CONVERSION_ERROR;
+ return *this;
+ }
if(ensureCapacity(len+s.length()+1, 0, errorCode)) {
len+=s.extract(0, 0x7fffffff, buffer.getAlias()+len, buffer.getCapacity()-len, US_INV);
}
@@ -142,4 +159,13 @@ CharString &CharString::appendPathPart(const StringPiece &s, UErrorCode &errorCo
return *this;
}
+CharString &CharString::ensureEndsWithFileSeparator(UErrorCode &errorCode) {
+ char c;
+ if(U_SUCCESS(errorCode) && len>0 &&
+ (c=buffer[len-1])!=U_FILE_SEP_CHAR && c!=U_FILE_ALT_SEP_CHAR) {
+ append(U_FILE_SEP_CHAR, errorCode);
+ }
+ return *this;
+}
+
U_NAMESPACE_END
« no previous file with comments | « source/common/charstr.h ('k') | source/common/cmemory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698