From 681f74a8bd5beaad5b821a5c4eb3c0bc1c471669 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 26 Oct 2020 14:39:44 +0100 Subject: pkgnames: Do not exclude virtual packages with --all-names We accidentally excluded virtual packages by excluding every group that had a package, but where the package had no versions. Rewrite the code so the lookup consistently uses VersionList() instead of FirstVersion and FindPkg("any") - those are all the same, and this is easier to read. --- cmdline/apt-cache.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index b40ff6efa..ffe650970 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -986,9 +986,7 @@ static bool ShowPkgNames(CommandLine &CmdL) { for (;I.end() != true; ++I) { - if (All == false && I->FirstPackage == 0) - continue; - if (I.FindPkg("any")->VersionList == 0) + if (All == false && (I.PackageList().end() || I.PackageList()->VersionList == 0)) continue; if (strncmp(I.Name(),CmdL.FileList[1],strlen(CmdL.FileList[1])) == 0) cout << I.Name() << endl; @@ -1000,13 +998,11 @@ static bool ShowPkgNames(CommandLine &CmdL) // Show all pkgs for (;I.end() != true; ++I) { - if (All == false && I->FirstPackage == 0) - continue; - if (I.FindPkg("any")->VersionList == 0) + if (All == false && (I.PackageList().end() || I.PackageList()->VersionList == 0)) continue; cout << I.Name() << endl; } - + return true; } /*}}}*/ -- cgit v1.2.3