summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/proparser/prowriter.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/shared/proparser/prowriter.cpp b/src/shared/proparser/prowriter.cpp
index 668820ba43..282080013f 100644
--- a/src/shared/proparser/prowriter.cpp
+++ b/src/shared/proparser/prowriter.cpp
@@ -30,8 +30,8 @@
#include <utils/algorithm.h>
#include <QDir>
-#include <QRegExp>
#include <QPair>
+#include <QRegularExpression>
using namespace QmakeProjectManager::Internal;
@@ -178,7 +178,7 @@ QString ProWriter::compileScope(const QString &scope)
if (scope.isEmpty())
return QString();
QMakeParser parser(nullptr, nullptr, nullptr);
- ProFile *includeFile = parser.parsedProBlock(QStringRef(&scope), 0, QLatin1String("no-file"), 1);
+ ProFile *includeFile = parser.parsedProBlock(QStringRef(&scope), 0, "no-file", 1);
if (!includeFile)
return QString();
const QString result = includeFile->items();
@@ -321,13 +321,13 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines, const QString
lines->erase(lines->begin() + lineNo + 1, lines->begin() + contInfo.lineNo);
// remove rest of the line
QString &line = (*lines)[lineNo];
- int eqs = line.indexOf(QLatin1Char('='));
+ int eqs = line.indexOf('=');
if (eqs >= 0) // If this is not true, we mess up the file a bit.
line.truncate(eqs + 1);
// put new values
for (const QString &v : values) {
- line += ((flags & MultiLine) ? QLatin1String(" \\\n") + effectiveContIndent(contInfo)
- : QString::fromLatin1(" ")) + v;
+ line += ((flags & MultiLine) ? QString(" \\\n") + effectiveContIndent(contInfo)
+ : QString(" ")) + v;
}
} else {
const ContinuationInfo contInfo = skipContLines(lines, lineNo, false);
@@ -354,13 +354,14 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines, const QString
ContinuationInfo contInfo;
if (!scope.isEmpty()) {
if (scopeStart < 0) {
- added = QLatin1Char('\n') + scope + QLatin1String(" {");
+ added = '\n' + scope + " {";
} else {
- QRegExp rx(QLatin1String("(\\s*") + scope + QLatin1String("\\s*:\\s*)[^\\s{].*"));
- if (rx.exactMatch(lines->at(scopeStart))) {
- (*lines)[scopeStart].replace(0, rx.cap(1).length(),
- QString(scope + QLatin1String(" {\n")
- + continuationIndent));
+ // TODO use anchoredPattern() once Qt 5.12 is mandatory
+ const QRegularExpression rx("\\A(\\s*" + scope + "\\s*:\\s*)[^\\s{].*\\z");
+ const QRegularExpressionMatch match(rx.match(lines->at(scopeStart)));
+ if (match.hasMatch()) {
+ (*lines)[scopeStart].replace(0, match.captured(1).length(),
+ scope + " {\n" + continuationIndent);
contInfo = skipContLines(lines, scopeStart, false);
lNo = contInfo.lineNo;
scopeStart = -1;
@@ -374,26 +375,26 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines, const QString
const QString &line = (*lines).at(lNo);
for (int i = 0; i < line.size(); i++)
// This is pretty sick, but qmake does pretty much the same ...
- if (line.at(i) == QLatin1Char('{')) {
+ if (line.at(i) == '{') {
++braces;
- } else if (line.at(i) == QLatin1Char('}')) {
+ } else if (line.at(i) == '}') {
if (!--braces)
break;
- } else if (line.at(i) == QLatin1Char('#')) {
+ } else if (line.at(i) == '#') {
break;
}
} while (braces && ++lNo < lines->size());
}
for (; lNo > scopeStart + 1 && lines->at(lNo - 1).isEmpty(); lNo--) ;
if (lNo != scopeStart + 1)
- added += QLatin1Char('\n');
- added += indent + var + QLatin1String((flags & AppendOperator) ? " +=" : " =");
+ added += '\n';
+ added += indent + var + ((flags & AppendOperator) ? " +=" : " =");
for (const QString &v : values) {
- added += ((flags & MultiLine) ? QLatin1String(" \\\n") + effectiveContIndent(contInfo)
- : QString::fromLatin1(" ")) + v;
+ added += ((flags & MultiLine) ? QString(" \\\n") + effectiveContIndent(contInfo)
+ : QString(" ")) + v;
}
if (!scope.isEmpty() && scopeStart < 0)
- added += QLatin1String("\n}");
+ added += "\n}";
lines->insert(lNo, added);
}
}
@@ -404,8 +405,8 @@ void ProWriter::addFiles(ProFile *profile, QStringList *lines, const QStringList
QStringList valuesToWrite;
QString prefixPwd;
QDir baseDir = QFileInfo(profile->fileName()).absoluteDir();
- if (profile->fileName().endsWith(QLatin1String(".pri")))
- prefixPwd = QLatin1String("$$PWD/");
+ if (profile->fileName().endsWith(".pri"))
+ prefixPwd = "$$PWD/";
for (const QString &v : values)
valuesToWrite << (prefixPwd + baseDir.relativeFilePath(v));
@@ -464,7 +465,7 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
int lineLen = line.length();
bool killed = false;
bool saved = false;
- int idx = line.indexOf(QLatin1Char('#'));
+ int idx = line.indexOf('#');
if (idx >= 0)
lineLen = idx;
QChar *chars = line.data();
@@ -475,30 +476,30 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
goto nextVar;
}
QChar c = chars[lineLen - 1];
- if (c != QLatin1Char(' ') && c != QLatin1Char('\t'))
+ if (c != ' ' && c != '\t')
break;
lineLen--;
}
{
int contCol = -1;
- if (chars[lineLen - 1] == QLatin1Char('\\'))
+ if (chars[lineLen - 1] == '\\')
contCol = --lineLen;
int colNo = 0;
if (first) {
- colNo = line.indexOf(QLatin1Char('=')) + 1;
+ colNo = line.indexOf('=') + 1;
first = false;
saved = true;
}
while (colNo < lineLen) {
QChar c = chars[colNo];
- if (c == QLatin1Char(' ') || c == QLatin1Char('\t')) {
+ if (c == ' ' || c == '\t') {
colNo++;
continue;
}
int varCol = colNo;
while (colNo < lineLen) {
QChar c = chars[colNo];
- if (c == QLatin1Char(' ') || c == QLatin1Char('\t'))
+ if (c == (' ') || c == ('\t'))
break;
colNo++;
}
@@ -517,7 +518,7 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
contCol -= len;
idx -= len;
if (idx >= 0)
- line.insert(idx, QLatin1String("# ") + fn + QLatin1Char(' '));
+ line.insert(idx, "# " + fn + ' ');
chars = line.data();
killed = true;
} else {
@@ -535,8 +536,7 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
QString &bline = (*lines)[pos.first];
bline.remove(pos.second, 1);
if (pos.second == bline.length())
- while (bline.endsWith(QLatin1Char(' '))
- || bline.endsWith(QLatin1Char('\t')))
+ while (bline.endsWith(' ') || bline.endsWith('\t'))
bline.chop(1);
}
contPos.clear();
@@ -572,7 +572,7 @@ QStringList ProWriter::removeFiles(ProFile *profile, QStringList *lines,
Utils::transform(removeVarValues(profile, lines, valuesToFind, vars),
[values](int i) { return values.at(i); });
- if (!profile->fileName().endsWith(QLatin1String(".pri")))
+ if (!profile->fileName().endsWith(".pri"))
return notYetChanged;
// If we didn't find them with a relative path to the .pro file
@@ -580,7 +580,7 @@ QStringList ProWriter::removeFiles(ProFile *profile, QStringList *lines,
valuesToFind.clear();
const QDir baseDir = QFileInfo(profile->fileName()).absoluteDir();
- const QString prefixPwd = QLatin1String("$$PWD/");
+ const QString prefixPwd = "$$PWD/";
for (const QString &absoluteFilePath : notYetChanged)
valuesToFind << (prefixPwd + baseDir.relativeFilePath(absoluteFilePath));