From 0f2a3b2ae317952ea4edf5a0004c698b41b0020e Mon Sep 17 00:00:00 2001 From: graham.gower Date: Tue, 17 Nov 2009 00:58:41 -0500 Subject: Fix depended_upon_by to only contain pre_depends and depends. Partially fixes Issue 23. Allows removal of suggested/recommended packages. git-svn-id: http://opkg.googlecode.com/svn/trunk@328 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- (limited to 'libopkg') diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c index d93ea0c..10a8ab5 100644 --- a/libopkg/pkg_depends.c +++ b/libopkg/pkg_depends.c @@ -642,6 +642,11 @@ void buildDepends(hash_table_t * hash, pkg_t * pkg) depends++; } + for(i = 0; i < pkg->depends_count; i++){ + parseDepends(depends, hash, pkg->depends_str[i]); + depends++; + } + for(i = 0; i < pkg->recommends_count; i++){ parseDepends(depends, hash, pkg->recommends_str[i]); depends->type = RECOMMEND; @@ -653,11 +658,6 @@ void buildDepends(hash_table_t * hash, pkg_t * pkg) depends->type = SUGGEST; depends++; } - - for(i = 0; i < pkg->depends_count; i++){ - parseDepends(depends, hash, pkg->depends_str[i]); - depends++; - } } /* @@ -675,6 +675,11 @@ char *pkg_depend_str(pkg_t *pkg, int index) } index -= pkg->pre_depends_count; + if (index < pkg->depends_count) { + return pkg->depends_str[index]; + } + index -= pkg->depends_count; + if (index < pkg->recommends_count) { return pkg->recommends_str[index]; } @@ -683,15 +688,15 @@ char *pkg_depend_str(pkg_t *pkg, int index) if (index < pkg->suggests_count) { return pkg->suggests_str[index]; } - index -= pkg->suggests_count; - if (index < pkg->depends_count) { - return pkg->depends_str[index]; - } fprintf(stderr, "pkg_depend_str: index %d out of range for pkg=%s\n", index, pkg->name); return NULL; } +/* + * WARNING: This function assumes pre_depends and depends are at the + * start of the pkg->depends array. + */ void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg) { compound_depend_t * depends; -- cgit v0.9.1