aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Platform.cpp4
-rw-r--r--src/VersionParser.cpp48
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();