ICU-6545 Allow regex reset to the end of a string
X-SVN-Rev: 28801
This commit is contained in:
parent
61460a2e97
commit
69a7b1ea42
@ -1947,18 +1947,11 @@ RegexMatcher &RegexMatcher::reset(int64_t position, UErrorCode &status) {
|
||||
}
|
||||
reset(); // Reset also resets the region to be the entire string.
|
||||
|
||||
if (position < 0) {
|
||||
if (position < 0 || position > fActiveLimit) {
|
||||
status = U_INDEX_OUTOFBOUNDS_ERROR;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int64_t nativePos;
|
||||
nativePos = position;
|
||||
if (nativePos < fActiveStart || nativePos >= fActiveLimit) {
|
||||
status = U_INDEX_OUTOFBOUNDS_ERROR;
|
||||
return *this;
|
||||
}
|
||||
fMatchEnd = nativePos;
|
||||
fMatchEnd = position;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -717,6 +717,10 @@ void RegexTest::API_Match() {
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
m1->reset(len, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
m1->reset(len+1, status);
|
||||
REGEX_ASSERT(status == U_INDEX_OUTOFBOUNDS_ERROR);
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
@ -1752,6 +1756,10 @@ void RegexTest::API_Match_UTF8() {
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
m1->reset(input1Len, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
m1->reset(input1Len+1, status);
|
||||
REGEX_ASSERT(status == U_INDEX_OUTOFBOUNDS_ERROR);
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user