From d06d12896c5beac724c4d788b0de36c999280c71 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Fri, 16 Feb 2018 18:07:32 +0000 Subject: [PATCH] ICU-13529 Make some changes based on review feedback. X-SVN-Rev: 40939 --- icu4c/source/i18n/nfrs.cpp | 2 +- icu4c/source/i18n/nfrs.h | 2 +- icu4c/source/i18n/nfrule.cpp | 4 ++-- icu4c/source/i18n/nfrule.h | 4 ++-- icu4c/source/i18n/nfsubs.cpp | 14 +++++++------- icu4c/source/i18n/nfsubs.h | 2 +- icu4c/source/test/intltest/itrbnf.cpp | 13 +++++-------- 7 files changed, 19 insertions(+), 22 deletions(-) diff --git a/icu4c/source/i18n/nfrs.cpp b/icu4c/source/i18n/nfrs.cpp index d5b368d4230..e7b17b46c3a 100644 --- a/icu4c/source/i18n/nfrs.cpp +++ b/icu4c/source/i18n/nfrs.cpp @@ -681,7 +681,7 @@ static void dumpUS(FILE* f, const UnicodeString& us) { #endif UBool -NFRuleSet::parse(const UnicodeString& text, ParsePosition& pos, double upperBound, int32_t nonNumericalExecutedRuleMask, Formattable& result) const +NFRuleSet::parse(const UnicodeString& text, ParsePosition& pos, double upperBound, uint32_t nonNumericalExecutedRuleMask, Formattable& result) const { // try matching each rule in the rule set against the text being // parsed. Whichever one matches the most characters is the one diff --git a/icu4c/source/i18n/nfrs.h b/icu4c/source/i18n/nfrs.h index d4797e7ff55..db03c9039de 100644 --- a/icu4c/source/i18n/nfrs.h +++ b/icu4c/source/i18n/nfrs.h @@ -55,7 +55,7 @@ public: void format(int64_t number, UnicodeString& toAppendTo, int32_t pos, int32_t recursionCount, UErrorCode& status) const; void format(double number, UnicodeString& toAppendTo, int32_t pos, int32_t recursionCount, UErrorCode& status) const; - UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, int32_t nonNumericalExecutedRuleMask, Formattable& result) const; + UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, uint32_t nonNumericalExecutedRuleMask, Formattable& result) const; void appendRules(UnicodeString& result) const; // toString diff --git a/icu4c/source/i18n/nfrule.cpp b/icu4c/source/i18n/nfrule.cpp index f32ed5a747c..c75ecf06705 100644 --- a/icu4c/source/i18n/nfrule.cpp +++ b/icu4c/source/i18n/nfrule.cpp @@ -900,7 +900,7 @@ NFRule::doParse(const UnicodeString& text, ParsePosition& parsePosition, UBool isFractionRule, double upperBound, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& resVal) const { // internally we operate on a copy of the string being parsed @@ -1161,7 +1161,7 @@ NFRule::matchToDelimiter(const UnicodeString& text, const UnicodeString& delimiter, ParsePosition& pp, const NFSubstitution* sub, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, double upperBound) const { UErrorCode status = U_ZERO_ERROR; diff --git a/icu4c/source/i18n/nfrule.h b/icu4c/source/i18n/nfrule.h index 0fabe202373..698b75bb637 100644 --- a/icu4c/source/i18n/nfrule.h +++ b/icu4c/source/i18n/nfrule.h @@ -74,7 +74,7 @@ public: ParsePosition& pos, UBool isFractional, double upperBound, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& result) const; UBool shouldRollBack(int64_t number) const; @@ -95,7 +95,7 @@ private: int32_t indexOfAnyRulePrefix() const; double matchToDelimiter(const UnicodeString& text, int32_t startPos, double baseValue, const UnicodeString& delimiter, ParsePosition& pp, const NFSubstitution* sub, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, double upperBound) const; void stripPrefix(UnicodeString& text, const UnicodeString& prefix, ParsePosition& pp) const; diff --git a/icu4c/source/i18n/nfsubs.cpp b/icu4c/source/i18n/nfsubs.cpp index ec9e9b873cb..4c17aa28186 100644 --- a/icu4c/source/i18n/nfsubs.cpp +++ b/icu4c/source/i18n/nfsubs.cpp @@ -155,7 +155,7 @@ public: double baseValue, double upperBound, UBool lenientParse, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& result) const; virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const { @@ -222,7 +222,7 @@ public: double baseValue, double upperBound, UBool lenientParse, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& result) const; virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const { return newRuleValue + oldRuleValue; } @@ -294,7 +294,7 @@ public: double baseValue, double upperBound, UBool /*lenientParse*/, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& result) const; virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const { return newRuleValue / oldRuleValue; } @@ -692,7 +692,7 @@ NFSubstitution::doParse(const UnicodeString& text, double baseValue, double upperBound, UBool lenientParse, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& result) const { #ifdef RBNF_DEBUG @@ -935,7 +935,7 @@ ModulusSubstitution::doParse(const UnicodeString& text, double baseValue, double upperBound, UBool lenientParse, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& result) const { // if this isn't a >>> substitution, we can just use the @@ -1123,7 +1123,7 @@ FractionalPartSubstitution::doParse(const UnicodeString& text, double baseValue, double /*upperBound*/, UBool lenientParse, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& resVal) const { // if we're not in byDigits mode, we can just use the inherited @@ -1255,7 +1255,7 @@ NumeratorSubstitution::doParse(const UnicodeString& text, double baseValue, double upperBound, UBool /*lenientParse*/, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& result) const { // we don't have to do anything special to do the parsing here, diff --git a/icu4c/source/i18n/nfsubs.h b/icu4c/source/i18n/nfsubs.h index b8a5fc66198..948627c0cc9 100644 --- a/icu4c/source/i18n/nfsubs.h +++ b/icu4c/source/i18n/nfsubs.h @@ -191,7 +191,7 @@ public: double baseValue, double upperBound, UBool lenientParse, - int32_t nonNumericalExecutedRuleMask, + uint32_t nonNumericalExecutedRuleMask, Formattable& result) const; /** diff --git a/icu4c/source/test/intltest/itrbnf.cpp b/icu4c/source/test/intltest/itrbnf.cpp index 719df6202aa..4689df40745 100644 --- a/icu4c/source/test/intltest/itrbnf.cpp +++ b/icu4c/source/test/intltest/itrbnf.cpp @@ -2287,18 +2287,15 @@ void IntlTestRBNF::TestCompactDecimalFormatStyle() { void IntlTestRBNF::TestParseFailure() { UErrorCode status = U_ZERO_ERROR; RuleBasedNumberFormat rbnf(URBNF_SPELLOUT, Locale::getJapanese(), status); - static const char* testData[][1] = { - { "\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB" }, - { NULL } + static const UChar* testData[] = { + u"・・・・・・・・・・・・・・・・・・・・・・・・" }; - for (int i = 0; testData[i][0]; ++i) { - const char* spelledNumber = testData[i][0]; // spelled-out number - - UnicodeString spelledNumberString = UnicodeString(spelledNumber).unescape(); + for (int i = 0; i < UPRV_LENGTHOF(testData); ++i) { + UnicodeString spelledNumberString = UnicodeString(testData[i]).unescape(); Formattable actualNumber; rbnf.parse(spelledNumberString, actualNumber, status); if (status != U_INVALID_FORMAT_ERROR) { // I would have expected U_PARSE_ERROR, but NumberFormat::parse gives U_INVALID_FORMAT_ERROR - errln("FAIL: string should be unparseable %s %s", spelledNumber, u_errorName(status)); + errln("FAIL: string should be unparseable index=%d %s", i, u_errorName(status)); } } }