aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 14:54:38 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 14:54:38 +0100
commit5c950263e9ea902e86030b5fd3a8c6b0760e7539 (patch)
treeeff1ba8b39ba44dc332f470c9717a896813b7b7c
parentb3d3ba6393d47447c9ee5fe444683d2409b3cd2d (diff)
downloadpaludis-5c950263e9ea902e86030b5fd3a8c6b0760e7539.tar.gz
paludis-5c950263e9ea902e86030b5fd3a8c6b0760e7539.tar.xz
[.key~value] operator
-rw-r--r--doc/configuration/specs.html.part8
-rw-r--r--paludis/package_dep_spec_constraint.cc94
-rw-r--r--paludis/package_dep_spec_constraint.se1
-rw-r--r--paludis/user_dep_spec.cc3
4 files changed, 96 insertions, 10 deletions
diff --git a/doc/configuration/specs.html.part b/doc/configuration/specs.html.part
index ad3758e..40833f3 100644
--- a/doc/configuration/specs.html.part
+++ b/doc/configuration/specs.html.part
@@ -46,10 +46,10 @@ the following order:</p>
<li><code>[.key=value]</code>: Match only if the specified metadata key has a particular exact value. Only works for
simple values, sets and sequences, not spec trees and other complex compound keys. If <code>&lt;</code> is used in
place of <code>=</code>, for numeric values a less-than comparison is used, and for sets, sequences and spec trees,
- a match occurs if any member of the set or sequence is equal to the value. Similarly if <code>&gt;</code> is used,
- for numeric values a greater-than comparison is used; it does not match for other types of values. As above, the key
- may be a raw name or a dollar-prefixed role name, and may be prefixed with <code>::</code> for checking repository
- metadata.</li>
+ a match occurs if any member of the set or sequence is equal to the value. If <code>&gt;</code> is used,
+ for numeric values a greater-than comparison is used; it does not match for other types of values. If <code>~</code>
+ is used, a substring match is performed. As above, the key may be a raw name or a dollar-prefixed role name, and
+ may be prefixed with <code>::</code> for checking repository metadata.</li>
</ul>
<p>Repository requirements are in the form <code>to</code>, <code>from-&gt;</code> or <code>::from-&gt;to</code>. The
diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc
index 5db0b2b..68b1639 100644
--- a/paludis/package_dep_spec_constraint.cc
+++ b/paludis/package_dep_spec_constraint.cc
@@ -481,6 +481,8 @@ namespace
{
case kco_equals:
return pattern == stringify(k.value().seconds());
+ case kco_tilde:
+ return std::string::npos != stringify(k.value().seconds()).find(pattern);
case kco_less_than:
return k.value().seconds() < destringify<time_t>(pattern);
case kco_greater_than:
@@ -495,22 +497,74 @@ namespace
bool visit(const MetadataValueKey<std::string> & k) const
{
- return pattern == stringify(k.value());
+ switch (op)
+ {
+ case kco_equals:
+ return pattern == stringify(k.value());
+ case kco_tilde:
+ return std::string::npos != stringify(k.value()).find(pattern);
+ case kco_less_than:
+ case kco_greater_than:
+ case kco_question:
+ case last_kco:
+ break;
+ }
+
+ return false;
}
bool visit(const MetadataValueKey<SlotName> & k) const
{
- return pattern == stringify(k.value());
+ switch (op)
+ {
+ case kco_equals:
+ return pattern == stringify(k.value());
+ case kco_tilde:
+ return std::string::npos != stringify(k.value()).find(pattern);
+ case kco_less_than:
+ case kco_greater_than:
+ case kco_question:
+ case last_kco:
+ break;
+ }
+
+ return false;
}
bool visit(const MetadataValueKey<FSPath> & k) const
{
- return pattern == stringify(k.value());
+ switch (op)
+ {
+ case kco_equals:
+ return pattern == stringify(k.value());
+ case kco_tilde:
+ return std::string::npos != stringify(k.value()).find(pattern);
+ case kco_less_than:
+ case kco_greater_than:
+ case kco_question:
+ case last_kco:
+ break;
+ }
+
+ return false;
}
bool visit(const MetadataValueKey<bool> & k) const
{
- return pattern == stringify(k.value());
+ switch (op)
+ {
+ case kco_equals:
+ return pattern == stringify(k.value());
+ case kco_tilde:
+ return std::string::npos != stringify(k.value()).find(pattern);
+ case kco_less_than:
+ case kco_greater_than:
+ case kco_question:
+ case last_kco:
+ break;
+ }
+
+ return false;
}
bool visit(const MetadataValueKey<long> & k) const
@@ -519,6 +573,8 @@ namespace
{
case kco_equals:
return pattern == stringify(k.value());
+ case kco_tilde:
+ return std::string::npos != stringify(k.value()).find(pattern);
case kco_less_than:
return k.value() < destringify<long>(pattern);
case kco_greater_than:
@@ -551,6 +607,7 @@ namespace
case kco_greater_than:
case kco_question:
+ case kco_tilde:
case last_kco:
break;
}
@@ -560,7 +617,20 @@ namespace
bool visit(const MetadataValueKey<std::shared_ptr<const PackageID> > & k) const
{
- return pattern == stringify(*k.value());
+ switch (op)
+ {
+ case kco_equals:
+ return pattern == stringify(*k.value());
+ case kco_tilde:
+ return std::string::npos != stringify(*k.value()).find(pattern);
+ case kco_less_than:
+ case kco_greater_than:
+ case kco_question:
+ case last_kco:
+ break;
+ }
+
+ return false;
}
bool visit(const MetadataSpecTreeKey<DependencySpecTree> & s) const
@@ -572,6 +642,7 @@ namespace
case kco_less_than:
return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -590,6 +661,7 @@ namespace
case kco_less_than:
return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -608,6 +680,7 @@ namespace
case kco_less_than:
return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -626,6 +699,7 @@ namespace
case kco_less_than:
return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -644,6 +718,7 @@ namespace
case kco_less_than:
return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -662,6 +737,7 @@ namespace
case kco_less_than:
return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -680,6 +756,7 @@ namespace
case kco_less_than:
return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -698,6 +775,7 @@ namespace
case kco_less_than:
return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -717,6 +795,7 @@ namespace
return s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(),
StringifyEqual(pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -738,6 +817,7 @@ namespace
indirect_iterator(s.value()->end()),
StringifyEqual(pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -757,6 +837,7 @@ namespace
return s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(),
StringifyEqual(pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -776,6 +857,7 @@ namespace
return s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(),
StringifyEqual(pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -800,6 +882,7 @@ namespace
return s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(),
StringifyEqual(pattern));
+ case kco_tilde:
case kco_greater_than:
case kco_question:
case last_kco:
@@ -1024,6 +1107,7 @@ KeyConstraint::as_raw_string() const
switch (operation())
{
case kco_equals: s << "=" << pattern(); break;
+ case kco_tilde: s << "~" << pattern(); break;
case kco_less_than: s << "<" << pattern(); break;
case kco_greater_than: s << ">" << pattern(); break;
case kco_question: s << "?"; break;
diff --git a/paludis/package_dep_spec_constraint.se b/paludis/package_dep_spec_constraint.se
index 54982f8..f224c1b 100644
--- a/paludis/package_dep_spec_constraint.se
+++ b/paludis/package_dep_spec_constraint.se
@@ -6,6 +6,7 @@ make_enum_KeyConstraintOperation()
prefix kco
key kco_equals "An = constraint"
+ key kco_tilde "A ~ constraint"
key kco_less_than "A less than constraint"
key kco_greater_than "A greater than constraint"
key kco_question "A question constraint"
diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc
index 37f1c12..7f88873 100644
--- a/paludis/user_dep_spec.cc
+++ b/paludis/user_dep_spec.cc
@@ -326,7 +326,7 @@ paludis::user_version_spec_options()
std::tuple<KeyConstraintKeyType, std::string, KeyConstraintOperation, std::string>
paludis::parse_user_key_constraint(const std::string & s)
{
- std::string::size_type p(s.find_first_of("=<>?"));
+ std::string::size_type p(s.find_first_of("=<>?~"));
if (std::string::npos == p)
throw PackageDepSpecError("[." + s + "] contains no operator");
@@ -348,6 +348,7 @@ paludis::parse_user_key_constraint(const std::string & s)
switch (s.at(p))
{
case '=': op = kco_equals; break;
+ case '~': op = kco_tilde; break;
case '<': op = kco_less_than; break;
case '>': op = kco_greater_than; break;
default: