From d5865692304c29ba8ea657a9b4a516e107a5aa9b Mon Sep 17 00:00:00 2001 From: swasti16 Date: Fri, 16 Aug 2024 16:31:50 +0530 Subject: [PATCH] Fix #13012: Duplicated misra warnings from misra.py and premiumaddon are not filtered properly in windows --- lib/settings.cpp | 2 ++ test/testsettings.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/settings.cpp b/lib/settings.cpp index e132ebcd00e..63d7d08f9bd 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -669,6 +669,8 @@ void Settings::setMisraRuleTexts(const std::string& data) std::string text = line.substr(pos + 1); if (id.empty() || text.empty()) continue; + if (text[text.size() -1] == '\r') + text.erase(text.size() -1); mMisraRuleTexts[id] = std::move(text); } } diff --git a/test/testsettings.cpp b/test/testsettings.cpp index be2c4353f8a..df79dd3d70f 100644 --- a/test/testsettings.cpp +++ b/test/testsettings.cpp @@ -263,9 +263,10 @@ class TestSettings : public TestFixture { void ruleTexts() const { Settings s; - s.setMisraRuleTexts("1.1 text 1\n1.2 text 2\n"); + s.setMisraRuleTexts("1.1 text 1\n1.2 text 2\n1.3 text 3\r\n"); ASSERT_EQUALS("text 1", s.getMisraRuleText("misra-c2012-1.1", "---")); ASSERT_EQUALS("text 2", s.getMisraRuleText("misra-c2012-1.2", "---")); + ASSERT_EQUALS("text 3", s.getMisraRuleText("misra-c2012-1.3", "---")); } void checkLevelDefault() const