diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/fileout.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/fileout.cpp | 77 |
1 files changed, 26 insertions, 51 deletions
diff --git a/sources/shiboken6/ApiExtractor/fileout.cpp b/sources/shiboken6/ApiExtractor/fileout.cpp index 84455dd9e..6f9ec4d8a 100644 --- a/sources/shiboken6/ApiExtractor/fileout.cpp +++ b/sources/shiboken6/ApiExtractor/fileout.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt for Python. -** -** $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 "fileout.h" #include "messages.h" @@ -67,20 +42,20 @@ FileOut::~FileOut() } } -static QList<int> lcsLength(const QByteArrayList &a, const QByteArrayList &b) +static QList<qsizetype> lcsLength(const QByteArrayList &a, const QByteArrayList &b) { - const int height = a.size() + 1; - const int width = b.size() + 1; + const auto height = a.size() + 1; + const auto width = b.size() + 1; - QList<int> res(width * height, 0); + QList<qsizetype> res(width * height, 0); - for (int row = 1; row < height; row++) { - for (int col = 1; col < width; col++) { - if (a[row-1] == b[col-1]) - res[width * row + col] = res[width * (row-1) + col-1] + 1; + for (qsizetype row = 1; row < height; row++) { + for (qsizetype col = 1; col < width; col++) { + if (a.at(row - 1) == b.at(col - 1)) + res[width * row + col] = res[width * (row - 1) + col - 1] + 1; else - res[width * row + col] = qMax(res[width * row + col-1], - res[width * (row-1) + col]); + res[width * row + col] = qMax(res[width * row + col - 1], + res[width * (row - 1) + col]); } } return res; @@ -95,8 +70,8 @@ enum Type { struct Unit { Type type; - int start; - int end; + qsizetype start; + qsizetype end; void print(const QByteArrayList &a, const QByteArrayList &b) const; }; @@ -106,33 +81,33 @@ void Unit::print(const QByteArrayList &a, const QByteArrayList &b) const switch (type) { case Unchanged: if ((end - start) > 9) { - for (int i = start; i <= start + 2; i++) + for (auto i = start; i <= start + 2; ++i) std::printf(" %s\n", a.at(i).constData()); std::printf("%s=\n= %d more lines\n=%s\n", - colorInfo, end - start - 6, colorReset); - for (int i = end - 2; i <= end; i++) + colorInfo, int(end - start - 6), colorReset); + for (auto i = end - 2; i <= end; ++i) std::printf(" %s\n", a.at(i).constData()); } else { - for (int i = start; i <= end; i++) + for (auto i = start; i <= end; ++i) std::printf(" %s\n", a.at(i).constData()); } break; case Add: std::fputs(colorAdd, stdout); - for (int i = start; i <= end; i++) + for (auto i = start; i <= end; ++i) std::printf("+ %s\n", b.at(i).constData()); std::fputs(colorReset, stdout); break; case Delete: std::fputs(colorDelete, stdout); - for (int i = start; i <= end; i++) + for (auto i = start; i <= end; ++i) std::printf("- %s\n", a.at(i).constData()); std::fputs(colorReset, stdout); break; } } -static void unitAppend(Type type, int pos, QList<Unit> *units) +static void unitAppend(Type type, qsizetype pos, QList<Unit> *units) { if (!units->isEmpty() && units->last().type == type) units->last().end = pos; @@ -140,9 +115,9 @@ static void unitAppend(Type type, int pos, QList<Unit> *units) units->append(Unit{type, pos, pos}); } -static QList<Unit> diffHelper(const QList<int> &lcs, - const QByteArrayList &a, const QByteArrayList &b, - int row, int col) +static QList<Unit> diffHelper(const QList<qsizetype> &lcs, + const QByteArrayList &a, const QByteArrayList &b, + qsizetype row, qsizetype col) { if (row > 0 && col > 0 && a.at(row - 1) == b.at(col - 1)) { QList<Unit> result = diffHelper(lcs, a, b, row - 1, col - 1); @@ -150,7 +125,7 @@ static QList<Unit> diffHelper(const QList<int> &lcs, return result; } - const int width = b.size() + 1; + const auto width = b.size() + 1; if (col > 0 && (row == 0 || lcs.at(width * row + col -1 ) >= lcs.at(width * (row - 1) + col))) { QList<Unit> result = diffHelper(lcs, a, b, row, col - 1); @@ -200,7 +175,7 @@ FileOut::State FileOut::done() if (!FileOut::m_dryRun) { QDir dir(info.absolutePath()); if (!dir.mkpath(dir.absolutePath())) { - const QString message = QStringLiteral("Unable to create directory '%1'") + const QString message = QString::fromLatin1("Unable to create directory '%1'") .arg(QDir::toNativeSeparators(dir.absolutePath())); throw Exception(message); } |