From 7ed993b54e20d74c000a29720bc9317ad4849ed0 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Wed, 18 Jan 2023 10:11:53 -0700 Subject: fix: proper null padded version comparison Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- launcher/Version.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'launcher/Version.cpp') diff --git a/launcher/Version.cpp b/launcher/Version.cpp index 2129ebfd..d59339e7 100644 --- a/launcher/Version.cpp +++ b/launcher/Version.cpp @@ -15,9 +15,9 @@ bool Version::operator<(const Version &other) const const int size = qMax(m_sections.size(), other.m_sections.size()); for (int i = 0; i < size; ++i) { - const Section sec1 = (i >= m_sections.size()) ? Section("0") : m_sections.at(i); + const Section sec1 = (i >= m_sections.size()) ? Section("") : m_sections.at(i); const Section sec2 = - (i >= other.m_sections.size()) ? Section("0") : other.m_sections.at(i); + (i >= other.m_sections.size()) ? Section("") : other.m_sections.at(i); if (sec1 != sec2) { return sec1 < sec2; @@ -35,9 +35,9 @@ bool Version::operator>(const Version &other) const const int size = qMax(m_sections.size(), other.m_sections.size()); for (int i = 0; i < size; ++i) { - const Section sec1 = (i >= m_sections.size()) ? Section("0") : m_sections.at(i); + const Section sec1 = (i >= m_sections.size()) ? Section("") : m_sections.at(i); const Section sec2 = - (i >= other.m_sections.size()) ? Section("0") : other.m_sections.at(i); + (i >= other.m_sections.size()) ? Section("") : other.m_sections.at(i); if (sec1 != sec2) { return sec1 > sec2; @@ -55,9 +55,9 @@ bool Version::operator==(const Version &other) const const int size = qMax(m_sections.size(), other.m_sections.size()); for (int i = 0; i < size; ++i) { - const Section sec1 = (i >= m_sections.size()) ? Section("0") : m_sections.at(i); + const Section sec1 = (i >= m_sections.size()) ? Section("") : m_sections.at(i); const Section sec2 = - (i >= other.m_sections.size()) ? Section("0") : other.m_sections.at(i); + (i >= other.m_sections.size()) ? Section("") : other.m_sections.at(i); if (sec1 != sec2) { return false; @@ -103,8 +103,11 @@ QDebug operator<<(QDebug debug, const Version& v) debug.nospace() << "Version{ string: " << v.toString() << ", sections: [ "; + bool first = true; for (auto s : v.m_sections) { - debug.nospace() << s.m_fullString << ", "; + if (!first) debug.nospace() << ", "; + debug.nospace() << s.m_fullString; + first = false; } debug.nospace() << " ]" << " }"; -- cgit