Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_set>
- #include <string>
- #include <QDir>
- #include <QProcess>
- #include <QCoreApplication>
- #include <QFileInfo>
- #include <QDebug>
- int main(int argc, char** argv) {
- QProcess qprocess;
- qprocess.start("gcc", {QString(argv[1]), "-o /dev/null"});
- qprocess.waitForFinished();
- QByteArray Err = qprocess.readAllStandardError();
- std::unordered_set<int> warnings, errors;
- QRegExp warning_expr(".*(\\d+):\\d+: warning:.*");
- QRegExp error_expr(".*(\\d+):\\d+: error:.*");
- std::string s = "";
- std::string err = Err.toStdString();
- for (size_t i = 0; i < err.size(); i++) {
- if (err[i] != '\n') {
- s += err[i];
- } else {
- s = "";
- }
- if (warning_expr.exactMatch(QString(s.c_str()))) {
- warnings.insert(warning_expr.cap(1).toInt());
- }
- if (error_expr.exactMatch(QString(s.c_str()))) {
- errors.insert(error_expr.cap(1).toInt());
- }
- }
- std::cout << errors.size() << "\n";
- std::cout << warnings.size() << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement