aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-17 08:52:17 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-17 08:52:17 +0000
commit0306b0b4a588cc14ad4ea0ceff8397dcf9f31fca (patch)
tree1ddd6bba1b72f8d8f8370bd380972b0270579837
parentb37da39643d450b20f61fb564b5a028afada6785 (diff)
downloadpaludis-0306b0b4a588cc14ad4ea0ceff8397dcf9f31fca.tar.gz
paludis-0306b0b4a588cc14ad4ea0ceff8397dcf9f31fca.tar.xz
Fix tilde comparisons
-rw-r--r--paludis/version_spec.cc6
-rw-r--r--paludis/version_spec_TEST.cc26
2 files changed, 16 insertions, 16 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index 064da84..58ee191 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -380,7 +380,7 @@ VersionSpec::tilde_compare(const VersionSpec & other) const
if (p1->kind != p2->kind)
{
- if (p1 != &end_part || p2->kind != revision)
+ if (p2 != &end_part || p1->kind != revision)
return false;
}
else
@@ -391,9 +391,9 @@ VersionSpec::tilde_compare(const VersionSpec & other) const
for (unsigned long x(0) ; x < p1->multiplier ; ++x)
m2 *= 10;
- if (p1->kind == revision)
+ if (p2->kind == revision)
{
- if (p1->value * m1 > p2->value * m2)
+ if (p2->value * m2 > p1->value * m1)
return false;
}
else if (p1->value * m1 != p2->value * m2)
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index 98dd845..54fae5c 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -151,22 +151,22 @@ namespace test_cases
void run()
{
- TEST_CHECK(! VersionSpec("1.3-r1").tilde_compare(VersionSpec("1.4-r1")));
- TEST_CHECK(! VersionSpec("1.3-r1").tilde_compare(VersionSpec("1.4")));
- TEST_CHECK(! VersionSpec("1.3-r1").tilde_compare(VersionSpec("1.2")));
- TEST_CHECK(! VersionSpec("1.3-r1").tilde_compare(VersionSpec("1.3")));
+ TEST_CHECK(! VersionSpec("1.4-r1").tilde_compare(VersionSpec("1.3-r1")));
+ TEST_CHECK(! VersionSpec("1.4").tilde_compare(VersionSpec("1.3-r1")));
+ TEST_CHECK(! VersionSpec("1.2").tilde_compare(VersionSpec("1.3-r1")));
+ TEST_CHECK(! VersionSpec("1.3").tilde_compare(VersionSpec("1.3-r1")));
TEST_CHECK(VersionSpec("1.2").tilde_compare(VersionSpec("1.2")));
- TEST_CHECK(VersionSpec("1.2").tilde_compare(VersionSpec("1.2-r1")));
- TEST_CHECK(VersionSpec("1.2").tilde_compare(VersionSpec("1.2-r1.2.3")));
- TEST_CHECK(! VersionSpec("1.2").tilde_compare(VersionSpec("1.3")));
- TEST_CHECK(VersionSpec("1.2-r1").tilde_compare(VersionSpec("1.2-r2")));
- TEST_CHECK(VersionSpec("1.2-r1").tilde_compare(VersionSpec("1.2-r2.3")));
+ TEST_CHECK(VersionSpec("1.2-r1").tilde_compare(VersionSpec("1.2")));
+ TEST_CHECK(VersionSpec("1.2-r1.2.3").tilde_compare(VersionSpec("1.2")));
+ TEST_CHECK(! VersionSpec("1.3").tilde_compare(VersionSpec("1.2")));
+ TEST_CHECK(VersionSpec("1.2-r2").tilde_compare(VersionSpec("1.2-r1")));
+ TEST_CHECK(VersionSpec("1.2-r2.3").tilde_compare(VersionSpec("1.2-r1")));
TEST_CHECK(VersionSpec("1.2-r2").tilde_compare(VersionSpec("1.2-r2")));
- TEST_CHECK(! VersionSpec("1.2-r2").tilde_compare(VersionSpec("1.2-r1")));
- TEST_CHECK(! VersionSpec("1.2-r2").tilde_compare(VersionSpec("1.2-r1.3")));
- TEST_CHECK(! VersionSpec("1.2-r2.3").tilde_compare(VersionSpec("1.2-r2")));
- TEST_CHECK(VersionSpec("1.2-r2.3").tilde_compare(VersionSpec("1.2-r2.4")));
+ TEST_CHECK(! VersionSpec("1.2-r1").tilde_compare(VersionSpec("1.2-r2")));
+ TEST_CHECK(! VersionSpec("1.2-r1.3").tilde_compare(VersionSpec("1.2-r2")));
+ TEST_CHECK(! VersionSpec("1.2-r2").tilde_compare(VersionSpec("1.2-r2.3")));
+ TEST_CHECK(VersionSpec("1.2-r2.4").tilde_compare(VersionSpec("1.2-r2.3")));
}
} test_version_spec_tilde_compare;