Version.cpp: Improve version parsing to handle mixed numeric and alphabetic characters
Signed-off-by: Edgars Cīrulis <edgarsscirulis@gmail.com>
This commit is contained in:
parent
72a9b98ef0
commit
c0c3892064
@ -74,12 +74,36 @@ bool Version::operator!=(const Version &other) const
|
|||||||
void Version::parse()
|
void Version::parse()
|
||||||
{
|
{
|
||||||
m_sections.clear();
|
m_sections.clear();
|
||||||
|
QString currentSection;
|
||||||
// FIXME: this is bad. versions can contain a lot more separators...
|
bool lastCharWasDigit = false;
|
||||||
QStringList parts = m_string.split('.');
|
for (int i = 0; i < m_string.size(); ++i) {
|
||||||
|
if(m_string[i].isDigit()){
|
||||||
for (const auto& part : parts)
|
if(!lastCharWasDigit){
|
||||||
{
|
if(!currentSection.isEmpty()){
|
||||||
m_sections.append(Section(part));
|
m_sections.append(Section(currentSection));
|
||||||
|
}
|
||||||
|
currentSection = "";
|
||||||
|
}
|
||||||
|
currentSection += m_string[i];
|
||||||
|
lastCharWasDigit = true;
|
||||||
|
}else if(m_string[i].isLetter()){
|
||||||
|
if(lastCharWasDigit){
|
||||||
|
if(!currentSection.isEmpty()){
|
||||||
|
m_sections.append(Section(currentSection));
|
||||||
|
}
|
||||||
|
currentSection = "";
|
||||||
|
}
|
||||||
|
currentSection += m_string[i];
|
||||||
|
lastCharWasDigit = false;
|
||||||
|
}
|
||||||
|
else if(m_string[i] == '-' || m_string[i] == '_'){
|
||||||
|
if(!currentSection.isEmpty()){
|
||||||
|
m_sections.append(Section(currentSection));
|
||||||
|
}
|
||||||
|
currentSection = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!currentSection.isEmpty()) {
|
||||||
|
m_sections.append(Section(currentSection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user