diff --git a/icu4c/source/i18n/quant.cpp b/icu4c/source/i18n/quant.cpp index f90951127a9..0b81fecee3b 100644 --- a/icu4c/source/i18n/quant.cpp +++ b/icu4c/source/i18n/quant.cpp @@ -42,7 +42,7 @@ UnicodeMatcher* Quantifier::clone() const { UMatchDegree Quantifier::matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const { + UBool incremental) { int32_t start = offset; uint32_t count = 0; while (count < maxCount) { diff --git a/icu4c/source/i18n/quant.h b/icu4c/source/i18n/quant.h index d478c672b0b..2a73c16d9d5 100644 --- a/icu4c/source/i18n/quant.h +++ b/icu4c/source/i18n/quant.h @@ -36,7 +36,7 @@ class Quantifier : public UnicodeMatcher { virtual UMatchDegree matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const; + UBool incremental); /** * Implement UnicodeMatcher diff --git a/icu4c/source/i18n/rbt_data.cpp b/icu4c/source/i18n/rbt_data.cpp index 0dfbae6f5a2..a686428cee2 100644 --- a/icu4c/source/i18n/rbt_data.cpp +++ b/icu4c/source/i18n/rbt_data.cpp @@ -69,7 +69,7 @@ TransliterationRuleData::~TransliterationRuleData() { } } -const UnicodeMatcher* +UnicodeMatcher* TransliterationRuleData::lookup(UChar32 standIn) const { int32_t i = standIn - variablesBase; return (i >= 0 && i < variablesLength) ? variables[i] : 0; diff --git a/icu4c/source/i18n/rbt_data.h b/icu4c/source/i18n/rbt_data.h index 2da87d39aa4..b23f90528bc 100644 --- a/icu4c/source/i18n/rbt_data.h +++ b/icu4c/source/i18n/rbt_data.h @@ -99,7 +99,7 @@ public: * Given a stand-in character, return the UnicodeMatcher that it * represents, or NULL. */ - const UnicodeMatcher* lookup(UChar32 standIn) const; + UnicodeMatcher* lookup(UChar32 standIn) const; /** * Return the zero-based index of the segment represented by the given diff --git a/icu4c/source/i18n/rbt_rule.cpp b/icu4c/source/i18n/rbt_rule.cpp index 03f16b94ee7..d0c656cb9ac 100644 --- a/icu4c/source/i18n/rbt_rule.cpp +++ b/icu4c/source/i18n/rbt_rule.cpp @@ -336,7 +336,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text, for (oPattern=anteContextLength-1; oPattern>=0; --oPattern) { UChar keyChar = pattern.charAt(oPattern); - const UnicodeMatcher* matcher = data->lookup(keyChar); + UnicodeMatcher* matcher = data->lookup(keyChar); if (matcher == 0) { if (oText >= pos.contextStart && keyChar == text.charAt(oText)) { @@ -394,7 +394,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text, int32_t matchLimit = (oPattern < keyLength) ? pos.limit : pos.contextLimit; UChar keyChar = pattern.charAt(anteContextLength + oPattern++); - const UnicodeMatcher* matcher = data->lookup(keyChar); + UnicodeMatcher* matcher = data->lookup(keyChar); if (matcher == 0) { // Don't need the oText < pos.contextLimit check if // incremental is TRUE (because it's done above); do need diff --git a/icu4c/source/i18n/strmatch.cpp b/icu4c/source/i18n/strmatch.cpp index 1ee59e0366c..12c6cc53e3c 100644 --- a/icu4c/source/i18n/strmatch.cpp +++ b/icu4c/source/i18n/strmatch.cpp @@ -54,14 +54,14 @@ UnicodeMatcher* StringMatcher::clone() const { UMatchDegree StringMatcher::matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const { + UBool incremental) { int32_t i; int32_t cursor = offset; if (limit < cursor) { // Match in the reverse direction for (i=pattern.length()-1; i>=0; --i) { UChar keyChar = pattern.charAt(i); - const UnicodeMatcher* subm = data.lookup(keyChar); + UnicodeMatcher* subm = data.lookup(keyChar); if (subm == 0) { if (cursor >= limit && keyChar == text.charAt(cursor)) { @@ -81,9 +81,8 @@ UMatchDegree StringMatcher::matches(const Replaceable& text, // forward start, limit, and only if a prior match does not // exist -- we want the rightmost match. if (matchStart < 0) { - // cast away const -- should modify method to be non-const - ((StringMatcher*)this)->matchStart = cursor+1; - ((StringMatcher*)this)->matchLimit = offset+1; + matchStart = cursor+1; + matchLimit = offset+1; } } else { for (i=0; imatchStart = offset; - ((StringMatcher*)this)->matchLimit = cursor; + matchStart = offset; + matchLimit = cursor; } offset = cursor; diff --git a/icu4c/source/i18n/strmatch.h b/icu4c/source/i18n/strmatch.h index 81873ed70e4..abf56abd90c 100644 --- a/icu4c/source/i18n/strmatch.h +++ b/icu4c/source/i18n/strmatch.h @@ -46,7 +46,7 @@ class StringMatcher : public UnicodeMatcher { virtual UMatchDegree matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const; + UBool incremental); /** * Implement UnicodeMatcher diff --git a/icu4c/source/i18n/unicode/unifilt.h b/icu4c/source/i18n/unicode/unifilt.h index dab6d0feaa3..6548ea4d87b 100644 --- a/icu4c/source/i18n/unicode/unifilt.h +++ b/icu4c/source/i18n/unicode/unifilt.h @@ -71,7 +71,7 @@ public: virtual UMatchDegree matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const; + UBool incremental); protected: diff --git a/icu4c/source/i18n/unicode/unimatch.h b/icu4c/source/i18n/unicode/unimatch.h index 9a1ecdbec2c..cb57d6d1af4 100644 --- a/icu4c/source/i18n/unicode/unimatch.h +++ b/icu4c/source/i18n/unicode/unimatch.h @@ -91,6 +91,9 @@ public: * reverse direction, this will be the index of the last matched * character minus one. * + *

Note: This method is not const because some classes may + * modify their state as the result of a match. + * * @param text the text to be matched * @param offset on input, the index into text at which to begin * matching. On output, the limit of the matched text. The @@ -114,7 +117,7 @@ public: virtual UMatchDegree matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const = 0; + UBool incremental) = 0; /** * Returns a string representation of this matcher. If the result of diff --git a/icu4c/source/i18n/unicode/uniset.h b/icu4c/source/i18n/unicode/uniset.h index 57c1d0389c3..63f26e25519 100644 --- a/icu4c/source/i18n/unicode/uniset.h +++ b/icu4c/source/i18n/unicode/uniset.h @@ -432,7 +432,7 @@ public: UMatchDegree matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const; + UBool incremental); /** * Adds the specified range to this set if it is not already diff --git a/icu4c/source/i18n/unifilt.cpp b/icu4c/source/i18n/unifilt.cpp index b27bf4ceb52..7a18b3f5213 100644 --- a/icu4c/source/i18n/unifilt.cpp +++ b/icu4c/source/i18n/unifilt.cpp @@ -19,7 +19,7 @@ U_NAMESPACE_BEGIN UMatchDegree UnicodeFilter::matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const { + UBool incremental) { UChar32 c; if (offset < limit && contains(c = text.char32At(offset))) { diff --git a/icu4c/source/i18n/uniset.cpp b/icu4c/source/i18n/uniset.cpp index 1ae931f6789..d28e257ae6a 100644 --- a/icu4c/source/i18n/uniset.cpp +++ b/icu4c/source/i18n/uniset.cpp @@ -598,7 +598,7 @@ UBool UnicodeSet::matchesIndexValue(uint8_t v) const { UMatchDegree UnicodeSet::matches(const Replaceable& text, int32_t& offset, int32_t limit, - UBool incremental) const { + UBool incremental) { if (offset == limit) { if (contains(TransliterationRule::ETHER)) { return incremental ? U_PARTIAL_MATCH : U_MATCH;