summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-02-13 04:22:58 +0100
committerGuillem Jover <guillem@debian.org>2015-03-30 20:32:12 +0200
commit6b4ff833d2f171da3740f00e90b0613db72a5601 (patch)
treea52f773108d1b85ff39758495fa2de437115bb7a /src
parent8f3f34cf26325a4cd9e0f3f53aaa113632ff9077 (diff)
downloaddpkg-6b4ff833d2f171da3740f00e90b0613db72a5601.tar.gz
dpkg-query: Do not fail on -W and -l when multiple arguments match a package
We should not short-circuit on first match for a package, as that produces bogus errors when the following arguments do match those packages as well, either because they are repeated or because they are sub or super-patterns. Closes: #588505
Diffstat (limited to 'src')
-rw-r--r--src/querycmd.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/querycmd.c b/src/querycmd.c
index 02c9f3b26..04f8769f3 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -285,21 +285,21 @@ listpackages(const char *const *argv)
}
for (i = 0; i < array.n_pkgs; i++) {
+ bool pkg_found = false;
+
pkg = array.pkgs[i];
for (ip = 0; ip < argc; ip++) {
if (pkg_spec_match_pkg(&ps[ip], pkg, &pkg->installed)) {
+ pkg_found = true;
found[ip]++;
- break;
}
}
- if (ip == argc)
+ if (!pkg_found)
array.pkgs[i] = NULL;
}
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. */
for (ip = 0; ip < argc; ip++) {
if (!found[ip]) {
notice(_("no packages found matching %s"), argv[ip]);
@@ -519,6 +519,14 @@ enqperpackage(const char *const *argv)
return failures;
}
+static void
+pkg_array_show_item(struct pkg_array *array, struct pkginfo *pkg, void *pkg_data)
+{
+ struct pkg_format_node *fmt = pkg_data;
+
+ pkg_format_show(fmt, pkg, &pkg->installed);
+}
+
static int
showpackages(const char *const *argv)
{
@@ -566,18 +574,21 @@ showpackages(const char *const *argv)
}
for (i = 0; i < array.n_pkgs; i++) {
+ bool pkg_found = false;
+
pkg = array.pkgs[i];
for (ip = 0; ip < argc; ip++) {
if (pkg_spec_match_pkg(&ps[ip], pkg, &pkg->installed)) {
- pkg_format_show(fmt, pkg, &pkg->installed);
+ pkg_found = true;
found[ip]++;
- break;
}
}
+ if (!pkg_found)
+ array.pkgs[i] = NULL;
}
- /* FIXME: we might get non-matching messages for sub-patterns specified
- * after their super-patterns, due to us skipping on first match. */
+ pkg_array_foreach(&array, pkg_array_show_item, fmt);
+
for (ip = 0; ip < argc; ip++) {
if (!found[ip]) {
notice(_("no packages found matching %s"), argv[ip]);