Skip to content

Commit 45ee4af

Browse files
author
William Jakobsson
committed
fix: strip trailing string from Misra C id extraction
1 parent 85b7902 commit 45ee4af

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/errorlogger.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,11 +1081,11 @@ std::string getGuideline(const std::string &errId, ReportType reportType,
10811081
case ReportType::misraC2023:
10821082
case ReportType::misraC2025:
10831083
if (errId.rfind("misra-c20", 0) == 0 || errId.rfind("premium-misra-c-20", 0) == 0) {
1084-
auto dashPos = errId.rfind('-');
1085-
while (dashPos != std::string::npos && isalpha(errId[dashPos + 1])) {
1086-
dashPos = errId.rfind('-', dashPos - 1);
1087-
}
1088-
guideline = errId.substr(dashPos + 1, errId.find('-', dashPos + 1) - dashPos - 1);
1084+
auto pos1 = errId.find("20") + 5;
1085+
if (errId.compare(pos1,4,"dir-",0,4) == 0)
1086+
pos1 += 4;
1087+
const auto endpos = errId.find('-', pos1);
1088+
guideline = errId.substr(pos1, endpos-pos1);
10891089
}
10901090
break;
10911091
case ReportType::misraCpp2008:

0 commit comments

Comments
 (0)