summaryrefslogtreecommitdiff
path: root/apt-private/private-list.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-02-27 22:52:34 +0100
committerMichael Vogt <mvo@debian.org>2014-02-27 22:52:34 +0100
commitfce69e7a0f38299c57ef96ae1c1dd9a5379bfd5a (patch)
treebe7d18baa836e9df166ec63f6c9fe6f94bb84b40 /apt-private/private-list.cc
parenta5e790985752c6820e08e7a7e650e1607fa826e4 (diff)
parentfc104da6a583736223b2f941e43a05ea26b63a7d (diff)
Merge branch 'debian/sid' into debian/experimental
Conflicts: apt-private/private-list.cc configure.ac debian/apt.install.in debian/changelog
Diffstat (limited to 'apt-private/private-list.cc')
-rw-r--r--apt-private/private-list.cc47
1 files changed, 26 insertions, 21 deletions
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index bbf4607f9..be2e07f43 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -42,7 +42,7 @@
#include <apti18n.h>
/*}}}*/
-struct PackageSortAlphabetic
+struct PackageSortAlphabetic /*{{{*/
{
bool operator () (const pkgCache::PkgIterator &p_lhs,
const pkgCache::PkgIterator &p_rhs)
@@ -52,17 +52,17 @@ struct PackageSortAlphabetic
return (l_name < r_name);
}
};
-
-class PackageNameMatcher : public Matcher
-{
+#ifdef PACKAGE_MATCHER_ABI_COMPAT
+#define PackageMatcher PackageNameMatchesFnmatch
+#endif
public:
PackageNameMatcher(const char **patterns)
{
- for(int i=0; patterns[i] != NULL; i++)
+ for(int i=0; patterns[i] != NULL; ++i)
{
std::string pattern = patterns[i];
APT::CacheFilter::PackageMatcher *cachefilter = NULL;
- if(_config->FindB("APT::Cmd::UseRegexp", false) == true)
+ if(_config->FindB("APT::Cmd::Use-Regexp", false) == true)
cachefilter = new APT::CacheFilter::PackageNameMatchesRegEx(pattern);
else
cachefilter = new APT::CacheFilter::PackageNameMatchesFnmatch(pattern);
@@ -71,12 +71,12 @@ class PackageNameMatcher : public Matcher
}
virtual ~PackageNameMatcher()
{
- for(J=filters.begin(); J != filters.end(); J++)
+ for(J=filters.begin(); J != filters.end(); ++J)
delete *J;
}
virtual bool operator () (const pkgCache::PkgIterator &P)
{
- for(J=filters.begin(); J != filters.end(); J++)
+ for(J=filters.begin(); J != filters.end(); ++J)
{
APT::CacheFilter::PackageMatcher *cachefilter = *J;
if((*cachefilter)(P))
@@ -90,17 +90,20 @@ private:
std::vector<APT::CacheFilter::PackageMatcher*>::const_iterator J;
#undef PackageMatcher
};
-
-
-void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records,
+ /*}}}*/
+void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
pkgCache::PkgIterator P,
- std::ostream &outs)
+ std::ostream &outs,
+ bool include_summary=true)
{
for (pkgCache::VerIterator Ver = P.VersionList();
- Ver.end() == false; Ver++)
- ListSingleVersion(CacheFile, records, Ver, outs);
+ Ver.end() == false; ++Ver)
+ {
+ ListSingleVersion(CacheFile, records, Ver, outs, include_summary);
+ outs << "\n";
+ }
}
-
+ /*}}}*/
// list - list package based on criteria /*{{{*/
// ---------------------------------------------------------------------
bool List(CommandLine &Cmd)
@@ -125,24 +128,26 @@ bool List(CommandLine &Cmd)
std::map<std::string, std::string> output_map;
std::map<std::string, std::string>::const_iterator K;
+ bool includeSummary = _config->FindB("APT::Cmd::List-Include-Summary");
+
PackageNameMatcher matcher(patterns);
LocalitySortedVersionSet bag;
- OpTextProgress progress;
+ OpTextProgress progress(*_config);
progress.OverallProgress(0,
Cache->Head().PackageCount,
Cache->Head().PackageCount,
_("Listing"));
GetLocalitySortedVersionSet(CacheFile, bag, matcher, progress);
- for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); V++)
+ for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); ++V)
{
std::stringstream outs;
- if(_config->FindB("APT::Cmd::AllVersions", false) == true)
+ if(_config->FindB("APT::Cmd::All-Versions", false) == true)
{
- ListAllVersions(CacheFile, records, V.ParentPkg(), outs);
+ ListAllVersions(CacheFile, records, V.ParentPkg(), outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
V.ParentPkg().Name(), outs.str()));
} else {
- ListSingleVersion(CacheFile, records, V, outs);
+ ListSingleVersion(CacheFile, records, V, outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
V.ParentPkg().Name(), outs.str()));
}
@@ -150,7 +155,7 @@ bool List(CommandLine &Cmd)
// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
// output the sorted map
- for (K = output_map.begin(); K != output_map.end(); K++)
+ for (K = output_map.begin(); K != output_map.end(); ++K)
std::cout << (*K).second << std::endl;