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