From 45e5dc20a2aa83932fb1cd29e7dd30f8d9ddfb4f Mon Sep 17 00:00:00 2001 From: Raphael Geissert Date: Wed, 2 Feb 2011 10:01:09 -0600 Subject: [PATCH] Try to match custom rules as many times as possible, not just once --- lib/cppcheck.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 951ca3470..8364e379e 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -340,11 +340,14 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) int pos = 0; int ovector[30]; - if (0 <= pcre_exec(re, NULL, str.c_str(), (int)str.size(), pos, 0, ovector, 30)) + while (0 <= pcre_exec(re, NULL, str.c_str(), (int)str.size(), pos, 0, ovector, 30)) { unsigned int pos1 = (unsigned int)ovector[0]; unsigned int pos2 = (unsigned int)ovector[1]; + // jump to the end of the match for the next pcre_exec + pos = pos2; + // determine location.. ErrorLogger::ErrorMessage::FileLocation loc; loc.setfile(_tokenizer.getFiles()->front());