diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-10-02 16:47:40 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-10-09 16:09:19 +0300 |
commit | 010497cb5ae50713f0ed4e4c4bf3b860bf751da7 (patch) | |
tree | da7626ff54d2086f4f9fb2dd5181484f35ab05d9 /src/version.c | |
parent | 6d71f49c11e22a617234ef47123ab9287cde23af (diff) | |
download | apk-tools-010497cb5ae50713f0ed4e4c4bf3b860bf751da7.tar.gz apk-tools-010497cb5ae50713f0ed4e4c4bf3b860bf751da7.tar.bz2 apk-tools-010497cb5ae50713f0ed4e4c4bf3b860bf751da7.tar.xz apk-tools-010497cb5ae50713f0ed4e4c4bf3b860bf751da7.zip |
add separate vertest applet for version string testing
start adding meson based tests
Diffstat (limited to 'src/version.c')
-rw-r--r-- | src/version.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/version.c b/src/version.c index f6fc5af..7c1c0b4 100644 --- a/src/version.c +++ b/src/version.c @@ -161,24 +161,32 @@ const char *apk_version_op_string(int mask) } } -int apk_version_result_mask(const char *str) +int apk_version_result_mask_blob(apk_blob_t op) { - int r = 0; - switch (*str) { - case '<': - r = APK_VERSION_LESS; - str++; - break; - case '>': - r = APK_VERSION_GREATER; - str++; - break; + int i, r = 0; + for (i = 0; i < op.len; i++) { + switch (op.ptr[i]) { + case '<': + r |= APK_VERSION_LESS; + break; + case '>': + r |= APK_VERSION_GREATER; + break; + case '=': + r |= APK_VERSION_EQUAL; + break; + default: + return 0; + } } - if (*str == '=') - r |= APK_VERSION_EQUAL; return r; } +int apk_version_result_mask(const char *op) +{ + return apk_version_result_mask_blob(APK_BLOB_STR(op)); +} + int apk_version_validate(apk_blob_t ver) { int t = TOKEN_DIGIT; |