ICU-6896 Workaround to allow parsing of spellouts in Arabic, Hebrew, and Maltese
X-SVN-Rev: 25971
This commit is contained in:
parent
30faf3d439
commit
1fffd46beb
@ -1,6 +1,6 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1997-2004, International Business Machines
|
||||
* Copyright (C) 1997-2009, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
* file name: nfrs.h
|
||||
@ -40,6 +40,15 @@ class NFRuleSet : public UMemory {
|
||||
UBool operator!=(const NFRuleSet& rhs) const { return !operator==(rhs); }
|
||||
|
||||
UBool isPublic() const { return fIsPublic; }
|
||||
|
||||
UBool isParseable() const {
|
||||
UnicodeString prefixpart = UNICODE_STRING_SIMPLE("-prefixpart");
|
||||
UnicodeString postfix = UNICODE_STRING_SIMPLE("-postfix");
|
||||
UnicodeString postfx = UNICODE_STRING_SIMPLE("-postfx");
|
||||
|
||||
return ( name.indexOf(prefixpart) == -1 && name.indexOf(postfix) == -1 && name.indexOf(postfx) == -1 );
|
||||
}
|
||||
|
||||
UBool isFractionRuleSet() const { return fIsFractionRuleSet; }
|
||||
|
||||
void getName(UnicodeString& result) const { result.setTo(name); }
|
||||
|
@ -58,7 +58,7 @@ static const UChar gSemiPercent[] =
|
||||
|
||||
// Temporary workaround - when noParse is true, do noting in parse.
|
||||
// TODO: We need a real fix - see #6895/#6896
|
||||
static const char *NO_SPELLOUT_PARSE_LANGUAGES[] = { "ar", "ga", "he", "mt", NULL };
|
||||
static const char *NO_SPELLOUT_PARSE_LANGUAGES[] = { "ga", NULL };
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
@ -1171,7 +1171,7 @@ RuleBasedNumberFormat::parse(const UnicodeString& text,
|
||||
|
||||
for (NFRuleSet** p = ruleSets; *p; ++p) {
|
||||
NFRuleSet *rp = *p;
|
||||
if (rp->isPublic()) {
|
||||
if (rp->isPublic() && rp->isParseable()) {
|
||||
ParsePosition working_pp(0);
|
||||
Formattable working_result;
|
||||
|
||||
|
@ -1798,13 +1798,21 @@ IntlTestRBNF::TestAllLocales()
|
||||
|
||||
// RBNF parse is extremely slow when lenient option is enabled.
|
||||
// For non-exhaustive mode, we only test a few locales.
|
||||
const char* noParseLocales[] = {"ga", NULL};
|
||||
const char* parseLocales[] = {"en_US", "nl_NL", "be", NULL};
|
||||
|
||||
|
||||
int32_t count = 0;
|
||||
const Locale* locales = Locale::getAvailableLocales(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const Locale* loc = &locales[i];
|
||||
UBool testParse = TRUE;
|
||||
for (int j = 0; noParseLocales[j] != NULL; j++) {
|
||||
if (strcmp(loc->getLanguage(), noParseLocales[j]) == 0) {
|
||||
testParse = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (quick) {
|
||||
testParse = FALSE;
|
||||
for (int k = 0; parseLocales[k] != NULL; k++) {
|
||||
|
Loading…
Reference in New Issue
Block a user