diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-05-15 22:53:08 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:58 +0200 |
commit | f6caac38117a99782513db0b62bfd29b921f873c (patch) | |
tree | cc1bbc54339a3044898b1618a69d425e1b178dcb /src | |
parent | d0aad1c2cf1c734c650d277d4ad61b3e593a9d01 (diff) |
Fix version =,< and <= not working. Also fix incorrect platform family handling
Diffstat (limited to 'src')
-rw-r--r-- | src/Platform.cpp | 4 | ||||
-rw-r--r-- | src/VersionParser.cpp | 48 |
2 files changed, 35 insertions, 17 deletions
diff --git a/src/Platform.cpp b/src/Platform.cpp index f92e1ea..55c2188 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -94,12 +94,12 @@ namespace sibs bool isSamePlatformFamily(Platform a, Platform b) { - return a & b; + return (a & b) == a; } bool isBaseForPlatform(Platform base, Platform platform) { - return base == PLATFORM_ANY || base == platform || (isSamePlatformFamily(platform, base) && countSetBits(base) < countSetBits(platform)); + return base == PLATFORM_ANY || base == platform || isSamePlatformFamily(base, platform); } Platform getPlatformGenericType(Platform platform) diff --git a/src/VersionParser.cpp b/src/VersionParser.cpp index eccd109..2b7936a 100644 --- a/src/VersionParser.cpp +++ b/src/VersionParser.cpp @@ -196,8 +196,16 @@ namespace sibs if(token == VersionToken::END_OF_FILE) { - if(!versionRange.startDefined) + if(!versionRange.startDefined && !versionRange.endDefined) return Result<PackageVersionRange>::Err("version can't be empty"); + + if(!versionRange.startDefined) { + versionRange.start.major = 0; + versionRange.start.minor = 0; + versionRange.start.patch = 0; + versionRange.startDefined = true; + versionRange.startOperation = VersionOperation::GREATER_EQUAL; + } if(versionRange.startOperation == VersionOperation::NONE) { @@ -264,40 +272,50 @@ namespace sibs } else if(token == VersionToken::OPERATION) { - versionRange.startOperation = tokenizer.operation; + VersionOperation operation = tokenizer.operation; token = tokenizer.next(); if(token == VersionToken::VERSION_NUMBER) { - versionRange.start = tokenizer.version; - versionRange.startDefined = true; - switch(versionRange.startOperation) + token = tokenizer.next(); + switch(operation) { case VersionOperation::LESS: { - token = VersionToken::INVALID; - tokenizer.errMsg = "Unexpected version end when start version is expected to less than "; - tokenizer.errMsg += versionRange.start.toString(); + versionRange.end = tokenizer.version; + versionRange.endDefined = true; + versionRange.endOperation = operation; return token; } case VersionOperation::LESS_EQUAL: { - token = VersionToken::INVALID; - tokenizer.errMsg = "Unexpected version end when start version is expected to be less or equal to "; - tokenizer.errMsg += versionRange.start.toString(); + versionRange.end = tokenizer.version; + versionRange.endDefined = true; + versionRange.endOperation = operation; return token; } case VersionOperation::EQUAL: { - token = VersionToken::INVALID; - tokenizer.errMsg = "Unexpected version end when start version is expected to be exactly "; - tokenizer.errMsg += versionRange.start.toString(); + versionRange.start = tokenizer.version; + versionRange.startDefined = true; + versionRange.startOperation = operation; return token; } + case VersionOperation::GREATER: + { + versionRange.start = tokenizer.version; + versionRange.startDefined = true; + versionRange.startOperation = operation; + } + case VersionOperation::GREATER_EQUAL: + { + versionRange.start = tokenizer.version; + versionRange.startDefined = true; + versionRange.startOperation = operation; + } default: break; } - token = tokenizer.next(); if(token == VersionToken::AND) { return parseEnd(); |