summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmdline/cmdline_search.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/cmdline/cmdline_search.cc b/src/cmdline/cmdline_search.cc
index b4ff98b1..4792db6e 100644
--- a/src/cmdline/cmdline_search.cc
+++ b/src/cmdline/cmdline_search.cc
@@ -69,6 +69,25 @@ public:
}
};
+/** \brief operator== for match results. */
+class result_equality
+{
+ pkg_sortpolicy *s;
+public:
+ result_equality(pkg_sortpolicy *_s):s(_s) {}
+
+ bool operator()(const pair<pkgCache::PkgIterator, pkg_match_result *> &a,
+ const pair<pkgCache::PkgIterator, pkg_match_result *> &b)
+ {
+ pkgCache::VerIterator av =
+ (*apt_cache_file)[a.first].CandidateVerIter(*apt_cache_file);
+ pkgCache::VerIterator bv =
+ (*apt_cache_file)[b.first].CandidateVerIter(*apt_cache_file);
+
+ return s->compare(a.first, av, b.first, bv) == 0;
+ }
+};
+
// FIXME: apt-cache does lots of tricks to make this fast. Should I?
int cmdline_search(int argc, char *argv[], const char *status_fname,
string display_format, string width, string sort)
@@ -85,8 +104,6 @@ int cmdline_search(int argc, char *argv[], const char *status_fname,
return -1;
}
- compare comp(s);
-
_error->DumpErrors();
if(!width.empty())
@@ -176,7 +193,9 @@ int cmdline_search(int argc, char *argv[], const char *status_fname,
}
}
- std::sort(output.begin(), output.end(), comp);
+ std::sort(output.begin(), output.end(), compare(s));
+ output.erase(std::unique(output.begin(), output.end(), result_equality(s)),
+ output.end());
for(vector<pair<pkgCache::PkgIterator, pkg_match_result *> >::iterator i=output.begin();
i!=output.end(); ++i)