ICU-13412 Merging the fix for #13466 ICU4C SimpleDateFormat fractional seconds parsing issue with Chakma locale (r40647) to maint-60.

X-SVN-Rev: 40651
This commit is contained in:
Yoshito Umaoka 2017-10-26 23:45:57 +00:00
parent 741f37529e
commit 1623af4b25
3 changed files with 24 additions and 6 deletions

View file

@ -3202,7 +3202,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
case UDAT_FRACTIONAL_SECOND_FIELD:
// Fractional seconds left-justify
i = pos.getIndex() - start;
i = countDigits(text, start, pos.getIndex());
if (i < 3) {
while (i < 3) {
value *= 10;
@ -3728,6 +3728,19 @@ void SimpleDateFormat::parseInt(const UnicodeString& text,
}
}
int32_t SimpleDateFormat::countDigits(const UnicodeString& text, int32_t start, int32_t end) const {
int32_t numDigits = 0;
int32_t idx = start;
while (idx < end) {
UChar32 cp = text.char32At(idx);
if (u_isdigit(cp)) {
numDigits++;
}
idx += U16_LENGTH(cp);
}
return numDigits;
}
//----------------------------------------------------------------------
void SimpleDateFormat::translatePattern(const UnicodeString& originalPattern,

View file

@ -1433,6 +1433,16 @@ private:
int32_t checkIntSuffix(const UnicodeString& text, int32_t start,
int32_t patLoc, UBool isNegative) const;
/**
* Counts number of digit code points in the specified text.
*
* @param text input text
* @param start start index, inclusive
* @param end end index, exclusive
* @return number of digits found in the text in the specified range.
*/
int32_t countDigits(const UnicodeString& text, int32_t start, int32_t end) const;
/**
* Translate a pattern, mapping each character in the from string to the
* corresponding character in the to string. Return an error if the original

View file

@ -567,11 +567,6 @@ void TimeZoneFormatTest::RunTimeRoundTripTests(int32_t threadNumber) {
logln(" Thread %d, Locale %s, Pattern %s",
threadNumber, gLocaleData->locales[locidx].getName(), CStr(pattern)());
if (uprv_strcmp(gLocaleData->locales[locidx].getLanguage(), "ccp") == 0
&& logKnownIssue("13446", "Chakma time zone parsing")) {
continue;
}
SimpleDateFormat *sdf = new SimpleDateFormat(pattern, gLocaleData->locales[locidx], status);
if (U_FAILURE(status)) {
errcheckln(status, (UnicodeString) "new SimpleDateFormat failed for pattern " +