Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3261)

Unified Diff: icu4c/source/i18n/compactdecimalformat.cpp

Issue 315420043: DecimalFormat rewrite, Java Base URL: svn+icussh://source.icu-project.org/repos/icu/branches/shane/numberformat/
Patch Set: r39857: Last commit before merge to trunk. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | icu4j/main/classes/core/src/com/ibm/icu/impl/TextTrieMap.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: icu4c/source/i18n/compactdecimalformat.cpp
===================================================================
--- icu4c/source/i18n/compactdecimalformat.cpp (revision 39589)
+++ icu4c/source/i18n/compactdecimalformat.cpp (working copy)
@@ -771,13 +771,22 @@
if (U_FAILURE(status)) {
return 0;
}
- int32_t firstIdx = formatStr.indexOf(kZero, UPRV_LENGTHOF(kZero), 0);
+
+ // ICU 59 HACK: Ignore negative part of format string, mimicking ICU 58 behavior.
+ // TODO(sffc): Make sure this is fixed during the overhaul port in ICU 60.
+ int32_t semiPos = formatStr.indexOf(';', 0);
+ if (semiPos == -1) {
+ semiPos = formatStr.length();
+ }
+ UnicodeString positivePart = formatStr.tempSubString(0, semiPos);
+
+ int32_t firstIdx = positivePart.indexOf(kZero, UPRV_LENGTHOF(kZero), 0);
// We must have 0's in format string.
if (firstIdx == -1) {
status = U_INTERNAL_PROGRAM_ERROR;
return 0;
}
- int32_t lastIdx = formatStr.lastIndexOf(kZero, UPRV_LENGTHOF(kZero), firstIdx);
+ int32_t lastIdx = positivePart.lastIndexOf(kZero, UPRV_LENGTHOF(kZero), firstIdx);
CDFUnit* unit = createCDFUnit(variant, log10Value, result, status);
if (U_FAILURE(status)) {
return 0;
@@ -790,10 +799,10 @@
unit->markAsSet();
// Everything up to first 0 is the prefix
- unit->prefix = formatStr.tempSubString(0, firstIdx);
+ unit->prefix = positivePart.tempSubString(0, firstIdx);
fixQuotes(unit->prefix);
// Everything beyond the last 0 is the suffix
- unit->suffix = formatStr.tempSubString(lastIdx + 1);
+ unit->suffix = positivePart.tempSubString(lastIdx + 1);
fixQuotes(unit->suffix);
// If there is effectively no prefix or suffix, ignore the actual number of
@@ -804,7 +813,7 @@
// Calculate number of zeros before decimal point
int32_t idx = firstIdx + 1;
- while (idx <= lastIdx && formatStr.charAt(idx) == u_0) {
+ while (idx <= lastIdx && positivePart.charAt(idx) == u_0) {
++idx;
}
return (idx - firstIdx);
« no previous file with comments | « no previous file | icu4j/main/classes/core/src/com/ibm/icu/impl/TextTrieMap.java » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b