From 3c367373b291483a75f649bf3c1cb77c1b298dd7 Mon Sep 17 00:00:00 2001 From: Martin Ribelotta Date: Sat, 3 Sep 2016 21:49:20 -0300 Subject: [PATCH] Replace regex string b c++11 raw string Signed-off-by: Martin Ribelotta --- clangcodecontext.cpp | 2 +- codeeditor.cpp | 2 +- configdialog.cpp | 2 +- etags.cpp | 2 +- mainwindow.cpp | 2 +- projectnewdialog.cpp | 4 ++-- projectview.cpp | 5 +++-- targetupdatediscover.cpp | 20 ++++++++++---------- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/clangcodecontext.cpp b/clangcodecontext.cpp index 8ab272f..4d707a7 100644 --- a/clangcodecontext.cpp +++ b/clangcodecontext.cpp @@ -61,7 +61,7 @@ void CLangCodeContext::clangTerminated() { QStringList list; QString out = clangProc->readAll(); - QRegularExpression re("COMPLETION\\: ([^\\n]*)", QRegularExpression::MultilineOption); + QRegularExpression re(R"(COMPLETION\: ([^\n]*))", QRegularExpression::MultilineOption); QRegularExpressionMatchIterator it = re.globalMatch(out); while(it.hasNext()) { QRegularExpressionMatch m = it.next(); diff --git a/codeeditor.cpp b/codeeditor.cpp index 35b05a3..0c72ec8 100644 --- a/codeeditor.cpp +++ b/codeeditor.cpp @@ -155,7 +155,7 @@ void CodeEditor::insertCompletion(const QString &completion) QString s = completion; QTextCursor tc = textUnderCursor(); if (s.startsWith("Pattern : ")) { - s = s.remove("Pattern : ").remove(QRegExp("[\\<|\\[]\\#[^\\#]*\\#[\\>|\\]]")); + s = s.remove("Pattern : ").remove(QRegExp(R"([\\<|\[]\#[^\#]*\#[\>|\]])")); } else if (s.contains(':')) { s = s.split(':').at(0).trimmed(); } diff --git a/configdialog.cpp b/configdialog.cpp index 5f03231..62e343f 100644 --- a/configdialog.cpp +++ b/configdialog.cpp @@ -51,7 +51,7 @@ void adjustPath() QStringList pathList = path.split(path_separator); QStringList additional = QSettings().value("build/additional_path").toStringList() #ifdef Q_OS_WIN - .replaceInStrings("/", "\\") + .replaceInStrings("/", R"(\)") #endif ; pathList = additional + pathList; diff --git a/etags.cpp b/etags.cpp index 112fd69..0570db6 100644 --- a/etags.cpp +++ b/etags.cpp @@ -43,7 +43,7 @@ static QString processFileName(const QString& line, int *len) static void parseDefs(const QString& in, const QString& file, ETags::TagMap *map) { - QRegularExpression re("([^\\x7f]+)\\x7f([^\\x01]+)\\x01(\\d+),(\\d+)\\n"); + QRegularExpression re(R"(([^\x7f]+)\x7f([^\x01]+)\x01(\d+),(\d+)\n)"); QRegularExpressionMatchIterator it = re.globalMatch(in); while(it.hasNext()) { QRegularExpressionMatch m = it.next(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 4091024..2d03992 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -202,7 +202,7 @@ QString mkUrl(const QString& p, const QString& x, const QString& y) { static QString consoleMarkErrorT1(const QString& s) { QString str(s); - QRegularExpression re("^(.+?):(\\d+):(\\d+):(.+?):(.+?)$"); + QRegularExpression re(R"(^(.+?):(\d+):(\d+):(.+?):(.+?)$)"); re.setPatternOptions(QRegularExpression::MultilineOption); QRegularExpressionMatchIterator it = re.globalMatch(s); while(it.hasNext()) { diff --git a/projectnewdialog.cpp b/projectnewdialog.cpp index c81556c..01db8d7 100644 --- a/projectnewdialog.cpp +++ b/projectnewdialog.cpp @@ -201,7 +201,7 @@ void ProjectNewDialog::on_templateFile_editTextChanged(const QString &fileName) QString text = readAll(name); ui->parameterTable->setRowCount(0); if (!text.isEmpty()) { - QRegExp re("\\$\\{\\{([a-zA-Z0-9_]+)\\s*([a-zA-Z0-9_]+)*\\s*\\:*(.*)\\}\\}"); + QRegExp re(R"(\$\{\{([a-zA-Z0-9_]+)\s*([a-zA-Z0-9_]+)*\s*\:*(.*)\}\})"); re.setMinimal(true); re.setPatternSyntax(QRegExp::RegExp2); int idx = 0; @@ -231,7 +231,7 @@ QString ProjectNewDialog::replaceTemplates(const QString &text) const QString key = ui->parameterTable->item(row, 0)->text().replace(' ', '_'); QString val = ui->parameterTable->item(row, 1)->text(); - QRegExp re(QString("\\$\\{\\{%1\\s*([a-zA-Z0-9_]+)*\\s*\\:*(.*)\\}\\}").arg(key)); + QRegExp re(QString(R"(\$\{\{%1\s*([a-zA-Z0-9_]+)*\s*\:*(.*)\}\})").arg(key)); re.setMinimal(true); re.setPatternSyntax(QRegExp::RegExp2); newString.replace(re, val); diff --git a/projectview.cpp b/projectview.cpp index 6f87f80..982f9f3 100644 --- a/projectview.cpp +++ b/projectview.cpp @@ -30,8 +30,9 @@ ProjectView::ProjectView(QWidget *parent) : QFile filterFiles(":/build/project-filters.txt"); filterFiles.open(QFile::ReadOnly); while (!filterFiles.atEnd()) { - QString name = QString(filterFiles.readLine()).remove(':').remove(QRegExp("[\\r\\n]*")); - QString filter = QString(filterFiles.readLine()).remove(QRegExp("[\\r\\n]*")); + QRegExp crlf(R"([\r\n]*)"); + QString name = QString(filterFiles.readLine()).remove(':').remove(crlf); + QString filter = QString(filterFiles.readLine()).remove(crlf); // qDebug() << "filter" << name << filter; if (!name.isEmpty() && !filter.isEmpty()) ui->filterCombo->addItem(name, filter.split(' ')); diff --git a/targetupdatediscover.cpp b/targetupdatediscover.cpp index 31f013f..04f9ceb 100644 --- a/targetupdatediscover.cpp +++ b/targetupdatediscover.cpp @@ -46,15 +46,15 @@ static QStringList parseRe(const QString& text, const QString& reText) { return set.toList(); } -static const QString TARGETS_RE = "(? search starts here\\:(.*?)End of search list"; -static const QString CC_OUT_DEFINES_RE = "\\#define ([_a-zA-Z0-9\\(\\,\\)]+) (.*?)$"; +static const QString TARGETS_RE = R"((? search starts here\:(.*?)End of search list)"; +static const QString CC_OUT_DEFINES_RE = R"(\#define ([_a-zA-Z0-9\(\,\)]+) (.*?)$)"; static void parseCCOut(const QString& text, QStringList *incs, QStringList *defs) { QRegularExpressionMatch m = QRegularExpression( @@ -138,7 +138,7 @@ void TargetUpdateDiscover::finish(int ret) QString cmd = QString("%1 -xc -dM -E -v -") .arg(QString(info.cc_cflags) .remove("-MMD") - .remove(QRegularExpression("-MF \\S+"))); + .remove(QRegularExpression(R"(-MF \S+)"))); ccProc.start(cmd); qDebug() << "start " << cmd; if (ccProc.waitForStarted()) {