ICU-2874 fix parsing of [^-b]

X-SVN-Rev: 11871
This commit is contained in:
Alan Liu 2003-05-09 21:01:57 +00:00
parent 4415b1122a
commit ec2fad40f1
2 changed files with 23 additions and 0 deletions

View File

@ -1963,6 +1963,12 @@ void UnicodeSet::_applyPattern(const UnicodeString& pattern,
isLiteral = TRUE; // Treat leading '-' as a literal
break; // Fall through
}
break;
case 2:
if (c == HYPHEN && invert) {
isLiteral = TRUE; // [^-...] starts with literal '-'
}
break;
// else fall through and parse this character normally
}

View File

@ -793,6 +793,23 @@ void UnicodeSetTest::TestPropertySet() {
"[:xdigit:]",
"09afAF",
"gG!",
// Regex compatibility test
"[-b]", // leading '-' is literal
"-b",
"ac",
"[^-b]", // leading '-' is literal
"ac",
"-b",
"[b-]", // trailing '-' is literal
"-b",
"ac",
"[^b-]", // trailing '-' is literal
"ac",
"-b"
};
static const int32_t DATA_LEN = sizeof(DATA)/sizeof(DATA[0]);