From 8cf2e86f700abdf24b1f2a18c9c00accc3645395 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:01:36 +0200 Subject: [PATCH 1/2] Update suppressions.cpp --- lib/suppressions.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 71481f324a5..f2e2836f3c4 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -85,10 +85,16 @@ std::string SuppressionList::parseFile(std::istream &istr) if (line.empty()) continue; + std::string::size_type pos = 0; + while (pos < line.size() && std::isspace(line[pos])) + ++pos; + if (pos == line.size()) + continue; + // Skip comments - if (line.length() > 1 && line[0] == '#') + if (line[pos] == '#') continue; - if (line.length() >= 2 && line[0] == '/' && line[1] == '/') + if (pos < line.size() - 1 && line[pos] == '/' && line[pos + 1] == '/') continue; const std::string errmsg(addSuppressionLine(line)); From 9b67a4e22510219740b2324ddf56e613986cd7cb Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:02:43 +0200 Subject: [PATCH 2/2] Update testsuppressions.cpp --- test/testsuppressions.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 4fa552679ec..d206f1f1b2a 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -967,6 +967,12 @@ class TestSuppressions : public TestFixture { SuppressionList suppressions6; ASSERT_EQUALS("", suppressions6.parseFile(file6)); ASSERT_EQUALS(true, suppressions6.isSuppressed(errorMessage("abc", "test.cpp", 123))); + + std::istringstream file7(" // comment\n" // #11450 + "abc"); + SuppressionList suppressions7; + ASSERT_EQUALS("", suppressions7.parseFile(file7)); + ASSERT_EQUALS(true, suppressions7.isSuppressed(errorMessage("abc", "test.cpp", 123))); } void inlinesuppress() const {