]> granicus.if.org Git - icu/commitdiff
ICU-13368 Hacking fix for en_GB currency parsing in ICU4C.
authorShane Carr <shane@unicode.org>
Tue, 3 Oct 2017 03:37:01 +0000 (03:37 +0000)
committerShane Carr <shane@unicode.org>
Tue, 3 Oct 2017 03:37:01 +0000 (03:37 +0000)
X-SVN-Rev: 40528

icu4c/source/common/ucurr.cpp
icu4c/source/test/cintltst/cnumtst.c
icu4c/source/test/intltest/datadrivennumberformattestsuite.cpp

index e2ccf50841a1ecd47ccf325d6afe276023e41888..df5d973a88c586429317f243910a0ebfabef62a2 100644 (file)
@@ -653,7 +653,20 @@ static UBool fallback(char *loc) {
         return FALSE;
     }
     UErrorCode status = U_ZERO_ERROR;
-    uloc_getParent(loc, loc, (int32_t)uprv_strlen(loc), &status);
+    static const char en_GB[] = { u'e', u'n', u'_', u'G', u'B', 0 };
+    if (uprv_strcmp(loc, en_GB) == 0) {
+        // HACK: See #13368.  We need "en_GB" to fall back to "en_001" instead of "en"
+        // in order to consume the correct data strings.  This hack will be removed
+        // when proper data sink loading is implemented here.
+        // NOTE: "001" adds 1 char over "GB".  However, both call sites allocate
+        // arrays with length ULOC_FULLNAME_CAPACITY (plenty of room for en_001).
+        loc[3] = u'0';
+        loc[4] = u'0';
+        loc[5] = u'1';
+        loc[6] = 0;
+    } else {
+        uloc_getParent(loc, loc, (int32_t)uprv_strlen(loc), &status);
+    }
  /*
     char *i = uprv_strrchr(loc, '_');
     if (i == NULL) {
index dbb88d23fd2d8a1b0249bb324dcbe2421bc0ace5..e2cd68abae106c5542f1b103f702b68899d37a80 100644 (file)
@@ -1040,7 +1040,7 @@ static const ParseCurrencyItem parseCurrencyItems[] = {
     { "en_GB", "euros4",   euros4Sym,   NULL,          U_PARSE_ERROR, 4, 0.0, U_PARSE_ERROR, 4, 0.0, ""    },
     { "en_GB", "euros6",   euros6Sym,   NULL,          U_PARSE_ERROR, 1, 0.0, U_PARSE_ERROR, 1, 0.0, ""    },
     { "en_GB", "euros8",   euros8Sym,     euros8PluEn,   U_PARSE_ERROR, 0, 0.0, U_ZERO_ERROR,  2, 8.0, "EUR" },
-    { "en_GB", "dollars4", dollarsUS4Sym, dollars4PluEn, U_PARSE_ERROR, 0, 0.0, U_ZERO_ERROR,  4, 4.0, "USD" }, // With CLDR 32/ICU 60, US$4 fails, $4 works, #13368
+    { "en_GB", "dollars4", dollarsUS4Sym, dollars4PluEn, U_PARSE_ERROR, 0, 0.0, U_ZERO_ERROR,  4, 4.0, "USD" },
 
     { "fr_FR", "euros4",   euros4Sym,   NULL,          U_ZERO_ERROR,  6, 4.0, U_ZERO_ERROR,  6, 4.0, "EUR" },
     { "fr_FR", "euros6",   euros6Sym,   euros6PluFr,   U_ZERO_ERROR,  3, 6.0, U_ZERO_ERROR,  3, 6.0, "EUR" },
@@ -1079,10 +1079,6 @@ static void TestParseCurrency()
             status = U_ZERO_ERROR;
             parsePos = 0;
             parseCurr[0] = 0;
-            if (currStr == dollarsUS4Sym && log_knownIssue("13368", "en_GB parsing of US$4 fails but $4 works")) {
-                currStr = dollars4Sym;
-                currExpectPos = 2;
-            }
             parseVal = unum_parseDoubleCurrency(unum, currStr, -1, &parsePos, parseCurr, &status);
             u_austrncpy(parseCurrB, parseCurr, 4);
             if (status != itemPtr->parsCurrExpectErr || parsePos != currExpectPos || parseVal != itemPtr->parsCurrExpectVal ||
index dce32f5e837c138343d494bf2de08c44cc99607f..9af8fdfd5208e9ea42ad2ecc8af4d0c682fb8c05 100644 (file)
@@ -92,10 +92,7 @@ void DataDrivenNumberFormatTestSuite::run(const char *fileName, UBool runAllTest
                 showError("Invalid column values");
                 return;
             }
-            if (NFTT_GET_FIELD(fTuple,output,"")=="fail" && NFTT_GET_FIELD(fTuple,parse,"")=="$53.45" &&
-                    logKnownIssue("13368", "en_GB parsing of $53.45 as USD works, shouldn't") ) {
-                // skip test
-            } else if (runAllTests || !breaksC()) {
+            if (runAllTests || !breaksC()) {
                 UnicodeString errorMessage;
                 UBool shouldFail = (NFTT_GET_FIELD(fTuple, output, "") == "fail")
                         ? !breaksC()