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

Unified Diff: source/common/simplepatternformatter.cpp

Issue 1621943002: ICU 56 step 4: Apply post-56 fixes for measure/date format (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@56goog
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/simplepatternformatter.h ('k') | source/common/uresbund.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/common/simplepatternformatter.cpp
diff --git a/source/common/simplepatternformatter.cpp b/source/common/simplepatternformatter.cpp
index 0cac2ec3fd0ac6b067faee2f6c00b8d81b86c8dc..abaaea9dcd51f9c19feddee5124cbafb5b7b06c5 100644
--- a/source/common/simplepatternformatter.cpp
+++ b/source/common/simplepatternformatter.cpp
@@ -1,6 +1,6 @@
/*
******************************************************************************
-* Copyright (C) 2014, International Business Machines
+* Copyright (C) 2014-2015, International Business Machines
* Corporation and others. All Rights Reserved.
******************************************************************************
* simplepatternformatter.cpp
@@ -149,6 +149,17 @@ SimplePatternFormatter::SimplePatternFormatter(const UnicodeString &pattern) :
compile(pattern, status);
}
+SimplePatternFormatter::SimplePatternFormatter(const UnicodeString &pattern,
+ int32_t min, int32_t max,
+ UErrorCode &errorCode)
+ : noPlaceholders(),
+ placeholders(),
+ placeholderSize(0),
+ placeholderCount(0),
+ firstPlaceholderReused(FALSE) {
+ compileMinMaxPlaceholders(pattern, min, max, errorCode);
+}
+
SimplePatternFormatter::SimplePatternFormatter(
const SimplePatternFormatter &other) :
noPlaceholders(other.noPlaceholders),
@@ -182,8 +193,10 @@ SimplePatternFormatter &SimplePatternFormatter::operator=(
SimplePatternFormatter::~SimplePatternFormatter() {
}
-UBool SimplePatternFormatter::compile(
- const UnicodeString &pattern, UErrorCode &status) {
+UBool SimplePatternFormatter::compileMinMaxPlaceholders(
+ const UnicodeString &pattern,
+ int32_t min, int32_t max,
+ UErrorCode &status) {
if (U_FAILURE(status)) {
return FALSE;
}
@@ -224,6 +237,7 @@ UBool SimplePatternFormatter::compile(
idBuilder.add(ch);
} else if (ch == 0x7D && idBuilder.isValid()) {
if (!addPlaceholder(idBuilder.getId(), len)) {
+ noPlaceholders.releaseBuffer(0);
status = U_MEMORY_ALLOCATION_ERROR;
return FALSE;
}
@@ -255,6 +269,10 @@ UBool SimplePatternFormatter::compile(
break;
}
noPlaceholders.releaseBuffer(len);
+ if (placeholderCount < min || max < placeholderCount) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return FALSE;
+ }
return TRUE;
}
« no previous file with comments | « source/common/simplepatternformatter.h ('k') | source/common/uresbund.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698