Skip to content

Commit

Permalink
Library: corrected usage of Container::startPattern2 in `detectCont…
Browse files Browse the repository at this point in the history
…ainerInternal()`
  • Loading branch information
firewave committed Jan 22, 2024
1 parent 74f1bb0 commit f1ad3c2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
const char* const startPattern = node->Attribute("startPattern");
if (startPattern) {
container.startPattern = startPattern;
container.startPattern2 = container.startPattern + " !!::";
if (!endsWith(container.startPattern, '<'))
container.startPattern2 = container.startPattern + " !!::";
}
const char* const endPattern = node->Attribute("endPattern");
if (endPattern)
Expand Down Expand Up @@ -1184,11 +1185,13 @@ const Library::Container* Library::detectContainerInternal(const Token* const ty
if (container.startPattern.empty())
continue;

const int offset = (withoutStd && startsWith(container.startPattern2, "std :: ")) ? 7 : 0;
const std::string& startPattern = container.startPattern2.empty() ? container.startPattern : container.startPattern2;

const int offset = (withoutStd && startsWith(startPattern, "std :: ")) ? 7 : 0;

// If endPattern is undefined, it will always match, but itEndPattern has to be defined.
if (detect != IteratorOnly && container.endPattern.empty()) {
if (!Token::Match(typeStart, container.startPattern2.c_str() + offset))
if (!Token::Match(typeStart, startPattern.c_str() + offset))
continue;

if (isIterator)
Expand All @@ -1199,7 +1202,7 @@ const Library::Container* Library::detectContainerInternal(const Token* const ty
if (!firstLinkedTok)
continue;

const bool matchedStartPattern = Token::Match(typeStart, container.startPattern2.c_str() + offset);
const bool matchedStartPattern = Token::Match(typeStart, startPattern.c_str() + offset);
if (!matchedStartPattern)
continue;

Expand Down

0 comments on commit f1ad3c2

Please sign in to comment.