From 4bbed2d648fcb98c613f88c1ced418e771407f84 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Sat, 20 Jun 2009 12:38:07 +0200 Subject: ver: only compare the given packages, show version make apk_version_compare() take strings rather than blobs add apk_pkgversion_compare(), a wrapper that takes packages --- src/version.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/version.c') diff --git a/src/version.c b/src/version.c index c270f68..57f9a22 100644 --- a/src/version.c +++ b/src/version.c @@ -174,16 +174,20 @@ int apk_version_validate(apk_blob_t ver) return t == TOKEN_END; } -int apk_version_compare(apk_blob_t a, apk_blob_t b) +int apk_version_compare(const char *str1, const char *str2) { int at = TOKEN_DIGIT, bt = TOKEN_DIGIT; int av = 0, bv = 0; + apk_blob_t a, b; - if (APK_BLOB_IS_NULL(a) || APK_BLOB_IS_NULL(b)) { - if (APK_BLOB_IS_NULL(a) && APK_BLOB_IS_NULL(b)) + if (str1 == NULL || str2 == NULL) { + if (str1 == NULL && str2 == NULL) return APK_VERSION_EQUAL; return APK_VERSION_EQUAL | APK_VERSION_GREATER | APK_VERSION_LESS; } + + a = APK_BLOB_STR(str1); + b = APK_BLOB_STR(str2); while (at == bt && at != TOKEN_END && at != TOKEN_INVALID && av == bv) { av = get_token(&at, &a); -- cgit v1.2.3