From 2dbd9ec3efae8a3814e6bece0f7ed45038c30380 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 18 Oct 2018 10:08:48 +0200 Subject: Fix version range not ending at next major version when not defining end --- src/GlobalLib.cpp | 2 +- src/VersionParser.cpp | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp index 61e6648..2dd829f 100644 --- a/src/GlobalLib.cpp +++ b/src/GlobalLib.cpp @@ -54,7 +54,7 @@ namespace sibs for(PackageListDependency *globalLibDependency : libs) { if(!parentConfig.packaging) - printf("Dependency %s is missing from pkg-config, trying global lib\n", globalLibDependency->name.c_str()); + printf("Dependency %s in version range %s is missing from pkg-config, trying global lib\n", globalLibDependency->name.c_str(), globalLibDependency->version.toString().c_str()); Result globalLibLinkerFlagsResult = GlobalLib::getLibsLinkerFlags(parentConfig, globalLibRootDir, globalLibDependency->name, globalLibDependency->version, staticLinkerFlagCallbackFunc, dynamicLinkerFlagCallbackFunc, globalIncludeDirCallback); if(!globalLibLinkerFlagsResult) { diff --git a/src/VersionParser.cpp b/src/VersionParser.cpp index 7b28cef..eccd109 100644 --- a/src/VersionParser.cpp +++ b/src/VersionParser.cpp @@ -6,13 +6,9 @@ namespace sibs static int stringToIntNoVerify(const StringView &str) { int result = 0; - if(str.size > 0) - result += (str[0] - '0'); - - for(int i = 1; i < (int)str.size; ++i) + for(usize i = 0; i < str.size; ++i) { - int num = str[i] - '0'; - result += (10 * ((int)str.size - i) * num); + result = (result * 10) + (str[i] - '0'); } return result; } @@ -202,6 +198,16 @@ namespace sibs { if(!versionRange.startDefined) return Result::Err("version can't be empty"); + + if(versionRange.startOperation == VersionOperation::NONE) + { + versionRange.startOperation = VersionOperation::GREATER_EQUAL; + versionRange.end.major = versionRange.start.major + 1; + versionRange.end.minor = 0; + versionRange.end.patch = 0; + versionRange.endOperation = VersionOperation::LESS; + versionRange.endDefined = true; + } return Result::Ok(versionRange); } else if(token == VersionToken::INVALID) @@ -246,7 +252,7 @@ namespace sibs VersionToken token = tokenizer.next(); if(token == VersionToken::VERSION_NUMBER) { - versionRange.startOperation = VersionOperation::GREATER_EQUAL; + versionRange.startOperation = VersionOperation::NONE; versionRange.start = tokenizer.version; versionRange.startDefined = true; token = tokenizer.next(); -- cgit v1.2.3