aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-05 11:56:01 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-05 11:56:01 +0000
commit51f66fbf7d6e861ddce496ddd9ad4df8fed9b353 (patch)
tree4c2c93fa60736c1725bc9be9ca1c0b2793b76f1d
parent6a64661951752de64a825b9d8bacb5e28e25def6 (diff)
downloadpaludis-51f66fbf7d6e861ddce496ddd9ad4df8fed9b353.tar.gz
paludis-51f66fbf7d6e861ddce496ddd9ad4df8fed9b353.tar.xz
Show the matching files for --owner -when --ful-match is not specified. Fixes: ticket:488
-rw-r--r--NEWS4
-rw-r--r--src/clients/paludis/owner.cc25
2 files changed, 23 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index c11ef08..5c10e4d 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ News for Paludis
This file lists the major changes between versions. For a more detailed list
of every change, see the ChangeLog.
+trunk/:
+ * paludis --owner now shows matching files when --full-match is not
+ specified.
+
0.26.0_alpha10:
* rsync based syncers (rsync://, file://, tar+http:// and tar+ftp://) now
support --exclude in sync_options, as well as --exclude-from.
diff --git a/src/clients/paludis/owner.cc b/src/clients/paludis/owner.cc
index a8c263a..fc852a8 100644
--- a/src/clients/paludis/owner.cc
+++ b/src/clients/paludis/owner.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -25,6 +25,7 @@
#include <paludis/paludis.hh>
#include <iostream>
#include <algorithm>
+#include <set>
using namespace paludis;
using std::cout;
@@ -36,12 +37,11 @@ namespace
struct ContentsFinder :
ConstVisitor<ContentsVisitorTypes>
{
- bool found;
+ std::set<std::string> matches;
const std::string query;
const bool full;
ContentsFinder(const std::string & q, bool f) :
- found(false),
query(q),
full(f)
{
@@ -50,9 +50,15 @@ namespace
void handle(const std::string & e)
{
if (full)
- found |= (e == query);
+ {
+ if (e == query)
+ matches.insert(e);
+ }
else
- found |= (std::string::npos != e.find(query));
+ {
+ if (std::string::npos != e.find(query))
+ matches.insert(e);
+ }
}
void visit(const ContentsFileEntry & e)
@@ -119,9 +125,16 @@ do_one_owner(
tr1::shared_ptr<const Contents> contents((*v)->contents_key()->value());
ContentsFinder d(query, CommandLine::get_instance()->a_full_match.specified());
std::for_each(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), accept_visitor(d));
- if (d.found)
+ if (! d.matches.empty())
{
cout << " " << **v << endl;
+ if (! CommandLine::get_instance()->a_full_match.specified())
+ {
+ for (std::set<std::string>::const_iterator f(d.matches.begin()), f_end(d.matches.end()) ;
+ f != f_end ; ++f)
+ cout << " " << *f << endl;
+ }
+
found_owner=true;
}
}