From 932c8d8f499f26d3f7ac0b5b0307f6a886396a0d Mon Sep 17 00:00:00 2001 From: pixdamix@gmail.com Date: Thu, 22 Nov 2012 04:18:17 -0500 Subject: pkg_depends: fix version constraints * factor parsing version constraint to str_to_constraint and use that from pkg (pkg_version_satisfied) and also pkg_depends (parseDepends) * fix constraint_to_str(), for EARLIER and LATER it was using '<' and '>' which is parsed later as EARLIER_EQUAL and LATER_EQUAL * show notice when deprecated '<' or '>' is used Signed-off-by: Martin Jansa git-svn-id: http://opkg.googlecode.com/svn/trunk@644 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- (limited to 'libopkg/pkg.c') diff --git a/libopkg/pkg.c b/libopkg/pkg.c index 39f4b30..23055f3 100644 --- a/libopkg/pkg.c +++ b/libopkg/pkg.c @@ -968,28 +968,24 @@ pkg_version_satisfied(pkg_t *it, pkg_t *ref, const char *op) int r; r = pkg_compare_versions(it, ref); + char *op2 = op; + enum version_constraint constraint = str_to_constraint(&op2); - if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) { - return r <= 0; - } - - if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) { - return r >= 0; - } - - if (strcmp(op, "<<") == 0) { - return r < 0; - } - - if (strcmp(op, ">>") == 0) { - return r > 0; - } - - if (strcmp(op, "=") == 0) { - return r == 0; + switch (constraint) + { + case EARLIER_EQUAL: + return r <= 0; + case LATER_EQUAL: + return r >= 0; + case EARLIER: + return r < 0; + case LATER: + return r > 0; + case EQUAL: + return r == 0; + case NONE: + opkg_msg(ERROR, "Unknown operator: %s.\n", op); } - - opkg_msg(ERROR, "Unknown operator: %s.\n", op); return 0; } -- cgit v0.9.1