diff options
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | src/querycmd.c | 27 |
2 files changed, 21 insertions, 8 deletions
diff --git a/debian/changelog b/debian/changelog index 179df9d5e..e49834e99 100644 --- a/debian/changelog +++ b/debian/changelog @@ -79,6 +79,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low * Remove old trigger related Breaks and Conflicts from dpkg. * Set the SE Linux context on «dpkg-statoverride --update». Closes: #690361 * Only use stackprotectorstrong when building dpkg with gcc >= 4.9. + * Do not fail on dpkg-query -W and -l when multiple arguments match the + same package. Closes: #588505 [ Raphaël Hertzog ] * Drop myself from Uploaders. 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]); |