aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-24 16:33:10 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-24 16:33:10 +0000
commitf338ac00f3388631aa65b721eb51104818a63ef4 (patch)
treee72a0d63f775595af22d207c966daecc1561a6bd
parentc9f4d964f2c667efda6060135004035a93ecf1c2 (diff)
downloadpaludis-f338ac00f3388631aa65b721eb51104818a63ef4.tar.gz
paludis-f338ac00f3388631aa65b721eb51104818a63ef4.tar.xz
VersionRequirements can now be 'or' rather than 'and'.
-rw-r--r--paludis/dep_atom.cc25
-rw-r--r--paludis/dep_atom.hh9
-rw-r--r--paludis/match_package.cc34
-rw-r--r--paludis/version_requirements.hh9
4 files changed, 67 insertions, 10 deletions
diff --git a/paludis/dep_atom.cc b/paludis/dep_atom.cc
index 7e5c866..361c0f0 100644
--- a/paludis/dep_atom.cc
+++ b/paludis/dep_atom.cc
@@ -130,6 +130,7 @@ PackageDepAtom::PackageDepAtom(const QualifiedPackageName & our_package) :
StringDepAtom(stringify(our_package)),
_package(our_package),
_version_requirements(0),
+ _version_requirements_mode(vr_and),
_slot(0),
_repository(0),
_use_requirements(0),
@@ -143,6 +144,7 @@ PackageDepAtom::PackageDepAtom(const PackageDepAtom & other) :
Visitable<PackageDepAtom, DepAtomVisitorTypes>(other),
_package(other._package),
_version_requirements(other._version_requirements),
+ _version_requirements_mode(other._version_requirements_mode),
_slot(other._slot),
_repository(other._repository),
_use_requirements(other._use_requirements),
@@ -154,6 +156,7 @@ PackageDepAtom::PackageDepAtom(const std::string & ss) :
StringDepAtom(ss),
_package(CategoryNamePart("later"), PackageNamePart("later")),
_version_requirements(0),
+ _version_requirements_mode(vr_and),
_slot(0),
_repository(0),
_use_requirements(0),
@@ -288,19 +291,33 @@ paludis::operator<< (std::ostream & s, const PackageDepAtom & a)
{
if (a.version_requirements_ptr())
{
- bool need_comma(false);
+ bool need_op(false);
for (VersionRequirements::Iterator r(a.version_requirements_ptr()->begin()),
r_end(a.version_requirements_ptr()->end()) ; r != r_end ; ++r)
{
- if (need_comma)
- s << ",";
+ if (need_op)
+ {
+ switch (a.version_requirements_mode())
+ {
+ case vr_and:
+ s << "&";
+ break;
+
+ case vr_or:
+ s << "|";
+ break;
+
+ case last_vr:
+ ;
+ }
+ }
if (r->version_operator == vo_equal_star)
s << "=";
else
s << r->version_operator;
- need_comma = true;
+ need_op = true;
}
}
diff --git a/paludis/dep_atom.hh b/paludis/dep_atom.hh
index 1ea2fe7..431d1c8 100644
--- a/paludis/dep_atom.hh
+++ b/paludis/dep_atom.hh
@@ -329,6 +329,7 @@ namespace paludis
private:
QualifiedPackageName _package;
VersionRequirements::Pointer _version_requirements;
+ VersionRequirementsMode _version_requirements_mode;
CountedPtr<SlotName, count_policy::ExternalCountTag> _slot;
CountedPtr<RepositoryName, count_policy::ExternalCountTag> _repository;
UseRequirements::Pointer _use_requirements;
@@ -374,6 +375,14 @@ namespace paludis
}
/**
+ * Fetch the version requirements mode.
+ */
+ VersionRequirementsMode version_requirements_mode() const
+ {
+ return _version_requirements_mode;
+ }
+
+ /**
* Fetch the slot name (may be a zero pointer).
*/
CountedPtr<SlotName, count_policy::ExternalCountTag> slot_ptr() const
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index 5c08897..9c3d0c3 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -37,10 +37,34 @@ match_package_internals::do_match(
return false;
if (atom->version_requirements_ptr())
- for (VersionRequirements::Iterator r(atom->version_requirements_ptr()->begin()),
- r_end(atom->version_requirements_ptr()->end()) ; r != r_end ; ++r)
- if (! (((entry->version).*(r->version_operator.as_version_spec_operator()))(r->version_spec)))
- return false;
+ switch (atom->version_requirements_mode())
+ {
+ case vr_and:
+ for (VersionRequirements::Iterator r(atom->version_requirements_ptr()->begin()),
+ r_end(atom->version_requirements_ptr()->end()) ; r != r_end ; ++r)
+ if (! (((entry->version).*(r->version_operator.as_version_spec_operator()))(r->version_spec)))
+ return false;
+ break;
+
+ case vr_or:
+ {
+ bool matched(false);
+ for (VersionRequirements::Iterator r(atom->version_requirements_ptr()->begin()),
+ r_end(atom->version_requirements_ptr()->end()) ; r != r_end ; ++r)
+ if ((((entry->version).*(r->version_operator.as_version_spec_operator()))(r->version_spec)))
+ {
+ matched = true;
+ break;
+ }
+
+ if (! matched)
+ return false;
+ }
+ break;
+
+ case last_vr:
+ ;
+ }
if (atom->repository_ptr())
if (*atom->repository_ptr() != entry->repository)
diff --git a/paludis/version_requirements.hh b/paludis/version_requirements.hh
index 24e7fdb..eb25fcb 100644
--- a/paludis/version_requirements.hh
+++ b/paludis/version_requirements.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -37,6 +37,13 @@ namespace paludis
* \ingroup grpversions
*/
typedef SequentialCollection<VersionRequirement> VersionRequirements;
+
+ enum VersionRequirementsMode
+ {
+ vr_or, ///\< Must match one
+ vr_and, ///\< Must match all
+ last_vr
+ };
}
#endif