From 010497cb5ae50713f0ed4e4c4bf3b860bf751da7 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Fri, 2 Oct 2020 16:47:40 +0300 Subject: add separate vertest applet for version string testing start adding meson based tests --- src/version.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/version.c') 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; -- cgit v1.2.3-70-g09d2