OLD | NEW |
| (Empty) |
1 diff --git a/source/i18n/regexcmp.cpp b/source/i18n/regexcmp.cpp | |
2 index e518e84..d56dce3 100644 | |
3 --- a/source/i18n/regexcmp.cpp | |
4 +++ b/source/i18n/regexcmp.cpp | |
5 @@ -71,6 +71,7 @@ RegexCompile::RegexCompile(RegexPattern *rxp, UErrorCode &stat
us) : | |
6 fMatchOpenParen = -1; | |
7 fMatchCloseParen = -1; | |
8 fCaptureName = NULL; | |
9 + fLastSetLiteral = U_SENTINEL; | |
10 | |
11 if (U_SUCCESS(status) && U_FAILURE(rxp->fDeferredStatus)) { | |
12 status = rxp->fDeferredStatus; | |
13 @@ -1752,12 +1753,14 @@ UBool RegexCompile::doParseActions(int32_t action) | |
14 case doSetNamedRange: | |
15 // We have scanned literal-\N{CHAR NAME}. Add the range to the set. | |
16 // The left character is already in the set, and is saved in fLastSetLi
teral. | |
17 + // Nonetheless, check if |fLastSetLiteral| is indeed set because it's | |
18 + // not set in some edge cases. | |
19 // The right side needs to be picked up, the scan is at the 'N'. | |
20 // Lower Limit > Upper limit being an error matches both Java | |
21 // and ICU UnicodeSet behavior. | |
22 { | |
23 UChar32 c = scanNamedChar(); | |
24 - if (U_SUCCESS(*fStatus) && fLastSetLiteral > c) { | |
25 + if (U_SUCCESS(*fStatus) && (fLastSetLiteral == U_SENTINEL || fLastS
etLiteral > c)) { | |
26 error(U_REGEX_INVALID_RANGE); | |
27 } | |
28 UnicodeSet *s = (UnicodeSet *)fSetStack.peek(); | |
29 @@ -1822,11 +1825,13 @@ UBool RegexCompile::doParseActions(int32_t action) | |
30 case doSetRange: | |
31 // We have scanned literal-literal. Add the range to the set. | |
32 // The left character is already in the set, and is saved in fLastSetLi
teral. | |
33 + // Nonetheless, check if |fLastSetLiteral| is indeed set because it's | |
34 + // not set in some edge cases. | |
35 // The right side is the current character. | |
36 // Lower Limit > Upper limit being an error matches both Java | |
37 // and ICU UnicodeSet behavior. | |
38 { | |
39 - if (fLastSetLiteral > fC.fChar) { | |
40 + if (fLastSetLiteral == U_SENTINEL || fLastSetLiteral > fC.fChar) { | |
41 error(U_REGEX_INVALID_RANGE); | |
42 } | |
43 UnicodeSet *s = (UnicodeSet *)fSetStack.peek(); | |
OLD | NEW |