summaryrefslogtreecommitdiffstats
path: root/libopkg/pkg.c
diff options
context:
space:
mode:
authorpixdamix@gmail.com <pixdamix@gmail.com@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2012-11-22 04:18:17 (EST)
committer pixdamix@gmail.com <pixdamix@gmail.com@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2012-11-22 04:18:17 (EST)
commit932c8d8f499f26d3f7ac0b5b0307f6a886396a0d (patch)
tree76ae05d6d664f45e6cb3d2d649319dcef989f363 /libopkg/pkg.c
parent15f255915ce893750165c89af9d1ebbbc571a8dc (diff)
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 <Martin.Jansa@gmail.com> git-svn-id: http://opkg.googlecode.com/svn/trunk@644 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/pkg.c')
-rw-r--r--libopkg/pkg.c36
1 files changed, 16 insertions, 20 deletions
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;
}