aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-10-26 09:31:14 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-10-26 09:31:14 +0000
commitd6ea84ebfedb53646b94779c7f25dfd3bdc18142 (patch)
treef76382e316a9597c2b27818c0837b631faf45f0e
parent6d533ba362502f2b2d6cab645d248c6daae8f4db (diff)
downloadpaludis-d6ea84ebfedb53646b94779c7f25dfd3bdc18142.tar.gz
paludis-d6ea84ebfedb53646b94779c7f25dfd3bdc18142.tar.xz
Change [opt+] and [opt-] to [opt(+)] and [opt(-)]
-rw-r--r--paludis/elike_use_requirement.cc54
-rw-r--r--paludis/elike_use_requirement_TEST.cc16
2 files changed, 37 insertions, 33 deletions
diff --git a/paludis/elike_use_requirement.cc b/paludis/elike_use_requirement.cc
index 1aabf33..574489f 100644
--- a/paludis/elike_use_requirement.cc
+++ b/paludis/elike_use_requirement.cc
@@ -476,37 +476,41 @@ namespace
else
factory = make_unconditional_requirement<EnabledUseRequirement>;
- if ('+' == flag.at(flag.length() - 1))
+ if (')' == flag.at(flag.length() - 1))
{
- if (! options[euro_allow_default_values])
- {
- if (options[euro_strict_parsing])
- throw ELikeUseRequirementError(s, "[use+] not safe for use here");
- else
- Log::get_instance()->message("e.use_requirement.flag_not_equal_not_allowed", ll_warning, lc_context)
- << "[use+] not safe for use here";
- }
-
- flag.erase(flag.length() - 1, 1);
- if (flag.empty())
+ if (flag.length() < 4 || flag.at(flag.length() - 3) != '(')
throw ELikeUseRequirementError(s, "Invalid [] contents");
- return factory(ChoiceNameWithPrefix(flag), id, Tribool(true));
- }
- else if ('-' == flag.at(flag.length() - 1))
- {
- if (! options[euro_allow_default_values])
+
+ if ('+' == flag.at(flag.length() - 2))
{
- if (options[euro_strict_parsing])
- throw ELikeUseRequirementError(s, "[use-] not safe for use here");
- else
- Log::get_instance()->message("e.use_requirement.flag_not_equal_not_allowed", ll_warning, lc_context)
- << "[use-] not safe for use here";
+ if (! options[euro_allow_default_values])
+ {
+ if (options[euro_strict_parsing])
+ throw ELikeUseRequirementError(s, "[use(+)] not safe for use here");
+ else
+ Log::get_instance()->message("e.use_requirement.flag_bracket_plus_not_allowed", ll_warning, lc_context)
+ << "[use(+)] not safe for use here";
+ }
+
+ flag.erase(flag.length() - 3, 3);
+ return factory(ChoiceNameWithPrefix(flag), id, Tribool(true));
}
+ else if ('-' == flag.at(flag.length() - 2))
+ {
+ if (! options[euro_allow_default_values])
+ {
+ if (options[euro_strict_parsing])
+ throw ELikeUseRequirementError(s, "[use(-)] not safe for use here");
+ else
+ Log::get_instance()->message("e.use_requirement.flag_bracket_minus_not_allowed", ll_warning, lc_context)
+ << "[use(-)] not safe for use here";
+ }
- flag.erase(flag.length() - 1, 1);
- if (flag.empty())
+ flag.erase(flag.length() - 3, 3);
+ return factory(ChoiceNameWithPrefix(flag), id, Tribool(false));
+ }
+ else
throw ELikeUseRequirementError(s, "Invalid [] contents");
- return factory(ChoiceNameWithPrefix(flag), id, Tribool(false));
}
else
return factory(ChoiceNameWithPrefix(flag), id, Tribool(indeterminate));
diff --git a/paludis/elike_use_requirement_TEST.cc b/paludis/elike_use_requirement_TEST.cc
index ba340e9..afe9366 100644
--- a/paludis/elike_use_requirement_TEST.cc
+++ b/paludis/elike_use_requirement_TEST.cc
@@ -820,26 +820,26 @@ namespace test_cases
set_conditionals(id, "enabled disabled");
std::tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("missing+", std::tr1::shared_ptr<const PackageID>(), ELikeUseRequirementOptions() + euro_allow_default_values + euro_strict_parsing));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[missing+]");
+ parse_elike_use_requirement("missing(+)", std::tr1::shared_ptr<const PackageID>(), ELikeUseRequirementOptions() + euro_allow_default_values + euro_strict_parsing));
+ TEST_CHECK_EQUAL(req1->as_raw_string(), "[missing(+)]");
TEST_CHECK_EQUAL(req1->as_human_string(), "Flag 'missing' enabled, assuming enabled if missing");
TEST_CHECK(req1->requirement_met(&env, *id));
std::tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("missing-", std::tr1::shared_ptr<const PackageID>(), ELikeUseRequirementOptions() + euro_allow_default_values + euro_strict_parsing));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[missing-]");
+ parse_elike_use_requirement("missing(-)", std::tr1::shared_ptr<const PackageID>(), ELikeUseRequirementOptions() + euro_allow_default_values + euro_strict_parsing));
+ TEST_CHECK_EQUAL(req2->as_raw_string(), "[missing(-)]");
TEST_CHECK_EQUAL(req2->as_human_string(), "Flag 'missing' enabled, assuming disabled if missing");
TEST_CHECK(! req2->requirement_met(&env, *id));
std::tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
- parse_elike_use_requirement("-missing+", std::tr1::shared_ptr<const PackageID>(), ELikeUseRequirementOptions() + euro_allow_default_values + euro_strict_parsing));
- TEST_CHECK_EQUAL(req3->as_raw_string(), "[-missing+]");
+ parse_elike_use_requirement("-missing(+)", std::tr1::shared_ptr<const PackageID>(), ELikeUseRequirementOptions() + euro_allow_default_values + euro_strict_parsing));
+ TEST_CHECK_EQUAL(req3->as_raw_string(), "[-missing(+)]");
TEST_CHECK_EQUAL(req3->as_human_string(), "Flag 'missing' disabled, assuming enabled if missing");
TEST_CHECK(! req3->requirement_met(&env, *id));
std::tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
- parse_elike_use_requirement("-missing-", std::tr1::shared_ptr<const PackageID>(), ELikeUseRequirementOptions() + euro_allow_default_values + euro_strict_parsing));
- TEST_CHECK_EQUAL(req4->as_raw_string(), "[-missing-]");
+ parse_elike_use_requirement("-missing(-)", std::tr1::shared_ptr<const PackageID>(), ELikeUseRequirementOptions() + euro_allow_default_values + euro_strict_parsing));
+ TEST_CHECK_EQUAL(req4->as_raw_string(), "[-missing(-)]");
TEST_CHECK_EQUAL(req4->as_human_string(), "Flag 'missing' disabled, assuming disabled if missing");
TEST_CHECK(req4->requirement_met(&env, *id));
}