ICU-2902 regex, matches with no input behave as if input was an empty string
Change requested in code review. X-SVN-Rev: 12045
This commit is contained in:
parent
feeca769d5
commit
615e84ebe0
@ -23,6 +23,7 @@
|
||||
#include "uvector.h"
|
||||
#include "uvectr32.h"
|
||||
#include "regeximp.h"
|
||||
#include "regexst.h"
|
||||
|
||||
// #include <malloc.h> // Needed for heapcheck testing
|
||||
|
||||
@ -52,7 +53,7 @@ RegexMatcher::RegexMatcher(const RegexPattern *pat) {
|
||||
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
|
||||
reset();
|
||||
reset(*RegexPattern::gStaticSets->fEmptyString);
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +99,7 @@ RegexMatcher::RegexMatcher(const UnicodeString ®exp,
|
||||
if (fStack == NULL || fData == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
reset();
|
||||
reset(*RegexPattern::gStaticSets->fEmptyString);
|
||||
}
|
||||
|
||||
|
||||
|
@ -748,7 +748,31 @@ void RegexTest::API_Match() {
|
||||
delete matcher;
|
||||
delete pat;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Matchers with no input string behave as if they had an empty input string.
|
||||
//
|
||||
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
RegexMatcher m(".?", 0, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(m.find());
|
||||
REGEX_ASSERT(m.start(status) == 0);
|
||||
REGEX_ASSERT(m.input() == "");
|
||||
}
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
RegexPattern *p = RegexPattern::compile(".", 0, status);
|
||||
RegexMatcher *m = p->matcher(status);
|
||||
REGEX_CHECK_STATUS;
|
||||
|
||||
REGEX_ASSERT(m->find() == FALSE);
|
||||
REGEX_ASSERT(m->input() == "");
|
||||
delete m;
|
||||
delete p;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user