aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-12-21 20:39:34 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-12-21 20:39:34 +0000
commitb7486baa74779a6a139bebff5fa97feaa07d2785 (patch)
tree282eed06eaad95317d344b291a1a3e1574c65677
parente592e4040793c6bb847c3e53fda92387216cfee3 (diff)
downloadpaludis-b7486baa74779a6a139bebff5fa97feaa07d2785.tar.gz
paludis-b7486baa74779a6a139bebff5fa97feaa07d2785.tar.xz
Don't duplicate flags that appear multiple times in IUSE with different defaults
-rw-r--r--paludis/repositories/e/e_choices_key.cc58
1 files changed, 46 insertions, 12 deletions
diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc
index 7ea30bc..4500529 100644
--- a/paludis/repositories/e/e_choices_key.cc
+++ b/paludis/repositories/e/e_choices_key.cc
@@ -218,6 +218,28 @@ namespace
}
}
+namespace
+{
+ void add_choice_to_map(std::map<ChoiceNameWithPrefix, Tribool> & values,
+ const std::pair<ChoiceNameWithPrefix, Tribool> & flag,
+ const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & key)
+ {
+ std::map<ChoiceNameWithPrefix, Tribool>::iterator i(values.find(flag.first));
+ if (values.end() == i)
+ values.insert(flag);
+ else if (! flag.second.is_indeterminate()) {
+ if (i->second.is_indeterminate())
+ i->second = flag.second;
+ else if (flag.second.is_true() != i->second.is_true()) {
+ Log::get_instance()->message("e.iuse_key.contradiction", ll_warning, lc_context)
+ << "Flag '" << flag.first << "' is both enabled and disabled by default in "
+ << "'" << key->raw_name() << "', using enabled";
+ i->second = true;
+ }
+ }
+ }
+}
+
const std::tr1::shared_ptr<const Choices>
EChoicesKey::value() const
{
@@ -242,7 +264,6 @@ EChoicesKey::value() const
_imp->value->add(use);
bool has_fancy_test_flag(false);
- std::tr1::shared_ptr<const ChoiceValue> unfancy_test_choice;
std::tr1::shared_ptr<const Set<std::string> > hidden;
if (_imp->id->raw_use_expand_hidden_key())
@@ -306,32 +327,39 @@ EChoicesKey::value() const
if (_imp->id->raw_iuse_key())
{
+ std::set<std::string> iuse_sanitised;
+
+ std::map<ChoiceNameWithPrefix, Tribool> values;
for (Set<std::string>::ConstIterator u(_imp->id->raw_iuse_key()->value()->begin()), u_end(_imp->id->raw_iuse_key()->value()->end()) ;
u != u_end ; ++u)
{
std::pair<ChoiceNameWithPrefix, Tribool> flag(parse_iuse(_imp->id->eapi(), *u));
+ iuse_sanitised.insert(stringify(flag.first));
if (_imp->id->raw_use_expand_key() &&
_imp->id->raw_use_expand_key()->value()->end() != std::find_if(
_imp->id->raw_use_expand_key()->value()->begin(),
_imp->id->raw_use_expand_key()->value()->end(),
IsExpand(flag.first, delim)))
- i_values.insert(flag);
+ add_choice_to_map(i_values, flag, _imp->id->raw_iuse_key());
else
{
- std::tr1::shared_ptr<const ChoiceValue> choice(_imp->id->make_choice_value(
- use, UnprefixedChoiceName(stringify(flag.first)), flag.second, true,
- get_maybe_description(_imp->maybe_descriptions, flag.first), false));
if (stringify(flag.first) == _imp->id->eapi()->supported()->choices_options()->fancy_test_flag())
- {
/* have to add this right at the end, after build_options is there */
has_fancy_test_flag = true;
- unfancy_test_choice = choice;
- }
else
- use->add(choice);
+ add_choice_to_map(values, flag, _imp->id->raw_iuse_key());
}
}
+ for (std::map<ChoiceNameWithPrefix, Tribool>::const_iterator it(values.begin()),
+ it_end(values.end()); it_end != it; ++it)
+ {
+ std::tr1::shared_ptr<const ChoiceValue> choice(_imp->id->make_choice_value(
+ use, UnprefixedChoiceName(stringify(it->first)), it->second, true,
+ get_maybe_description(_imp->maybe_descriptions, it->first), false));
+ use->add(choice);
+ }
+
/* pain in the ass: installed packages with DEPEND="x86? ( blah )" need to work,
* even if x86 isn't listed in IUSE. */
if (_imp->id->raw_use_key())
@@ -339,7 +367,7 @@ EChoicesKey::value() const
for (Set<std::string>::ConstIterator u(_imp->id->raw_use_key()->value()->begin()), u_end(_imp->id->raw_use_key()->value()->end()) ;
u != u_end ; ++u)
{
- if (_imp->id->raw_iuse_key()->value()->end() != _imp->id->raw_iuse_key()->value()->find(*u))
+ if (iuse_sanitised.end() != iuse_sanitised.find(*u))
continue;
std::pair<ChoiceNameWithPrefix, Tribool> flag(ChoiceNameWithPrefix("x"), indeterminate);
@@ -444,8 +472,14 @@ EChoicesKey::value() const
if (choice)
use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(_imp->id->eapi()->supported()->choices_options()->fancy_test_flag()),
choice->enabled(), true, "", true));
- else if (unfancy_test_choice)
- use->add(unfancy_test_choice);
+ else
+ {
+ std::string name(_imp->id->eapi()->supported()->choices_options()->fancy_test_flag());
+ choice = _imp->id->make_choice_value(
+ use, UnprefixedChoiceName(name), indeterminate, true,
+ get_maybe_description(_imp->maybe_descriptions, ChoiceNameWithPrefix(name)), false);
+ use->add(choice);
+ }
}
return _imp->value;