From f6caac38117a99782513db0b62bfd29b921f873c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 15 May 2020 22:53:08 +0200 Subject: Fix version =,< and <= not working. Also fix incorrect platform family handling --- src/Platform.cpp | 4 ++-- src/VersionParser.cpp | 48 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 17 deletions(-) (limited to 'src') 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::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(); -- cgit v1.2.3