MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / simpleMatch

Method simpleMatch

lib/token.cpp:611–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609}
610
611bool 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
639bool Token::firstWordEquals(const char *s, const char *word)
640{

Callers 5

simpleMatchFunction · 0.80
simpleMatchFunction · 0.80
misra_configMethod · 0.80
misra_18_7Method · 0.80
misra_22_5Method · 0.80

Calls 1

nextMethod · 0.80

Tested by

no test coverage detected