diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index 58123f844..b7beee0dd 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include static bool executeCommand(std::string exe, std::vector args, std::string redirect, std::string *output) @@ -307,8 +307,8 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS { QList errorItems; ErrorItem errorItem; - QRegExp r1("(.+):([0-9]+):([0-9]+): (note|warning|error|fatal error): (.*)"); - QRegExp r2("(.*)\\[([a-zA-Z0-9\\-_\\.]+)\\]"); + const QRegularExpression r1("^(.+):([0-9]+):([0-9]+): (note|warning|error|fatal error): (.*)$"); + const QRegularExpression r2("^(.*)\\[([a-zA-Z0-9\\-_\\.]+)\\]$"); QTextStream in(&err, QIODevice::ReadOnly); while (!in.atEnd()) { QString line = in.readLine(); @@ -327,31 +327,33 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS continue; } - if (!r1.exactMatch(line)) + const QRegularExpressionMatch r1MatchRes = r1.match(line); + if (!r1MatchRes.hasMatch()) continue; - if (r1.cap(4) != "note") { + if (r1MatchRes.captured(4) != "note") { errorItems.append(errorItem); errorItem = ErrorItem(); - errorItem.file0 = r1.cap(1); + errorItem.file0 = r1MatchRes.captured(1); } errorItem.errorPath.append(QErrorPathItem()); - errorItem.errorPath.last().file = r1.cap(1); - errorItem.errorPath.last().line = r1.cap(2).toInt(); - errorItem.errorPath.last().column = r1.cap(3).toInt(); - if (r1.cap(4) == "warning") + errorItem.errorPath.last().file = r1MatchRes.captured(1); + errorItem.errorPath.last().line = r1MatchRes.captured(2).toInt(); + errorItem.errorPath.last().column = r1MatchRes.captured(3).toInt(); + if (r1MatchRes.captured(4) == "warning") errorItem.severity = Severity::SeverityType::warning; - else if (r1.cap(4) == "error" || r1.cap(4) == "fatal error") + else if (r1MatchRes.captured(4) == "error" || r1MatchRes.captured(4) == "fatal error") errorItem.severity = Severity::SeverityType::error; QString message,id; - if (r2.exactMatch(r1.cap(5))) { - message = r2.cap(1); - const QString id1(r2.cap(2)); + const QRegularExpressionMatch r2MatchRes = r2.match(r1MatchRes.captured(5)); + if (r2MatchRes.hasMatch()) { + message = r2MatchRes.captured(1); + const QString id1(r2MatchRes.captured(2)); if (id1.startsWith("clang")) id = id1; else - id = tool + '-' + r2.cap(2); + id = tool + '-' + r2MatchRes.captured(2); if (tool == CLANG_TIDY) { if (id1.startsWith("performance")) errorItem.severity = Severity::SeverityType::performance; @@ -363,7 +365,7 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS errorItem.severity = Severity::SeverityType::style; } } else { - message = r1.cap(5); + message = r1MatchRes.captured(5); id = CLANG_ANALYZER; } diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index ebea93e9f..1baa835bf 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -1723,82 +1723,82 @@ Options: ProjectFileDialog - + Project file: %1 Projektdatei: %1 - + Select Cppcheck build dir Wähle Cppcheck-Erstellungsverzeichnis - + Select include directory Wähle Include-Verzeichnisse - + Select a directory to check Wähle zu prüfendes Verzeichnis - + (no rule texts file) (keine Regeltexte) - + Clang-tidy (not found) Clang-tidy (nicht gefunden) - + Visual Studio Visual Studio - + Compile database Compilerdatenbank - + Borland C++ Builder 6 Borland C++-Builder 6 - + Import Project Projekt importieren - + Select directory to ignore Wähle zu ignorierendes Verzeichnis - + Source files - + All files - + Exclude file - + Select MISRA rule texts file Wähle MISRA-Regeltext-Datei - + MISRA rule texts file (%1) MISRA-Regeltext-Datei @@ -1850,7 +1850,7 @@ Options: - + (Not found) (nicht gefunden) diff --git a/gui/cppcheck_es.ts b/gui/cppcheck_es.ts index 4939ca964..0fa077eb3 100644 --- a/gui/cppcheck_es.ts +++ b/gui/cppcheck_es.ts @@ -1849,72 +1849,72 @@ Options: ProjectFileDialog - + Project file: %1 Archivo de proyecto: %1 - + Select Cppcheck build dir - + Select include directory Selecciona una carpeta para incluir - + Select a directory to check Selecciona la carpeta a comprobar - + (no rule texts file) - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore Selecciona la carpeta a ignorar - + Source files - + All files - + Exclude file @@ -1923,12 +1923,12 @@ Options: Añadir supresión - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -1980,7 +1980,7 @@ Options: - + (Not found) diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index 3353c0351..d11883d2c 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -1695,82 +1695,82 @@ Options: ProjectFileDialog - + Project file: %1 - + Select Cppcheck build dir - + Select include directory - + Select a directory to check - + (no rule texts file) - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -1805,7 +1805,7 @@ Options: - + (Not found) diff --git a/gui/cppcheck_fr.ts b/gui/cppcheck_fr.ts index db7d09c6b..3dd7679a3 100644 --- a/gui/cppcheck_fr.ts +++ b/gui/cppcheck_fr.ts @@ -1760,82 +1760,82 @@ Do you want to proceed? ProjectFileDialog - + Project file: %1 Fichier projet : %1 - + Select include directory Selectionner un répertoire à inclure - + Select directory to ignore Selectionner un répertoire à ignorer - + Select a directory to check Selectionner un répertoire à vérifier - + Select Cppcheck build dir - + Import Project - + Clang-tidy (not found) - + (no rule texts file) - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) - + Visual Studio - + Compile database - + Borland C++ Builder 6 @@ -1887,7 +1887,7 @@ Do you want to proceed? - + (Not found) diff --git a/gui/cppcheck_it.ts b/gui/cppcheck_it.ts index c0f04c1cd..1d6f2a651 100644 --- a/gui/cppcheck_it.ts +++ b/gui/cppcheck_it.ts @@ -1862,82 +1862,82 @@ Options: ProjectFileDialog - + Project file: %1 File di progetto: %1 - + Select Cppcheck build dir - + Select include directory Seleziona la cartella da includere - + Select a directory to check Seleziona una cartella da scansionare - + (no rule texts file) - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore Seleziona la cartella da ignorare - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -1977,7 +1977,7 @@ Options: - + (Not found) diff --git a/gui/cppcheck_ja.ts b/gui/cppcheck_ja.ts index b42453557..a11198d68 100644 --- a/gui/cppcheck_ja.ts +++ b/gui/cppcheck_ja.ts @@ -1963,12 +1963,12 @@ Options: ProjectFileDialog - + Project file: %1 プロジェクトファイル:%1 - + Select Cppcheck build dir Cppcheckビルドディレクトリ @@ -1977,62 +1977,62 @@ Options: Visual Studio (*.sln *.vcxproj);;コンパイルデータベース (compile_commands.json) - + Select include directory includeディレクトリを選択 - + Select a directory to check チェックするディレクトリを選択してください - + (no rule texts file) (ルールテキストファイルがない) - + Clang-tidy (not found) Clang-tidy (みつかりません) - + Visual Studio Visual Studio - + Compile database コンパイルデータベース - + Borland C++ Builder 6 Borland C++ Builder 6 - + Import Project プロジェクトのインポート - + Select directory to ignore 除外するディレクトリを選択してください - + Source files ソースファイル - + All files 全ファイル - + Exclude file 除外ファイル @@ -2045,12 +2045,12 @@ Options: 抑制するエラーID(error id)を選択してください - + Select MISRA rule texts file MISRAルールテキストファイルを選択 - + MISRA rule texts file (%1) MISRAルールテキストファイル (%1) @@ -2102,7 +2102,7 @@ Options: 行 %1: 必須の属性 '%2' が '%3'にない - + (Not found) (見つかりません) diff --git a/gui/cppcheck_ko.ts b/gui/cppcheck_ko.ts index 669271e3f..d83d3c699 100644 --- a/gui/cppcheck_ko.ts +++ b/gui/cppcheck_ko.ts @@ -1843,82 +1843,82 @@ Do you want to proceed? ProjectFileDialog - + Project file: %1 프로젝트 파일: %1 - + Select include directory Include 디렉토리 선택 - + Select a directory to check 검사할 디렉토리 선택 - + Select directory to ignore 무시할 디렉토리 선택 - + Select Cppcheck build dir - + Import Project - + Clang-tidy (not found) - + (no rule texts file) - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) - + Visual Studio - + Compile database - + Borland C++ Builder 6 @@ -1958,7 +1958,7 @@ Do you want to proceed? - + (Not found) diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts index 222f224ee..abafcfabe 100644 --- a/gui/cppcheck_nl.ts +++ b/gui/cppcheck_nl.ts @@ -1844,82 +1844,82 @@ Options: ProjectFileDialog - + Project file: %1 Project Bestand %1 - + Select Cppcheck build dir - + Select include directory Selecteer include map - + Select a directory to check Selecteer een map om te controleren - + (no rule texts file) - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore Selecteer een map om te negeren - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -1969,7 +1969,7 @@ Options: - + (Not found) diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 8e6f55c26..803d3dbaa 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -1962,82 +1962,82 @@ Options: ProjectFileDialog - + Project file: %1 Файл проекта: %1 - + Select Cppcheck build dir Выбрать директорию сборки Cppcheck - + Select include directory Выберите директорию для поиска заголовочных файлов - + Select a directory to check Выберите директорию для проверки - + (no rule texts file) (файл с текстами правил недоступен) - + Clang-tidy (not found) Clang-tidy (не найден) - + Visual Studio Visual Studio - + Compile database - + Borland C++ Builder 6 Borland C++ Builder 6 - + Import Project Импорт проекта - + Select directory to ignore Выберите директорию, которую надо проигнорировать - + Source files - + All files - + Exclude file - + Select MISRA rule texts file Выбрать файл текстов правил MISRA - + MISRA rule texts file (%1) Файл текстов правил MISRA (%1) @@ -2091,7 +2091,7 @@ Options: - + (Not found) (Недоступно) diff --git a/gui/cppcheck_sr.ts b/gui/cppcheck_sr.ts index 4404bc4aa..67e3bd7ac 100644 --- a/gui/cppcheck_sr.ts +++ b/gui/cppcheck_sr.ts @@ -1720,82 +1720,82 @@ Options: ProjectFileDialog - + Project file: %1 - + Select Cppcheck build dir - + Select include directory - + Select a directory to check - + (no rule texts file) - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -1828,7 +1828,7 @@ Options: - + (Not found) diff --git a/gui/cppcheck_sv.ts b/gui/cppcheck_sv.ts index 37626a0a7..ec73d8fa7 100644 --- a/gui/cppcheck_sv.ts +++ b/gui/cppcheck_sv.ts @@ -2006,22 +2006,22 @@ Sökvägar och defines importeras. ProjectFileDialog - + Project file: %1 Projektfil: %1 - + (no rule texts file) - + Clang-tidy (not found) - + Select Cppcheck build dir Välj Cppcheck build dir @@ -2030,57 +2030,57 @@ Sökvägar och defines importeras. Visual Studio (*.sln *.vcxproj);;Compile database (compile_commands.json) - + Select include directory Välj include sökväg - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) - + Select a directory to check Välj mapp att analysera - + Visual Studio Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project Importera Projekt @@ -2089,7 +2089,7 @@ Sökvägar och defines importeras. Visual Studio (*.sln *.vcxproj);;Compile database (compile_database.json) - + Select directory to ignore Välj sökväg att ignorera @@ -2151,7 +2151,7 @@ Sökvägar och defines importeras. - + (Not found) diff --git a/gui/cppcheck_zh_CN.ts b/gui/cppcheck_zh_CN.ts index 14963f3b3..b1d31d693 100644 --- a/gui/cppcheck_zh_CN.ts +++ b/gui/cppcheck_zh_CN.ts @@ -1898,82 +1898,82 @@ Options: ProjectFileDialog - + Project file: %1 项目文件: %1 - + Select Cppcheck build dir 选择 Cppcheck 构建目录 - + Select include directory 选择 Include 目录 - + Select a directory to check 选择一个检查目录 - + (no rule texts file) (无规则文本文件) - + Clang-tidy (not found) Clang-tidy (未找到) - + Visual Studio Visual Studio - + Compile database Compile database - + Borland C++ Builder 6 Borland C++ Builder 6 - + Import Project 导入项目 - + Select directory to ignore 选择忽略的目录 - + Source files 源文件 - + All files 全部文件 - + Exclude file 排除文件 - + Select MISRA rule texts file 选择 MISRA 规则文本文件 - + MISRA rule texts file (%1) MISRA 规则文本文件 (%1) @@ -2013,7 +2013,7 @@ Options: 第%1行:在 "%3" 中缺失的必选属性 "%2" - + (Not found) (未找到) diff --git a/gui/libraryaddfunctiondialog.cpp b/gui/libraryaddfunctiondialog.cpp index 7507d476a..5fc979b1f 100644 --- a/gui/libraryaddfunctiondialog.cpp +++ b/gui/libraryaddfunctiondialog.cpp @@ -20,15 +20,16 @@ #include "ui_libraryaddfunctiondialog.h" -#include +#include +#include LibraryAddFunctionDialog::LibraryAddFunctionDialog(QWidget *parent) : QDialog(parent), mUi(new Ui::LibraryAddFunctionDialog) { mUi->setupUi(this); - QRegExp rx(NAMES); - QValidator *validator = new QRegExpValidator(rx, this); + const QRegularExpression rx(NAMES); + QValidator *validator = new QRegularExpressionValidator(rx, this); mUi->functionName->setValidator(validator); } diff --git a/gui/librarydialog.cpp b/gui/librarydialog.cpp index 22edbd63f..66f26d97d 100644 --- a/gui/librarydialog.cpp +++ b/gui/librarydialog.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include // TODO: get/compare functions from header @@ -198,7 +198,8 @@ void LibraryDialog::editFunctionName(QListWidgetItem* item) QString functionName = item->text(); CppcheckLibraryData::Function * const function = dynamic_cast(item)->function; if (functionName != function->name) { - if (QRegExp(NAMES).exactMatch(functionName)) { + const QRegularExpressionMatch matchRes = QRegularExpression("^" NAMES "$").match(functionName); + if (matchRes.hasMatch()) { function->name = functionName; mUi->buttonSave->setEnabled(true); } else { diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index bacc9fd9d..c62040990 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include @@ -262,9 +262,9 @@ void MainWindow::handleCLIParams(const QStringList ¶ms) } else { loadResults(logFile); } - } else if ((index = params.indexOf(QRegExp(".*\\.cppcheck$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) { + } else if ((index = params.indexOf(QRegularExpression(".*\\.cppcheck$", QRegularExpression::CaseInsensitiveOption), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) { loadProjectFile(params[index]); - } else if ((index = params.indexOf(QRegExp(".*\\.xml$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) { + } else if ((index = params.indexOf(QRegularExpression(".*\\.xml$", QRegularExpression::CaseInsensitiveOption), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) { loadResults(params[index],QDir::currentPath()); } else doAnalyzeFiles(params); @@ -1179,7 +1179,7 @@ void MainWindow::clearResults() if (mProjectFile && !mProjectFile->getBuildDir().isEmpty()) { QDir dir(QFileInfo(mProjectFile->getFilename()).absolutePath() + '/' + mProjectFile->getBuildDir()); for (const QString& f: dir.entryList(QDir::Files)) { - if (!f.endsWith("files.txt") && !QRegExp(".*.s[0-9]+$").exactMatch(f)) + if (!f.endsWith("files.txt") && !QRegularExpression("^.*.s[0-9]+$").match(f).hasMatch()) dir.remove(f); } } diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 3cbc7cab2..0ba3be170 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -31,7 +31,8 @@ #include #include #include -#include +#include +#include #include /** Return paths from QListWidget */ @@ -183,10 +184,10 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, QWidget *parent) platformFiles.sort(); mUI->mComboBoxPlatform->addItems(platformFiles); - mUI->mEditTags->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9 ;]*"),this)); + mUI->mEditTags->setValidator(new QRegularExpressionValidator(QRegularExpression("[a-zA-Z0-9 ;]*"),this)); - const QRegExp undefRegExp("\\s*([a-zA-Z_][a-zA-Z0-9_]*[; ]*)*"); - mUI->mEditUndefines->setValidator(new QRegExpValidator(undefRegExp, this)); + const QRegularExpression undefRegExp("\\s*([a-zA-Z_][a-zA-Z0-9_]*[; ]*)*"); + mUI->mEditUndefines->setValidator(new QRegularExpressionValidator(undefRegExp, this)); connect(mUI->mButtons, &QDialogButtonBox::accepted, this, &ProjectFileDialog::ok); connect(mUI->mBtnBrowseBuildDir, &QPushButton::clicked, this, &ProjectFileDialog::browseBuildDir); @@ -595,9 +596,9 @@ QStringList ProjectFileDialog::getIncludePaths() const QStringList ProjectFileDialog::getDefines() const { #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - return mUI->mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), Qt::SkipEmptyParts); + return mUI->mEditDefines->text().trimmed().split(QRegularExpression("\\s*;\\s*"), Qt::SkipEmptyParts); #else - return mUI->mEditDefines->text().trimmed().split(QRegExp("\\s*;\\s*"), QString::SkipEmptyParts); + return mUI->mEditDefines->text().trimmed().split(QRegularExpression("\\s*;\\s*"), QString::SkipEmptyParts); #endif } @@ -605,9 +606,9 @@ QStringList ProjectFileDialog::getUndefines() const { const QString undefine = mUI->mEditUndefines->text().trimmed(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - QStringList undefines = undefine.split(QRegExp("\\s*;\\s*"), Qt::SkipEmptyParts); + QStringList undefines = undefine.split(QRegularExpression("\\s*;\\s*"), Qt::SkipEmptyParts); #else - QStringList undefines = undefine.split(QRegExp("\\s*;\\s*"), QString::SkipEmptyParts); + QStringList undefines = undefine.split(QRegularExpression("\\s*;\\s*"), QString::SkipEmptyParts); #endif undefines.removeDuplicates(); return undefines; diff --git a/gui/statsdialog.cpp b/gui/statsdialog.cpp index 9285ada49..85c51e121 100644 --- a/gui/statsdialog.cpp +++ b/gui/statsdialog.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -406,11 +406,12 @@ QLineSeries *StatsDialog::numberOfReports(const QString &fileName, const QString QTextStream in(&f); while (!in.atEnd()) { QString line = in.readLine(); - QRegExp rxdate("\\[(\\d\\d)\\.(\\d\\d)\\.(\\d\\d\\d\\d)\\]"); - if (rxdate.exactMatch(line)) { - int y = rxdate.cap(3).toInt(); - int m = rxdate.cap(2).toInt(); - int d = rxdate.cap(1).toInt(); + const QRegularExpression rxdate("^\\[(\\d\\d)\\.(\\d\\d)\\.(\\d\\d\\d\\d)\\]$"); + const QRegularExpressionMatch matchRes = rxdate.match(line); + if (matchRes.hasMatch()) { + int y = matchRes.captured(3).toInt(); + int m = matchRes.captured(2).toInt(); + int d = matchRes.captured(1).toInt(); QDateTime dt; dt.setDate(QDate(y,m,d)); if (t == dt.toMSecsSinceEpoch()) diff --git a/gui/variablecontractsdialog.cpp b/gui/variablecontractsdialog.cpp index 9959965e3..8bbfb7089 100644 --- a/gui/variablecontractsdialog.cpp +++ b/gui/variablecontractsdialog.cpp @@ -20,7 +20,8 @@ #include "ui_variablecontractsdialog.h" -#include +#include +#include VariableContractsDialog::VariableContractsDialog(QWidget *parent, QString var) : QDialog(parent), @@ -45,8 +46,8 @@ VariableContractsDialog::VariableContractsDialog(QWidget *parent, QString var) : mUI->mMinValue->setText(getMinMax(var, "min")); mUI->mMaxValue->setText(getMinMax(var, "max")); - mUI->mMinValue->setValidator(new QRegExpValidator(QRegExp("-?[0-9]*"))); - mUI->mMaxValue->setValidator(new QRegExpValidator(QRegExp("-?[0-9]*"))); + mUI->mMinValue->setValidator(new QRegularExpressionValidator(QRegularExpression("-?[0-9]*"))); + mUI->mMaxValue->setValidator(new QRegularExpressionValidator(QRegularExpression("-?[0-9]*"))); } VariableContractsDialog::~VariableContractsDialog() diff --git a/tools/triage/mainwindow.cpp b/tools/triage/mainwindow.cpp index dcb2d577d..d872b6c18 100644 --- a/tools/triage/mainwindow.cpp +++ b/tools/triage/mainwindow.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include const QString WORK_FOLDER(QDir::homePath() + "/triage"); @@ -42,7 +43,7 @@ const int MAX_ERRORS = 100; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - mVersionRe("^(master|main|your|head|[12].[0-9][0-9]?) (.*)"), + mVersionRe("^(master|main|your|head|[12].[0-9][0-9]?) (.*)$"), hFiles{"*.hpp", "*.h", "*.hxx", "*.hh", "*.tpp", "*.txx", "*.ipp", "*.ixx"}, srcFiles{"*.cpp", "*.cxx", "*.cc", "*.c++", "*.C", "*.c", "*.cl"} { @@ -110,9 +111,10 @@ void MainWindow::load(QTextStream &textStream) if (!errorMessage.isEmpty()) mAllErrors << errorMessage; errorMessage.clear(); - } else if (!url.isEmpty() && QRegExp(".*: (error|warning|style|note):.*").exactMatch(line)) { - if (mVersionRe.exactMatch(line)) { - const QString version = mVersionRe.cap(1); + } else if (!url.isEmpty() && QRegularExpression("^.*: (error|warning|style|note):.*$").match(line).hasMatch()) { + const QRegularExpressionMatch matchRes = mVersionRe.match(line); + if (matchRes.hasMatch()) { + const QString version = matchRes.captured(1); if (versions.indexOf(version) < 0) versions << version; } @@ -260,8 +262,9 @@ void MainWindow::showResult(QListWidgetItem *item) return; const QString url = lines[0]; QString msg = lines[1]; - if (mVersionRe.exactMatch(msg)) - msg = mVersionRe.cap(2); + const QRegularExpressionMatch matchRes = mVersionRe.match(msg); + if (matchRes.hasMatch()) + msg = matchRes.captured(2); const QString archiveName = url.mid(url.lastIndexOf("/") + 1); const int pos1 = msg.indexOf(":"); const int pos2 = msg.indexOf(":", pos1+1); diff --git a/tools/triage/mainwindow.h b/tools/triage/mainwindow.h index 429ed6120..b429b4c4d 100644 --- a/tools/triage/mainwindow.h +++ b/tools/triage/mainwindow.h @@ -21,6 +21,7 @@ #include #include +#include #include class QListWidgetItem; @@ -61,7 +62,7 @@ private: QStringList mAllErrors; QFileSystemModel mFSmodel; - const QRegExp mVersionRe; + const QRegularExpression mVersionRe; const QStringList hFiles; const QStringList srcFiles;