forked from qt-creator/qt-creator
Qnx: Replace QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098 Change-Id: Ic32313d8879b6497209196b0e3e4846c00c9846a Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <QThread>
|
||||
|
||||
@@ -120,11 +120,12 @@ void QnxDevice::updateVersionNumber() const
|
||||
|
||||
QByteArray output = versionNumberProcess.readAllStandardOutput();
|
||||
QString versionMessage = QString::fromLatin1(output);
|
||||
QRegExp versionNumberRegExp = QRegExp(QLatin1String("(\\d+)\\.(\\d+)\\.(\\d+)"));
|
||||
if (versionNumberRegExp.indexIn(versionMessage) > -1 && versionNumberRegExp.captureCount() == 3) {
|
||||
int major = versionNumberRegExp.cap(1).toInt();
|
||||
int minor = versionNumberRegExp.cap(2).toInt();
|
||||
int patch = versionNumberRegExp.cap(3).toInt();
|
||||
const QRegularExpression versionNumberRegExp("(\\d+)\\.(\\d+)\\.(\\d+)");
|
||||
const QRegularExpressionMatch match = versionNumberRegExp.match(versionMessage);
|
||||
if (match.hasMatch()) {
|
||||
int major = match.captured(1).toInt();
|
||||
int minor = match.captured(2).toInt();
|
||||
int patch = match.captured(3).toInt();
|
||||
m_versionNumber = (major << 16)|(minor<<8)|(patch);
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
|
||||
using namespace Qnx;
|
||||
@@ -53,11 +53,12 @@ QList<ProjectExplorer::DeviceProcessItem> QnxDeviceProcessList::buildProcessList
|
||||
return processes;
|
||||
|
||||
lines.pop_front(); // drop headers
|
||||
QRegExp re(QLatin1String("\\s*(\\d+)\\s+(.*)'(.*)'"));
|
||||
const QRegularExpression re("\\s*(\\d+)\\s+(.*)'(.*)'");
|
||||
|
||||
foreach (const QString& line, lines) {
|
||||
if (re.exactMatch(line)) {
|
||||
const QStringList captures = re.capturedTexts();
|
||||
for (const QString &line : qAsConst(lines)) {
|
||||
const QRegularExpressionMatch match = re.match(line);
|
||||
if (match.hasMatch()) {
|
||||
const QStringList captures = match.capturedTexts();
|
||||
if (captures.size() == 4) {
|
||||
const int pid = captures[1].toInt();
|
||||
const QString args = captures[2];
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include "qnxversionnumber.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
@@ -89,14 +89,15 @@ QString QnxVersionNumber::segment(int index) const
|
||||
|
||||
QnxVersionNumber QnxVersionNumber::fromTargetName(const QString &targetName)
|
||||
{
|
||||
return fromFileName(targetName, QRegExp(QLatin1String("^target_(.*)$")));
|
||||
return fromFileName(targetName, QRegularExpression("^target_(.*)$"));
|
||||
}
|
||||
|
||||
QnxVersionNumber QnxVersionNumber::fromFileName(const QString &fileName, const QRegExp ®Exp)
|
||||
QnxVersionNumber QnxVersionNumber::fromFileName(const QString &fileName, const QRegularExpression ®Exp)
|
||||
{
|
||||
QStringList segments;
|
||||
if (regExp.exactMatch(fileName) && regExp.captureCount() == 1)
|
||||
segments << regExp.cap(1).split(QLatin1Char('_'));
|
||||
const QRegularExpressionMatch match = regExp.match(fileName);
|
||||
if (match.hasMatch() && regExp.captureCount() == 1)
|
||||
segments << match.captured(1).split(QLatin1Char('_'));
|
||||
|
||||
return QnxVersionNumber(segments);
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
QString toString() const;
|
||||
|
||||
static QnxVersionNumber fromTargetName(const QString &targetName);
|
||||
static QnxVersionNumber fromFileName(const QString &fileName, const QRegExp ®Exp);
|
||||
static QnxVersionNumber fromFileName(const QString &fileName, const QRegularExpression ®Exp);
|
||||
|
||||
bool operator >(const QnxVersionNumber &b) const;
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
@@ -160,17 +160,18 @@ void Slog2InfoRunner::processLogLine(const QString &line)
|
||||
// The "\\s+(\\b.*)?$" represents a space followed by a message. We are unable to determinate
|
||||
// how many spaces represent separators and how many are a part of the messages, so resulting
|
||||
// messages has all whitespaces at the beginning of the message trimmed.
|
||||
static QRegExp regexp(QLatin1String(
|
||||
static QRegularExpression regexp(QLatin1String(
|
||||
"^[a-zA-Z]+\\s+([0-9]+ [0-9]+:[0-9]+:[0-9]+.[0-9]+)\\s+(\\S+)(\\s+(\\S+))?\\s+([0-9]+)\\s+(.*)?$"));
|
||||
|
||||
if (!regexp.exactMatch(line) || regexp.captureCount() != 6)
|
||||
const QRegularExpressionMatch match = regexp.match(line);
|
||||
if (!match.hasMatch())
|
||||
return;
|
||||
|
||||
// Note: This is useless if/once slog2info -b displays only logs from recent launches
|
||||
if (!m_launchDateTime.isNull()) {
|
||||
// Check if logs are from the recent launch
|
||||
if (!m_currentLogs) {
|
||||
QDateTime dateTime = QDateTime::fromString(regexp.cap(1),
|
||||
QDateTime dateTime = QDateTime::fromString(match.captured(1),
|
||||
QLatin1String("dd HH:mm:ss.zzz"));
|
||||
m_currentLogs = dateTime >= m_launchDateTime;
|
||||
if (!m_currentLogs)
|
||||
@@ -178,17 +179,17 @@ void Slog2InfoRunner::processLogLine(const QString &line)
|
||||
}
|
||||
}
|
||||
|
||||
QString applicationId = regexp.cap(2);
|
||||
QString applicationId = match.captured(2);
|
||||
if (!applicationId.startsWith(m_applicationId))
|
||||
return;
|
||||
|
||||
QString bufferName = regexp.cap(4);
|
||||
int bufferId = regexp.cap(5).toInt();
|
||||
QString bufferName = match.captured(4);
|
||||
int bufferId = match.captured(5).toInt();
|
||||
// filtering out standard BB10 messages
|
||||
if (bufferName == QLatin1String("default") && bufferId == 8900)
|
||||
return;
|
||||
|
||||
appendMessage(regexp.cap(6).trimmed() + '\n', Utils::StdOutFormat);
|
||||
appendMessage(match.captured(6).trimmed() + '\n', Utils::StdOutFormat);
|
||||
}
|
||||
|
||||
void Slog2InfoRunner::readLogStandardError()
|
||||
|
Reference in New Issue
Block a user