Return true if a string (p1, l1) matches a given pattern (p2, l2). The character '?' in the pattern may match any single character in the the string, and the character '*' may match any sequence of characters. Wide SCHAR version operates on short-based buffer, instead of SCHAR-based. Matches is not a case-sensitive operation, thus it has no 8-bit international impact.
| 604 | // Matches is not a case-sensitive operation, thus it has no |
| 605 | // 8-bit international impact. |
| 606 | static bool matches(MemoryPool& pool, Jrd::TextType* obj, const CharType* p1, |
| 607 | SLONG l1_bytes, const CharType* p2, SLONG l2_bytes) |
| 608 | { |
| 609 | fb_assert(p1 != NULL); |
| 610 | fb_assert(p2 != NULL); |
| 611 | fb_assert((l1_bytes % sizeof(CharType)) == 0); |
| 612 | fb_assert((l2_bytes % sizeof(CharType)) == 0); |
| 613 | fb_assert((obj->getCanonicalWidth() == sizeof(CharType))); |
| 614 | |
| 615 | SLONG l1 = l1_bytes / sizeof(CharType); |
| 616 | SLONG l2 = l2_bytes / sizeof(CharType); |
| 617 | |
| 618 | while (l2-- > 0) |
| 619 | { |
| 620 | const CharType c = *p2++; |
| 621 | if (c == *(CharType*) obj->getCanonicalChar(CHAR_GDML_MATCH_ANY)) |
| 622 | { |
| 623 | while ((l2 > 0) && (*p2 == *(CharType*) obj->getCanonicalChar(CHAR_GDML_MATCH_ANY))) |
| 624 | { |
| 625 | l2--; |
| 626 | p2++; |
| 627 | } |
| 628 | if (l2 == 0) |
| 629 | return true; |
| 630 | while (l1) |
| 631 | { |
| 632 | if (matches(pool, obj, p1++, l1-- * sizeof(CharType), p2, l2 * sizeof(CharType))) |
| 633 | return true; |
| 634 | } |
| 635 | return false; |
| 636 | } |
| 637 | if (l1-- == 0) |
| 638 | return false; |
| 639 | if (c != *(CharType*) obj->getCanonicalChar(CHAR_GDML_MATCH_ONE) && c != *p1) |
| 640 | return false; |
| 641 | p1++; |
| 642 | } |
| 643 | |
| 644 | return !l1; |
| 645 | } |
| 646 | }; |
| 647 | |
| 648 | template <typename CharType, typename StrConverter = CanonicalConverter<> > |
nothing calls this directly
no test coverage detected