aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-07 10:32:48 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-07 10:32:48 +0000
commit493f7d0974e238baef36d6cd15335f6d31703032 (patch)
treedf98413850d121809335ee6c202f3c4c8078e586 /src
parentMerge pull request #2845 (diff)
downloadmonero-493f7d0974e238baef36d6cd15335f6d31703032.tar.xz
util: allow non numeric version parts
Diffstat (limited to 'src')
-rw-r--r--src/common/util.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp
index e8ac61815..c834cb3bd 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -628,13 +628,13 @@ std::string get_nix_version_display_string()
int vercmp(const char *v0, const char *v1)
{
std::vector<std::string> f0, f1;
- boost::split(f0, v0, boost::is_any_of("."));
- boost::split(f1, v1, boost::is_any_of("."));
- while (f0.size() < f1.size())
- f0.push_back("0");
- while (f1.size() < f0.size())
- f1.push_back("0");
- for (size_t i = 0; i < f0.size(); ++i) {
+ boost::split(f0, v0, boost::is_any_of(".-"));
+ boost::split(f1, v1, boost::is_any_of(".-"));
+ for (size_t i = 0; i < std::max(f0.size(), f1.size()); ++i) {
+ if (i >= f0.size())
+ return -1;
+ if (i >= f1.size())
+ return 1;
int f0i = atoi(f0[i].c_str()), f1i = atoi(f1[i].c_str());
int n = f0i - f1i;
if (n)