summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp
diff options
context:
space:
mode:
authorSteven R. Loomis <srloomis@us.ibm.com>2017-04-13 16:25:08 -0700
committerSteven R. Loomis <srloomis@us.ibm.com>2017-05-09 15:20:02 -0700
commit5d0a770c129c00e3942263b429f8efa4c42efba9 (patch)
tree0766989dae39097084b6c5c8e2f75bf92812c713 /deps/icu-small/source/common/ustr_titlecase_brkiter.cpp
parent147048a0d3e255d2a0604f3ab7c8f62252cb8252 (diff)
downloadandroid-node-v8-5d0a770c129c00e3942263b429f8efa4c42efba9.tar.gz
android-node-v8-5d0a770c129c00e3942263b429f8efa4c42efba9.tar.bz2
android-node-v8-5d0a770c129c00e3942263b429f8efa4c42efba9.zip
deps: ICU 59.1 bump
* No feature changes. * Bug fixes. * Details: http://site.icu-project.org/download/59 Fixes: https://github.com/nodejs/node/issues/12077 PR-URL: https://github.com/nodejs/node/pull/12486 Refs: https://github.com/nodejs/node/issues/7844 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'deps/icu-small/source/common/ustr_titlecase_brkiter.cpp')
-rw-r--r--deps/icu-small/source/common/ustr_titlecase_brkiter.cpp93
1 files changed, 57 insertions, 36 deletions
diff --git a/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp b/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp
index 6380877619..0b2ba02064 100644
--- a/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp
+++ b/deps/icu-small/source/common/ustr_titlecase_brkiter.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 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: ustr_titlecase_brkiter.cpp
-* encoding: US-ASCII
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
@@ -22,30 +22,17 @@
#if !UCONFIG_NO_BREAK_ITERATION
#include "unicode/brkiter.h"
+#include "unicode/casemap.h"
+#include "unicode/localpointer.h"
#include "unicode/ubrk.h"
#include "unicode/ucasemap.h"
#include "cmemory.h"
#include "ucase.h"
-#include "ustr_imp.h"
+#include "ucasemap_imp.h"
-/* functions available in the common library (for unistr_case.cpp) */
+U_NAMESPACE_USE
-/*
- * Set parameters on an empty UCaseMap, for UCaseMap-less API functions.
- * Do this fast because it is called with every function call.
- * Duplicate of the same function in ustrcase.cpp, to keep it inline.
- */
-static inline void
-setTempCaseMap(UCaseMap *csm, const char *locale) {
- if(csm->csp==NULL) {
- csm->csp=ucase_getSingleton();
- }
- if(locale!=NULL && locale[0]==0) {
- csm->locale[0]=0;
- } else {
- ustrcase_setTempCaseMapLocale(csm, locale);
- }
-}
+/* functions available in the common library (for unistr_case.cpp) */
/* public API functions */
@@ -55,39 +42,73 @@ u_strToTitle(UChar *dest, int32_t destCapacity,
UBreakIterator *titleIter,
const char *locale,
UErrorCode *pErrorCode) {
- UCaseMap csm=UCASEMAP_INITIALIZER;
- setTempCaseMap(&csm, locale);
+ LocalPointer<BreakIterator> ownedIter;
+ BreakIterator *iter;
if(titleIter!=NULL) {
- ubrk_setText(csm.iter=titleIter, src, srcLength, pErrorCode);
+ iter=reinterpret_cast<BreakIterator *>(titleIter);
} else {
- csm.iter=ubrk_open(UBRK_WORD, csm.locale, src, srcLength, pErrorCode);
+ iter=BreakIterator::createWordInstance(Locale(locale), *pErrorCode);
+ ownedIter.adoptInstead(iter);
+ }
+ if(U_FAILURE(*pErrorCode)) {
+ return 0;
}
- int32_t length=ustrcase_map(
- &csm,
+ UnicodeString s(srcLength<0, src, srcLength);
+ iter->setText(s);
+ return ustrcase_mapWithOverlap(
+ ustrcase_getCaseLocale(locale), 0, iter,
dest, destCapacity,
src, srcLength,
- ustrcase_internalToTitle, pErrorCode);
- if(titleIter==NULL && csm.iter!=NULL) {
- ubrk_close(csm.iter);
+ ustrcase_internalToTitle, *pErrorCode);
+}
+
+U_NAMESPACE_BEGIN
+
+int32_t CaseMap::toTitle(
+ const char *locale, uint32_t options, BreakIterator *iter,
+ const UChar *src, int32_t srcLength,
+ UChar *dest, int32_t destCapacity, Edits *edits,
+ UErrorCode &errorCode) {
+ LocalPointer<BreakIterator> ownedIter;
+ if(iter==NULL) {
+ iter=BreakIterator::createWordInstance(Locale(locale), errorCode);
+ ownedIter.adoptInstead(iter);
+ }
+ if(U_FAILURE(errorCode)) {
+ return 0;
}
- return length;
+ UnicodeString s(srcLength<0, src, srcLength);
+ iter->setText(s);
+ return ustrcase_map(
+ ustrcase_getCaseLocale(locale), options, iter,
+ dest, destCapacity,
+ src, srcLength,
+ ustrcase_internalToTitle, edits, errorCode);
}
+U_NAMESPACE_END
+
U_CAPI int32_t U_EXPORT2
ucasemap_toTitle(UCaseMap *csm,
UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
UErrorCode *pErrorCode) {
- if(csm->iter!=NULL) {
- ubrk_setText(csm->iter, src, srcLength, pErrorCode);
- } else {
- csm->iter=ubrk_open(UBRK_WORD, csm->locale, src, srcLength, pErrorCode);
+ if (U_FAILURE(*pErrorCode)) {
+ return 0;
+ }
+ if (csm->iter == NULL) {
+ csm->iter = BreakIterator::createWordInstance(Locale(csm->locale), *pErrorCode);
+ }
+ if (U_FAILURE(*pErrorCode)) {
+ return 0;
}
+ UnicodeString s(srcLength<0, src, srcLength);
+ csm->iter->setText(s);
return ustrcase_map(
- csm,
+ csm->caseLocale, csm->options, csm->iter,
dest, destCapacity,
src, srcLength,
- ustrcase_internalToTitle, pErrorCode);
+ ustrcase_internalToTitle, NULL, *pErrorCode);
}
#endif // !UCONFIG_NO_BREAK_ITERATION