summaryrefslogtreecommitdiff
path: root/src/dot.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-06-18 08:03:40 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-06-18 08:03:40 +0300
commit54509e7a1a33923569848ce69c6e7f94fc6a021b (patch)
treea64133f0311c56fe1091fae3a5e293688c3caf01 /src/dot.c
parent72139b82d3e6631c839745f3c34a5aca8c5c61e4 (diff)
downloadapk-tools-54509e7a1a33923569848ce69c6e7f94fc6a021b.tar.gz
apk-tools-54509e7a1a33923569848ce69c6e7f94fc6a021b.tar.bz2
apk-tools-54509e7a1a33923569848ce69c6e7f94fc6a021b.tar.xz
apk-tools-54509e7a1a33923569848ce69c6e7f94fc6a021b.zip
all: various conversions to foreach_array_item, and simplifications of code
Diffstat (limited to 'src/dot.c')
-rw-r--r--src/dot.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/dot.c b/src/dot.c
index eed4fbb..1939ca9 100644
--- a/src/dot.c
+++ b/src/dot.c
@@ -64,7 +64,9 @@ static void dump_name(struct dot_ctx *ctx, struct apk_name *name)
static int dump_pkg(struct dot_ctx *ctx, struct apk_package *pkg)
{
- int i, j, r, ret = 0;
+ struct apk_dependency *dep;
+ struct apk_provider *p0;
+ int r, ret = 0;
if (pkg->state_int == S_EVALUATED)
return 0;
@@ -75,8 +77,7 @@ static int dump_pkg(struct dot_ctx *ctx, struct apk_package *pkg)
}
pkg->state_int = S_EVALUATING;
- for (i = 0; i < pkg->depends->num; i++) {
- struct apk_dependency *dep = &pkg->depends->item[i];
+ foreach_array_item(dep, pkg->depends) {
struct apk_name *name = dep->name;
dump_name(ctx, name);
@@ -87,9 +88,7 @@ static int dump_pkg(struct dot_ctx *ctx, struct apk_package *pkg)
continue;
}
- for (j = 0; j < name->providers->num; j++) {
- struct apk_provider *p0 = &name->providers->item[j];
-
+ foreach_array_item(p0, name->providers) {
if (!apk_dep_is_provided(dep, p0))
continue;
@@ -124,15 +123,16 @@ static int foreach_pkg(apk_hash_item item, void *ctx)
static int dot_main(void *pctx, struct apk_database *db, int argc, char **argv)
{
struct dot_ctx *ctx = (struct dot_ctx *) pctx;
- int i, j;
+ struct apk_provider *p;
+ int i;
if (argc) {
for (i = 0; i < argc; i++) {
struct apk_name *name = apk_db_get_name(db, APK_BLOB_STR(argv[i]));
if (!name)
continue;
- for (j = 0; j < name->providers->num; j++)
- dump_pkg(ctx, name->providers->item[j].pkg);
+ foreach_array_item(p, name->providers)
+ dump_pkg(ctx, p->pkg);
}
} else {
apk_hash_foreach(&db->available.packages, foreach_pkg, pctx);