]> granicus.if.org Git - icu/commitdiff
ICU-10880 Minor optimization and documentation fix
authorGeorge Rhoten <grhoten@users.noreply.github.com>
Tue, 19 Aug 2014 17:11:13 +0000 (17:11 +0000)
committerGeorge Rhoten <grhoten@users.noreply.github.com>
Tue, 19 Aug 2014 17:11:13 +0000 (17:11 +0000)
X-SVN-Rev: 36202

icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java
icu4j/main/classes/core/src/com/ibm/icu/text/PluralFormat.java
icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java

index d5fb5c4829fae21af4e930a6ad11ed1db8f0a4ba..938284b55cd96bfd5113323aa4dd776d9c3f21d6 100644 (file)
@@ -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");
             }
index 3b26452bc70800e3b0a5edcc6c127586930a7f13..9a47df5cfbc1f9823713c8efb3889ddb0400221f 100644 (file)
@@ -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());
index 310869405f6eaeb668a66dbc61c655724720501c..03a156f43cfee3f143873773824010139eaf8dbc 100644 (file)
@@ -437,15 +437,19 @@ import com.ibm.icu.util.UResourceBundleIterator;
  *     <td width="37">$(cardinal,<i>plural syntax</i>)</td>
  *     <td width="23"></td>
  *     <td width="165" valign="top">in all rule sets</td>
- *     <td>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.</td>
+ *     <td>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 &lt;&lt; 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.</td>
  *   </tr>
  *   <tr>
  *     <td width="37">$(ordinal,<i>plural syntax</i>)</td>
  *     <td width="23"></td>
  *     <td width="165" valign="top">in all rule sets</td>
- *     <td>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.</td>
+ *     <td>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 &lt;&lt; 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.</td>
  *   </tr>
  * </table>
  *