ICU-8444 Remove PATTERN_IS_UTEXT from regex API.
X-SVN-Rev: 29845
This commit is contained in:
parent
e4bda133f1
commit
f777c14042
@ -3,7 +3,7 @@
|
||||
//
|
||||
/*
|
||||
***************************************************************************
|
||||
* Copyright (C) 2002-2010 International Business Machines Corporation *
|
||||
* Copyright (C) 2002-2011 International Business Machines Corporation *
|
||||
* and others. All rights reserved. *
|
||||
***************************************************************************
|
||||
*/
|
||||
@ -442,31 +442,6 @@ RegexMatcher *RegexPattern::matcher(const UnicodeString &input,
|
||||
return retMatcher;
|
||||
}
|
||||
|
||||
//
|
||||
// matcher, UText mode
|
||||
//
|
||||
RegexMatcher *RegexPattern::matcher(UText *input,
|
||||
PatternIsUTextFlag /*flag*/,
|
||||
UErrorCode &status) const {
|
||||
RegexMatcher *retMatcher = matcher(status);
|
||||
if (retMatcher != NULL) {
|
||||
retMatcher->fDeferredStatus = status;
|
||||
retMatcher->reset(input);
|
||||
}
|
||||
return retMatcher;
|
||||
}
|
||||
|
||||
#if 0
|
||||
RegexMatcher *RegexPattern::matcher(const UChar * /*input*/,
|
||||
UErrorCode &status) const
|
||||
{
|
||||
/* This should never get called. The API with UnicodeString should be called instead. */
|
||||
if (U_SUCCESS(status)) {
|
||||
status = U_UNSUPPORTED_ERROR;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
@ -531,13 +506,16 @@ UBool U_EXPORT2 RegexPattern::matches(UText *regex,
|
||||
|
||||
if (U_FAILURE(status)) {return FALSE;}
|
||||
|
||||
UBool retVal;
|
||||
UBool retVal = FALSE;
|
||||
RegexPattern *pat = NULL;
|
||||
RegexMatcher *matcher = NULL;
|
||||
|
||||
pat = RegexPattern::compile(regex, 0, pe, status);
|
||||
matcher = pat->matcher(input, PATTERN_IS_UTEXT, status);
|
||||
retVal = matcher->matches(status);
|
||||
matcher = pat->matcher(status);
|
||||
if (U_SUCCESS(status)) {
|
||||
matcher->reset(input);
|
||||
retVal = matcher->matches(status);
|
||||
}
|
||||
|
||||
delete matcher;
|
||||
delete pat;
|
||||
|
@ -365,36 +365,6 @@ public:
|
||||
virtual RegexMatcher *matcher(const UnicodeString &input,
|
||||
UErrorCode &status) const;
|
||||
|
||||
|
||||
/**
|
||||
* Flag to disambiguate RegexPattern::matcher signature
|
||||
* @draft ICU 4.6
|
||||
*/
|
||||
enum PatternIsUTextFlag { PATTERN_IS_UTEXT };
|
||||
|
||||
/**
|
||||
* Creates a RegexMatcher that will match the given input against this pattern. The
|
||||
* RegexMatcher can then be used to perform match, find or replace operations
|
||||
* on the input. Note that a RegexPattern object must not be deleted while
|
||||
* RegexMatchers created from it still exist and might possibly be used again.
|
||||
* <p>
|
||||
* The matcher will make a shallow clone of the supplied input text, and all regexp
|
||||
* pattern matching operations happen on this clone. While read-only operations on
|
||||
* the supplied text are permitted, it is critical that the underlying string not be
|
||||
* altered or deleted before use by the regular expression operations is complete.
|
||||
*
|
||||
* @param input The input text to which the regular expression will be applied.
|
||||
* @param flag Must be RegexPattern::PATTERN_IS_UTEXT; used to disambiguate
|
||||
* method signature.
|
||||
* @param status A reference to a UErrorCode to receive any errors.
|
||||
* @return A RegexMatcher object for this pattern and input.
|
||||
*
|
||||
* @draft ICU 4.6
|
||||
*/
|
||||
virtual RegexMatcher *matcher(UText *input,
|
||||
PatternIsUTextFlag flag,
|
||||
UErrorCode &status) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Cause a compilation error if an application accidentally attempts to
|
||||
|
@ -359,7 +359,7 @@ UBool RegexTest::doRegexLMTestUTF8(const char *pat, const char *text, UBool look
|
||||
unEscapedInput.extract(textChars, inputUTF8Length+1, UTF8Converter.getAlias(), status);
|
||||
utext_openUTF8(&inputText, textChars, inputUTF8Length, &status);
|
||||
|
||||
REMatcher = REPattern->matcher(&inputText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
REMatcher = &REPattern->matcher(status)->reset(&inputText);
|
||||
if (U_FAILURE(status)) {
|
||||
errln("RegexTest failure in REPattern::matcher() at line %d (UTF8). Status = %s\n",
|
||||
line, u_errorName(status));
|
||||
@ -1755,7 +1755,7 @@ void RegexTest::API_Match_UTF8() {
|
||||
//
|
||||
// Matcher creation and reset.
|
||||
//
|
||||
RegexMatcher *m1 = pat2->matcher(&input1, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
RegexMatcher *m1 = &pat2->matcher(status)->reset(&input1);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(m1->lookingAt(status) == TRUE);
|
||||
const char str_abcdefthisisatest[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x00 }; /* abcdef this is a test */
|
||||
@ -1886,7 +1886,7 @@ void RegexTest::API_Match_UTF8() {
|
||||
const char str_0123456789[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x00 }; /* 0123456789 */
|
||||
utext_openUTF8(&input, str_0123456789, -1, &status);
|
||||
|
||||
RegexMatcher *matcher = pat->matcher(&input, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
RegexMatcher *matcher = &pat->matcher(status)->reset(&input);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(matcher->lookingAt(status) == TRUE);
|
||||
static const int32_t matchStarts[] = {0, 2, 4, 8};
|
||||
@ -2006,7 +2006,7 @@ void RegexTest::API_Match_UTF8() {
|
||||
utext_openUTF8(&input, str_abcabcabc, -1, &status);
|
||||
// 012345678901234567
|
||||
|
||||
RegexMatcher *matcher = pat->matcher(&input, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
RegexMatcher *matcher = &pat->matcher(status)->reset(&input);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(matcher->find());
|
||||
REGEX_ASSERT(matcher->start(status) == 1);
|
||||
@ -2068,7 +2068,7 @@ void RegexTest::API_Match_UTF8() {
|
||||
utext_openUTF8(&input, str_abcabcabc, -1, &status);
|
||||
// 012345678901234567
|
||||
|
||||
RegexMatcher *matcher = pat->matcher(&input, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
RegexMatcher *matcher = &pat->matcher(status)->reset(&input);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(matcher->find());
|
||||
REGEX_ASSERT(matcher->start(status) == 0);
|
||||
@ -2304,7 +2304,7 @@ void RegexTest::API_Replace_UTF8() {
|
||||
utext_openUTF8(&dataText, data, -1, &status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_VERBOSE_TEXT(&dataText);
|
||||
RegexMatcher *matcher = pat->matcher(&dataText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
RegexMatcher *matcher = &pat->matcher(status)->reset(&dataText);
|
||||
|
||||
//
|
||||
// Plain vanilla matches.
|
||||
@ -2458,7 +2458,7 @@ void RegexTest::API_Replace_UTF8() {
|
||||
|
||||
const char str_abcdefg[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x00 }; /* abcdefg */
|
||||
utext_openUTF8(&dataText, str_abcdefg, -1, &status);
|
||||
RegexMatcher *matcher2 = pat2->matcher(&dataText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
RegexMatcher *matcher2 = &pat2->matcher(status)->reset(&dataText);
|
||||
REGEX_CHECK_STATUS;
|
||||
|
||||
const char str_11[] = { 0x24, 0x31, 0x24, 0x31, 0x00 }; /* $1$1 */
|
||||
@ -3382,7 +3382,7 @@ void RegexTest::regex_find(const UnicodeString &pattern,
|
||||
utext_openUTF8(&inputText, inputChars, inputUTF8Length, &status);
|
||||
|
||||
if (status == U_ZERO_ERROR) {
|
||||
UTF8Matcher = UTF8Pattern->matcher(&inputText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
UTF8Matcher = &UTF8Pattern->matcher(status)->reset(&inputText);
|
||||
REGEX_CHECK_STATUS_L(line);
|
||||
}
|
||||
|
||||
@ -4406,7 +4406,7 @@ void RegexTest::PerlTestsUTF8() {
|
||||
//
|
||||
// Run the test, check for expected match/don't match result.
|
||||
//
|
||||
RegexMatcher *testMat = testPat->matcher(&inputText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
RegexMatcher *testMat = &testPat->matcher(status)->reset(&inputText);
|
||||
UBool found = testMat->find();
|
||||
UBool expected = FALSE;
|
||||
if (fields[2].indexOf(UChar_y) >=0) {
|
||||
|
Loading…
Reference in New Issue
Block a user