summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-02-13 04:36:19 +0100
committerGuillem Jover <guillem@debian.org>2015-03-30 20:31:16 +0200
commit8f3f34cf26325a4cd9e0f3f53aaa113632ff9077 (patch)
tree21787188a2ed928de533b4d1551c2fd1ed65c645 /src
parent55553c41c15ddcf93b3c3a7ee42feccff4366bb9 (diff)
downloaddpkg-8f3f34cf26325a4cd9e0f3f53aaa113632ff9077.tar.gz
dpkg-query: Use pkg_array_foreach() instead of ad-hoc traversal
Diffstat (limited to 'src')
-rw-r--r--src/querycmd.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/querycmd.c b/src/querycmd.c
index 7cd84ede7..02c9f3b26 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -222,8 +222,9 @@ Desired=Unknown/Install/Remove/Purge/Hold\n\
}
static void
-list1package(struct pkginfo *pkg, struct list_format *fmt, struct pkg_array *array)
+pkg_array_list_item(struct pkg_array *array, struct pkginfo *pkg, void *pkg_data)
{
+ struct list_format *fmt = pkg_data;
int l;
const char *pdesc;
@@ -243,21 +244,6 @@ list1package(struct pkginfo *pkg, struct list_format *fmt, struct pkg_array *arr
pdesc, l);
}
-static void
-list_found_packages(struct list_format *fmt, struct pkg_array *array)
-{
- int i;
-
- for (i = 0; i < array->n_pkgs; i++) {
- struct pkginfo *pkg = array->pkgs[i];
-
- if (pkg == NULL)
- continue;
-
- list1package(pkg, fmt, array);
- }
-}
-
static int
listpackages(const char *const *argv)
{
@@ -284,7 +270,7 @@ listpackages(const char *const *argv)
array.pkgs[i] = NULL;
}
- list_found_packages(&fmt, &array);
+ pkg_array_foreach(&array, pkg_array_list_item, &fmt);
} else {
int argc, ip, *found;
struct pkg_spec *ps;
@@ -310,7 +296,7 @@ listpackages(const char *const *argv)
array.pkgs[i] = NULL;
}
- list_found_packages(&fmt, &array);
+ pkg_array_foreach(&array, pkg_array_list_item, &fmt);
/* FIXME: we might get non-matching messages for sub-patterns specified
* after their super-patterns, due to us skipping on first match. */