The problem is really in RegexMatcher &RegexMatcher::reset(int32_t position, UErrorCode &status), specifically the following piece of code in it:
if (position < 0
position >= fInput->length()) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
return *this;
}
The position check should be "> Greater Than", not ">= Greater Than or Equal". This is obviously a problem for zero-length strings (ie, ""), since there is no way to reset them.
This in turn causes problems with the likes of uregex_replaceAll(), as it performs "uregex_reset(regexp, 0, status);". Consider the example where the string to scan has a length of zero, with a regex of "$". Now, calling uregex_replaceAll() with a replacement string of "REPLACED" should work, since "$" matches the end of the string. This can't happen, however, since uregex_reset incorrectly reports an error via status.
Attachments
Change History
Download in other formats:
|