summaryrefslogtreecommitdiffstats
path: root/qmake/library
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/library')
-rw-r--r--qmake/library/ioutils.cpp111
-rw-r--r--qmake/library/ioutils.h34
-rw-r--r--qmake/library/proitems.cpp177
-rw-r--r--qmake/library/proitems.h203
-rw-r--r--qmake/library/qmake_global.h29
-rw-r--r--qmake/library/qmakebuiltins.cpp254
-rw-r--r--qmake/library/qmakeevaluator.cpp120
-rw-r--r--qmake/library/qmakeevaluator.h35
-rw-r--r--qmake/library/qmakeevaluator_p.h33
-rw-r--r--qmake/library/qmakeglobals.cpp62
-rw-r--r--qmake/library/qmakeglobals.h33
-rw-r--r--qmake/library/qmakeparser.cpp76
-rw-r--r--qmake/library/qmakeparser.h37
-rw-r--r--qmake/library/qmakevfs.cpp55
-rw-r--r--qmake/library/qmakevfs.h40
-rw-r--r--qmake/library/registry.cpp31
-rw-r--r--qmake/library/registry_p.h29
17 files changed, 484 insertions, 875 deletions
diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp
index d2171274d8..38bb246341 100644
--- a/qmake/library/ioutils.cpp
+++ b/qmake/library/ioutils.cpp
@@ -1,39 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "ioutils.h"
#include <qdir.h>
#include <qfile.h>
-#include <qregexp.h>
+#include <qregularexpression.h>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
+# include <private/qsystemerror_p.h>
#else
# include <sys/types.h>
# include <sys/stat.h>
@@ -49,6 +25,40 @@ QT_BEGIN_NAMESPACE
using namespace QMakeInternal;
+QString IoUtils::binaryAbsLocation(const QString &argv0)
+{
+ QString ret;
+ if (!argv0.isEmpty() && isAbsolutePath(argv0)) {
+ ret = argv0;
+ } else if (argv0.contains(QLatin1Char('/'))
+#ifdef Q_OS_WIN
+ || argv0.contains(QLatin1Char('\\'))
+#endif
+ ) { // relative PWD
+ ret = QDir::current().absoluteFilePath(argv0);
+ } else { // in the PATH
+ QByteArray pEnv = qgetenv("PATH");
+ QDir currentDir = QDir::current();
+#ifdef Q_OS_WIN
+ QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(";"));
+ paths.prepend(QLatin1String("."));
+#else
+ QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(":"));
+#endif
+ for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) {
+ if ((*p).isEmpty())
+ continue;
+ QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + argv0);
+ if (QFile::exists(candidate)) {
+ ret = candidate;
+ break;
+ }
+ }
+ }
+
+ return QDir::cleanPath(ret);
+}
+
IoUtils::FileType IoUtils::fileType(const QString &fileName)
{
Q_ASSERT(fileName.isEmpty() || isAbsolutePath(fileName));
@@ -91,14 +101,14 @@ bool IoUtils::isRelativePath(const QString &path)
return true;
}
-QStringRef IoUtils::pathName(const QString &fileName)
+QStringView IoUtils::pathName(const QString &fileName)
{
- return fileName.leftRef(fileName.lastIndexOf(QLatin1Char('/')) + 1);
+ return QStringView{fileName}.left(fileName.lastIndexOf(QLatin1Char('/')) + 1);
}
-QStringRef IoUtils::fileName(const QString &fileName)
+QStringView IoUtils::fileName(const QString &fileName)
{
- return fileName.midRef(fileName.lastIndexOf(QLatin1Char('/')) + 1);
+ return QStringView(fileName).mid(fileName.lastIndexOf(QLatin1Char('/')) + 1);
}
QString IoUtils::resolvePath(const QString &baseDir, const QString &fileName)
@@ -127,7 +137,7 @@ bool isSpecialChar(ushort c, const uchar (&iqm)[16])
inline static
bool hasSpecialChars(const QString &arg, const uchar (&iqm)[16])
{
- for (int x = arg.length() - 1; x >= 0; --x) {
+ for (int x = arg.size() - 1; x >= 0; --x) {
if (isSpecialChar(arg.unicode()[x].unicode(), iqm))
return true;
}
@@ -142,7 +152,7 @@ QString IoUtils::shellQuoteUnix(const QString &arg)
0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78
}; // 0-32 \'"$`<>|;&(){}*?#!~[]
- if (!arg.length())
+ if (!arg.size())
return QString::fromLatin1("''");
QString ret(arg);
@@ -170,7 +180,7 @@ QString IoUtils::shellQuoteWin(const QString &arg)
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10
}; // &()<>^|
- if (!arg.length())
+ if (!arg.size())
return QString::fromLatin1("\"\"");
QString ret(arg);
@@ -178,15 +188,15 @@ QString IoUtils::shellQuoteWin(const QString &arg)
// The process-level standard quoting allows escaping quotes with backslashes (note
// that backslashes don't escape themselves, unless they are followed by a quote).
// Consequently, quotes are escaped and their preceding backslashes are doubled.
- ret.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
+ ret.replace(QRegularExpression(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
// Trailing backslashes must be doubled as well, as they are followed by a quote.
- ret.replace(QRegExp(QLatin1String("(\\\\+)$")), QLatin1String("\\1\\1"));
+ ret.replace(QRegularExpression(QLatin1String("(\\\\+)$")), QLatin1String("\\1\\1"));
// However, the shell also interprets the command, and no backslash-escaping exists
// there - a quote always toggles the quoting state, but is nonetheless passed down
// to the called process verbatim. In the unquoted state, the circumflex escapes
// meta chars (including itself and quotes), and is removed from the command.
bool quoted = true;
- for (int i = 0; i < ret.length(); i++) {
+ for (int i = 0; i < ret.size(); i++) {
QChar c = ret.unicode()[i];
if (c.unicode() == '"')
quoted = !quoted;
@@ -203,23 +213,6 @@ QString IoUtils::shellQuoteWin(const QString &arg)
#if defined(PROEVALUATOR_FULL)
-# if defined(Q_OS_WIN)
-static QString windowsErrorCode()
-{
- wchar_t *string = nullptr;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&string,
- 0,
- NULL);
- QString ret = QString::fromWCharArray(string);
- LocalFree((HLOCAL)string);
- return ret.trimmed();
-}
-# endif
-
bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceFileName, QString *errorString)
{
# ifdef Q_OS_UNIX
@@ -246,7 +239,8 @@ bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceF
GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (rHand == INVALID_HANDLE_VALUE) {
- *errorString = fL1S("Cannot open reference file %1: %2").arg(referenceFileName, windowsErrorCode());
+ *errorString = fL1S("Cannot open reference file %1: %2")
+ .arg(referenceFileName, QSystemError::windowsString());
return false;
}
FILETIME ft;
@@ -256,7 +250,8 @@ bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceF
GENERIC_WRITE, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (wHand == INVALID_HANDLE_VALUE) {
- *errorString = fL1S("Cannot open %1: %2").arg(targetFileName, windowsErrorCode());
+ *errorString = fL1S("Cannot open %1: %2")
+ .arg(targetFileName, QSystemError::windowsString());
return false;
}
SetFileTime(wHand, NULL, NULL, &ft);
diff --git a/qmake/library/ioutils.h b/qmake/library/ioutils.h
index 32bf675f62..2f288e543e 100644
--- a/qmake/library/ioutils.h
+++ b/qmake/library/ioutils.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef IOUTILS_H
#define IOUTILS_H
@@ -49,12 +24,13 @@ public:
FileIsDir = 2
};
+ static QString binaryAbsLocation(const QString &argv0);
static FileType fileType(const QString &fileName);
static bool exists(const QString &fileName) { return fileType(fileName) != FileNotFound; }
static bool isRelativePath(const QString &fileName);
static bool isAbsolutePath(const QString &fileName) { return !isRelativePath(fileName); }
- static QStringRef pathName(const QString &fileName); // Requires normalized path
- static QStringRef fileName(const QString &fileName); // Requires normalized path
+ static QStringView pathName(const QString &fileName); // Requires normalized path
+ static QStringView fileName(const QString &fileName); // Requires normalized path
static QString resolvePath(const QString &baseDir, const QString &fileName);
static QString shellQuoteUnix(const QString &arg);
static QString shellQuoteWin(const QString &arg);
diff --git a/qmake/library/proitems.cpp b/qmake/library/proitems.cpp
index 9330c2b1bf..2edd40a35c 100644
--- a/qmake/library/proitems.cpp
+++ b/qmake/library/proitems.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "proitems.h"
@@ -32,13 +7,14 @@
#include <qset.h>
#include <qstringlist.h>
#include <qtextstream.h>
+#include <private/qduplicatetracker_p.h>
QT_BEGIN_NAMESPACE
// from qhash.cpp
-uint ProString::hash(const QChar *p, int n)
+size_t ProString::hash(const QChar *p, int n)
{
- uint h = 0;
+ size_t h = 0;
while (n--) {
h = (h << 4) + (*p++).unicode();
@@ -64,29 +40,29 @@ ProString::ProString(const ProString &other, OmitPreHashing) :
}
ProString::ProString(const QString &str, DoPreHashing) :
- m_string(str), m_offset(0), m_length(str.length()), m_file(0)
+ m_string(str), m_offset(0), m_length(str.size()), m_file(0)
{
updatedHash();
}
ProString::ProString(const QString &str) :
- m_string(str), m_offset(0), m_length(str.length()), m_file(0), m_hash(0x80000000)
+ m_string(str), m_offset(0), m_length(str.size()), m_file(0), m_hash(0x80000000)
{
}
-ProString::ProString(const QStringRef &str) :
- m_string(*str.string()), m_offset(str.position()), m_length(str.size()), m_file(0), m_hash(0x80000000)
+ProString::ProString(QStringView str) :
+ m_string(str.toString()), m_offset(0), m_length(str.size()), m_file(0), m_hash(0x80000000)
{
}
ProString::ProString(const char *str, DoPreHashing) :
- m_string(QString::fromLatin1(str)), m_offset(0), m_length(qstrlen(str)), m_file(0)
+ m_string(QString::fromLatin1(str)), m_offset(0), m_length(int(qstrlen(str))), m_file(0)
{
updatedHash();
}
ProString::ProString(const char *str) :
- m_string(QString::fromLatin1(str)), m_offset(0), m_length(qstrlen(str)), m_file(0), m_hash(0x80000000)
+ m_string(QString::fromLatin1(str)), m_offset(0), m_length(int(qstrlen(str))), m_file(0), m_hash(0x80000000)
{
}
@@ -108,15 +84,15 @@ ProString::ProString(const QString &str, int offset, int length) :
void ProString::setValue(const QString &str)
{
- m_string = str, m_offset = 0, m_length = str.length(), m_hash = 0x80000000;
+ m_string = str, m_offset = 0, m_length = str.size(), m_hash = 0x80000000;
}
-uint ProString::updatedHash() const
+size_t ProString::updatedHash() const
{
return (m_hash = hash(m_string.constData() + m_offset, m_length));
}
-uint qHash(const ProString &str)
+size_t qHash(const ProString &str)
{
if (!(str.m_hash & 0x80000000))
return str.m_hash;
@@ -145,7 +121,7 @@ ProKey::ProKey(const QString &str, int off, int len, uint hash) :
void ProKey::setValue(const QString &str)
{
- m_string = str, m_offset = 0, m_length = str.length();
+ m_string = str, m_offset = 0, m_length = str.size();
updatedHash();
}
@@ -156,42 +132,8 @@ QString ProString::toQString() const
QString &ProString::toQString(QString &tmp) const
{
- return tmp.setRawData(m_string.constData() + m_offset, m_length);
-}
-
-/*
- * \brief ProString::prepareExtend
- * \param extraLen number of new characters to be added
- * \param thisTarget offset to which current contents should be moved
- * \param extraTarget offset at which new characters will be added
- * \return pointer to storage location for new characters
- *
- * Prepares the string for adding new characters.
- * If the string is detached and has enough space, it will be changed in place.
- * Otherwise, it will be replaced with a new string object, thus detaching.
- * In either case, the hash will be reset.
- */
-QChar *ProString::prepareExtend(int extraLen, int thisTarget, int extraTarget)
-{
- if (m_string.isDetached() && m_length + extraLen <= m_string.capacity()) {
- m_string.reserve(0); // Prevent the resize() below from reallocating
- QChar *ptr = (QChar *)m_string.constData();
- if (m_offset != thisTarget)
- memmove(ptr + thisTarget, ptr + m_offset, m_length * 2);
- ptr += extraTarget;
- m_offset = 0;
- m_length += extraLen;
- m_string.resize(m_length);
- m_hash = 0x80000000;
- return ptr;
- } else {
- QString neu(m_length + extraLen, Qt::Uninitialized);
- QChar *ptr = (QChar *)neu.constData();
- memcpy(ptr + thisTarget, m_string.constData() + m_offset, m_length * 2);
- ptr += extraTarget;
- *this = ProString(neu);
- return ptr;
- }
+ tmp = m_string.mid(m_offset, m_length);
+ return tmp;
}
ProString &ProString::prepend(const ProString &other)
@@ -200,10 +142,12 @@ ProString &ProString::prepend(const ProString &other)
if (!m_length) {
*this = other;
} else {
- QChar *ptr = prepareExtend(other.m_length, other.m_length, 0);
- memcpy(ptr, other.constData(), other.m_length * 2);
+ m_string = other.toQStringView() + toQStringView();
+ m_offset = 0;
+ m_length = m_string.size();
if (!m_file)
m_file = other.m_file;
+ m_hash = 0x80000000;
}
}
return *this;
@@ -211,20 +155,33 @@ ProString &ProString::prepend(const ProString &other)
ProString &ProString::append(const QLatin1String other)
{
- const char *latin1 = other.latin1();
- int size = other.size();
- if (size) {
- QChar *ptr = prepareExtend(size, 0, m_length);
- for (int i = 0; i < size; i++)
- *ptr++ = QLatin1Char(latin1[i]);
+ if (other.size()) {
+ if (m_length != m_string.size()) {
+ m_string = toQStringView() + other;
+ m_offset = 0;
+ m_length = m_string.size();
+ } else {
+ Q_ASSERT(m_offset == 0);
+ m_string.append(other);
+ m_length += other.size();
+ }
+ m_hash = 0x80000000;
}
return *this;
}
ProString &ProString::append(QChar other)
{
- QChar *ptr = prepareExtend(1, 0, m_length);
- *ptr = other;
+ if (m_length != m_string.size()) {
+ m_string = toQStringView() + other;
+ m_offset = 0;
+ m_length = m_string.size();
+ } else {
+ Q_ASSERT(m_offset == 0);
+ m_string.append(other);
+ ++m_length;
+ }
+ m_hash = 0x80000000;
return *this;
}
@@ -235,16 +192,18 @@ ProString &ProString::append(const ProString &other, bool *pending)
if (!m_length) {
*this = other;
} else {
- QChar *ptr;
+ if (m_length != m_string.size())
+ m_string = toQString();
if (pending && !*pending) {
- ptr = prepareExtend(1 + other.m_length, 0, m_length);
- *ptr++ = QLatin1Char(' ');
+ m_string += QLatin1Char(' ') + other.toQStringView();
} else {
- ptr = prepareExtend(other.m_length, 0, m_length);
+ m_string += other.toQStringView();
}
- memcpy(ptr, other.m_string.constData() + other.m_offset, other.m_length * 2);
+ m_length = m_string.size();
+ m_offset = 0;
if (other.m_file)
m_file = other.m_file;
+ m_hash = 0x80000000;
}
if (pending)
*pending = true;
@@ -264,27 +223,24 @@ ProString &ProString::append(const ProStringList &other, bool *pending, bool ski
if (!m_length && sz == startIdx + 1) {
*this = other.at(startIdx);
} else {
- int totalLength = sz - startIdx;
- for (int i = startIdx; i < sz; ++i)
- totalLength += other.at(i).size();
bool putSpace = false;
if (pending && !*pending && m_length)
putSpace = true;
- else
- totalLength--;
- QChar *ptr = prepareExtend(totalLength, 0, m_length);
+ m_string = toQString();
+ m_offset = 0;
for (int i = startIdx; i < sz; ++i) {
if (putSpace)
- *ptr++ = QLatin1Char(' ');
+ m_string += QLatin1Char(' ');
else
putSpace = true;
const ProString &str = other.at(i);
- memcpy(ptr, str.m_string.constData() + str.m_offset, str.m_length * 2);
- ptr += str.m_length;
+ m_string += str.toQStringView();
}
+ m_length = m_string.size();
if (other.last().m_file)
m_file = other.last().m_file;
+ m_hash = 0x80000000;
}
if (pending)
*pending = true;
@@ -341,7 +297,7 @@ ProString ProString::trimmed() const
QTextStream &operator<<(QTextStream &t, const ProString &str)
{
- t << str.toQStringRef();
+ t << str.toQStringView();
return t;
}
@@ -418,21 +374,8 @@ void ProStringList::removeEmpty()
void ProStringList::removeDuplicates()
{
- int n = size();
- int j = 0;
- QSet<ProString> seen;
- seen.reserve(n);
- for (int i = 0; i < n; ++i) {
- const ProString &s = at(i);
- if (seen.contains(s))
- continue;
- seen.insert(s);
- if (j != i)
- (*this)[j] = s;
- ++j;
- }
- if (n != j)
- erase(begin() + j, end());
+ QDuplicateTracker<ProString> seen(size());
+ removeIf([&](const ProString &s) { return seen.hasSeen(s); });
}
void ProStringList::insertUnique(const ProStringList &value)
@@ -466,10 +409,10 @@ bool ProStringList::contains(const ProString &str, Qt::CaseSensitivity cs) const
return false;
}
-bool ProStringList::contains(const QStringRef &str, Qt::CaseSensitivity cs) const
+bool ProStringList::contains(QStringView str, Qt::CaseSensitivity cs) const
{
for (int i = 0; i < size(); i++)
- if (!at(i).toQStringRef().compare(str, cs))
+ if (!at(i).toQStringView().compare(str, cs))
return true;
return false;
}
diff --git a/qmake/library/proitems.h b/qmake/library/proitems.h
index 4569d7c3ff..2de982034c 100644
--- a/qmake/library/proitems.h
+++ b/qmake/library/proitems.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef PROITEMS_H
#define PROITEMS_H
@@ -32,9 +7,10 @@
#include "qmake_global.h"
#include <qdebug.h>
-#include <qstring.h>
-#include <qvector.h>
#include <qhash.h>
+#include <qlist.h>
+#include <qmap.h>
+#include <qstring.h>
QT_BEGIN_NAMESPACE
@@ -69,9 +45,16 @@ public:
ProString();
ProString(const ProString &other);
ProString &operator=(const ProString &) = default;
- PROITEM_EXPLICIT ProString(const QString &str);
- PROITEM_EXPLICIT ProString(const QStringRef &str);
+ template<typename A, typename B>
+ ProString &operator=(const QStringBuilder<A, B> &str)
+ { return *this = QString(str); }
+ ProString(const QString &str);
+ PROITEM_EXPLICIT ProString(QStringView str);
PROITEM_EXPLICIT ProString(const char *str);
+ template<typename A, typename B>
+ ProString(const QStringBuilder<A, B> &str)
+ : ProString(QString(str))
+ {}
ProString(const QString &str, int offset, int length);
void setValue(const QString &str);
void clear() { m_string.clear(); m_length = 0; }
@@ -82,12 +65,16 @@ public:
ProString &prepend(const ProString &other);
ProString &append(const ProString &other, bool *pending = nullptr);
ProString &append(const QString &other) { return append(ProString(other)); }
+ template<typename A, typename B>
+ ProString &append(const QStringBuilder<A, B> &other) { return append(QString(other)); }
ProString &append(const QLatin1String other);
ProString &append(const char *other) { return append(QLatin1String(other)); }
ProString &append(QChar other);
ProString &append(const ProStringList &other, bool *pending = nullptr, bool skipEmpty1st = false);
ProString &operator+=(const ProString &other) { return append(other); }
ProString &operator+=(const QString &other) { return append(other); }
+ template<typename A, typename B>
+ ProString &operator+=(const QStringBuilder<A, B> &other) { return append(QString(other)); }
ProString &operator+=(const QLatin1String other) { return append(other); }
ProString &operator+=(const char *other) { return append(other); }
ProString &operator+=(QChar other) { return append(other); }
@@ -95,16 +82,16 @@ public:
void chop(int n) { Q_ASSERT(n <= m_length); m_length -= n; }
void chopFront(int n) { Q_ASSERT(n <= m_length); m_offset += n; m_length -= n; }
- bool operator==(const ProString &other) const { return toQStringRef() == other.toQStringRef(); }
- bool operator==(const QString &other) const { return toQStringRef() == other; }
- bool operator==(const QStringRef &other) const { return toQStringRef() == other; }
- bool operator==(QLatin1String other) const { return toQStringRef() == other; }
- bool operator==(const char *other) const { return toQStringRef() == QLatin1String(other); }
+ bool operator==(const ProString &other) const { return toQStringView() == other.toQStringView(); }
+ bool operator==(const QString &other) const { return toQStringView() == other; }
+ bool operator==(QStringView other) const { return toQStringView() == other; }
+ bool operator==(QLatin1String other) const { return toQStringView() == other; }
+ bool operator==(const char *other) const { return toQStringView() == QLatin1String(other); }
bool operator!=(const ProString &other) const { return !(*this == other); }
bool operator!=(const QString &other) const { return !(*this == other); }
bool operator!=(QLatin1String other) const { return !(*this == other); }
bool operator!=(const char *other) const { return !(*this == other); }
- bool operator<(const ProString &other) const { return toQStringRef() < other.toQStringRef(); }
+ bool operator<(const ProString &other) const { return toQStringView() < other.toQStringView(); }
bool isNull() const { return m_string.isNull(); }
bool isEmpty() const { return !m_length; }
int length() const { return m_length; }
@@ -115,34 +102,37 @@ public:
ProString left(int len) const { return mid(0, len); }
ProString right(int len) const { return mid(qMax(0, size() - len)); }
ProString trimmed() const;
- int compare(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().compare(sub.toQStringRef(), cs); }
- int compare(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().compare(sub, cs); }
- int compare(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().compare(QLatin1String(sub), cs); }
- bool startsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(sub.toQStringRef(), cs); }
- bool startsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(sub, cs); }
- bool startsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(QLatin1String(sub), cs); }
- bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(c, cs); }
- bool endsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(sub.toQStringRef(), cs); }
- bool endsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(sub, cs); }
- bool endsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(QLatin1String(sub), cs); }
- bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(c, cs); }
- int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(s, from, cs); }
- int indexOf(const char *s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(QLatin1String(s), from, cs); }
- int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(c, from, cs); }
- int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().lastIndexOf(s, from, cs); }
- int lastIndexOf(const char *s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().lastIndexOf(QLatin1String(s), from, cs); }
- int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().lastIndexOf(c, from, cs); }
+ int compare(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().compare(sub.toQStringView(), cs); }
+ int compare(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().compare(sub, cs); }
+ int compare(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().compare(QLatin1String(sub), cs); }
+ bool startsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().startsWith(sub.toQStringView(), cs); }
+ bool startsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().startsWith(sub, cs); }
+ bool startsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().startsWith(QLatin1String(sub), cs); }
+ bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().startsWith(c, cs); }
+ template<typename A, typename B>
+ bool startsWith(const QStringBuilder<A, B> &str) { return startsWith(QString(str)); }
+ bool endsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().endsWith(sub.toQStringView(), cs); }
+ bool endsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().endsWith(sub, cs); }
+ bool endsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().endsWith(QLatin1String(sub), cs); }
+ template<typename A, typename B>
+ bool endsWith(const QStringBuilder<A, B> &str) { return endsWith(QString(str)); }
+ bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().endsWith(c, cs); }
+ int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().indexOf(s, from, cs); }
+ int indexOf(const char *s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().indexOf(QLatin1String(s), from, cs); }
+ int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().indexOf(c, from, cs); }
+ int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().lastIndexOf(s, from, cs); }
+ int lastIndexOf(const char *s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().lastIndexOf(QLatin1String(s), from, cs); }
+ int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().lastIndexOf(c, from, cs); }
bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(s, 0, cs) >= 0; }
bool contains(const char *s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(QLatin1String(s), 0, cs) >= 0; }
bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(c, 0, cs) >= 0; }
- qlonglong toLongLong(bool *ok = nullptr, int base = 10) const { return toQStringRef().toLongLong(ok, base); }
- int toInt(bool *ok = nullptr, int base = 10) const { return toQStringRef().toInt(ok, base); }
- short toShort(bool *ok = nullptr, int base = 10) const { return toQStringRef().toShort(ok, base); }
+ qlonglong toLongLong(bool *ok = nullptr, int base = 10) const { return toQStringView().toLongLong(ok, base); }
+ int toInt(bool *ok = nullptr, int base = 10) const { return toQStringView().toInt(ok, base); }
+ short toShort(bool *ok = nullptr, int base = 10) const { return toQStringView().toShort(ok, base); }
- uint hash() const { return m_hash; }
- static uint hash(const QChar *p, int n);
+ size_t hash() const { return m_hash; }
+ static size_t hash(const QChar *p, int n);
- ALWAYS_INLINE QStringRef toQStringRef() const { return QStringRef(&m_string, m_offset, m_length); }
ALWAYS_INLINE QStringView toQStringView() const { return QStringView(m_string).mid(m_offset, m_length); }
ALWAYS_INLINE ProKey &toKey() { return *(ProKey *)this; }
@@ -151,7 +141,7 @@ public:
QString toQString() const;
QString &toQString(QString &tmp) const;
- QByteArray toLatin1() const { return toQStringRef().toLatin1(); }
+ QByteArray toLatin1() const { return toQStringView().toLatin1(); }
private:
ProString(const ProKey &other);
@@ -169,19 +159,23 @@ private:
QString m_string;
int m_offset, m_length;
int m_file;
- mutable uint m_hash;
- QChar *prepareExtend(int extraLen, int thisTarget, int extraTarget);
- uint updatedHash() const;
- friend uint qHash(const ProString &str);
+ mutable size_t m_hash;
+ size_t updatedHash() const;
+ friend size_t qHash(const ProString &str);
friend QString operator+(const ProString &one, const ProString &two);
friend class ProKey;
};
-Q_DECLARE_TYPEINFO(ProString, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(ProString, Q_RELOCATABLE_TYPE);
+
class ProKey : public ProString {
public:
ALWAYS_INLINE ProKey() : ProString() {}
explicit ProKey(const QString &str);
+ template<typename A, typename B>
+ ProKey(const QStringBuilder<A, B> &str)
+ : ProString(str)
+ {}
PROITEM_EXPLICIT ProKey(const char *str);
ProKey(const QString &str, int off, int len);
ProKey(const QString &str, int off, int len, uint hash);
@@ -203,33 +197,49 @@ public:
private:
ProKey(const ProString &other);
};
-Q_DECLARE_TYPEINFO(ProKey, Q_MOVABLE_TYPE);
-
-uint qHash(const ProString &str);
-QString operator+(const ProString &one, const ProString &two);
-inline QString operator+(const ProString &one, const QString &two)
- { return one.toQStringRef() + two; }
-inline QString operator+(const QString &one, const ProString &two)
- { return one + two.toQStringRef(); }
-
-inline QString operator+(const ProString &one, const char *two)
- { return one.toQStringRef() + QLatin1String(two); }
-inline QString operator+(const char *one, const ProString &two)
- { return QLatin1String(one) + two.toQStringRef(); }
-inline QString operator+(const ProString &one, QChar two)
- { return one.toQStringRef() + two; }
-inline QString operator+(QChar one, const ProString &two)
- { return one + two.toQStringRef(); }
+Q_DECLARE_TYPEINFO(ProKey, Q_RELOCATABLE_TYPE);
-inline QString &operator+=(QString &that, const ProString &other)
- { return that += other.toQStringRef(); }
+template <> struct QConcatenable<ProString> : private QAbstractConcatenable
+{
+ typedef ProString type;
+ typedef QString ConvertTo;
+ enum { ExactSize = true };
+ static int size(const ProString &a) { return a.length(); }
+ static inline void appendTo(const ProString &a, QChar *&out)
+ {
+ const auto n = a.size();
+ if (!n)
+ return;
+ memcpy(out, a.toQStringView().data(), sizeof(QChar) * n);
+ out += n;
+ }
+};
-inline bool operator==(const QString &that, const ProString &other)
- { return other == that; }
-inline bool operator!=(const QString &that, const ProString &other)
- { return !(other == that); }
+template <> struct QConcatenable<ProKey> : private QAbstractConcatenable
+{
+ typedef ProKey type;
+ typedef QString ConvertTo;
+ enum { ExactSize = true };
+ static int size(const ProKey &a) { return a.length(); }
+ static inline void appendTo(const ProKey &a, QChar *&out)
+ {
+ const auto n = a.size();
+ if (!n)
+ return;
+ memcpy(out, a.toQStringView().data(), sizeof(QChar) * n);
+ out += n;
+ }
+};
+
+
+size_t qHash(const ProString &str);
+
+inline QString &operator+=(QString &that, const ProString &other)
+ { return that += other.toQStringView(); }
QTextStream &operator<<(QTextStream &t, const ProString &str);
+template<typename A, typename B>
+QTextStream &operator<<(QTextStream &t, const QStringBuilder<A, B> &str) { return t << QString(str); }
// This class manages read-only access to a ProString via a raw data QString
// temporary, ensuring that the latter is accessed exclusively.
@@ -238,7 +248,6 @@ class ProStringRoUser
public:
ProStringRoUser(QString &rs)
{
- Q_ASSERT(rs.isDetached() || rs.isEmpty());
m_rs = &rs;
}
ProStringRoUser(const ProString &ps, QString &rs)
@@ -280,7 +289,7 @@ private:
const ProString *m_ps;
};
-class ProStringList : public QVector<ProString> {
+class ProStringList : public QList<ProString> {
public:
ProStringList() {}
ProStringList(const ProString &str) { *this << str; }
@@ -288,13 +297,15 @@ public:
QStringList toQStringList() const;
ProStringList &operator<<(const ProString &str)
- { QVector<ProString>::operator<<(str); return *this; }
+ { QList<ProString>::operator<<(str); return *this; }
int length() const { return size(); }
QString join(const ProString &sep) const;
QString join(const QString &sep) const;
QString join(QChar sep) const;
+ template<typename A, typename B>
+ QString join(const QStringBuilder<A, B> &str) { return join(QString(str)); }
void insertUnique(const ProStringList &value);
@@ -306,17 +317,17 @@ public:
void removeDuplicates();
bool contains(const ProString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- bool contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
{ return contains(ProString(str), cs); }
bool contains(const char *str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
};
-Q_DECLARE_TYPEINFO(ProStringList, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(ProStringList, Q_RELOCATABLE_TYPE);
inline ProStringList operator+(const ProStringList &one, const ProStringList &two)
{ ProStringList ret = one; ret += two; return ret; }
-typedef QHash<ProKey, ProStringList> ProValueMap;
+typedef QMap<ProKey, ProStringList> ProValueMap;
// These token definitions affect both ProFileEvaluator and ProWriter
enum ProToken {
@@ -464,7 +475,7 @@ private:
int m_offset;
};
-Q_DECLARE_TYPEINFO(ProFunctionDef, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(ProFunctionDef, Q_RELOCATABLE_TYPE);
struct ProFunctionDefs {
QHash<ProKey, ProFunctionDef> testFunctions;
diff --git a/qmake/library/qmake_global.h b/qmake/library/qmake_global.h
index a718763859..612de43e9b 100644
--- a/qmake/library/qmake_global.h
+++ b/qmake/library/qmake_global.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QMAKE_GLOBAL_H
#define QMAKE_GLOBAL_H
diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp
index 7f6926e98e..f885bb19c3 100644
--- a/qmake/library/qmakebuiltins.cpp
+++ b/qmake/library/qmakebuiltins.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmakeevaluator.h"
@@ -38,16 +13,15 @@
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
+#include <qjsonarray.h>
+#include <qjsondocument.h>
+#include <qjsonobject.h>
#include <qlist.h>
-#include <qregexp.h>
+#include <qregularexpression.h>
#include <qset.h>
#include <qstringlist.h>
#include <qtextstream.h>
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-# include <qjsondocument.h>
-# include <qjsonobject.h>
-# include <qjsonarray.h>
-#endif
+
#ifdef PROEVALUATOR_THREAD_SAFE
# include <qthreadpool.h>
#endif
@@ -67,7 +41,7 @@
#include <sys/stat.h>
#include <sys/utsname.h>
#else
-#include <windows.h>
+#include <qt_windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
@@ -222,9 +196,7 @@ void QMakeEvaluator::initFunctionStatics()
{ "infile", T_INFILE, 2, 3, "file, var, [values]" },
{ "count", T_COUNT, 2, 3, "var, count, [op=operator]" },
{ "isEmpty", T_ISEMPTY, 1, 1, "var" },
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
{ "parseJson", T_PARSE_JSON, 2, 2, "var, into" },
-#endif
{ "load", T_LOAD, 1, 2, "feature, [ignore_errors=false]" },
{ "include", T_INCLUDE, 1, 3, "file, [into, [silent]]" },
{ "debug", T_DEBUG, 2, 2, "level, message" },
@@ -253,12 +225,12 @@ QMakeEvaluator::getMemberArgs(const ProKey &func, int srclen, const ProStringLis
int *start, int *end)
{
*start = 0, *end = 0;
- if (args.count() >= 2) {
+ if (args.size() >= 2) {
bool ok = true;
const ProString &start_str = args.at(1);
*start = start_str.toInt(&ok);
if (!ok) {
- if (args.count() == 2) {
+ if (args.size() == 2) {
int dotdot = start_str.indexOf(statics.strDotDot);
if (dotdot != -1) {
*start = start_str.left(dotdot).toInt(&ok);
@@ -274,7 +246,7 @@ QMakeEvaluator::getMemberArgs(const ProKey &func, int srclen, const ProStringLis
}
} else {
*end = *start;
- if (args.count() == 3)
+ if (args.size() == 3)
*end = args.at(2).toInt(&ok);
if (!ok) {
ProStringRoUser u1(func, m_tmp1);
@@ -362,7 +334,6 @@ QMakeEvaluator::quoteValue(const ProString &val)
return ret;
}
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
static void addJsonValue(const QJsonValue &value, const QString &keyPrefix, ProValueMap *map);
static void insertJsonKeyValue(const QString &key, const QStringList &values, ProValueMap *map)
@@ -474,7 +445,6 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::parseJsonInto(const QByteArray &json
return QMakeEvaluator::ReturnTrue;
}
-#endif
QMakeEvaluator::VisitReturn
QMakeEvaluator::writeFile(const QString &ctx, const QString &fn, QIODevice::OpenMode mode,
@@ -576,7 +546,7 @@ void QMakeEvaluator::populateDeps(
if (depends.isEmpty()) {
rootSet.insert(first(ProKey(prefix + item + priosfx)).toInt(), item);
} else {
- for (const ProString &dep : qAsConst(depends)) {
+ for (const ProString &dep : std::as_const(depends)) {
dset.insert(dep.toKey());
dependees[dep.toKey()] << item;
}
@@ -625,7 +595,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
var = args[0];
sep = args.at(1).toQString();
beg = args.at(2).toInt();
- if (args.count() == 4)
+ if (args.size() == 4)
end = args.at(3).toInt();
} else {
var = args[0];
@@ -639,7 +609,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
if (!var.isEmpty()) {
const auto strings = values(map(var));
if (regexp) {
- QRegExp sepRx(sep);
+ QRegularExpression sepRx(sep, QRegularExpression::DotMatchesEverythingOption);
+ if (!sepRx.isValid()) {
+ evalError(fL1S("section(): Encountered invalid regular expression '%1'.").arg(sep));
+ goto allfail;
+ }
for (const ProString &str : strings) {
ProStringRwUser u1(str, m_tmp[m_toggle ^= 1]);
ret << u1.extract(u1.str().section(sepRx, beg, end));
@@ -656,7 +630,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
case E_SPRINTF: {
ProStringRwUser u1(args.at(0), m_tmp1);
QString tmp = u1.str();
- for (int i = 1; i < args.count(); ++i)
+ for (int i = 1; i < args.size(); ++i)
tmp = tmp.arg(args.at(i).toQStringView());
ret << u1.extract(tmp);
break;
@@ -668,8 +642,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
bool zeropad = false;
bool leftalign = false;
enum { DefaultSign, PadSign, AlwaysSign } sign = DefaultSign;
- if (args.count() >= 2) {
- const auto opts = split_value_list(args.at(1).toQStringRef());
+ if (args.size() >= 2) {
+ const auto opts = split_value_list(args.at(1).toQStringView());
for (const ProString &opt : opts) {
if (opt.startsWith(QLatin1String("ibase="))) {
ibase = opt.mid(6).toInt();
@@ -713,7 +687,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
outstr = QLatin1Char(' ');
}
QString numstr = QString::number(num, obase);
- int space = width - outstr.length() - numstr.length();
+ int space = width - outstr.size() - numstr.size();
if (space <= 0) {
outstr += numstr;
} else if (leftalign) {
@@ -729,7 +703,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
}
case E_NUM_ADD: {
qlonglong sum = 0;
- for (const ProString &arg : qAsConst(args)) {
+ for (const ProString &arg : std::as_const(args)) {
if (arg.contains(QLatin1Char('.'))) {
evalError(fL1S("num_add(): floats are currently not supported."));
goto allfail;
@@ -748,11 +722,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
}
case E_JOIN: {
ProString glue, before, after;
- if (args.count() >= 2)
+ if (args.size() >= 2)
glue = args.at(1);
- if (args.count() >= 3)
+ if (args.size() >= 3)
before = args[2];
- if (args.count() == 4)
+ if (args.size() == 4)
after = args[3];
const ProStringList &var = values(map(args.at(0)));
if (!var.isEmpty()) {
@@ -768,11 +742,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
}
case E_SPLIT: {
ProStringRoUser u1(m_tmp1);
- const QString &sep = (args.count() == 2) ? u1.set(args.at(1)) : statics.field_sep;
+ const QString &sep = (args.size() == 2) ? u1.set(args.at(1)) : statics.field_sep;
const auto vars = values(map(args.at(0)));
for (const ProString &var : vars) {
// FIXME: this is inconsistent with the "there are no empty strings" dogma.
- const auto splits = var.toQStringRef().split(sep, QString::KeepEmptyParts);
+ const auto splits = var.toQStringView().split(sep, Qt::KeepEmptyParts);
for (const auto &splt : splits)
ret << ProString(splt).setSource(var);
}
@@ -842,7 +816,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
bool blob = false;
bool lines = false;
bool singleLine = true;
- if (args.count() > 1) {
+ if (args.size() > 1) {
if (!args.at(1).compare(QLatin1String("false"), Qt::CaseInsensitive))
singleLine = false;
else if (!args.at(1).compare(QLatin1String("blob"), Qt::CaseInsensitive))
@@ -862,7 +836,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
ret += ProString(stream.readLine());
} else {
const QString &line = stream.readLine();
- ret += split_value_list(QStringRef(&line).trimmed());
+ ret += split_value_list(QStringView(line).trimmed());
if (!singleLine)
ret += ProString("\n");
}
@@ -886,15 +860,19 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
ret = ProStringList(ProString(tmp));
ProStringList lst;
for (const ProString &arg : args)
- lst += split_value_list(arg.toQStringRef(), arg.sourceFile()); // Relies on deep copy
+ lst += split_value_list(arg.toQStringView(), arg.sourceFile()); // Relies on deep copy
m_valuemapStack.top()[ret.at(0).toKey()] = lst;
break; }
case E_FIND: {
- QRegExp regx(args.at(1).toQString());
+ QRegularExpression regx(args.at(1).toQString(), QRegularExpression::DotMatchesEverythingOption);
+ if (!regx.isValid()) {
+ evalError(fL1S("find(): Encountered invalid regular expression '%1'.").arg(regx.pattern()));
+ goto allfail;
+ }
const auto vals = values(map(args.at(0)));
for (const ProString &val : vals) {
ProStringRoUser u1(val, m_tmp[m_toggle ^= 1]);
- if (regx.indexIn(u1.str()) != -1)
+ if (u1.str().contains(regx))
ret += val;
}
break;
@@ -905,7 +883,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
bool blob = false;
bool lines = false;
bool singleLine = true;
- if (args.count() > 1) {
+ if (args.size() > 1) {
if (!args.at(1).compare(QLatin1String("false"), Qt::CaseInsensitive))
singleLine = false;
else if (!args.at(1).compare(QLatin1String("blob"), Qt::CaseInsensitive))
@@ -915,7 +893,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
}
int exitCode;
QByteArray bytes = getCommandOutput(args.at(0).toQString(), &exitCode);
- if (args.count() > 2 && !args.at(2).isEmpty()) {
+ if (args.size() > 2 && !args.at(2).isEmpty()) {
m_valuemapStack.top()[args.at(2).toKey()] =
ProStringList(ProString(QString::number(exitCode)));
}
@@ -931,7 +909,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
output.replace(QLatin1Char('\t'), QLatin1Char(' '));
if (singleLine)
output.replace(QLatin1Char('\n'), QLatin1Char(' '));
- ret += split_value_list(QStringRef(&output));
+ ret += split_value_list(QStringView(output));
}
}
break;
@@ -958,7 +936,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
for (int i = 0; i < args.size(); ++i) {
QString str = args.at(i).toQString();
QChar *i_data = str.data();
- int i_len = str.length();
+ int i_len = str.size();
for (int x = 0; x < i_len; ++x) {
if (*(i_data+x) == QLatin1Char('\\') && x < i_len-1) {
if (*(i_data+x+1) == QLatin1Char('\\')) {
@@ -990,7 +968,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
case E_RE_ESCAPE:
for (int i = 0; i < args.size(); ++i) {
ProStringRwUser u1(args.at(i), m_tmp1);
- ret << u1.extract(QRegExp::escape(u1.str()));
+ ret << u1.extract(QRegularExpression::escape(u1.str()));
}
break;
case E_VAL_ESCAPE: {
@@ -1003,14 +981,14 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
case E_UPPER:
case E_LOWER:
case E_TITLE:
- for (int i = 0; i < args.count(); ++i) {
+ for (int i = 0; i < args.size(); ++i) {
ProStringRwUser u1(args.at(i), m_tmp1);
QString rstr = u1.str();
if (func_t == E_UPPER) {
rstr = rstr.toUpper();
} else {
rstr = rstr.toLower();
- if (func_t == E_TITLE && rstr.length() > 0)
+ if (func_t == E_TITLE && rstr.size() > 0)
rstr[0] = rstr.at(0).toTitleCase();
}
ret << u1.extract(rstr);
@@ -1018,7 +996,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
break;
case E_FILES: {
bool recursive = false;
- if (args.count() == 2)
+ if (args.size() == 2)
recursive = isTrue(args.at(1));
QStringList dirs;
ProStringRoUser u1(args.at(0), m_tmp1);
@@ -1038,9 +1016,13 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
dirs.append(QString());
}
- r.detach(); // Keep m_tmp out of QRegExp's cache
- QRegExp regex(r, Qt::CaseSensitive, QRegExp::Wildcard);
- for (int d = 0; d < dirs.count(); d++) {
+ QString pattern = QRegularExpression::wildcardToRegularExpression(r);
+ QRegularExpression regex(pattern, QRegularExpression::DotMatchesEverythingOption);
+ if (!regex.isValid()) {
+ evalError(fL1S("section(): Encountered invalid wildcard expression '%1'.").arg(pattern));
+ goto allfail;
+ }
+ for (int d = 0; d < dirs.size(); d++) {
QString dir = dirs[d];
QDir qdir(pfx + dir);
for (int i = 0, count = int(qdir.count()); i < count; ++i) {
@@ -1051,7 +1033,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
if (recursive)
dirs.append(fname + QLatin1Char('/'));
}
- if (regex.exactMatch(qdir[i]))
+ if (regex.match(qdir[i]).hasMatch())
ret += ProString(fname).setSource(currentFileId());
}
}
@@ -1062,7 +1044,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
ProStringRoUser u1(args.at(0), m_tmp1);
QString msg = m_option->expandEnvVars(u1.str());
bool decorate = true;
- if (args.count() == 2)
+ if (args.size() == 2)
decorate = isTrue(args.at(1));
if (decorate) {
if (!msg.endsWith(QLatin1Char('?')))
@@ -1080,13 +1062,17 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
evalError(fL1S("Unexpected EOF."));
return ReturnError;
}
- ret = split_value_list(QStringRef(&line));
+ ret = split_value_list(QStringView(line));
}
break;
}
#endif
case E_REPLACE: {
- const QRegExp before(args.at(1).toQString());
+ const QRegularExpression before(args.at(1).toQString(), QRegularExpression::DotMatchesEverythingOption);
+ if (!before.isValid()) {
+ evalError(fL1S("replace(): Encountered invalid regular expression '%1'.").arg(before.pattern()));
+ goto allfail;
+ }
ProStringRwUser u2(args.at(2), m_tmp2);
const QString &after = u2.str();
const auto vals = values(map(args.at(0)));
@@ -1105,11 +1091,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
ProValueMap dependees;
QMultiMap<int, ProString> rootSet;
ProStringList orgList = values(args.at(0).toKey());
- ProString prefix = args.count() < 2 ? ProString() : args.at(1);
- ProString priosfx = args.count() < 4 ? ProString(".priority") : args.at(3);
+ ProString prefix = args.size() < 2 ? ProString() : args.at(1);
+ ProString priosfx = args.size() < 4 ? ProString(".priority") : args.at(3);
populateDeps(orgList, prefix,
- args.count() < 3 ? ProStringList(ProString(".depends"))
- : split_value_list(args.at(2).toQStringRef()),
+ args.size() < 3 ? ProStringList(ProString(".depends"))
+ : split_value_list(args.at(2).toQStringView()),
priosfx, dependencies, dependees, rootSet);
while (!rootSet.isEmpty()) {
QMultiMap<int, ProString>::iterator it = rootSet.begin();
@@ -1117,7 +1103,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
rootSet.erase(it);
if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
ret.prepend(item);
- for (const ProString &dep : qAsConst(dependees[item.toKey()])) {
+ for (const ProString &dep : std::as_const(dependees[item.toKey()])) {
QSet<ProKey> &dset = dependencies[dep.toKey()];
dset.remove(item.toKey());
if (dset.isEmpty())
@@ -1128,11 +1114,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
}
case E_ENUMERATE_VARS: {
QSet<ProString> keys;
- for (const ProValueMap &vmap : qAsConst(m_valuemapStack))
+ for (const ProValueMap &vmap : std::as_const(m_valuemapStack))
for (ProValueMap::ConstIterator it = vmap.constBegin(); it != vmap.constEnd(); ++it)
keys.insert(it.key());
ret.reserve(keys.size());
- for (const ProString &key : qAsConst(keys))
+ for (const ProString &key : std::as_const(keys))
ret << key;
break; }
case E_SHADOWED: {
@@ -1145,7 +1131,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
case E_ABSOLUTE_PATH: {
ProStringRwUser u1(args.at(0), m_tmp1);
ProStringRwUser u2(m_tmp2);
- QString baseDir = args.count() > 1
+ QString baseDir = args.size() > 1
? IoUtils::resolvePath(currentDirectory(), u2.set(args.at(1)))
: currentDirectory();
QString rstr = u1.str().isEmpty() ? baseDir : IoUtils::resolvePath(baseDir, u1.str());
@@ -1155,7 +1141,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
case E_RELATIVE_PATH: {
ProStringRwUser u1(args.at(0), m_tmp1);
ProStringRoUser u2(m_tmp2);
- QString baseDir = args.count() > 1
+ QString baseDir = args.size() > 1
? IoUtils::resolvePath(currentDirectory(), u2.set(args.at(1)))
: currentDirectory();
QString absArg = u1.str().isEmpty() ? baseDir : IoUtils::resolvePath(baseDir, u1.str());
@@ -1266,8 +1252,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::testFunc_cache(const ProStringList &
enum { TargetStash, TargetCache, TargetSuper } target = TargetCache;
enum { CacheSet, CacheAdd, CacheSub } mode = CacheSet;
ProKey srcvar;
- if (args.count() >= 2) {
- const auto opts = split_value_list(args.at(1).toQStringRef());
+ if (args.size() >= 2) {
+ const auto opts = split_value_list(args.at(1).toQStringView());
for (const ProString &opt : opts) {
if (opt == QLatin1String("transient")) {
persist = false;
@@ -1286,7 +1272,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::testFunc_cache(const ProStringList &
return ReturnFalse;
}
}
- if (args.count() >= 3) {
+ if (args.size() >= 3) {
srcvar = args.at(2).toKey();
} else if (mode != CacheSet) {
evalError(fL1S("cache(): modes other than 'set' require a source variable."));
@@ -1381,7 +1367,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::testFunc_cache(const ProStringList &
varstr += QLatin1String(" -=");
else
varstr += QLatin1String(" =");
- if (diffval.count() == 1) {
+ if (diffval.size() == 1) {
varstr += QLatin1Char(' ');
varstr += quoteValue(diffval.at(0));
} else if (!diffval.isEmpty()) {
@@ -1439,7 +1425,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
switch (func_t) {
case T_DEFINED: {
const ProKey &var = args.at(0).toKey();
- if (args.count() > 1) {
+ if (args.size() > 1) {
if (args[1] == QLatin1String("test")) {
return returnBool(m_functionDefs.testFunctions.contains(var));
} else if (args[1] == QLatin1String("replace")) {
@@ -1492,7 +1478,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
auto isFrom = [pro](const ProString &s) {
return s.sourceFile() == pro;
};
- vit->erase(std::remove_if(vit->begin(), vit->end(), isFrom), vit->end());
+ vit->removeIf(isFrom);
if (vit->isEmpty()) {
// When an initially non-empty variable becomes entirely empty,
// undefine it altogether.
@@ -1526,23 +1512,26 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
VisitReturn ok = evaluateFileInto(fn, &vars, LoadProOnly);
if (ok != ReturnTrue)
return ok;
- if (args.count() == 2)
+ if (args.size() == 2)
return returnBool(vars.contains(map(args.at(1))));
- QRegExp regx;
+ QRegularExpression regx;
+ regx.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
ProStringRoUser u1(args.at(2), m_tmp1);
const QString &qry = u1.str();
- if (qry != QRegExp::escape(qry)) {
- QString copy = qry;
- copy.detach();
- regx.setPattern(copy);
+ if (qry != QRegularExpression::escape(qry)) {
+ regx.setPattern(QRegularExpression::anchoredPattern(qry));
+ if (!regx.isValid()) {
+ evalError(fL1S("infile(): Encountered invalid regular expression '%1'.").arg(qry));
+ return ReturnFalse;
+ }
}
const auto strings = vars.value(map(args.at(1)));
for (const ProString &s : strings) {
if (s == qry)
return ReturnTrue;
- if (!regx.isEmpty()) {
+ if (!regx.pattern().isEmpty()) {
ProStringRoUser u2(s, m_tmp[m_toggle ^= 1]);
- if (regx.exactMatch(u2.str()))
+ if (regx.match(u2.str()).hasMatch())
return ReturnTrue;
}
}
@@ -1557,7 +1546,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
case T_EVAL: {
VisitReturn ret = ReturnFalse;
QString contents = args.join(statics.field_sep);
- ProFile *pro = m_parser->parsedProBlock(QStringRef(&contents),
+ ProFile *pro = m_parser->parsedProBlock(QStringView(contents),
0, m_current.pro->fileName(), m_current.line);
if (m_cumulative || pro->isOk()) {
m_locationStack.push(m_current);
@@ -1569,19 +1558,19 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ret;
}
case T_IF: {
- return evaluateConditional(args.at(0).toQStringRef(),
+ return evaluateConditional(args.at(0).toQStringView(),
m_current.pro->fileName(), m_current.line);
}
case T_CONFIG: {
- if (args.count() == 1)
- return returnBool(isActiveConfig(args.at(0).toQStringRef()));
- const auto mutuals = args.at(1).toQStringRef().split(QLatin1Char('|'),
- QString::SkipEmptyParts);
+ if (args.size() == 1)
+ return returnBool(isActiveConfig(args.at(0).toQStringView()));
+ const auto mutuals = args.at(1).toQStringView().split(QLatin1Char('|'),
+ Qt::SkipEmptyParts);
const ProStringList &configs = values(statics.strCONFIG);
for (int i = configs.size() - 1; i >= 0; i--) {
- for (int mut = 0; mut < mutuals.count(); mut++) {
- if (configs[i].toQStringRef() == mutuals[mut].trimmed())
+ for (int mut = 0; mut < mutuals.size(); mut++) {
+ if (configs[i].toQStringView() == mutuals[mut].trimmed())
return returnBool(configs[i] == args[0]);
}
}
@@ -1590,36 +1579,39 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
case T_CONTAINS: {
ProStringRoUser u1(args.at(1), m_tmp1);
const QString &qry = u1.str();
- QRegExp regx;
- if (qry != QRegExp::escape(qry)) {
- QString copy = qry;
- copy.detach();
- regx.setPattern(copy);
+ QRegularExpression regx;
+ regx.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
+ if (qry != QRegularExpression::escape(qry)) {
+ regx.setPattern(QRegularExpression::anchoredPattern(qry));
+ if (!regx.isValid()) {
+ evalError(fL1S("contains(): Encountered invalid regular expression '%1'.").arg(qry));
+ return ReturnFalse;
+ }
}
const ProStringList &l = values(map(args.at(0)));
- if (args.count() == 2) {
+ if (args.size() == 2) {
for (int i = 0; i < l.size(); ++i) {
const ProString &val = l[i];
if (val == qry)
return ReturnTrue;
- if (!regx.isEmpty()) {
+ if (!regx.pattern().isEmpty()) {
ProStringRoUser u2(val, m_tmp[m_toggle ^= 1]);
- if (regx.exactMatch(u2.str()))
+ if (regx.match(u2.str()).hasMatch())
return ReturnTrue;
}
}
} else {
- const auto mutuals = args.at(2).toQStringRef().split(QLatin1Char('|'),
- QString::SkipEmptyParts);
+ const auto mutuals = args.at(2).toQStringView().split(QLatin1Char('|'),
+ Qt::SkipEmptyParts);
for (int i = l.size() - 1; i >= 0; i--) {
const ProString &val = l[i];
- for (int mut = 0; mut < mutuals.count(); mut++) {
- if (val.toQStringRef() == mutuals[mut].trimmed()) {
+ for (int mut = 0; mut < mutuals.size(); mut++) {
+ if (val.toQStringView() == mutuals[mut].trimmed()) {
if (val == qry)
return ReturnTrue;
- if (!regx.isEmpty()) {
+ if (!regx.pattern().isEmpty()) {
ProStringRoUser u2(val, m_tmp[m_toggle ^= 1]);
- if (regx.exactMatch(u2.str()))
+ if (regx.match(u2.str()).hasMatch())
return ReturnTrue;
}
return ReturnFalse;
@@ -1630,9 +1622,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ReturnFalse;
}
case T_COUNT: {
- int cnt = values(map(args.at(0))).count();
+ int cnt = values(map(args.at(0))).size();
int val = args.at(1).toInt();
- if (args.count() == 3) {
+ if (args.size() == 3) {
const ProString &comp = args.at(2);
if (comp == QLatin1String(">") || comp == QLatin1String("greaterThan")) {
return returnBool(cnt > val);
@@ -1667,15 +1659,15 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
}
}
if (func_t == T_GREATERTHAN)
- return returnBool(lhs > rhs.toQStringRef());
- return returnBool(lhs < rhs.toQStringRef());
+ return returnBool(lhs > rhs.toQStringView());
+ return returnBool(lhs < rhs.toQStringView());
}
case T_EQUALS:
return returnBool(values(map(args.at(0))).join(statics.field_sep)
== args.at(1).toQStringView());
case T_VERSION_AT_LEAST:
case T_VERSION_AT_MOST: {
- const QVersionNumber lvn = QVersionNumber::fromString(values(args.at(0).toKey()).join('.'));
+ const QVersionNumber lvn = QVersionNumber::fromString(values(args.at(0).toKey()).join(QLatin1Char('.')));
const QVersionNumber rvn = QVersionNumber::fromString(args.at(1).toQStringView());
if (func_t == T_VERSION_AT_LEAST)
return returnBool(lvn >= rvn);
@@ -1707,23 +1699,21 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
m_valuemapStack.top()[var] = statics.fakeValue;
return ReturnTrue;
}
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
case T_PARSE_JSON: {
QByteArray json = values(args.at(0).toKey()).join(QLatin1Char(' ')).toUtf8();
ProStringRoUser u1(args.at(1), m_tmp2);
QString parseInto = u1.str();
return parseJsonInto(json, parseInto, &m_valuemapStack.top());
}
-#endif
case T_INCLUDE: {
QString parseInto;
LoadFlags flags;
if (m_cumulative)
flags = LoadSilent;
- if (args.count() >= 2) {
+ if (args.size() >= 2) {
if (!args.at(1).isEmpty())
parseInto = args.at(1) + QLatin1Char('.');
- if (args.count() >= 3 && isTrue(args.at(2)))
+ if (args.size() >= 3 && isTrue(args.at(2)))
flags = LoadSilent;
}
QString fn = filePathEnvArg0(args);
@@ -1755,7 +1745,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ok;
}
case T_LOAD: {
- bool ignore_error = (args.count() == 2 && isTrue(args.at(1)));
+ bool ignore_error = (args.size() == 2 && isTrue(args.at(1)));
VisitReturn ok = evaluateFeatureFile(m_option->expandEnvVars(args.at(0).toQString()),
ignore_error);
if (ok == ReturnFalse && ignore_error)
@@ -1854,12 +1844,12 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
QIODevice::OpenMode mode = QIODevice::Truncate;
QMakeVfs::VfsFlags flags = (m_cumulative ? QMakeVfs::VfsCumulative : QMakeVfs::VfsExact);
QString contents;
- if (args.count() >= 2) {
+ if (args.size() >= 2) {
const ProStringList &vals = values(args.at(1).toKey());
if (!vals.isEmpty())
contents = vals.join(QLatin1Char('\n')) + QLatin1Char('\n');
- if (args.count() >= 3) {
- const auto opts = split_value_list(args.at(2).toQStringRef());
+ if (args.size() >= 3) {
+ const auto opts = split_value_list(args.at(2).toQStringView());
for (const ProString &opt : opts) {
if (opt == QLatin1String("append")) {
mode = QIODevice::Append;
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp
index 70897214b2..df3f92d7d5 100644
--- a/qmake/library/qmakeevaluator.cpp
+++ b/qmake/library/qmakeevaluator.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmakeevaluator.h"
#include "qmakeevaluator_p.h"
@@ -41,7 +16,7 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qlist.h>
-#include <qregexp.h>
+#include <qregularexpression.h>
#include <qset.h>
#include <qstack.h>
#include <qstring.h>
@@ -57,7 +32,7 @@
# include <sys/sysctl.h>
# endif
#else
-#include <windows.h>
+#include <qt_windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
@@ -107,7 +82,7 @@ QMakeBaseKey::QMakeBaseKey(const QString &_root, const QString &_stash, bool _ho
{
}
-uint qHash(const QMakeBaseKey &key)
+size_t qHash(const QMakeBaseKey &key)
{
return qHash(key.root) ^ qHash(key.stash) ^ (uint)key.hostBuild;
}
@@ -272,7 +247,7 @@ void QMakeEvaluator::skipHashStr(const ushort *&tokPtr)
// FIXME: this should not build new strings for direct sections.
// Note that the E_SPRINTF and E_LIST implementations rely on the deep copy.
-ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, int source)
+ProStringList QMakeEvaluator::split_value_list(QStringView vals, int source)
{
QString build;
ProStringList ret;
@@ -281,11 +256,11 @@ ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, int sourc
source = currentFileId();
const QChar *vals_data = vals.data();
- const int vals_len = vals.length();
- ushort quote = 0;
+ const int vals_len = vals.size();
+ char16_t quote = 0;
bool hadWord = false;
for (int x = 0; x < vals_len; x++) {
- ushort unicode = vals_data[x].unicode();
+ char16_t unicode = vals_data[x].unicode();
if (unicode == quote) {
quote = 0;
hadWord = true;
@@ -313,7 +288,7 @@ ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, int sourc
break;
case '\\':
if (x + 1 != vals_len) {
- ushort next = vals_data[++x].unicode();
+ char16_t next = vals_data[++x].unicode();
if (next == '\'' || next == '"' || next == '\\') {
build += QChar(unicode);
unicode = next;
@@ -334,7 +309,7 @@ ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, int sourc
}
static void replaceInList(ProStringList *varlist,
- const QRegExp &regexp, const QString &replace, bool global, QString &tmp)
+ const QRegularExpression &regexp, const QString &replace, bool global, QString &tmp)
{
for (ProStringList::Iterator varit = varlist->begin(); varit != varlist->end(); ) {
ProStringRoUser u1(*varit, tmp);
@@ -653,7 +628,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
evalError(fL1S("Conditional must expand to exactly one word."));
okey = false;
} else {
- okey = isActiveConfig(curr.at(0).toQStringRef(), true);
+ okey = isActiveConfig(curr.at(0).toQStringView(), true);
traceMsg("condition %s is %s", dbgStr(curr.at(0)), dbgBool(okey));
okey ^= invert;
}
@@ -780,7 +755,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
}
infinite = true;
} else {
- const QStringRef &itl = it_list.toQStringRef();
+ QStringView itl = it_list.toQStringView();
int dotdot = itl.indexOf(statics.strDotDot);
if (dotdot != -1) {
bool ok;
@@ -826,7 +801,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
} else {
ProString val;
do {
- if (index >= list.count())
+ if (index >= list.size())
goto do_break;
val = list.at(index++);
} while (val.isEmpty()); // stupid, but qmake is like that
@@ -877,20 +852,20 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
ProStringList varVal;
if (expandVariableReferences(tokPtr, sizeHint, &varVal, true) == ReturnError)
return ReturnError;
- const QStringRef &val = varVal.at(0).toQStringRef();
- if (val.length() < 4 || val.at(0) != QLatin1Char('s')) {
+ QStringView val = varVal.at(0).toQStringView();
+ if (val.size() < 4 || val.at(0) != QLatin1Char('s')) {
evalError(fL1S("The ~= operator can handle only the s/// function."));
return ReturnTrue;
}
QChar sep = val.at(1);
- auto func = val.split(sep, QString::KeepEmptyParts);
- if (func.count() < 3 || func.count() > 4) {
+ auto func = val.split(sep, Qt::KeepEmptyParts);
+ if (func.size() < 3 || func.size() > 4) {
evalError(fL1S("The s/// function expects 3 or 4 arguments."));
return ReturnTrue;
}
bool global = false, quote = false, case_sense = false;
- if (func.count() == 4) {
+ if (func.size() == 4) {
global = func[3].indexOf(QLatin1Char('g')) != -1;
case_sense = func[3].indexOf(QLatin1Char('i')) == -1;
quote = func[3].indexOf(QLatin1Char('q')) != -1;
@@ -898,9 +873,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
QString pattern = func[1].toString();
QString replace = func[2].toString();
if (quote)
- pattern = QRegExp::escape(pattern);
+ pattern = QRegularExpression::escape(pattern);
- QRegExp regexp(pattern, case_sense ? Qt::CaseSensitive : Qt::CaseInsensitive);
+ QRegularExpression regexp(pattern, case_sense ? QRegularExpression::NoPatternOption :
+ QRegularExpression::CaseInsensitiveOption);
// We could make a union of modified and unmodified values,
// but this will break just as much as it fixes, so leave it as is.
@@ -1022,7 +998,7 @@ static ProString msvcArchitecture(const QString &vcInstallDir, const QString &pa
QString vcBinDir = vcInstallDir;
if (vcBinDir.endsWith(QLatin1Char('\\')))
vcBinDir.chop(1);
- const auto dirs = pathVar.split(QLatin1Char(';'), QString::SkipEmptyParts);
+ const auto dirs = pathVar.split(QLatin1Char(';'), Qt::SkipEmptyParts);
for (const QString &dir : dirs) {
if (!dir.startsWith(vcBinDir, Qt::CaseInsensitive))
continue;
@@ -1037,10 +1013,13 @@ static ProString msvcArchitecture(const QString &vcInstallDir, const QString &pa
void QMakeEvaluator::loadDefaults()
{
ProValueMap &vars = m_valuemapStack.top();
+ qlonglong sde = qgetenv("SOURCE_DATE_EPOCH").toLongLong();
+ QDateTime builddate = sde ? QDateTime::fromSecsSinceEpoch(sde)
+ : QDateTime::currentDateTime();
vars[ProKey("DIR_SEPARATOR")] << ProString(m_option->dir_sep);
vars[ProKey("DIRLIST_SEPARATOR")] << ProString(m_option->dirlist_sep);
- vars[ProKey("_DATE_")] << ProString(QDateTime::currentDateTime().toString());
+ vars[ProKey("_DATE_")] << ProString(builddate.toString());
if (!m_option->qmake_abslocation.isEmpty())
vars[ProKey("QMAKE_QMAKE")] << ProString(m_option->qmake_abslocation);
if (!m_option->qmake_args.isEmpty())
@@ -1257,7 +1236,7 @@ bool QMakeEvaluator::loadSpec()
qmakespec = m_hostBuild ? QLatin1String("default-host") : QLatin1String("default");
#endif
if (IoUtils::isRelativePath(qmakespec)) {
- for (const QString &root : qAsConst(m_mkspecPaths)) {
+ for (const QString &root : std::as_const(m_mkspecPaths)) {
QString mkspec = root + QLatin1Char('/') + qmakespec;
if (IoUtils::exists(mkspec)) {
qmakespec = mkspec;
@@ -1314,7 +1293,7 @@ void QMakeEvaluator::setupProject()
void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where)
{
if (!cmds.isEmpty()) {
- ProFile *pro = m_parser->parsedProBlock(QStringRef(&cmds), 0, where, -1);
+ ProFile *pro = m_parser->parsedProBlock(QStringView(cmds), 0, where, -1);
if (pro->isOk()) {
m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr());
@@ -1499,7 +1478,7 @@ void QMakeEvaluator::updateMkspecPaths()
for (const QString &it : paths)
ret << it + concat;
- for (const QString &it : qAsConst(m_qmakepath))
+ for (const QString &it : std::as_const(m_qmakepath))
ret << it + concat;
if (!m_buildRoot.isEmpty())
@@ -1540,7 +1519,7 @@ void QMakeEvaluator::updateFeaturePaths()
for (const QString &item : items)
feature_bases << (item + mkspecs_concat);
- for (const QString &item : qAsConst(m_qmakepath))
+ for (const QString &item : std::as_const(m_qmakepath))
feature_bases << (item + mkspecs_concat);
if (!m_qmakespec.isEmpty()) {
@@ -1562,21 +1541,21 @@ void QMakeEvaluator::updateFeaturePaths()
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/get")) + mkspecs_concat);
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/src")) + mkspecs_concat);
- for (const QString &fb : qAsConst(feature_bases)) {
+ for (const QString &fb : std::as_const(feature_bases)) {
const auto sfxs = values(ProKey("QMAKE_PLATFORM"));
for (const ProString &sfx : sfxs)
feature_roots << (fb + features_concat + sfx + QLatin1Char('/'));
feature_roots << (fb + features_concat);
}
- for (int i = 0; i < feature_roots.count(); ++i)
+ for (int i = 0; i < feature_roots.size(); ++i)
if (!feature_roots.at(i).endsWith(QLatin1Char('/')))
feature_roots[i].append(QLatin1Char('/'));
feature_roots.removeDuplicates();
QStringList ret;
- for (const QString &root : qAsConst(feature_roots))
+ for (const QString &root : std::as_const(feature_roots))
if (IoUtils::exists(root))
ret << root;
m_featureRoots = new QMakeFeatureRoots(ret);
@@ -1594,7 +1573,7 @@ ProString QMakeEvaluator::propertyValue(const ProKey &name) const
ProFile *QMakeEvaluator::currentProFile() const
{
- if (m_profileStack.count() > 0)
+ if (m_profileStack.size() > 0)
return m_profileStack.top();
return nullptr;
}
@@ -1623,7 +1602,7 @@ QString QMakeEvaluator::currentDirectory() const
return QString();
}
-bool QMakeEvaluator::isActiveConfig(const QStringRef &config, bool regex)
+bool QMakeEvaluator::isActiveConfig(QStringView config, bool regex)
{
// magic types for easy flipping
if (config == statics.strtrue)
@@ -1635,17 +1614,17 @@ bool QMakeEvaluator::isActiveConfig(const QStringRef &config, bool regex)
return m_hostBuild;
if (regex && (config.contains(QLatin1Char('*')) || config.contains(QLatin1Char('?')))) {
- QRegExp re(config.toString(), Qt::CaseSensitive, QRegExp::Wildcard);
+ auto re = QRegularExpression::fromWildcard(config.toString());
// mkspecs
- if (re.exactMatch(m_qmakespecName))
+ if (re.match(m_qmakespecName).hasMatch())
return true;
// CONFIG variable
const auto configValues = values(statics.strCONFIG);
for (const ProString &configValue : configValues) {
ProStringRoUser u1(configValue, m_tmp[m_toggle ^= 1]);
- if (re.exactMatch(u1.str()))
+ if (re.match(u1.str()).hasMatch())
return true;
}
} else {
@@ -1717,12 +1696,12 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFunction(
m_locationStack.push(m_current);
ProStringList args;
- for (int i = 0; i < argumentsList.count(); ++i) {
+ for (int i = 0; i < argumentsList.size(); ++i) {
args += argumentsList[i];
m_valuemapStack.top()[ProKey(QString::number(i+1))] = argumentsList[i];
}
m_valuemapStack.top()[statics.strARGS] = args;
- m_valuemapStack.top()[statics.strARGC] = ProStringList(ProString(QString::number(argumentsList.count())));
+ m_valuemapStack.top()[statics.strARGC] = ProStringList(ProString(QString::number(argumentsList.size())));
vr = visitProBlock(func.pro(), func.tokPtr());
if (vr == ReturnReturn)
vr = ReturnTrue;
@@ -1819,7 +1798,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpandFunction(
}
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional(
- const QStringRef &cond, const QString &where, int line)
+ QStringView cond, const QString &where, int line)
{
VisitReturn ret = ReturnFalse;
ProFile *pro = m_parser->parsedProBlock(cond, 0, where, line, QMakeParser::TestGrammar);
@@ -1837,7 +1816,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::checkRequirements(const ProStringLis
{
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
for (const ProString &dep : deps) {
- VisitReturn vr = evaluateConditional(dep.toQStringRef(), m_current.pro->fileName(), m_current.line);
+ VisitReturn vr = evaluateConditional(dep.toQStringView(), m_current.pro->fileName(), m_current.line);
if (vr == ReturnError)
return ReturnError;
if (vr != ReturnTrue)
@@ -2003,7 +1982,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFeatureFile(
int start_root = 0;
const QStringList &paths = m_featureRoots->paths;
if (!currFn.isEmpty()) {
- QStringRef currPath = IoUtils::pathName(currFn);
+ QStringView currPath = IoUtils::pathName(currFn);
for (int root = 0; root < paths.size(); ++root)
if (currPath == paths.at(root)) {
start_root = root + 1;
@@ -2049,6 +2028,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFeatureFile(
#ifdef PROEVALUATOR_CUMULATIVE
bool cumulative = m_cumulative;
+ // Even when evaluating the project in cumulative mode to maximize the
+ // chance of collecting all source declarations, prfs are evaluated in
+ // exact mode to maximize the chance of them successfully executing
+ // their programmatic function.
m_cumulative = false;
#endif
@@ -2057,6 +2040,13 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFeatureFile(
#ifdef PROEVALUATOR_CUMULATIVE
m_cumulative = cumulative;
+ if (cumulative) {
+ // As the data collected in cumulative mode is potentially total
+ // garbage, yet the prfs fed with it are executed in exact mode,
+ // we must ignore their results to avoid that evaluation is unduly
+ // aborted.
+ ok = ReturnTrue;
+ }
#endif
return ok;
}
diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h
index 9f702b9182..2889ac0bee 100644
--- a/qmake/library/qmakeevaluator.h
+++ b/qmake/library/qmakeevaluator.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QMAKEEVALUATOR_H
#define QMAKEEVALUATOR_H
@@ -180,7 +155,7 @@ public:
void setTemplate();
- ProStringList split_value_list(const QStringRef &vals, int source = 0);
+ ProStringList split_value_list(QStringView vals, int source = 0);
VisitReturn expandVariableReferences(const ushort *&tokPtr, int sizeHint, ProStringList *ret, bool joined);
QString currentFileName() const;
@@ -224,7 +199,7 @@ public:
VisitReturn evaluateBuiltinConditional(const QMakeInternal::QMakeBuiltin &adef,
const ProKey &function, const ProStringList &args);
- VisitReturn evaluateConditional(const QStringRef &cond, const QString &where, int line = -1);
+ VisitReturn evaluateConditional(QStringView cond, const QString &where, int line = -1);
#ifdef PROEVALUATOR_FULL
VisitReturn checkRequirements(const ProStringList &deps);
#endif
@@ -232,7 +207,7 @@ public:
void updateMkspecPaths();
void updateFeaturePaths();
- bool isActiveConfig(const QStringRef &config, bool regex = false);
+ bool isActiveConfig(QStringView config, bool regex = false);
void populateDeps(
const ProStringList &deps, const ProString &prefix, const ProStringList &suffixes,
diff --git a/qmake/library/qmakeevaluator_p.h b/qmake/library/qmakeevaluator_p.h
index da83ff0de2..ea18c3b45a 100644
--- a/qmake/library/qmakeevaluator_p.h
+++ b/qmake/library/qmakeevaluator_p.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QMAKEEVALUATOR_P_H
#define QMAKEEVALUATOR_P_H
@@ -41,7 +16,7 @@
r == ReturnNext ? "next" : \
r == ReturnReturn ? "return" : \
"<invalid>")
-# define dbgKey(s) s.toString().toQStringRef().toLocal8Bit().constData()
+# define dbgKey(s) s.toString().toQStringView().toLocal8Bit().constData()
# define dbgStr(s) qPrintable(formatValue(s, true))
# define dbgStrList(s) qPrintable(formatValueList(s))
# define dbgSepStrList(s) qPrintable(formatValueList(s, true))
@@ -107,7 +82,7 @@ extern QMakeStatics statics;
}
-Q_DECLARE_TYPEINFO(QMakeInternal::QMakeBuiltin, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QMakeInternal::QMakeBuiltin, Q_RELOCATABLE_TYPE);
QT_END_NAMESPACE
diff --git a/qmake/library/qmakeglobals.cpp b/qmake/library/qmakeglobals.cpp
index 1d76cecc45..e05d33c7c9 100644
--- a/qmake/library/qmakeglobals.cpp
+++ b/qmake/library/qmakeglobals.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmakeglobals.h"
@@ -51,7 +26,7 @@
#include <unistd.h>
#include <sys/utsname.h>
#else
-#include <windows.h>
+#include <qt_windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
@@ -103,11 +78,18 @@ QString QMakeGlobals::cleanSpec(QMakeCmdLineParserState &state, const QString &s
return ret;
}
+/*
+ * Return value meanings:
+ * ArgumentUnknown The argument at *pos was not handled by this function.
+ * Leave it to the caller to handle this argument.
+ * ArgumentMalformed There was an error detected.
+ * ArgumentsOk All arguments were known. There are no arguments left to handle.
+ */
QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
QMakeCmdLineParserState &state, QStringList &args, int *pos)
{
enum { ArgNone, ArgConfig, ArgSpec, ArgXSpec, ArgTmpl, ArgTmplPfx, ArgCache, ArgQtConf } argState = ArgNone;
- for (; *pos < args.count(); (*pos)++) {
+ for (; *pos < args.size(); (*pos)++) {
QString arg = args.at(*pos);
switch (argState) {
case ArgConfig:
@@ -186,7 +168,7 @@ void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state)
{
if (!state.extraargs.isEmpty()) {
QString extra = fL1S("QMAKE_EXTRA_ARGS =");
- for (const QString &ea : qAsConst(state.extraargs))
+ for (const QString &ea : std::as_const(state.extraargs))
extra += QLatin1Char(' ') + QMakeEvaluator::quoteValue(ProString(ea));
state.cmds[QMakeEvalBefore] << extra;
}
@@ -231,8 +213,8 @@ void QMakeGlobals::setDirectories(const QString &input_dir, const QString &outpu
QString dstpath = output_dir;
if (!dstpath.endsWith(QLatin1Char('/')))
dstpath += QLatin1Char('/');
- int srcLen = srcpath.length();
- int dstLen = dstpath.length();
+ int srcLen = srcpath.size();
+ int dstLen = dstpath.size();
int lastSl = -1;
while (++lastSl, --srcLen, --dstLen,
srcLen && dstLen && srcpath.at(srcLen) == dstpath.at(dstLen))
@@ -248,9 +230,9 @@ QString QMakeGlobals::shadowedPath(const QString &fileName) const
if (source_root.isEmpty())
return fileName;
if (fileName.startsWith(source_root)
- && (fileName.length() == source_root.length()
- || fileName.at(source_root.length()) == QLatin1Char('/'))) {
- return build_root + fileName.mid(source_root.length());
+ && (fileName.size() == source_root.size()
+ || fileName.at(source_root.size()) == QLatin1Char('/'))) {
+ return build_root + fileName.mid(source_root.size());
}
return QString();
}
@@ -260,8 +242,8 @@ QStringList QMakeGlobals::splitPathList(const QString &val) const
QStringList ret;
if (!val.isEmpty()) {
QString cwd(QDir::currentPath());
- const QStringList vals = val.split(dirlist_sep, QString::SkipEmptyParts);
- ret.reserve(vals.length());
+ const QStringList vals = val.split(dirlist_sep, Qt::SkipEmptyParts);
+ ret.reserve(vals.size());
for (const QString &it : vals)
ret << IoUtils::resolvePath(cwd, it);
}
@@ -290,7 +272,7 @@ QString QMakeGlobals::expandEnvVars(const QString &str) const
startIndex = string.indexOf(QLatin1Char('$'), startIndex);
if (startIndex < 0)
break;
- if (string.length() < startIndex + 3)
+ if (string.size() < startIndex + 3)
break;
if (string.at(startIndex + 1) != QLatin1Char('(')) {
startIndex++;
@@ -301,7 +283,7 @@ QString QMakeGlobals::expandEnvVars(const QString &str) const
break;
QString value = getEnv(string.mid(startIndex + 2, endIndex - startIndex - 2));
string.replace(startIndex, endIndex - startIndex + 1, value);
- startIndex += value.length();
+ startIndex += value.size();
}
return string;
}
@@ -311,7 +293,7 @@ QString QMakeGlobals::expandEnvVars(const QString &str) const
bool QMakeGlobals::initProperties()
{
QByteArray data;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(process)
QProcess proc;
proc.start(qmake_abslocation, QStringList() << QLatin1String("-query"));
if (!proc.waitForFinished())
diff --git a/qmake/library/qmakeglobals.h b/qmake/library/qmakeglobals.h
index 6c00b1f3af..437f131786 100644
--- a/qmake/library/qmakeglobals.h
+++ b/qmake/library/qmakeglobals.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QMAKEGLOBALS_H
#define QMAKEGLOBALS_H
@@ -38,7 +13,7 @@
#include <qhash.h>
#include <qstringlist.h>
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(process)
# include <qprocess.h>
#endif
#ifdef PROEVALUATOR_THREAD_SAFE
@@ -62,7 +37,7 @@ public:
bool hostBuild;
};
-uint qHash(const QMakeBaseKey &key);
+size_t qHash(const QMakeBaseKey &key);
bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two);
class QMakeBaseEnv
diff --git a/qmake/library/qmakeparser.cpp b/qmake/library/qmakeparser.cpp
index ffe90ebda7..ade2b091fe 100644
--- a/qmake/library/qmakeparser.cpp
+++ b/qmake/library/qmakeparser.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmakeparser.h"
@@ -52,7 +27,7 @@ ProFileCache::ProFileCache()
ProFileCache::~ProFileCache()
{
- for (const Entry &ent : qAsConst(parsed_files))
+ for (const Entry &ent : std::as_const(parsed_files))
if (ent.pro)
ent.pro->deref();
QMakeVfs::deref();
@@ -217,7 +192,7 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
#endif
QString contents;
if (readFile(id, flags, &contents)) {
- pro = parsedProBlock(QStringRef(&contents), id, fileName, 1, FullGrammar);
+ pro = parsedProBlock(QStringView(contents), id, fileName, 1, FullGrammar);
pro->itemsRef()->squeeze();
pro->ref();
} else {
@@ -238,7 +213,7 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
} else {
QString contents;
if (readFile(id, flags, &contents))
- pro = parsedProBlock(QStringRef(&contents), id, fileName, 1, FullGrammar);
+ pro = parsedProBlock(QStringView(contents), id, fileName, 1, FullGrammar);
else
pro = nullptr;
}
@@ -246,7 +221,7 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
}
ProFile *QMakeParser::parsedProBlock(
- const QStringRef &contents, int id, const QString &name, int line, SubGrammar grammar)
+ QStringView contents, int id, const QString &name, int line, SubGrammar grammar)
{
ProFile *pro = new ProFile(id, name);
read(pro, contents, line, grammar);
@@ -291,7 +266,7 @@ void QMakeParser::putBlock(ushort *&tokPtr, const ushort *buf, uint len)
void QMakeParser::putHashStr(ushort *&pTokPtr, const ushort *buf, uint len)
{
- uint hash = ProString::hash((const QChar *)buf, len);
+ const size_t hash = ProString::hash((const QChar *)buf, len);
ushort *tokPtr = pTokPtr;
*tokPtr++ = (ushort)hash;
*tokPtr++ = (ushort)(hash >> 16);
@@ -305,12 +280,12 @@ void QMakeParser::finalizeHashStr(ushort *buf, uint len)
{
buf[-4] = TokHashLiteral;
buf[-1] = len;
- uint hash = ProString::hash((const QChar *)buf, len);
+ const size_t hash = ProString::hash((const QChar *)buf, len);
buf[-3] = (ushort)hash;
buf[-2] = (ushort)(hash >> 16);
}
-void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar grammar)
+void QMakeParser::read(ProFile *pro, QStringView in, int line, SubGrammar grammar)
{
m_proFile = pro;
m_lineNo = line;
@@ -358,8 +333,8 @@ void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar
QStack<ParseCtx> xprStack;
xprStack.reserve(10);
- const ushort *cur = (const ushort *)in.unicode();
- const ushort *inend = cur + in.length();
+ const ushort *cur = (const ushort *)in.data();
+ const ushort *inend = cur + in.size();
m_canElse = false;
freshLine:
m_state = StNew;
@@ -372,9 +347,9 @@ void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar
int wordCount = 0; // Number of words in currently accumulated expression
int lastIndent = 0; // Previous line's indentation, to detect accidental continuation abuse
bool lineMarked = true; // For in-expression markers
- ushort needSep = TokNewStr; // Met unquoted whitespace
- ushort quote = 0;
- ushort term = 0;
+ char16_t needSep = TokNewStr; // Met unquoted whitespace
+ char16_t quote = 0;
+ char16_t term = 0;
Context context;
ushort *ptr;
@@ -450,7 +425,7 @@ void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar
}
forever {
- ushort c;
+ char16_t c;
// First, skip leading whitespace
for (indent = 0; ; ++cur, ++indent) {
@@ -581,7 +556,7 @@ void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar
&buf, &xprBuff, &tokPtr, &tokBuff, cur, in)) {
if (rtok == TokVariable || rtok == TokProperty) {
xprPtr[-4] = tok;
- uint hash = ProString::hash((const QChar *)xprPtr, tlen);
+ const size_t hash = ProString::hash((const QChar *)xprPtr, tlen);
xprPtr[-3] = (ushort)hash;
xprPtr[-2] = (ushort)(hash >> 16);
xprPtr[-1] = tlen;
@@ -636,7 +611,7 @@ void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar
}
} else if (c == '\\') {
static const char symbols[] = "[]{}()$\\'\"";
- ushort c2;
+ char16_t c2;
if (cur != end && !((c2 = *cur) & 0xff00) && strchr(symbols, c2)) {
c = c2;
cur++;
@@ -757,7 +732,7 @@ void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar
if (!m_blockstack.top().braceLevel) {
parseError(fL1S("Excess closing brace."));
} else if (!--m_blockstack.top().braceLevel
- && m_blockstack.count() != 1) {
+ && m_blockstack.size() != 1) {
leaveScope(tokPtr);
m_state = StNew;
m_canElse = false;
@@ -1260,7 +1235,7 @@ void QMakeParser::finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int arg
bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort **ptr,
ushort **buf, QString *xprBuff,
ushort **tokPtr, QString *tokBuff,
- const ushort *cur, const QStringRef &in)
+ const ushort *cur, QStringView in)
{
QString out;
m_tmp.setRawData((const QChar *)xprPtr, tlen);
@@ -1271,7 +1246,7 @@ bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort
// The string is typically longer than the variable reference, so we need
// to ensure that there is enough space in the output buffer - as unlikely
// as an overflow is to actually happen in practice.
- int need = (in.length() - (cur - (const ushort *)in.constData()) + 2) * 5 + out.length();
+ int need = (in.size() - (cur - (const ushort *)in.constData()) + 2) * 5 + out.size();
int tused = *tokPtr - (ushort *)tokBuff->constData();
int xused;
int total;
@@ -1302,9 +1277,9 @@ bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort
}
xprPtr -= 2; // Was set up for variable reference
xprPtr[-2] = TokLiteral | needSep;
- xprPtr[-1] = out.length();
- memcpy(xprPtr, out.constData(), out.length() * 2);
- *ptr = xprPtr + out.length();
+ xprPtr[-1] = out.size();
+ memcpy(xprPtr, out.constData(), out.size() * 2);
+ *ptr = xprPtr + out.size();
return true;
}
@@ -1549,7 +1524,8 @@ static bool getBlock(const ushort *tokens, int limit, int &offset, QString *outS
ok = getSubBlock(tokens, limit, offset, outStr, indent, "block");
break;
default:
- Q_ASSERT(!"unhandled token");
+ // unhandled token
+ Q_UNREACHABLE();
}
}
if (!ok)
@@ -1563,7 +1539,7 @@ QString QMakeParser::formatProBlock(const QString &block)
QString outStr;
outStr += fL1S("\n << TS(");
int offset = 0;
- getBlock(reinterpret_cast<const ushort *>(block.constData()), block.length(),
+ getBlock(reinterpret_cast<const ushort *>(block.constData()), block.size(),
offset, &outStr, 0);
outStr += QLatin1Char(')');
return outStr;
diff --git a/qmake/library/qmakeparser.h b/qmake/library/qmakeparser.h
index c8c5c7718e..a5a1192ec9 100644
--- a/qmake/library/qmakeparser.h
+++ b/qmake/library/qmakeparser.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QMAKEPARSER_H
#define QMAKEPARSER_H
@@ -93,7 +68,7 @@ public:
enum SubGrammar { FullGrammar, TestGrammar, ValueGrammar };
// fileName is expected to be absolute and cleanPath()ed.
ProFile *parsedProFile(const QString &fileName, ParseFlags flags = ParseDefault);
- ProFile *parsedProBlock(const QStringRef &contents, int id, const QString &name, int line = 0,
+ ProFile *parsedProBlock(QStringView contents, int id, const QString &name, int line = 0,
SubGrammar grammar = FullGrammar);
void discardFileFromCache(int id);
@@ -135,7 +110,7 @@ private:
};
bool readFile(int id, QMakeParser::ParseFlags flags, QString *contents);
- void read(ProFile *pro, const QStringRef &content, int line, SubGrammar grammar);
+ void read(ProFile *pro, QStringView content, int line, SubGrammar grammar);
ALWAYS_INLINE void putTok(ushort *&tokPtr, ushort tok);
ALWAYS_INLINE void putBlockLen(ushort *&tokPtr, uint len);
@@ -146,7 +121,7 @@ private:
ALWAYS_INLINE bool resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort **ptr,
ushort **buf, QString *xprBuff,
ushort **tokPtr, QString *tokBuff,
- const ushort *cur, const QStringRef &in);
+ const ushort *cur, QStringView in);
void finalizeCond(ushort *&tokPtr, ushort *uc, ushort *ptr, int wordCount);
void finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int argc);
void warnOperator(const char *msg);
@@ -230,7 +205,7 @@ private:
};
#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
-Q_DECLARE_TYPEINFO(QMakeParser::BlockScope, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QMakeParser::BlockScope, Q_RELOCATABLE_TYPE);
Q_DECLARE_TYPEINFO(QMakeParser::Context, Q_PRIMITIVE_TYPE);
#endif
diff --git a/qmake/library/qmakevfs.cpp b/qmake/library/qmakevfs.cpp
index 1f77595535..a8517de0ff 100644
--- a/qmake/library/qmakevfs.cpp
+++ b/qmake/library/qmakevfs.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmakevfs.h"
@@ -35,10 +10,6 @@ using namespace QMakeInternal;
#include <qfile.h>
#include <qfileinfo.h>
-#if QT_CONFIG(textcodec)
-#include <qtextcodec.h>
-#endif
-
#define fL1S(s) QString::fromLatin1(s)
QT_BEGIN_NAMESPACE
@@ -49,9 +20,6 @@ QMakeVfs::QMakeVfs()
, m_magicExisting(fL1S("existing"))
#endif
{
-#if QT_CONFIG(textcodec)
- m_textCodec = 0;
-#endif
ref();
}
@@ -149,12 +117,12 @@ bool QMakeVfs::writeFile(int id, QIODevice::OpenMode mode, VfsFlags flags,
QMutexLocker locker(&m_mutex);
# endif
QString *cont = &m_files[id];
- Q_UNUSED(flags)
+ Q_UNUSED(flags);
if (mode & QIODevice::Append)
*cont += contents;
else
*cont = contents;
- Q_UNUSED(errStr)
+ Q_UNUSED(errStr);
return true;
#else
QFileInfo qfi(fileNameForId(id));
@@ -235,11 +203,7 @@ QMakeVfs::ReadResult QMakeVfs::readFile(int id, QString *contents, QString *errS
*errStr = fL1S("Unexpected UTF-8 BOM");
return ReadOtherError;
}
- *contents =
-#if QT_CONFIG(textcodec)
- m_textCodec ? m_textCodec->toUnicode(bcont) :
-#endif
- QString::fromLocal8Bit(bcont);
+ *contents = QString::fromLocal8Bit(bcont);
return ReadOk;
}
@@ -254,7 +218,7 @@ bool QMakeVfs::exists(const QString &fn, VfsFlags flags)
if (it != m_files.constEnd())
return it->constData() != m_magicMissing.constData();
#else
- Q_UNUSED(flags)
+ Q_UNUSED(flags);
#endif
bool ex = IoUtils::fileType(fn) == IoUtils::FileIsRegular;
#ifndef PROEVALUATOR_FULL
@@ -290,11 +254,4 @@ void QMakeVfs::invalidateContents()
}
#endif
-#if QT_CONFIG(textcodec)
-void QMakeVfs::setTextCodec(const QTextCodec *textCodec)
-{
- m_textCodec = textCodec;
-}
-#endif
-
QT_END_NAMESPACE
diff --git a/qmake/library/qmakevfs.h b/qmake/library/qmakevfs.h
index fccbcfb765..56bda3d0a0 100644
--- a/qmake/library/qmakevfs.h
+++ b/qmake/library/qmakevfs.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QMAKEVFS_H
#define QMAKEVFS_H
@@ -38,10 +13,6 @@
# include <qmutex.h>
#endif
-#if QT_CONFIG(textcodec)
-QT_FORWARD_DECLARE_CLASS(QTextCodec)
-#endif
-
#ifdef PROEVALUATOR_DUAL_VFS
# ifndef PROEVALUATOR_CUMULATIVE
# error PROEVALUATOR_DUAL_VFS requires PROEVALUATOR_CUMULATIVE
@@ -92,10 +63,6 @@ public:
void invalidateContents();
#endif
-#if QT_CONFIG(textcodec)
- void setTextCodec(const QTextCodec *textCodec);
-#endif
-
private:
#ifdef PROEVALUATOR_THREAD_SAFE
static QMutex s_mutex;
@@ -129,9 +96,6 @@ private:
QString m_magicMissing;
QString m_magicExisting;
#endif
-#if QT_CONFIG(textcodec)
- const QTextCodec *m_textCodec;
-#endif
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QMakeVfs::VfsFlags)
diff --git a/qmake/library/registry.cpp b/qmake/library/registry.cpp
index 3391ab9512..7ab0c71fe6 100644
--- a/qmake/library/registry.cpp
+++ b/qmake/library/registry.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtCore/qstringlist.h>
#include "registry_p.h"
@@ -147,7 +122,7 @@ QString qt_readRegistryKey(HKEY parentHandle, const QString &rSubkey, unsigned l
RegCloseKey(handle);
#else
Q_UNUSED(parentHandle);
- Q_UNUSED(rSubkey)
+ Q_UNUSED(rSubkey);
Q_UNUSED(options);
#endif
diff --git a/qmake/library/registry_p.h b/qmake/library/registry_p.h
index f9e8bba016..00f2431f69 100644
--- a/qmake/library/registry_p.h
+++ b/qmake/library/registry_p.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QT_WINDOWS_REGISTRY_H
#define QT_WINDOWS_REGISTRY_H