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>
This commit is contained in:
parent
a84e4b0e07
commit
3bec4a80b3
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user