Skip to content

Commit 69c27e9

Browse files
committed
matchArg refactoring
1 parent 31875b1 commit 69c27e9

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/suppressions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,10 @@ polyspace::Parser::Parser(const Settings &settings)
669669
if (pos == std::string::npos)
670670
return false;
671671

672-
if (pos > 0 && args[pos - 1] != ' ')
673-
return false;
672+
const char prevChar = (pos > 0) ? args[pos - 1] : ' ';
673+
const char nextChar = (pos + arg.size() < args.size()) ? args[pos + arg.size()] : ' ';
674674

675-
return pos == args.size() - arg.size() || args[pos + arg.size()] == ' ';
675+
return prevChar == ' ' && (nextChar == ' ' || nextChar == ':');
676676
};
677677

678678
if (matchArg("--misra-c-2012")) {

0 commit comments

Comments
 (0)