| 731 | // Move the strings pointers to the point where they start to differ. |
| 732 | template <typename CHAR, typename NEXT> |
| 733 | static void EatSameChars(const CHAR** pattern, const CHAR* pattern_end, |
| 734 | const CHAR** string, const CHAR* string_end, |
| 735 | NEXT next) { |
| 736 | const CHAR* escape = NULL; |
| 737 | while (*pattern != pattern_end && *string != string_end) { |
| 738 | if (!escape && IsWildcard(**pattern)) { |
| 739 | // We don't want to match wildcard here, except if it's escaped. |
| 740 | return; |
| 741 | } |
| 742 | |
| 743 | // Check if the escapement char is found. If so, skip it and move to the |
| 744 | // next character. |
| 745 | if (!escape && **pattern == '\\') { |
| 746 | escape = *pattern; |
| 747 | next(pattern, pattern_end); |
| 748 | continue; |
| 749 | } |
| 750 | |
| 751 | // Check if the chars match, if so, increment the ptrs. |
| 752 | const CHAR* pattern_next = *pattern; |
| 753 | const CHAR* string_next = *string; |
| 754 | base_icu::UChar32 pattern_char = next(&pattern_next, pattern_end); |
| 755 | if (pattern_char == next(&string_next, string_end) && |
| 756 | pattern_char != (base_icu::UChar32) CBU_SENTINEL) { |
| 757 | *pattern = pattern_next; |
| 758 | *string = string_next; |
| 759 | } else { |
| 760 | // Uh ho, it did not match, we are done. If the last char was an |
| 761 | // escapement, that means that it was an error to advance the ptr here, |
| 762 | // let's put it back where it was. This also mean that the MatchPattern |
| 763 | // function will return false because if we can't match an escape char |
| 764 | // here, then no one will. |
| 765 | if (escape) { |
| 766 | *pattern = escape; |
| 767 | } |
| 768 | return; |
| 769 | } |
| 770 | |
| 771 | escape = NULL; |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | template <typename CHAR, typename NEXT> |
| 776 | static void EatWildcard(const CHAR** pattern, const CHAR* end, NEXT next) { |
no test coverage detected