mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-4521 Disambiguate signatures for RegexPattern::matcher,RegexMatcher::group for 0 pointers; fix warnings
X-SVN-Rev: 27522
This commit is contained in:
parent
b11c49bcd5
commit
f308bffc8c
5 changed files with 38 additions and 19 deletions
|
@ -1060,10 +1060,10 @@ UBool RegexMatcher::findUsingChunk() {
|
|||
//
|
||||
//--------------------------------------------------------------------------------
|
||||
UnicodeString RegexMatcher::group(UErrorCode &status) const {
|
||||
return group((int32_t)0, status);
|
||||
return group(0, status);
|
||||
}
|
||||
|
||||
UText *RegexMatcher::group(UText *dest, UErrorCode &status) const {
|
||||
UText *RegexMatcher::group(UText *dest, MatcherDestIsUTextFlag /*flag*/, UErrorCode &status) const {
|
||||
return group(0, dest, status);
|
||||
}
|
||||
|
||||
|
|
|
@ -430,6 +430,7 @@ RegexMatcher *RegexPattern::matcher(const UnicodeString &input,
|
|||
// matcher, UText mode
|
||||
//
|
||||
RegexMatcher *RegexPattern::matcher(UText *input,
|
||||
PatternIsUTextFlag /*flag*/,
|
||||
UErrorCode &status) const {
|
||||
RegexMatcher *retMatcher = matcher(status);
|
||||
if (retMatcher != NULL) {
|
||||
|
@ -519,7 +520,7 @@ UBool U_EXPORT2 RegexPattern::matches(UText *regex,
|
|||
RegexMatcher *matcher = NULL;
|
||||
|
||||
pat = RegexPattern::compile(regex, 0, pe, status);
|
||||
matcher = pat->matcher(input, status);
|
||||
matcher = pat->matcher(input, PATTERN_IS_UTEXT, status);
|
||||
retVal = matcher->matches(status);
|
||||
|
||||
delete matcher;
|
||||
|
|
|
@ -359,6 +359,12 @@ public:
|
|||
UErrorCode &status) const;
|
||||
|
||||
|
||||
/**
|
||||
* Flag to disambiguate RegexPattern::matcher signature
|
||||
* @internal ICU 4.4 technology preview
|
||||
*/
|
||||
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
|
||||
|
@ -371,12 +377,15 @@ public:
|
|||
* 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.
|
||||
*
|
||||
* @internal ICU 4.4 technology preview
|
||||
*/
|
||||
virtual RegexMatcher *matcher(UText *input,
|
||||
PatternIsUTextFlag flag,
|
||||
UErrorCode &status) const;
|
||||
|
||||
private:
|
||||
|
@ -832,11 +841,19 @@ public:
|
|||
virtual UnicodeString group(UErrorCode &status) const;
|
||||
|
||||
|
||||
/**
|
||||
* Flag to disambiguate RegexMatcher::group signature
|
||||
* @internal ICU 4.4 technology preview
|
||||
*/
|
||||
enum MatcherDestIsUTextFlag { MATCHER_DEST_IS_UTEXT };
|
||||
|
||||
/**
|
||||
* Returns a string containing the text matched by the previous match.
|
||||
* If the pattern can match an empty string, an empty string may be returned.
|
||||
* @param dest A mutable UText in which the matching text is placed.
|
||||
* If NULL, a new UText will be created (which may not be mutable).
|
||||
* @param flag Must be RegexMatcher::MATCHER_DEST_IS_UTEXT; used to
|
||||
* disambiguate method signature.
|
||||
* @param status A reference to a UErrorCode to receive any errors.
|
||||
* Possible errors are U_REGEX_INVALID_STATE if no match
|
||||
* has been attempted or the last match failed.
|
||||
|
@ -845,7 +862,7 @@ public:
|
|||
*
|
||||
* @internal ICU 4.4 technology preview
|
||||
*/
|
||||
virtual UText *group(UText *dest, UErrorCode &status) const;
|
||||
virtual UText *group(UText *dest, MatcherDestIsUTextFlag flag, UErrorCode &status) const;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1582,6 +1582,7 @@ uregex_appendTailUText(URegularExpression *regexp2,
|
|||
// and the NUL is counted in the output size.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#if 0
|
||||
static void copyString(UChar *destBuffer, // Destination buffer.
|
||||
int32_t destCapacity, // Total capacity of dest buffer
|
||||
int32_t *destIndex, // Index into dest buffer. Updated on return.
|
||||
|
@ -1609,7 +1610,7 @@ static void copyString(UChar *destBuffer, // Destination buffer.
|
|||
di++;
|
||||
*destIndex = di;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -266,7 +266,7 @@ UBool RegexTest::doRegexLMTestUTF8(const char *pat, const char *text, UBool look
|
|||
unEscapedInput.extract(textChars, inputUTF8Length+1, UTF8Converter, status);
|
||||
utext_openUTF8(&inputText, textChars, inputUTF8Length, &status);
|
||||
|
||||
REMatcher = REPattern->matcher(&inputText, status);
|
||||
REMatcher = REPattern->matcher(&inputText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
if (U_FAILURE(status)) {
|
||||
errln("RegexTest failure in REPattern::matcher() at line %d (UTF8). Status = %s\n",
|
||||
line, u_errorName(status));
|
||||
|
@ -1622,7 +1622,7 @@ void RegexTest::API_Match_UTF8() {
|
|||
//
|
||||
// Matcher creation and reset.
|
||||
//
|
||||
RegexMatcher *m1 = pat2->matcher(&input1, status);
|
||||
RegexMatcher *m1 = pat2->matcher(&input1, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(m1->lookingAt(status) == TRUE);
|
||||
REGEX_ASSERT_UTEXT("abcdef this is a test", m1->inputText());
|
||||
|
@ -1745,7 +1745,7 @@ void RegexTest::API_Match_UTF8() {
|
|||
UText input = UTEXT_INITIALIZER;
|
||||
utext_openUTF8(&input, "0123456789", -1, &status);
|
||||
|
||||
RegexMatcher *matcher = pat->matcher(&input, status);
|
||||
RegexMatcher *matcher = pat->matcher(&input, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(matcher->lookingAt(status) == TRUE);
|
||||
static const int32_t matchStarts[] = {0, 2, 4, 8};
|
||||
|
@ -1781,11 +1781,11 @@ void RegexTest::API_Match_UTF8() {
|
|||
utext_openUnicodeString(&destText, &dest, &status);
|
||||
UText *result;
|
||||
|
||||
result = matcher->group((UText *)NULL, status);
|
||||
result = matcher->group((UText *)NULL, RegexMatcher::MATCHER_DEST_IS_UTEXT, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT_UTEXT("0123456789", result);
|
||||
utext_close(result);
|
||||
result = matcher->group(&destText, status);
|
||||
result = matcher->group(&destText, RegexMatcher::MATCHER_DEST_IS_UTEXT, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(result == &destText);
|
||||
REGEX_ASSERT_UTEXT("0123456789", result);
|
||||
|
@ -1855,7 +1855,7 @@ void RegexTest::API_Match_UTF8() {
|
|||
utext_openUTF8(&input, ".abc..abc...abc..", -1, &status);
|
||||
// 012345678901234567
|
||||
|
||||
RegexMatcher *matcher = pat->matcher(&input, status);
|
||||
RegexMatcher *matcher = pat->matcher(&input, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(matcher->find());
|
||||
REGEX_ASSERT(matcher->start(status) == 1);
|
||||
|
@ -1915,7 +1915,7 @@ void RegexTest::API_Match_UTF8() {
|
|||
utext_openUTF8(&input, ".abcabc.abc..", -1, &status);
|
||||
// 012345678901234567
|
||||
|
||||
RegexMatcher *matcher = pat->matcher(&input, status);
|
||||
RegexMatcher *matcher = pat->matcher(&input, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(matcher->find());
|
||||
REGEX_ASSERT(matcher->start(status) == 0);
|
||||
|
@ -2034,7 +2034,7 @@ void RegexTest::API_Match_UTF8() {
|
|||
RegexMatcher m(&testPattern, &testText, 0, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
REGEX_ASSERT(m.regionStart() == 0);
|
||||
REGEX_ASSERT(m.regionEnd() == strlen("This is test data"));
|
||||
REGEX_ASSERT(m.regionEnd() == (int32_t)strlen("This is test data"));
|
||||
REGEX_ASSERT(m.hasTransparentBounds() == FALSE);
|
||||
REGEX_ASSERT(m.hasAnchoringBounds() == TRUE);
|
||||
|
||||
|
@ -2047,12 +2047,12 @@ void RegexTest::API_Match_UTF8() {
|
|||
|
||||
m.reset();
|
||||
REGEX_ASSERT(m.regionStart() == 0);
|
||||
REGEX_ASSERT(m.regionEnd() == strlen("This is test data"));
|
||||
REGEX_ASSERT(m.regionEnd() == (int32_t)strlen("This is test data"));
|
||||
|
||||
utext_openUTF8(&testText, "short", -1, &status);
|
||||
m.reset(&testText);
|
||||
REGEX_ASSERT(m.regionStart() == 0);
|
||||
REGEX_ASSERT(m.regionEnd() == strlen("short"));
|
||||
REGEX_ASSERT(m.regionEnd() == (int32_t)strlen("short"));
|
||||
|
||||
REGEX_ASSERT(m.hasAnchoringBounds() == TRUE);
|
||||
REGEX_ASSERT(&m == &m.useAnchoringBounds(FALSE));
|
||||
|
@ -2141,7 +2141,7 @@ void RegexTest::API_Replace_UTF8() {
|
|||
// 012345678901234567
|
||||
UText dataText = UTEXT_INITIALIZER;
|
||||
utext_openUTF8(&dataText, data, -1, &status);
|
||||
RegexMatcher *matcher = pat->matcher(&dataText, status);
|
||||
RegexMatcher *matcher = pat->matcher(&dataText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
|
||||
//
|
||||
// Plain vanilla matches.
|
||||
|
@ -2284,7 +2284,7 @@ void RegexTest::API_Replace_UTF8() {
|
|||
REGEX_CHECK_STATUS;
|
||||
|
||||
utext_openUTF8(&dataText, "abcdefg", -1, &status);
|
||||
RegexMatcher *matcher2 = pat2->matcher(&dataText, status);
|
||||
RegexMatcher *matcher2 = pat2->matcher(&dataText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
REGEX_CHECK_STATUS;
|
||||
|
||||
utext_openUTF8(&replText, "$1$1", -1, &status);
|
||||
|
@ -3141,7 +3141,7 @@ void RegexTest::regex_find(const UnicodeString &pattern,
|
|||
utext_openUTF8(&inputText, inputChars, inputUTF8Length, &status);
|
||||
|
||||
if (status == U_ZERO_ERROR) {
|
||||
UTF8Matcher = UTF8Pattern->matcher(&inputText, status);
|
||||
UTF8Matcher = UTF8Pattern->matcher(&inputText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
REGEX_CHECK_STATUS_L(line);
|
||||
}
|
||||
|
||||
|
@ -4127,7 +4127,7 @@ void RegexTest::PerlTestsUTF8() {
|
|||
//
|
||||
// Run the test, check for expected match/don't match result.
|
||||
//
|
||||
RegexMatcher *testMat = testPat->matcher(&inputText, status);
|
||||
RegexMatcher *testMat = testPat->matcher(&inputText, RegexPattern::PATTERN_IS_UTEXT, status);
|
||||
UBool found = testMat->find();
|
||||
UBool expected = FALSE;
|
||||
if (fields[2].indexOf(UChar_y) >=0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue