forked from qt-creator/qt-creator
Utils: Use QRegularExpression in fileutils
Change-Id: I48b192630e52ff3825bcb401a19faef59e846da3 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <QOperatingSystemVersion>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <qplatformdefs.h>
|
||||
@@ -325,10 +325,10 @@ QString FilePath::shortNativePath() const
|
||||
QString FileUtils::fileSystemFriendlyName(const QString &name)
|
||||
{
|
||||
QString result = name;
|
||||
result.replace(QRegExp(QLatin1String("\\W")), QLatin1String("_"));
|
||||
result.replace(QRegExp(QLatin1String("_+")), QLatin1String("_")); // compact _
|
||||
result.remove(QRegExp(QLatin1String("^_*"))); // remove leading _
|
||||
result.remove(QRegExp(QLatin1String("_+$"))); // remove trailing _
|
||||
result.replace(QRegularExpression(QLatin1String("\\W")), QLatin1String("_"));
|
||||
result.replace(QRegularExpression(QLatin1String("_+")), QLatin1String("_")); // compact _
|
||||
result.remove(QRegularExpression(QLatin1String("^_*"))); // remove leading _
|
||||
result.remove(QRegularExpression(QLatin1String("_+$"))); // remove trailing _
|
||||
if (result.isEmpty())
|
||||
result = QLatin1String("unknown");
|
||||
return result;
|
||||
@@ -336,8 +336,8 @@ QString FileUtils::fileSystemFriendlyName(const QString &name)
|
||||
|
||||
int FileUtils::indexOfQmakeUnfriendly(const QString &name, int startpos)
|
||||
{
|
||||
static QRegExp checkRegExp(QLatin1String("[^a-zA-Z0-9_.-]"));
|
||||
return checkRegExp.indexIn(name, startpos);
|
||||
static const QRegularExpression checkRegExp(QLatin1String("[^a-zA-Z0-9_.-]"));
|
||||
return checkRegExp.match(name, startpos).capturedStart();
|
||||
}
|
||||
|
||||
QString FileUtils::qmakeFriendlyName(const QString &name)
|
||||
|
Reference in New Issue
Block a user