diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-06-22 11:08:39 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-06-22 11:08:39 +0200 |
commit | 5b75b40bf9c6769ef14e23d13cc0765929a5b83a (patch) | |
tree | 98649f7e5d5bd751508094f2fa29d81b72b076bb /src/version.c | |
parent | 4bbed2d648fcb98c613f88c1ced418e771407f84 (diff) | |
download | apk-tools-5b75b40bf9c6769ef14e23d13cc0765929a5b83a.tar.gz apk-tools-5b75b40bf9c6769ef14e23d13cc0765929a5b83a.tar.bz2 apk-tools-5b75b40bf9c6769ef14e23d13cc0765929a5b83a.tar.xz apk-tools-5b75b40bf9c6769ef14e23d13cc0765929a5b83a.zip |
version: added apk_version_compare_blob() function
We want be able to compare blobs so we basicly revert the old change,
and make a wrapper that takes version strings.
Diffstat (limited to 'src/version.c')
-rw-r--r-- | src/version.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/version.c b/src/version.c index 57f9a22..a1796a1 100644 --- a/src/version.c +++ b/src/version.c @@ -174,20 +174,16 @@ int apk_version_validate(apk_blob_t ver) return t == TOKEN_END; } -int apk_version_compare(const char *str1, const char *str2) +int apk_version_compare_blob(apk_blob_t a, apk_blob_t b) { int at = TOKEN_DIGIT, bt = TOKEN_DIGIT; int av = 0, bv = 0; - apk_blob_t a, b; - if (str1 == NULL || str2 == NULL) { - if (str1 == NULL && str2 == NULL) + if (APK_BLOB_IS_NULL(a) || APK_BLOB_IS_NULL(b)) { + if (APK_BLOB_IS_NULL(a) && APK_BLOB_IS_NULL(b)) 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); @@ -213,3 +209,8 @@ int apk_version_compare(const char *str1, const char *str2) APK_VERSION_LESS : APK_VERSION_GREATER; return APK_VERSION_EQUAL; } + +int apk_version_compare(const char *str1, const char *str2) +{ + return apk_version_compare_blob(APK_BLOB_STR(str1), APK_BLOB_STR(str2)); +} |