MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / match

Method match

lib/regex.cpp:226–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224 }
225
226 std::string PcreRegex::match(const std::string& str, const MatchFn& matchFn) const
227 {
228 if (!mRe)
229 return "regular expression has not been compiled yet";
230
231 int pos = 0;
232 int ovector[30]= {0};
233 while (pos < static_cast<int>(str.size())) {
234 const int pcreExecRet = pcre_exec(mRe, mExtra, str.c_str(), static_cast<int>(str.size()), pos, 0, ovector, 30);
235 if (pcreExecRet == PCRE_ERROR_NOMATCH)
236 return "";
237 if (pcreExecRet < 0) {
238 return pcreErrorCodeToString(pcreExecRet) + " (pos: " + std::to_string(pos) + ")";
239 }
240 const auto pos1 = static_cast<unsigned int>(ovector[0]);
241 const auto pos2 = static_cast<unsigned int>(ovector[1]);
242
243 matchFn(pos1, pos2);
244
245 // jump to the end of the match for the next pcre_exec
246 pos = static_cast<int>(pos2);
247 }
248
249 return "";
250 }
251}
252
253template<typename T>

Callers 15

ignorePathsMethod · 0.45
importVcxprojMethod · 0.45
importVcxitemsMethod · 0.45
executeRulesMethod · 0.45
fillSettingsFromArgsMethod · 0.45
filterFilesMethod · 0.45
addFiles2Function · 0.45
applyExcludeListMethod · 0.45
highlightBlockMethod · 0.45
clearResultsMethod · 0.45
numberOfReportsFunction · 0.45
parseClangErrorsMethod · 0.45

Calls 2

pcreErrorCodeToStringFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected