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

Unified Diff: source/i18n/dtptngen.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/i18n/dtitvinf.cpp ('k') | source/i18n/dtptngen_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/i18n/dtptngen.cpp
diff --git a/source/i18n/dtptngen.cpp b/source/i18n/dtptngen.cpp
index fe1f5a150f6359eb5399b0b408309e38389a3448..0a7d4b3833bab732f2e306cd6878284fc969ea52 100644
--- a/source/i18n/dtptngen.cpp
+++ b/source/i18n/dtptngen.cpp
@@ -1,6 +1,6 @@
/*
*******************************************************************************
-* Copyright (C) 2007-2014, International Business Machines Corporation and
+* Copyright (C) 2007-2015, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
@@ -124,7 +124,6 @@ static const UChar *ures_a_getNextString(UResourceBundleAIterator *aiter, int32_
U_NAMESPACE_BEGIN
-
// *****************************************************************************
// class DateTimePatternGenerator
// *****************************************************************************
@@ -245,15 +244,12 @@ DateTimePatternGenerator::createInstance(UErrorCode& status) {
DateTimePatternGenerator* U_EXPORT2
DateTimePatternGenerator::createInstance(const Locale& locale, UErrorCode& status) {
- DateTimePatternGenerator *result = new DateTimePatternGenerator(locale, status);
- if (result == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
if (U_FAILURE(status)) {
- delete result;
- result = NULL;
+ return NULL;
}
- return result;
+ LocalPointer<DateTimePatternGenerator> result(
+ new DateTimePatternGenerator(locale, status), status);
+ return U_SUCCESS(status) ? result.orphan() : NULL;
}
DateTimePatternGenerator* U_EXPORT2
@@ -312,6 +308,10 @@ DateTimePatternGenerator::DateTimePatternGenerator(const DateTimePatternGenerato
DateTimePatternGenerator&
DateTimePatternGenerator::operator=(const DateTimePatternGenerator& other) {
+ // reflexive case
+ if (&other == this) {
+ return *this;
+ }
pLocale = other.pLocale;
fDefaultHourFormatChar = other.fDefaultHourFormatChar;
*fp = *(other.fp);
@@ -397,16 +397,23 @@ DateTimePatternGenerator::initData(const Locale& locale, UErrorCode &status) {
} // DateTimePatternGenerator::initData
UnicodeString
-DateTimePatternGenerator::getSkeleton(const UnicodeString& pattern, UErrorCode&
-/*status*/) {
- dtMatcher->set(pattern, fp);
- return dtMatcher->getSkeletonPtr()->getSkeleton();
+DateTimePatternGenerator::staticGetSkeleton(
+ const UnicodeString& pattern, UErrorCode& /*status*/) {
+ FormatParser fp;
+ DateTimeMatcher matcher;
+ PtnSkeleton localSkeleton;
+ matcher.set(pattern, &fp, localSkeleton);
+ return localSkeleton.getSkeleton();
}
UnicodeString
-DateTimePatternGenerator::getBaseSkeleton(const UnicodeString& pattern, UErrorCode& /*status*/) {
- dtMatcher->set(pattern, fp);
- return dtMatcher->getSkeletonPtr()->getBaseSkeleton();
+DateTimePatternGenerator::staticGetBaseSkeleton(
+ const UnicodeString& pattern, UErrorCode& /*status*/) {
+ FormatParser fp;
+ DateTimeMatcher matcher;
+ PtnSkeleton localSkeleton;
+ matcher.set(pattern, &fp, localSkeleton);
+ return localSkeleton.getBaseSkeleton();
}
void
@@ -1217,7 +1224,7 @@ DateTimePatternGenerator::copyHashtable(Hashtable *other, UErrorCode &status) {
if(U_FAILURE(status)){
return;
}
- int32_t pos = -1;
+ int32_t pos = UHASH_FIRST;
const UHashElement* elem = NULL;
// walk through the hash table and create a deep clone
while((elem = other->nextElement(pos))!= NULL){
@@ -1333,7 +1340,7 @@ PatternMap::copyFrom(const PatternMap& other, UErrorCode& status) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
-
+ curElem->skeletonWasSpecified = otherElem->skeletonWasSpecified;
if (prevElem!=NULL) {
prevElem->next=curElem;
}
@@ -1840,7 +1847,7 @@ FormatParser::getCanonicalIndex(const UnicodeString& s, UBool strict) {
}
UBool
-FormatParser::isQuoteLiteral(const UnicodeString& s) const {
+FormatParser::isQuoteLiteral(const UnicodeString& s) {
return (UBool)(s.charAt(0)==SINGLE_QUOTE);
}
« no previous file with comments | « source/i18n/dtitvinf.cpp ('k') | source/i18n/dtptngen_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698