]> granicus.if.org Git - icu/commitdiff
ICU-9132 finalize new MessageFormat pattern argument type to selectordinal
authorMarkus Scherer <markus.icu@gmail.com>
Fri, 13 Apr 2012 17:37:12 +0000 (17:37 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Fri, 13 Apr 2012 17:37:12 +0000 (17:37 +0000)
X-SVN-Rev: 31702

icu4c/source/common/messagepattern.cpp
icu4c/source/common/unicode/messagepattern.h
icu4c/source/i18n/msgfmt.cpp
icu4c/source/i18n/unicode/msgfmt.h
icu4c/source/test/intltest/tmsgfmt.cpp
icu4c/source/test/intltest/tmsgfmt.h

index a1dd02793fca7102e904239b0a7f4bc43808b6c9..ed6ee252a66dd5275b7c5ff2b376abbfc3ed85f0 100644 (file)
@@ -54,7 +54,6 @@ static const UChar u_S=0x53;
 static const UChar u_T=0x54;
 static const UChar u_U=0x55;
 static const UChar u_Z=0x5A;
-static const UChar u__=0x5F;  // '_'
 static const UChar u_a=0x61;
 static const UChar u_c=0x63;
 static const UChar u_d=0x64;
@@ -618,9 +617,9 @@ MessagePattern::parseArg(int32_t index, int32_t argStartLength, int32_t nestingL
             } else if(isSelect(typeIndex)) {
                 argType=UMSGPAT_ARG_TYPE_SELECT;
             }
-        } else if(length==9) {
-            if(isOrdinal(typeIndex)) {
-                argType=UMSGPAT_ARG_TYPE_ORDINAL;
+        } else if(length==13) {
+            if(isSelect(typeIndex) && isOrdinal(typeIndex+6)) {
+                argType=UMSGPAT_ARG_TYPE_SELECTORDINAL;
             }
         }
         // change the ARG_START type from NONE to argType
@@ -1073,8 +1072,6 @@ UBool
 MessagePattern::isOrdinal(int32_t index) {
     UChar c;
     return
-        ((c=msg.charAt(index++))==u_p || c==u_P) &&
-        ((c=msg.charAt(index++))==u_l || c==u_L) &&
         ((c=msg.charAt(index++))==u_o || c==u_O) &&
         ((c=msg.charAt(index++))==u_r || c==u_R) &&
         ((c=msg.charAt(index++))==u_d || c==u_D) &&
index 140a9f6a4786f1b74461f026c36926ebc10892b4..a5204c1438047682ea4ebd1a77b839b214510905 100644 (file)
@@ -252,7 +252,7 @@ enum UMessagePatternArgType {
      * with the same style parts sequence and semantics as UMSGPAT_ARG_TYPE_PLURAL.
      * @draft ICU 50
      */
-    UMSGPAT_ARG_TYPE_ORDINAL
+    UMSGPAT_ARG_TYPE_SELECTORDINAL
 };
 /**
  * @stable ICU 4.8
@@ -261,11 +261,11 @@ typedef enum UMessagePatternArgType UMessagePatternArgType;
 
 /**
  * Returns TRUE if the argument type has a plural style part sequence and semantics,
- * for example UMSGPAT_ARG_TYPE_PLURAL and UMSGPAT_ARG_TYPE_ORDINAL.
+ * for example UMSGPAT_ARG_TYPE_PLURAL and UMSGPAT_ARG_TYPE_SELECTORDINAL.
  * @draft ICU 50
  */
 #define UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE(argType) \
-    ((argType)==UMSGPAT_ARG_TYPE_PLURAL || (argType)==UMSGPAT_ARG_TYPE_ORDINAL)
+    ((argType)==UMSGPAT_ARG_TYPE_PLURAL || (argType)==UMSGPAT_ARG_TYPE_SELECTORDINAL)
 
 enum {
     /**
index dd8eb1eee0bae4fea81a4b362b74b52d582e826a..bec283a08a06145582fb726e4e6cd9b1ec9e20d2 100644 (file)
@@ -1531,7 +1531,7 @@ void MessageFormat::cacheExplicitFormats(UErrorCode& status) {
         }
         case UMSGPAT_ARG_TYPE_CHOICE:
         case UMSGPAT_ARG_TYPE_PLURAL:
-        case UMSGPAT_ARG_TYPE_ORDINAL:
+        case UMSGPAT_ARG_TYPE_SELECTORDINAL:
             formattableType = Formattable::kDouble;
             break;
         case UMSGPAT_ARG_TYPE_SELECT:
index 0c93305feaeff064c823be034aa6cf1351f73865..7c5cb0ddff403ea2277edb06315f06c73569ac0c 100644 (file)
@@ -104,14 +104,14 @@ class NumberFormat;
  * <pre>
  * message = messageText (argument messageText)*
  * argument = noneArg | simpleArg | complexArg
- * complexArg = choiceArg | pluralArg | ordinalArg | selectArg
+ * complexArg = choiceArg | pluralArg | selectArg | selectordinalArg
  *
  * noneArg = '{' argNameOrNumber '}'
  * simpleArg = '{' argNameOrNumber ',' argType [',' argStyle] '}'
  * choiceArg = '{' argNameOrNumber ',' "choice" ',' choiceStyle '}'
  * pluralArg = '{' argNameOrNumber ',' "plural" ',' pluralStyle '}'
- * ordinalArg = '{' argNameOrNumber ',' "plordinal" ',' pluralStyle '}'
  * selectArg = '{' argNameOrNumber ',' "select" ',' selectStyle '}'
+ * selectordinalArg = '{' argNameOrNumber ',' "selectordinal" ',' pluralStyle '}'
  *
  * choiceStyle: see {@link ChoiceFormat}
  * pluralStyle: see {@link PluralFormat}
index 59389db030b813d7a9e21ed8b244c1112aef685b..b571f7e8fdb1af6a42b8da5a7ad489d3d5525c10 100644 (file)
@@ -64,7 +64,7 @@ TestMessageFormat::runIndexedTest(int32_t index, UBool exec,
     TESTCASE_AUTO(TestCompatibleApostrophe);
     TESTCASE_AUTO(testCoverage);
     TESTCASE_AUTO(TestTrimArgumentName);
-    TESTCASE_AUTO(TestOrdinalPlural);
+    TESTCASE_AUTO(TestSelectOrdinal);
     TESTCASE_AUTO_END;
 }
 
@@ -1813,13 +1813,13 @@ void TestMessageFormat::TestTrimArgumentName() {
                   m.format(&argName, args, 1, result, errorCode));
 }
 
-void TestMessageFormat::TestOrdinalPlural() {
-    IcuTestErrorCode errorCode(*this, "TestOrdinalPlural");
+void TestMessageFormat::TestSelectOrdinal() {
+    IcuTestErrorCode errorCode(*this, "TestSelectOrdinal");
     // Test plural & ordinal together,
     // to make sure that we get the correct cached PluralSelector for each.
     MessageFormat m(
         "{0,plural,one{1 file}other{# files}}, "
-        "{0,plordinal,one{#st file}two{#nd file}few{#rd file}other{#th file}}",
+        "{0,selectordinal,one{#st file}two{#nd file}few{#rd file}other{#th file}}",
         Locale::getEnglish(), errorCode);
     if (errorCode.logDataIfFailureAndReset("Unable to instantiate MessageFormat")) {
         return;
@@ -1827,19 +1827,19 @@ void TestMessageFormat::TestOrdinalPlural() {
     Formattable args[1] = { (int32_t)21 };
     FieldPosition ignore(0);
     UnicodeString result;
-    assertEquals("plural-ordinal format(21) failed", "21 files, 21st file",
+    assertEquals("plural-and-ordinal format(21) failed", "21 files, 21st file",
                  m.format(args, 1, result, ignore, errorCode));
 
     args[0].setLong(2);
-    assertEquals("plural-ordinal format(2) failed", "2 files, 2nd file",
+    assertEquals("plural-and-ordinal format(2) failed", "2 files, 2nd file",
                  m.format(args, 1, result.remove(), ignore, errorCode));
 
     args[0].setLong(1);
-    assertEquals("plural-ordinal format(1) failed", "1 file, 1st file",
+    assertEquals("plural-and-ordinal format(1) failed", "1 file, 1st file",
                  m.format(args, 1, result.remove(), ignore, errorCode));
 
     args[0].setLong(3);
-    assertEquals("plural-ordinal format(3) failed", "3 files, 3rd file",
+    assertEquals("plural-and-ordinal format(3) failed", "3 files, 3rd file",
                  m.format(args, 1, result.remove(), ignore, errorCode));
 }
 
index dc69866d10e29eeef1745d700c19ddb691efab24..2e68da3cb31964d925239990697a2fdc756a1c2e 100644 (file)
@@ -114,7 +114,7 @@ public:
     void TestTurkishCasing(void);
     void testAutoQuoteApostrophe(void);
     void TestTrimArgumentName();
-    void TestOrdinalPlural();
+    void TestSelectOrdinal();
 
     /* Provide better code coverage */
     void testCoverage(void);