From 5c12dc4923f4e2accde2f66932fc6b7f5c9eddeb Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Tue, 19 Aug 2014 17:11:13 +0000 Subject: [PATCH] ICU-10880 Minor optimization and documentation fix X-SVN-Rev: 36202 --- .../classes/core/src/com/ibm/icu/text/NFRule.java | 2 +- .../core/src/com/ibm/icu/text/PluralFormat.java | 2 +- .../src/com/ibm/icu/text/RuleBasedNumberFormat.java | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java b/icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java index d5fb5c4829f..938284b55cd 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java @@ -384,7 +384,7 @@ final class NFRule { int pluralRuleStart = ruleText.indexOf("$("); int pluralRuleEnd = (pluralRuleStart >= 0 ? ruleText.indexOf(')', pluralRuleStart) : -1); if (pluralRuleEnd >= 0) { - int endType = ruleText.indexOf(','); + int endType = ruleText.indexOf(',', pluralRuleStart); if (endType < 0) { throw new IllegalArgumentException("Rule \"" + ruleText + "\" does not have a defined type"); } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java index 3b26452bc70..9a47df5cfbc 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java @@ -755,7 +755,7 @@ public class PluralFormat extends UFormat { else { currMatchIndex = source.indexOf(currArg); } - if (currMatchIndex > matchedIndex && (matchedWord == null || currArg.length() > matchedWord.length())) { + if (currMatchIndex >= 0 && currMatchIndex >= matchedIndex && (matchedWord == null || currArg.length() > matchedWord.length())) { matchedIndex = currMatchIndex; matchedWord = currArg; keyword = pattern.substring(partStart.getLimit(), partLimit.getIndex()); diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java index 310869405f6..03a156f43cf 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java @@ -437,15 +437,19 @@ import com.ibm.icu.util.UResourceBundleIterator; * $(cardinal,plural syntax) * * in all rule sets - * This provides the ability to choose a word based on the number divided by the base value for the specified locale. - * This uses the cardinal plural rules from PluralFormat. All strings used in the plural format are treated as the same base value for parsing. + * This provides the ability to choose a word based on the number divided by the radix to the power of the + * exponent of the base value for the specified locale, which is normally equivalent to the << value. + * This uses the cardinal plural rules from PluralFormat. All strings used in the plural format are treated + * as the same base value for parsing. * * * $(ordinal,plural syntax) * * in all rule sets - * This provides the ability to choose a word based on the number divided by the base value for the specified locale. - * This uses the ordinal plural rules from PluralFormat. All strings used in the plural format are treated as the same base value for parsing. + * This provides the ability to choose a word based on the number divided by the radix to the power of the + * exponent of the base value for the specified locale, which is normally equivalent to the << value. + * This uses the ordinal plural rules from PluralFormat. All strings used in the plural format are treated + * as the same base value for parsing. * * * -- 2.40.0