aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-18 10:08:48 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commit2dbd9ec3efae8a3814e6bece0f7ed45038c30380 (patch)
tree06a4e2da2eb290315ce859933f88db97793ead27 /src
parentc2b6468835b6174ce6474910fc488931dfd003a4 (diff)
Fix version range not ending at next major version when not defining end
Diffstat (limited to 'src')
-rw-r--r--src/GlobalLib.cpp2
-rw-r--r--src/VersionParser.cpp20
2 files changed, 14 insertions, 8 deletions
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<bool> 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<PackageVersionRange>::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<PackageVersionRange>::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();