aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-06 12:54:37 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-06 17:21:14 +0100
commit4b437b846b25f0f9f0d626f902979082cef3e2f3 (patch)
treeb3099dc2ccf358fcb7f7f314f22120a79d59874c
parent9538f2a7fa74240b8ca6ac6cccb0ad51433cb1d3 (diff)
downloadpaludis-4b437b846b25f0f9f0d626f902979082cef3e2f3.tar.gz
paludis-4b437b846b25f0f9f0d626f902979082cef3e2f3.tar.xz
vso_allow_leading_dot, and allow v.1
-rw-r--r--paludis/version_spec.cc34
-rw-r--r--paludis/version_spec.se1
-rw-r--r--paludis/version_spec_TEST.cc3
3 files changed, 30 insertions, 8 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index b2e21ee..8590998 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -110,13 +110,16 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op
/* parse */
SimpleParser parser(text);
- if (options[vso_ignore_leading_v] && parser.consume(
- options[vso_ignore_case] ? simple_parser::exact_ignoring_case("v") : simple_parser::exact("v")))
- _imp->parts.push_back(make_named_values<VersionSpecComponent>(
- n::number_value() = "",
- n::text() = "",
- n::type() = vsct_ignore
- ));
+ {
+ std::string leading_v_str;
+ 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::text() = leading_v_str,
+ n::type() = vsct_ignore
+ ));
+ }
std::string scm_str;
if (parser.consume((options[vso_ignore_case] ? simple_parser::exact_ignoring_case("scm") : simple_parser::exact("scm")) >> scm_str))
@@ -134,6 +137,21 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op
std::string number_prefix;
while (true)
{
+ if (first_number && options[vso_allow_leading_dot])
+ {
+ std::string dot_chars(".");
+ if (options[vso_flexible_dots])
+ {
+ dot_chars.append("-");
+ if (options[vso_flexible_dashes])
+ dot_chars.append("_");
+ }
+
+ std::string leading_ick;
+ if (parser.consume(simple_parser::any_of(dot_chars) >> leading_ick))
+ number_prefix = leading_ick;
+ }
+
std::string number_part;
if (! parser.consume(+simple_parser::any_of("0123456789") >> number_part))
throw BadVersionSpecError(text, "Expected number part not found at offset " + stringify(parser.offset()));
@@ -141,7 +159,7 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op
if (first_number || '0' != number_part[0])
_imp->parts.push_back(make_named_values<VersionSpecComponent>(
n::number_value() = strip_leading(number_part, "0"),
- n::text() = first_number ? number_part : number_prefix + number_part,
+ n::text() = number_prefix + number_part,
n::type() = vsct_number
));
else
diff --git a/paludis/version_spec.se b/paludis/version_spec.se
index 7dc046d..7a43cba 100644
--- a/paludis/version_spec.se
+++ b/paludis/version_spec.se
@@ -39,6 +39,7 @@ make_enum_VersionSpecOption()
key vso_letters_anywhere "Allow 1a2.3 etc"
key vso_dotted_suffixes "Allow 1_alpha2.3"
key vso_ignore_leading_v "Allow v1 etc"
+ key vso_allow_leading_dot "Allow .1.2.3 etc"
want_destringify
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index 5495dcb..8a05d7d 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -741,8 +741,11 @@ namespace test_cases
TEST_CHECK_THROWS(VersionSpec("v1.2.3", VersionSpecOptions()), BadVersionSpecError);
VersionSpec v1("v1.2.3", VersionSpecOptions() + vso_ignore_leading_v);
VersionSpec v2("1.2.3", VersionSpecOptions());
+ VersionSpec v3("v.1.2.3", VersionSpecOptions() + vso_ignore_leading_v + vso_allow_leading_dot);
TEST_CHECK(v1 == v2);
TEST_CHECK(v1.hash() == v2.hash());
+ TEST_CHECK(v2 == v3);
+ TEST_CHECK(v2.hash() == v3.hash());
}
} test_version_spec_leading_v;
}