From 0e70c8a916ad2da70b1451da67fcfc2dd6bc288e Mon Sep 17 00:00:00 2001 From: Konrad Grochowski Date: Fri, 17 Aug 2018 08:20:39 +0200 Subject: [PATCH] Added '-' and '.' to allowed chars in error ids for suppressions. (#1338) Those chars are used for example in misra.py --- lib/suppressions.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 1c1c4ed73..8a0625eac 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -45,6 +45,18 @@ static bool isValidGlobPattern(const std::string &pattern) return true; } +static bool isAcceptedErrorIdChar(char c) +{ + switch (c) { + case '_': + case '-': + case '.': + return true; + default: + return std::isalnum(c); + } +} + std::string Suppressions::parseFile(std::istream &istr) { // Change '\r' to '\n' in the istr @@ -155,7 +167,7 @@ std::string Suppressions::addSuppression(const Suppressions::Suppression &suppre } if (suppression.errorId != "*") { for (std::string::size_type pos = 0; pos < suppression.errorId.length(); ++pos) { - if (suppression.errorId[pos] < 0 || (!std::isalnum(suppression.errorId[pos]) && suppression.errorId[pos] != '_')) { + if (suppression.errorId[pos] < 0 || !isAcceptedErrorIdChar(suppression.errorId[pos])) { return "Failed to add suppression. Invalid id \"" + suppression.errorId + "\""; } if (pos == 0 && std::isdigit(suppression.errorId[pos])) {