aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgars Cīrulis <edgarsscirulis@gmail.com>2023-01-17 06:53:01 +0200
committerEdgars Cīrulis <edgarsscirulis@gmail.com>2023-01-17 22:39:12 +0200
commit3bec4a80b3de58d31992eda8497a3d099190b92d (patch)
tree7dd43297bc58bbd41a24dde91141da00bb8517ac
parenta84e4b0e07dbcb736d92e98a3beca9025c981686 (diff)
downloadPrismLauncher-3bec4a80b3de58d31992eda8497a3d099190b92d.tar.gz
PrismLauncher-3bec4a80b3de58d31992eda8497a3d099190b92d.tar.bz2
PrismLauncher-3bec4a80b3de58d31992eda8497a3d099190b92d.zip
Version.cpp: Decompose version strings according to flexver
Co-authored-by: Rachel Powers <508861+Ryex@users.noreply.github.com> Signed-off-by: Edgars Cīrulis <edgarsscirulis@gmail.com>
-rw-r--r--launcher/Version.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/launcher/Version.cpp b/launcher/Version.cpp
index 0640e6d3..01f513e3 100644
--- a/launcher/Version.cpp
+++ b/launcher/Version.cpp
@@ -75,25 +75,20 @@ void Version::parse()
{
m_sections.clear();
QString currentSection;
+
auto classChange = [](QChar lastChar, QChar currentChar) {
- return ((lastChar.isLetter() && currentChar.isDigit()) || (lastChar.isDigit() && currentChar.isLetter()));
+ return !lastChar.isNull() && ((!lastChar.isDigit() && currentChar.isDigit()) || (lastChar.isDigit() && !currentChar.isDigit()));
};
+
for (int i = 0; i < m_string.size(); ++i) {
const auto& current_char = m_string.at(i);
- if (current_char.isDigit() || current_char.isLetter()) {
- if (i > 0 && classChange(m_string.at(i - 1), current_char)) {
- if (!currentSection.isEmpty()) {
- m_sections.append(Section(currentSection));
- }
- currentSection = "";
- }
- currentSection += current_char;
- } else if (current_char == '.' || current_char == '-' || current_char == '_') {
+ if ((i > 0 && classChange(m_string.at(i - 1), current_char)) || current_char == '.' || current_char == '-' || current_char == '+') {
if (!currentSection.isEmpty()) {
m_sections.append(Section(currentSection));
}
currentSection = "";
}
+ currentSection += current_char;
}
if (!currentSection.isEmpty()) {
m_sections.append(Section(currentSection));