| 87 | } |
| 88 | |
| 89 | void Job::postProcessStderr(const QStringList& lines) |
| 90 | { |
| 91 | static const auto xmlStartRegex = QRegularExpression(QStringLiteral("\\s*<")); |
| 92 | |
| 93 | for (const QString & line : lines) { |
| 94 | // unfortunately sometime cppcheck send non-XML messages to stderr. |
| 95 | // For example, if we pass '-I /missing_include_dir' to the argument list, |
| 96 | // then stderr output will contains such line (tested on cppcheck 1.72): |
| 97 | // |
| 98 | // (information) Couldn't find path given by -I '/missing_include_dir' |
| 99 | // |
| 100 | // Therefore we must 'move' such messages to m_standardOutput. |
| 101 | |
| 102 | if (line.indexOf(xmlStartRegex) != -1) { // the line contains XML |
| 103 | m_xmlOutput << line; |
| 104 | |
| 105 | m_parser->addData(line); |
| 106 | |
| 107 | m_problems = m_parser->parse(); |
| 108 | emitProblems(); |
| 109 | } |
| 110 | else { |
| 111 | KDevelop::IProblem::Ptr problem(new KDevelop::DetectedProblem(i18n("Cppcheck"))); |
| 112 | |
| 113 | problem->setSeverity(KDevelop::IProblem::Error); |
| 114 | problem->setDescription(line); |
| 115 | problem->setExplanation(QStringLiteral("Check your cppcheck settings")); |
| 116 | |
| 117 | m_problems = {problem}; |
| 118 | emitProblems(); |
| 119 | |
| 120 | if (m_showXmlOutput) { |
| 121 | m_standardOutput << line; |
| 122 | } else { |
| 123 | postProcessStdout({line}); |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | if (status() == KDevelop::OutputExecuteJob::JobStatus::JobRunning && m_showXmlOutput) { |
| 129 | KDevelop::OutputExecuteJob::postProcessStderr(lines); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | void Job::start() |
| 134 | { |