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 <utils/stringutils.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
@@ -120,11 +120,12 @@ void QnxDevice::updateVersionNumber() const
|
|||||||
|
|
||||||
QByteArray output = versionNumberProcess.readAllStandardOutput();
|
QByteArray output = versionNumberProcess.readAllStandardOutput();
|
||||||
QString versionMessage = QString::fromLatin1(output);
|
QString versionMessage = QString::fromLatin1(output);
|
||||||
QRegExp versionNumberRegExp = QRegExp(QLatin1String("(\\d+)\\.(\\d+)\\.(\\d+)"));
|
const QRegularExpression versionNumberRegExp("(\\d+)\\.(\\d+)\\.(\\d+)");
|
||||||
if (versionNumberRegExp.indexIn(versionMessage) > -1 && versionNumberRegExp.captureCount() == 3) {
|
const QRegularExpressionMatch match = versionNumberRegExp.match(versionMessage);
|
||||||
int major = versionNumberRegExp.cap(1).toInt();
|
if (match.hasMatch()) {
|
||||||
int minor = versionNumberRegExp.cap(2).toInt();
|
int major = match.captured(1).toInt();
|
||||||
int patch = versionNumberRegExp.cap(3).toInt();
|
int minor = match.captured(2).toInt();
|
||||||
|
int patch = match.captured(3).toInt();
|
||||||
m_versionNumber = (major << 16)|(minor<<8)|(patch);
|
m_versionNumber = (major << 16)|(minor<<8)|(patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
using namespace Qnx;
|
using namespace Qnx;
|
||||||
@@ -53,11 +53,12 @@ QList<ProjectExplorer::DeviceProcessItem> QnxDeviceProcessList::buildProcessList
|
|||||||
return processes;
|
return processes;
|
||||||
|
|
||||||
lines.pop_front(); // drop headers
|
lines.pop_front(); // drop headers
|
||||||
QRegExp re(QLatin1String("\\s*(\\d+)\\s+(.*)'(.*)'"));
|
const QRegularExpression re("\\s*(\\d+)\\s+(.*)'(.*)'");
|
||||||
|
|
||||||
foreach (const QString& line, lines) {
|
for (const QString &line : qAsConst(lines)) {
|
||||||
if (re.exactMatch(line)) {
|
const QRegularExpressionMatch match = re.match(line);
|
||||||
const QStringList captures = re.capturedTexts();
|
if (match.hasMatch()) {
|
||||||
|
const QStringList captures = match.capturedTexts();
|
||||||
if (captures.size() == 4) {
|
if (captures.size() == 4) {
|
||||||
const int pid = captures[1].toInt();
|
const int pid = captures[1].toInt();
|
||||||
const QString args = captures[2];
|
const QString args = captures[2];
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include "qnxversionnumber.h"
|
#include "qnxversionnumber.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace Qnx {
|
namespace Qnx {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -89,14 +89,15 @@ QString QnxVersionNumber::segment(int index) const
|
|||||||
|
|
||||||
QnxVersionNumber QnxVersionNumber::fromTargetName(const QString &targetName)
|
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;
|
QStringList segments;
|
||||||
if (regExp.exactMatch(fileName) && regExp.captureCount() == 1)
|
const QRegularExpressionMatch match = regExp.match(fileName);
|
||||||
segments << regExp.cap(1).split(QLatin1Char('_'));
|
if (match.hasMatch() && regExp.captureCount() == 1)
|
||||||
|
segments << match.captured(1).split(QLatin1Char('_'));
|
||||||
|
|
||||||
return QnxVersionNumber(segments);
|
return QnxVersionNumber(segments);
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ public:
|
|||||||
QString toString() const;
|
QString toString() const;
|
||||||
|
|
||||||
static QnxVersionNumber fromTargetName(const QString &targetName);
|
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;
|
bool operator >(const QnxVersionNumber &b) const;
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
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
|
// 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
|
// 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.
|
// 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+(.*)?$"));
|
"^[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;
|
return;
|
||||||
|
|
||||||
// Note: This is useless if/once slog2info -b displays only logs from recent launches
|
// Note: This is useless if/once slog2info -b displays only logs from recent launches
|
||||||
if (!m_launchDateTime.isNull()) {
|
if (!m_launchDateTime.isNull()) {
|
||||||
// Check if logs are from the recent launch
|
// Check if logs are from the recent launch
|
||||||
if (!m_currentLogs) {
|
if (!m_currentLogs) {
|
||||||
QDateTime dateTime = QDateTime::fromString(regexp.cap(1),
|
QDateTime dateTime = QDateTime::fromString(match.captured(1),
|
||||||
QLatin1String("dd HH:mm:ss.zzz"));
|
QLatin1String("dd HH:mm:ss.zzz"));
|
||||||
m_currentLogs = dateTime >= m_launchDateTime;
|
m_currentLogs = dateTime >= m_launchDateTime;
|
||||||
if (!m_currentLogs)
|
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))
|
if (!applicationId.startsWith(m_applicationId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString bufferName = regexp.cap(4);
|
QString bufferName = match.captured(4);
|
||||||
int bufferId = regexp.cap(5).toInt();
|
int bufferId = match.captured(5).toInt();
|
||||||
// filtering out standard BB10 messages
|
// filtering out standard BB10 messages
|
||||||
if (bufferName == QLatin1String("default") && bufferId == 8900)
|
if (bufferName == QLatin1String("default") && bufferId == 8900)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
appendMessage(regexp.cap(6).trimmed() + '\n', Utils::StdOutFormat);
|
appendMessage(match.captured(6).trimmed() + '\n', Utils::StdOutFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slog2InfoRunner::readLogStandardError()
|
void Slog2InfoRunner::readLogStandardError()
|
||||||
|
Reference in New Issue
Block a user