aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-12-08 23:35:36 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-12-08 23:35:36 +0000
commit12a065ff94baf61a8d16576e3e76e019013c3d85 (patch)
tree0cc4ecad93593722c4b68856994abb03aae710ae
parent287113c3f446eeb5864080b86f657ec7f5142e05 (diff)
downloadpaludis-12a065ff94baf61a8d16576e3e76e019013c3d85.tar.gz
paludis-12a065ff94baf61a8d16576e3e76e019013c3d85.tar.xz
Fix ** in package.keywords
-rw-r--r--paludis/environments/portage/portage_environment.cc45
-rw-r--r--paludis/environments/portage/portage_environment_TEST.cc2
2 files changed, 22 insertions, 25 deletions
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 160fca1..00c71bf 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -601,39 +601,34 @@ bool
PortageEnvironment::accept_keywords(const std::tr1::shared_ptr <const KeywordNameSet> & keywords,
const PackageID & d) const
{
- bool result(false);
-
if (keywords->end() != keywords->find(KeywordName("*")))
return true;
- for (KeywordNameSet::ConstIterator k(keywords->begin()), k_end(keywords->end()) ;
- k != k_end ; ++k)
+ std::set<std::string> accepted;
+ std::copy(_imp->accept_keywords.begin(), _imp->accept_keywords.end(), std::inserter(accepted, accepted.begin()));
+ for (PackageKeywords::const_iterator it(_imp->package_keywords.begin()),
+ it_end(_imp->package_keywords.end()); it_end != it; ++it)
{
- bool local_result(false);
-
- if (_imp->accept_keywords.end() != _imp->accept_keywords.find(stringify(*k)))
- local_result = true;
+ if (! match_package(*this, *it->first, d, MatchPackageOptions()))
+ continue;
- for (PackageKeywords::const_iterator i(_imp->package_keywords.begin()), i_end(_imp->package_keywords.end()) ;
- i != i_end ; ++i)
- {
- if (! match_package(*this, *i->first, d, MatchPackageOptions()))
- continue;
+ if ("-*" == it->second)
+ accepted.clear();
+ else if ('-' == it->second.at(0))
+ accepted.erase(it->second.substr(1));
+ else
+ accepted.insert(it->second);
+ }
- if (i->second == stringify(*k))
- local_result = true;
- else if (i->second == "-" + stringify(*k))
- local_result = false;
- else if (i->second == "-*")
- local_result = false;
- else if (i->second == "**")
- local_result = true;
- }
+ if (accepted.end() != accepted.find("**"))
+ return true;
- result |= local_result;
- }
+ for (KeywordNameSet::ConstIterator it(keywords->begin()),
+ it_end(keywords->end()); it_end != it; ++it)
+ if (accepted.end() != accepted.find(stringify(*it)))
+ return true;
- return result;
+ return false;
}
const FSEntry
diff --git a/paludis/environments/portage/portage_environment_TEST.cc b/paludis/environments/portage/portage_environment_TEST.cc
index a6626f2..1a3931e 100644
--- a/paludis/environments/portage/portage_environment_TEST.cc
+++ b/paludis/environments/portage/portage_environment_TEST.cc
@@ -172,6 +172,8 @@ namespace test_cases
generator::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-four-1",
&env, UserPackageDepSpecOptions())), MatchPackageOptions()))]->begin());
TEST_CHECK(accept_keyword(env, KeywordName("fred"), *id4));
+ std::tr1::shared_ptr<const KeywordNameSet> empty(new KeywordNameSet);
+ TEST_CHECK(env.accept_keywords(empty, *id4));
}
} test_accept_keywords;
}