From 493f7d0974e238baef36d6cd15335f6d31703032 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 7 Dec 2017 10:32:48 +0000 Subject: [PATCH 1/2] util: allow non numeric version parts --- src/common/util.cpp | 14 +++++++------- tests/unit_tests/vercmp.cpp | 2 ++ 2 files changed, 9 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 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) diff --git a/tests/unit_tests/vercmp.cpp b/tests/unit_tests/vercmp.cpp index d48dfdf7c..8f359585d 100644 --- a/tests/unit_tests/vercmp.cpp +++ b/tests/unit_tests/vercmp.cpp @@ -40,4 +40,6 @@ TEST(vercmp, two_one) { ASSERT_TRUE(tools::vercmp("2", "1") > 0); } TEST(vercmp, ten_nine) { ASSERT_TRUE(tools::vercmp("10", "9") > 0); } TEST(vercmp, one_dot_ten_one_dot_nine) { ASSERT_TRUE(tools::vercmp("1.10", "1.9") > 0); } TEST(vercmp, one_one_dot_nine) { ASSERT_TRUE(tools::vercmp("1", "1.9") < 0); } +TEST(vercmp, to_master) { ASSERT_TRUE(tools::vercmp("1.0", "1.0-master") < 0); } +TEST(vercmp, from_master) { ASSERT_TRUE(tools::vercmp("1.0-master", "1.1") < 0); } From 83b0f9e6c5ff1d4acde6202be60e812b588c7bcd Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 7 Dec 2017 10:33:12 +0000 Subject: [PATCH 2/2] version: add -master to master version This makes master versions play better with automated update checks --- src/version.cpp.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.cpp.in b/src/version.cpp.in index d1444f867..18d62db6b 100644 --- a/src/version.cpp.in +++ b/src/version.cpp.in @@ -1,5 +1,5 @@ #define DEF_MONERO_VERSION_TAG "@VERSIONTAG@" -#define DEF_MONERO_VERSION "0.11.0.0" +#define DEF_MONERO_VERSION "0.11.1.0-master" #define DEF_MONERO_RELEASE_NAME "Helium Hydra" #define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG