aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2012-08-14 21:29:40 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2012-08-14 21:29:53 +0100
commit6b58f594bc9d7177ac174bab907d285bd5326f89 (patch)
tree1ebefc2ac7929f779c43227fab812bb9bedece77
parent5ccca1a066d8ca62940cc964d266970177e82255 (diff)
downloadpaludis-6b58f594bc9d7177ac174bab907d285bd5326f89.tar.gz
paludis-6b58f594bc9d7177ac174bab907d285bd5326f89.tar.xz
Fix 0-scm versus 1
-rw-r--r--paludis/version_spec.cc21
-rw-r--r--paludis/version_spec_TEST.cc3
2 files changed, 18 insertions, 6 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index 42e7e61..948fa36 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -105,7 +105,7 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op
if (options[vso_ignore_leading_v] && parser.consume(
(options[vso_ignore_case] ? simple_parser::exact_ignoring_case("v") : simple_parser::exact("v")) >> leading_v_str))
_imp->parts.push_back(make_named_values<VersionSpecComponent>(
- n::number_value() = "",
+ n::number_value() = "0",
n::text() = leading_v_str,
n::type() = vsct_ignore
));
@@ -115,7 +115,7 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op
if (parser.consume((options[vso_ignore_case] ? simple_parser::exact_ignoring_case("scm") : simple_parser::exact("scm")) >> scm_str))
{
_imp->parts.push_back(make_named_values<VersionSpecComponent>(
- n::number_value() = "",
+ n::number_value() = "0",
n::text() = scm_str,
n::type() = vsct_scm
));
@@ -147,11 +147,14 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op
throw BadVersionSpecError(text, "Expected number part not found at offset " + stringify(parser.offset()));
if (first_number || '0' != number_part[0])
+ {
+ std::string number_str(strip_leading(number_part, "0"));
_imp->parts.push_back(make_named_values<VersionSpecComponent>(
- n::number_value() = strip_leading(number_part, "0"),
+ n::number_value() = number_str.empty() ? "0" : number_str,
n::text() = number_prefix + number_part,
n::type() = vsct_number
));
+ }
else
_imp->parts.push_back(make_named_values<VersionSpecComponent>(
n::number_value() = number_part,
@@ -258,11 +261,14 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op
if (parser.consume(make_dash_parse_expression("-", "scm", options[vso_ignore_case], options[vso_flexible_dashes]) >> scm_str))
{
/* _suffix-scm? */
- if (_imp->parts.back().number_value().empty())
+ if (_imp->parts.back().number_value().empty() &&
+ ((_imp->parts.back().type() >= vsct_alpha && _imp->parts.back().type() <= vsct_rc) ||
+ _imp->parts.back().type() == vsct_patch ||
+ _imp->parts.back().type() == vsct_trypart))
_imp->parts.back().number_value() = "MAX";
_imp->parts.push_back(make_named_values<VersionSpecComponent>(
- n::number_value() = "",
+ n::number_value() = "0",
n::text() = scm_str,
n::type() = vsct_scm
));
@@ -271,7 +277,10 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op
/* Now we can change empty values to "0" */
for (Parts::iterator i(_imp->parts.begin()),
i_end(_imp->parts.end()) ; i != i_end ; ++i)
- if ((*i).number_value().empty())
+ if ((*i).number_value().empty() &&
+ (((*i).type() >= vsct_alpha && (*i).type() <= vsct_rc) ||
+ (*i).type() == vsct_patch ||
+ (*i).type() == vsct_trypart))
(*i).number_value() = "0";
}
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index f27e3c5..19ab039 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -345,6 +345,9 @@ TEST(VersionSpec, Ordering)
ASSERT_TRUE(VersionSpec("1.2-r3", { }).hash() == VersionSpec("1.2-r3.0", { }).hash());
ASSERT_TRUE(VersionSpec("1.2", { }).hash() == VersionSpec("1.2-r0.0", { }).hash());
+ ASSERT_TRUE(VersionSpec("0-scm", { }) < VersionSpec("1", { }));
+ ASSERT_TRUE(VersionSpec("1-try-scm", { }) > VersionSpec("1-try1", { }));
+
std::vector<VersionSpec> v;
v.push_back(VersionSpec("1_alpha_alpha", { }));
v.push_back(VersionSpec("1_alpha", { }));