Skip to content

Commit

Permalink
Replace regex string b c++11 raw string
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Ribelotta <[email protected]>
  • Loading branch information
martinribelotta committed Sep 4, 2016
1 parent 6f9c0b9 commit 3c36737
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion clangcodecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion etags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions projectnewdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions projectview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(' '));
Expand Down
20 changes: 10 additions & 10 deletions targetupdatediscover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ static QStringList parseRe(const QString& text, const QString& reText) {
return set.toList();
}

static const QString TARGETS_RE = "(?<!^# Not a target\\:\\n)^([a-zA-Z0-9][^$#\\\\\\/\\t=\\.]*):(?:[^=]|$)";
static const QString DEFINES_RE = "\\-D([^\\s\\$]+)";
static const QString INCLUDES_RE = "\\-I([^\\s\\$]+)";
static const QString CC_RE = "^\\s*([a-zA-Z0-9\\-]*gcc\\b)";
static const QString CC_CFLAGS_RE = "\\b([a-zA-Z0-9\\-]*gcc.*?-c.*?$)";
static const QString C_CXX_FILE_RE = "\\S+\\.cp?p?";
static const QString O_FILE_RE = "\\-o\\s*\\S+\\.o";
static const QString CC_OUT_INCLUDE_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"((?<!^# Not a target\:\n)^([a-zA-Z0-9][^$#\\\/\t=\.]*):(?:[^=]|$))";
static const QString DEFINES_RE = R"(\-D([^\s\$]+))";
static const QString INCLUDES_RE = R"(\-I([^\s\$]+))";
static const QString CC_RE = R"(^\s*([a-zA-Z0-9\-]*gcc\b))";
static const QString CC_CFLAGS_RE = R"(\b([a-zA-Z0-9\-]*gcc.*?-c.*?$))";
static const QString C_CXX_FILE_RE = R"(\S+\.cp?p?)";
static const QString O_FILE_RE = R"(\-o\s*\S+\.o)";
static const QString CC_OUT_INCLUDE_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(
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 3c36737

Please sign in to comment.