diff --git a/icu4c/source/i18n/rbt_rule.cpp b/icu4c/source/i18n/rbt_rule.cpp index a165bb260c..cb8ea4a961 100644 --- a/icu4c/source/i18n/rbt_rule.cpp +++ b/icu4c/source/i18n/rbt_rule.cpp @@ -185,41 +185,6 @@ bool_t TransliterationRule::masks(const TransliterationRule& r2) const { 0 == r2.pattern.compare(left2 - left, len, pattern); } -/** - * Return true if this rule matches the given text. The text being matched - * occupies a virtual buffer consisting of the contents of - * result concatenated to a substring of text. - * The substring is specified by start and limit. - * The value of cursor is an index into this virtual buffer, - * from 0 to the length of the buffer. In terms of the parameters, - * cursor must be between 0 and result.length() + limit - - * start. - * @param text the untranslated text - * @param start the beginning index, inclusive; 0 <= start - * <= limit. - * @param limit the ending index, exclusive; start <= limit - * <= text.length(). - * @param result translated text so far - * @param cursor position at which to translate next, an offset into result. - * If greater than or equal to result.length(), represents offset start + - * cursor - result.length() into text. - * @param filter the filter. Any character for which - * filter.contains() returns false will not be - * altered by this transliterator. If filter is - * null then no filtering is applied. - */ -bool_t TransliterationRule::matches(const UnicodeString& text, - int32_t start, int32_t limit, - const UnicodeString& result, - int32_t cursor, - const TransliterationRuleData& data, - const UnicodeFilter* filter) const { - // Match anteContext, key, and postContext - return regionMatches(text, start, limit, result, - cursor - anteContextLength, - pattern, data, filter); -} - /** * Return true if this rule matches the given text. * @param text the text, both translated and untranslated @@ -241,9 +206,17 @@ bool_t TransliterationRule::matches(const Replaceable& text, const TransliterationRuleData& data, const UnicodeFilter* filter) const { // Match anteContext, key, and postContext - return regionMatches(text, start, limit, - cursor - anteContextLength, - pattern, data, filter); + cursor -= anteContextLength; + if (cursor < start || (cursor + pattern.length()) > limit) { + return FALSE; + } + for (int32_t i=0; imatches(), the text being matched occupies a virtual buffer - * consisting of the contents of result concatenated to a - * substring of text. See matches() for details. - * @param text the untranslated text - * @param start the beginning index, inclusive; 0 <= start - * <= limit. - * @param limit the ending index, exclusive; start <= limit - * <= text.length(). - * @param result translated text so far - * @param cursor position at which to translate next, an offset into result. - * If greater than or equal to result.length(), represents offset start + - * cursor - result.length() into text. - * @param templ the text to match against. All characters must match. - * @param data a dictionary of variables mapping Character - * to UnicodeSet - * @param filter the filter. Any character for which - * filter.contains() returns false will not be - * altered by this transliterator. If filter is - * null then no filtering is applied. - * @return true if there is a match - */ -bool_t TransliterationRule::regionMatches(const UnicodeString& text, - int32_t start, int32_t limit, - const UnicodeString& result, - int32_t cursor, - const UnicodeString& templ, - const TransliterationRuleData& data, - const UnicodeFilter* filter) const { - int32_t rlen = result.length(); - if (cursor < 0 - || (cursor + templ.length()) > (rlen + limit - start)) { - return FALSE; - } - for (int32_t i=0; i0 <= start - * <= limit. - * @param limit the ending index, exclusive; start <= limit - * <= text.length(). - * @param cursor position at which to translate next, representing offset - * into text. This value must be between start and - * limit. - * @param templ the text to match against. All characters must match. - * @param data a dictionary of variables mapping Character - * to UnicodeSet - * @param filter the filter. Any character for which - * filter.contains() returns false will not be - * altered by this transliterator. If filter is - * null then no filtering is applied. - * @return true if there is a match - */ -bool_t TransliterationRule::regionMatches(const Replaceable& text, - int32_t start, int32_t limit, - int32_t cursor, - const UnicodeString& templ, - const TransliterationRuleData& data, - const UnicodeFilter* filter) const { - if (cursor < start - || (cursor + templ.length()) > limit) { - return FALSE; - } - for (int32_t i=0; iresult concatenated to a substring of text. - * The substring is specified by start and limit. - * The value of cursor is an index into this virtual buffer, - * from 0 to the length of the buffer. In terms of the parameters, - * cursor must be between 0 and result.length() + limit - - * start. - * @param text the untranslated text - * @param start the beginning index, inclusive; 0 <= start - * <= limit. - * @param limit the ending index, exclusive; start <= limit - * <= text.length(). - * @param result translated text so far - * @param cursor position at which to translate next, an offset into result. - * If greater than or equal to result.length(), represents offset start + - * cursor - result.length() into text. - * @param filter the filter. Any character for which - * filter.isIn() returns false will not be - * altered by this transliterator. If filter is - * null then no filtering is applied. - */ - virtual bool_t matches(const UnicodeString& text, - int32_t start, int32_t limit, - const UnicodeString& result, - int32_t cursor, - const TransliterationRuleData& data, - const UnicodeFilter* filter) const; - /** * Return true if this rule matches the given text. * @param text the text, both translated and untranslated @@ -273,65 +243,6 @@ public: const TransliterationRuleData& data, const UnicodeFilter* filter) const; - /** - * Return true if a template matches the text. The entire length of the - * template is compared to the text at the cursor. As in - * matches(), the text being matched occupies a virtual buffer - * consisting of the contents of result concatenated to a - * substring of text. See matches() for details. - * @param text the untranslated text - * @param start the beginning index, inclusive; 0 <= start - * <= limit. - * @param limit the ending index, exclusive; start <= limit - * <= text.length(). - * @param result translated text so far - * @param cursor position at which to translate next, an offset into result. - * If greater than or equal to result.length(), represents offset start + - * cursor - result.length() into text. - * @param templ the text to match against. All characters must match. - * @param data a dictionary of variables mapping Character - * to UnicodeSet - * @param filter the filter. Any character for which - * filter.isIn() returns false will not be - * altered by this transliterator. If filter is - * null then no filtering is applied. - * @return true if there is a match - */ - virtual bool_t regionMatches(const UnicodeString& text, - int32_t start, int32_t limit, - const UnicodeString& result, - int32_t cursor, - const UnicodeString& templ, - const TransliterationRuleData& data, - const UnicodeFilter* filter) const; - - /** - * Return true if a template matches the text. The entire length of the - * template is compared to the text at the cursor. - * @param text the text, both translated and untranslated - * @param start the beginning index, inclusive; 0 <= start - * <= limit. - * @param limit the ending index, exclusive; start <= limit - * <= text.length(). - * @param cursor position at which to translate next, representing offset - * into text. This value must be between start and - * limit. - * @param templ the text to match against. All characters must match. - * @param data a dictionary of variables mapping Character - * to UnicodeSet - * @param filter the filter. Any character for which - * filter.isIn() returns false will not be - * altered by this transliterator. If filter is - * null then no filtering is applied. - * @return true if there is a match - */ - virtual bool_t regionMatches(const Replaceable& text, - int32_t start, int32_t limit, - int32_t cursor, - const UnicodeString& templ, - const TransliterationRuleData& data, - const UnicodeFilter* filter) const; - /** * Return the number of characters of the text that match this rule. If * there is a mismatch, return -1. If the text is not long enough to match diff --git a/icu4c/source/i18n/rbt_set.cpp b/icu4c/source/i18n/rbt_set.cpp index a8f7ffb3fb..df14d7396e 100644 --- a/icu4c/source/i18n/rbt_set.cpp +++ b/icu4c/source/i18n/rbt_set.cpp @@ -183,53 +183,6 @@ void TransliterationRuleSet::freeze(const TransliterationRuleData& data, //} } -/** - * Attempt to find a matching rule at the specified point in the text. The - * text being matched occupies a virtual buffer consisting of the contents - * of result concatenated to a substring of text. - * The substring is specified by start and limit. - * The value of cursor is an index into this virtual buffer, - * from 0 to the length of the buffer. In terms of the parameters, - * cursor must be between 0 and result.length() + limit - - * start. - * @param text the untranslated text - * @param start the beginning index, inclusive; 0 <= start - * <= limit. - * @param limit the ending index, exclusive; start <= limit - * <= text.length(). - * @param result translated text - * @param cursor position at which to translate next, an offset into result. - * If greater than or equal to result.length(), represents offset start + - * cursor - result.length() into text. - * @param data a dictionary mapping variables to the sets they - * represent (maps Character to UnicodeSet) - * @param filter the filter. Any character for which - * filter.contains() returns false will not be - * altered by this transliterator. If filter is - * null then no filtering is applied. - * @return the matching rule, or null if none found. - */ -TransliterationRule* -TransliterationRuleSet::findMatch(const UnicodeString& text, - int32_t start, int32_t limit, - const UnicodeString& result, - int32_t cursor, - const TransliterationRuleData& data, - const UnicodeFilter* filter) const { - /* We only need to check our indexed bin of the rule table, - * based on the low byte of the first key character. - */ - int32_t rlen = result.length(); - int16_t x = 0xFF & (cursor < rlen ? result.charAt(cursor) - : text.charAt(cursor - rlen + start)); - for (int32_t i=index[x]; imatches(text, start, limit, result, cursor, data, filter)) { - return rules[i]; - } - } - return NULL; -} - /** * Attempt to find a matching rule at the specified point in the text. * @param text the text, both translated and untranslated diff --git a/icu4c/source/i18n/rbt_set.h b/icu4c/source/i18n/rbt_set.h index 3b9aa5c9d0..4cc2e5eecb 100644 --- a/icu4c/source/i18n/rbt_set.h +++ b/icu4c/source/i18n/rbt_set.h @@ -91,39 +91,6 @@ public: virtual void freeze(const TransliterationRuleData& data, UErrorCode& status); - /** - * Attempt to find a matching rule at the specified point in the text. The - * text being matched occupies a virtual buffer consisting of the contents - * of result concatenated to a substring of text. - * The substring is specified by start and limit. - * The value of cursor is an index into this virtual buffer, - * from 0 to the length of the buffer. In terms of the parameters, - * cursor must be between 0 and result.length() + limit - - * start. - * @param text the untranslated text - * @param start the beginning index, inclusive; 0 <= start - * <= limit. - * @param limit the ending index, exclusive; start <= limit - * <= text.length(). - * @param result tranlated text - * @param cursor position at which to translate next, an offset into result. - * If greater than or equal to result.length(), represents offset start + - * cursor - result.length() into text. - * @param data a dictionary mapping variables to the sets they - * represent (maps Character to UnicodeSet) - * @param filter the filter. Any character for which - * filter.isIn() returns false will not be - * altered by this transliterator. If filter is - * null then no filtering is applied. - * @return the matching rule, or null if none found. - */ - virtual TransliterationRule* findMatch(const UnicodeString& text, - int32_t start, int32_t limit, - const UnicodeString& result, - int32_t cursor, - const TransliterationRuleData& data, - const UnicodeFilter* filter) const; - /** * Attempt to find a matching rule at the specified point in the text. * @param text the text, both translated and untranslated