| 609 | } |
| 610 | |
| 611 | bool Token::simpleMatch(const Token *tok, const char pattern[], size_t pattern_len) |
| 612 | { |
| 613 | if (!tok) |
| 614 | return false; // shortcut |
| 615 | const char *current = pattern; |
| 616 | const char *end = pattern + pattern_len; |
| 617 | const char *next = static_cast<const char*>(std::memchr(pattern, ' ', pattern_len)); |
| 618 | if (!next) |
| 619 | next = end; |
| 620 | |
| 621 | while (*current) { |
| 622 | const std::size_t length = next - current; |
| 623 | |
| 624 | if (!tok || length != tok->mStr.length() || std::strncmp(current, tok->mStr.c_str(), length) != 0) |
| 625 | return false; |
| 626 | |
| 627 | current = next; |
| 628 | if (*next) { |
| 629 | next = std::strchr(++current, ' '); |
| 630 | if (!next) |
| 631 | next = end; |
| 632 | } |
| 633 | tok = tok->next(); |
| 634 | } |
| 635 | |
| 636 | return true; |
| 637 | } |
| 638 | |
| 639 | bool Token::firstWordEquals(const char *s, const char *word) |
| 640 | { |
no test coverage detected