Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <unordered_set>
  3. #include <string>
  4. #include <QDir>
  5. #include <QProcess>
  6. #include <QCoreApplication>
  7. #include <QFileInfo>
  8. #include <QDebug>
  9.  
  10. int main(int argc, char** argv) {
  11. QProcess qprocess;
  12. qprocess.start("gcc", argv[1] + "-o tmpexe");
  13. qprocess.waitForFinished();
  14. QByteArray Err = qprocess.readAllStandardError();
  15.  
  16. std::unordered_set<int> warnings, errors;
  17. QRegExp warning_expr(".*(\\d+):\\d+: warning:.*");
  18. QRegExp error_expr(".*(\\d+):\\d+: error:.*");
  19.  
  20. std::string s = "";
  21. std::string err = Err.toStdString();
  22. for (size_t i = 0; i < err.size(); i++) {
  23. if (err[i] != '\n') {
  24. s += err[i];
  25. } else {
  26. s = "";
  27. }
  28. if (warning_expr.exactMatch(s)) {
  29. warnings.insert(warning_expr.cap(1).toInt());
  30. }
  31. if (error_expr.exactMatch(s)) {
  32. errors.insert(error_expr.cap(1).toInt());
  33. }
  34. }
  35.  
  36. std::cout << errors.size() << "\n";
  37. std::cout << warnings.size();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement