aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-07-14 14:27:53 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-07-15 12:08:09 +0000
commit6a811936d88fd999760699d7661508ffac1408c4 (patch)
tree6e081861e2532cddcd0333b67cf66e6a2251d848
parent1f5c89b111d17d5340aa5ab671a65b7ec92c2fad (diff)
Tools: Replace QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098 Change-Id: I16d8928689d208c13776b76cabd663c006a0eb51 Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/tools/iostool/iosdevicemanager.cpp11
-rw-r--r--src/tools/iostool/main.cpp16
-rw-r--r--src/tools/qtcreatorcrashhandler/crashhandler.cpp10
-rw-r--r--src/tools/sdktool/addkitoperation.cpp6
4 files changed, 23 insertions, 20 deletions
diff --git a/src/tools/iostool/iosdevicemanager.cpp b/src/tools/iostool/iosdevicemanager.cpp
index 0c09ee61f4a..fe339ddec99 100644
--- a/src/tools/iostool/iosdevicemanager.cpp
+++ b/src/tools/iostool/iosdevicemanager.cpp
@@ -33,7 +33,7 @@
#include <QTimer>
#include <QThread>
#include <QSettings>
-#include <QRegExp>
+#include <QRegularExpression>
#include <QUrl>
#include <mach/error.h>
@@ -1437,11 +1437,12 @@ void AppOpSession::deviceCallbackReturned()
int AppOpSession::qmljsDebugPort() const
{
- QRegExp qmlPortRe = QRegExp(QLatin1String("-qmljsdebugger=port:([0-9]+)"));
- foreach (const QString &arg, extraArgs) {
- if (qmlPortRe.indexIn(arg) == 0) {
+ const QRegularExpression qmlPortRe(QLatin1String("-qmljsdebugger=port:([0-9]+)"));
+ for (const QString &arg : qAsConst(extraArgs)) {
+ const QRegularExpressionMatch match = qmlPortRe.match(arg);
+ if (match.hasMatch()) {
bool ok;
- int res = qmlPortRe.cap(1).toInt(&ok);
+ int res = match.captured(1).toInt(&ok);
if (ok && res >0 && res <= 0xFFFF)
return res;
}
diff --git a/src/tools/iostool/main.cpp b/src/tools/iostool/main.cpp
index 3e4141aaf3b..6195888d37f 100644
--- a/src/tools/iostool/main.cpp
+++ b/src/tools/iostool/main.cpp
@@ -31,6 +31,7 @@
#include <QDebug>
#include <QXmlStreamWriter>
#include <QFile>
+#include <QRegularExpression>
#include <QScopedArrayPointer>
#include <QTcpServer>
#include <QSocketNotifier>
@@ -605,13 +606,14 @@ void IosTool::run(const QStringList &args)
connect(manager,&Ios::IosDeviceManager::appOutput, this, &IosTool::appOutput);
connect(manager,&Ios::IosDeviceManager::errorMsg, this, &IosTool::errorMsg);
manager->watchDevices();
- QRegExp qmlPortRe=QRegExp(QLatin1String("-qmljsdebugger=port:([0-9]+)"));
- foreach (const QString &arg, extraArgs) {
- if (qmlPortRe.indexIn(arg) == 0) {
+ const QRegularExpression qmlPortRe(QLatin1String("-qmljsdebugger=port:([0-9]+)"));
+ for (const QString &arg : extraArgs) {
+ const QRegularExpressionMatch match = qmlPortRe.match(arg);
+ if (match.hasMatch()) {
bool ok;
- int qmlPort = qmlPortRe.cap(1).toInt(&ok);
+ int qmlPort = match.captured(1).toInt(&ok);
if (ok && qmlPort > 0 && qmlPort <= 0xFFFF)
- m_qmlPort = qmlPortRe.cap(1);
+ m_qmlPort = match.captured(1);
break;
}
}
@@ -832,11 +834,11 @@ void IosTool::deviceInfo(const QString &deviceId, const Ios::IosDeviceManager::D
void IosTool::writeTextInElement(const QString &output)
{
- QRegExp controlCharRe(QLatin1String("[\x01-\x08]|\x0B|\x0C|[\x0E-\x1F]|\\0000"));
+ const QRegularExpression controlCharRe(QLatin1String("[\x01-\x08]|\x0B|\x0C|[\x0E-\x1F]|\\0000"));
int pos = 0;
int oldPos = 0;
- while ((pos = controlCharRe.indexIn(output, pos)) != -1) {
+ while ((pos = output.indexOf(controlCharRe, pos)) != -1) {
QMutexLocker l(&m_xmlMutex);
out.writeCharacters(output.mid(oldPos, pos - oldPos));
out.writeEmptyElement(QLatin1String("control_char"));
diff --git a/src/tools/qtcreatorcrashhandler/crashhandler.cpp b/src/tools/qtcreatorcrashhandler/crashhandler.cpp
index 89ff098420c..621361499eb 100644
--- a/src/tools/qtcreatorcrashhandler/crashhandler.cpp
+++ b/src/tools/qtcreatorcrashhandler/crashhandler.cpp
@@ -36,7 +36,7 @@
#include <QDesktopServices>
#include <QDir>
#include <QFile>
-#include <QRegExp>
+#include <QRegularExpression>
#include <QTextStream>
#include <QUrl>
#include <QVector>
@@ -166,11 +166,11 @@ void CrashHandler::onBacktraceFinished(const QString &backtrace)
// ...
// Thread 1 (Thread 0x7f1c33c79780 (LWP 975)):
// ...
- QRegExp rx(QLatin1String("\\[Current thread is (\\d+)"));
- const int pos = rx.indexIn(backtrace);
- if (pos == -1)
+ const QRegularExpression rx(QLatin1String("\\[Current thread is (\\d+)"));
+ const QRegularExpressionMatch match = rx.match(backtrace);
+ if (!match.hasMatch())
return;
- const QString threadNumber = rx.cap(1);
+ const QString threadNumber = match.captured(1);
const QString textToSelect = QString::fromLatin1("Thread %1").arg(threadNumber);
d->dialog.selectLineWithContents(textToSelect);
}
diff --git a/src/tools/sdktool/addkitoperation.cpp b/src/tools/sdktool/addkitoperation.cpp
index f0213f17a3c..df5b297c978 100644
--- a/src/tools/sdktool/addkitoperation.cpp
+++ b/src/tools/sdktool/addkitoperation.cpp
@@ -38,7 +38,7 @@
#include "settings.h"
#include <QDir>
-#include <QRegExp>
+#include <QRegularExpression>
#include <iostream>
@@ -582,8 +582,8 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, const QVariantMap &t
for (auto i = tcs.constBegin(); i != tcs.constEnd(); ++i) {
if (!i.value().isEmpty() && !AddToolChainOperation::exists(tcMap, i.value())) {
- QRegExp abiRegExp = QRegExp("[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-(8|16|32|64|128)bit");
- if (!abiRegExp.exactMatch(i.value())) {
+ const QRegularExpression abiRegExp("^[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-(8|16|32|64|128)bit$");
+ if (!abiRegExp.match(i.value()).hasMatch()) {
std::cerr << "Error: Toolchain " << qPrintable(i.value())
<< " for language " << qPrintable(i.key()) << " does not exist." << std::endl;
return QVariantMap();