diff options
author | hjk <hjk@qt.io> | 2020-06-23 18:36:26 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2020-06-24 05:48:56 +0000 |
commit | 9efa934ae099585bb63e5daeade8e4989523b961 (patch) | |
tree | ec715bf9551e9bd3da5a8114c8d84cd0d0dc00a9 /src/plugins/clearcase | |
parent | a6fe2efd4e7409c99c2adc5e0911a540b86ae81e (diff) |
ClearCase: Drop QRegExp use
Change-Id: Ia47d2efec42e9df59c5d30a695b4becee942e085
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/clearcase')
-rw-r--r-- | src/plugins/clearcase/clearcaseplugin.cpp | 27 | ||||
-rw-r--r-- | src/plugins/clearcase/clearcasesync.cpp | 14 | ||||
-rw-r--r-- | src/plugins/clearcase/versionselector.cpp | 26 |
3 files changed, 39 insertions, 28 deletions
diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 227ff5419a..e5996f2e13 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -89,7 +89,7 @@ #include <QMetaObject> #include <QMutex> #include <QProcess> -#include <QRegExp> +#include <QRegularExpression> #include <QSharedPointer> #include <QTextCodec> #include <QUrl> @@ -490,7 +490,7 @@ FileStatus::Status ClearCasePluginPrivate::getFileStatus(const QString &fileName return FileStatus::Derived; // find first whitespace. anything before that is not interesting - const int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s"))); + const int wspos = buffer.indexOf(QRegularExpression("\\s")); if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1) return FileStatus::CheckedOut; else @@ -1303,7 +1303,7 @@ void ClearCasePluginPrivate::diffActivity() // pre-first version. only for the first occurrence if (filever[file].first.isEmpty()) { - int verpos = shortver.lastIndexOf(QRegExp(QLatin1String("[^0-9]"))) + 1; + int verpos = shortver.lastIndexOf(QRegularExpression("[^0-9]")) + 1; int vernum = shortver.midRef(verpos).toInt(); if (vernum) --vernum; @@ -1890,11 +1890,12 @@ bool ClearCasePluginPrivate::vcsCheckIn(const QString &messageFile, const QStrin const ClearCaseResponse response = runCleartool(m_checkInView, args, m_settings.longTimeOutS(), VcsCommand::ShowStdOut); - QRegExp checkedIn(QLatin1String("Checked in \\\"([^\"]*)\\\"")); + const QRegularExpression checkedIn("Checked in \\\"([^\"]*)\\\""); + QRegularExpressionMatch match = checkedIn.match(response.stdOut); bool anySucceeded = false; - int offset = checkedIn.indexIn(response.stdOut); - while (offset != -1) { - QString file = checkedIn.cap(1); + int offset = match.capturedStart(); + while (match.hasMatch()) { + QString file = match.captured(1); QFileInfo fi(m_checkInView, file); QString absPath = fi.absoluteFilePath(); @@ -1902,7 +1903,8 @@ bool ClearCasePluginPrivate::vcsCheckIn(const QString &messageFile, const QStrin setStatus(QDir::fromNativeSeparators(absPath), FileStatus::CheckedIn); emit filesChanged(files); anySucceeded = true; - offset = checkedIn.indexIn(response.stdOut, offset + 12); + match = checkedIn.match(response.stdOut, offset + 12); + offset = match.capturedStart(); } return anySucceeded; } @@ -2139,7 +2141,7 @@ bool ClearCasePluginPrivate::ccCheckUcm(const QString &viewname, const QString & QString catcsData = runCleartoolSync(workingDir, catcsArgs); // check output for the word "ucm" - return QRegExp(QLatin1String("(^|\\n)ucm\\n")).indexIn(catcsData) != -1; + return catcsData.indexOf(QRegularExpression("(^|\\n)ucm\\n")) != -1; } bool ClearCasePluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const @@ -2182,9 +2184,10 @@ void ClearCasePluginPrivate::updateStreamAndView() const QString sresponse = runCleartoolSync(m_topLevel, args); int tabPos = sresponse.indexOf(QLatin1Char('\t')); m_stream = sresponse.left(tabPos); - QRegExp intStreamExp(QLatin1String("stream:([^@]*)")); - if (intStreamExp.indexIn(sresponse.mid(tabPos + 1)) != -1) - m_intStream = intStreamExp.cap(1); + const QRegularExpression intStreamExp("stream:([^@]*)"); + const QRegularExpressionMatch match = intStreamExp.match(sresponse.mid(tabPos + 1)); + if (match.hasMatch()) + m_intStream = match.captured(1); m_viewData = ccGetView(m_topLevel); m_updateViewAction->setParameter(m_viewData.isDynamic ? QString() : m_viewData.name); } diff --git a/src/plugins/clearcase/clearcasesync.cpp b/src/plugins/clearcase/clearcasesync.cpp index cc8efeb0c5..939badec15 100644 --- a/src/plugins/clearcase/clearcasesync.cpp +++ b/src/plugins/clearcase/clearcasesync.cpp @@ -29,7 +29,7 @@ #include <QDir> #include <QFutureInterface> #include <QProcess> -#include <QRegExp> +#include <QRegularExpression> #include <QStringList> #include <utils/qtcassert.h> @@ -85,17 +85,19 @@ void ClearCaseSync::processCleartoolLsLine(const QDir &viewRootDir, const QStrin return; // find first whitespace. anything before that is not interesting - const int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s"))); + const int wspos = buffer.indexOf(QRegularExpression("\\s")); const QString absFile = viewRootDir.absoluteFilePath( QDir::fromNativeSeparators(buffer.left(atatpos))); QTC_CHECK(QFileInfo::exists(absFile)); QTC_CHECK(!absFile.isEmpty()); - QString ccState; - const QRegExp reState(QLatin1String("^\\s*\\[[^\\]]*\\]")); // [hijacked]; [loaded but missing] - if (reState.indexIn(buffer, wspos + 1, QRegExp::CaretAtOffset) != -1) { - ccState = reState.cap(); + const QRegularExpression reState("^\\s*\\[[^\\]]*\\]"); // [hijacked]; [loaded but missing] + const QRegularExpressionMatch match = reState.match(buffer, wspos + 1, + QRegularExpression::NormalMatch, + QRegularExpression::AnchorAtOffsetMatchOption); + if (match.hasMatch()) { + const QString ccState = match.captured(); if (ccState.indexOf(QLatin1String("hijacked")) != -1) ClearCasePlugin::setStatus(absFile, FileStatus::Hijacked, true); else if (ccState.indexOf(QLatin1String("loaded but missing")) != -1) diff --git a/src/plugins/clearcase/versionselector.cpp b/src/plugins/clearcase/versionselector.cpp index 453ce132ab..9364437414 100644 --- a/src/plugins/clearcase/versionselector.cpp +++ b/src/plugins/clearcase/versionselector.cpp @@ -27,7 +27,7 @@ #include "versionselector.h" #include "ui_versionselector.h" -#include <QRegExp> +#include <QRegularExpression> #include <QTextStream> namespace ClearCase { @@ -73,20 +73,26 @@ bool VersionSelector::readValues() { QString line; line = m_stream->readLine(); - QRegExp id(QLatin1String("Version ID: (.*)")); - if (id.indexIn(line) == -1) + const QRegularExpression id("Version ID: (.*)"); + const QRegularExpressionMatch idMatch = id.match(line); + if (!idMatch.hasMatch()) return false; - m_versionID = id.cap(1); + m_versionID = idMatch.captured(1); + line = m_stream->readLine(); - QRegExp owner(QLatin1String("Created by: (.*)")); - if (owner.indexIn(line) == -1) + const QRegularExpression owner("Created by: (.*)"); + const QRegularExpressionMatch ownerMatch = owner.match(line); + if (!ownerMatch.hasMatch()) return false; - m_createdBy = owner.cap(1); + m_createdBy = ownerMatch.captured(1); + line = m_stream->readLine(); - QRegExp dateTimeRE(QLatin1String("Created on: (.*)")); - if (dateTimeRE.indexIn(line) == -1) + const QRegularExpression dateTimeRE("Created on: (.*)"); + const QRegularExpressionMatch dateTimeMatch = dateTimeRE.match(line); + if (!dateTimeMatch.hasMatch()) return false; - m_createdOn = dateTimeRE.cap(1); + m_createdOn = dateTimeMatch.captured(1); + QStringList messageLines; do { |