From 7f9329f8217d1bb4d21a3062317fd6f537474478 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Sat, 3 Sep 2016 00:39:01 +0000 Subject: [PATCH] ICU-12428 don t fallback to default for filtered break rules X-SVN-Rev: 39130 --- icu4c/source/common/filteredbrk.cpp | 19 ++++++++++++++----- icu4c/source/test/cintltst/cbiapts.c | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/icu4c/source/common/filteredbrk.cpp b/icu4c/source/common/filteredbrk.cpp index 79f46ad12ce..eb2e1fb0fc0 100644 --- a/icu4c/source/common/filteredbrk.cpp +++ b/icu4c/source/common/filteredbrk.cpp @@ -478,13 +478,22 @@ SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(const Loc : fSet(status) { if(U_SUCCESS(status)) { - LocalUResourceBundlePointer b(ures_open(U_ICUDATA_BRKITR, fromLocale.getBaseName(), &status)); - LocalUResourceBundlePointer exceptions(ures_getByKeyWithFallback(b.getAlias(), "exceptions", NULL, &status)); - LocalUResourceBundlePointer breaks(ures_getByKeyWithFallback(exceptions.getAlias(), "SentenceBreak", NULL, &status)); - if(U_FAILURE(status)) return; // leaves the builder empty, if you try to use it. + UErrorCode subStatus = U_ZERO_ERROR; + LocalUResourceBundlePointer b(ures_open(U_ICUDATA_BRKITR, fromLocale.getBaseName(), &subStatus)); + LocalUResourceBundlePointer exceptions(ures_getByKeyWithFallback(b.getAlias(), "exceptions", NULL, &subStatus)); + LocalUResourceBundlePointer breaks(ures_getByKeyWithFallback(exceptions.getAlias(), "SentenceBreak", NULL, &subStatus)); + +#if FB_DEBUG + fprintf(stderr, "open %s => %s, %s\n", fromLocale.getBaseName(), "?", u_errorName(subStatus)); +#endif + + if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) { + status = subStatus; // copy the failing status + return; // leaves the builder empty, if you try to use it. + } LocalUResourceBundlePointer strs; - UErrorCode subStatus = status; + subStatus = status; // Pick up inherited warning status now do { strs.adoptInstead(ures_getNextResource(breaks.getAlias(), strs.orphan(), &subStatus)); if(strs.isValid() && U_SUCCESS(subStatus)) { diff --git a/icu4c/source/test/cintltst/cbiapts.c b/icu4c/source/test/cintltst/cbiapts.c index 09f288a2f4c..0c2fb9bb7c7 100644 --- a/icu4c/source/test/cintltst/cbiapts.c +++ b/icu4c/source/test/cintltst/cbiapts.c @@ -977,7 +977,7 @@ static const TestBISuppressionsItem testBISuppressionsItems[] = { { "en@ss=standard", testSentenceSuppressionsEn, testSentSuppFwdOffsetsEn, testSentSuppRevOffsetsEn }, { "en", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, { "fr@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, - { "af@ss=standard", testSentenceSuppressionsEn, testSentSuppFwdOffsetsEn, testSentSuppRevOffsetsEn }, /* no brkiter data => en suppressions? */ + { "af@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* no brkiter data => nosuppressions? */ { "zh@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* brkiter data, no suppressions data => no suppressions */ { "zh_Hant@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* brkiter data, no suppressions data => no suppressions */ { "fi@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* brkiter data, no suppressions data => no suppressions */ -- 2.40.0