summaryrefslogtreecommitdiffstats
path: root/src/version.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/version.c')
-rw-r--r--src/version.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/version.c b/src/version.c
index eaac762..9bd96cb 100644
--- a/src/version.c
+++ b/src/version.c
@@ -145,6 +145,9 @@ const char *apk_version_op_string(int mask)
return "<";
case APK_VERSION_LESS|APK_VERSION_EQUAL:
return "<=";
+ case APK_VERSION_EQUAL|APK_VERSION_FUZZY:
+ case APK_VERSION_FUZZY:
+ return "~";
case APK_VERSION_EQUAL:
return "=";
case APK_VERSION_GREATER|APK_VERSION_EQUAL:
@@ -186,7 +189,7 @@ int apk_version_validate(apk_blob_t ver)
return t == TOKEN_END;
}
-int apk_version_compare_blob(apk_blob_t a, apk_blob_t b)
+int apk_version_compare_blob_fuzzy(apk_blob_t a, apk_blob_t b, int fuzzy)
{
int at = TOKEN_DIGIT, bt = TOKEN_DIGIT, tt;
int av = 0, bv = 0;
@@ -215,7 +218,7 @@ int apk_version_compare_blob(apk_blob_t a, apk_blob_t b)
return APK_VERSION_GREATER;
/* both have TOKEN_END or TOKEN_INVALID next? */
- if (at == bt)
+ if (at == bt || fuzzy)
return APK_VERSION_EQUAL;
/* if only difference is pkgrev, they are equal. */
@@ -240,6 +243,11 @@ int apk_version_compare_blob(apk_blob_t a, apk_blob_t b)
return APK_VERSION_EQUAL;
}
+int apk_version_compare_blob(apk_blob_t a, apk_blob_t b)
+{
+ return apk_version_compare_blob_fuzzy(a, b, FALSE);
+}
+
int apk_version_compare(const char *str1, const char *str2)
{
return apk_version_compare_blob(APK_BLOB_STR(str1), APK_BLOB_STR(str2));