ICU-6545 Allow regex reset to the end of a string

X-SVN-Rev: 28801
This commit is contained in:
Andy Heninger 2010-10-12 22:52:51 +00:00
parent 61460a2e97
commit 69a7b1ea42
2 changed files with 10 additions and 9 deletions

View File

@ -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;
}

View File

@ -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;