aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-02 13:59:37 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-02 13:59:37 +0000
commite1a0c7f22ec94da7e063c5021c636ea66b5ced0e (patch)
tree39ab6f204ddcadf5212bb67fa3270d013b72ad15
parente2f024b0052951901595dfea192eb9ad519b10a8 (diff)
downloadpaludis-e1a0c7f22ec94da7e063c5021c636ea66b5ced0e.tar.gz
paludis-e1a0c7f22ec94da7e063c5021c636ea66b5ced0e.tar.xz
Allow only one _p and -try in VersionSpec.
-rw-r--r--paludis/version_spec.cc72
-rw-r--r--paludis/version_spec_TEST.cc7
2 files changed, 42 insertions, 37 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index aa36a5c..ef223cc 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -203,52 +203,50 @@ VersionSpec::VersionSpec(const std::string & text) :
_imp->parts.push_back(Part(k, number_part));
suffix = true;
} while (false);
+ }
- /* patch level */
- if (p < text.length() && 0 == text.compare(p, 2, "_p") && 0 != text.compare(p, 3, "_pr"))
- {
- p += 2;
+ /* patch level */
+ if (p < text.length() && 0 == text.compare(p, 2, "_p"))
+ {
+ p += 2;
- std::string::size_type q(text.find_first_not_of("0123456789", p));
- std::string number_part(std::string::npos == q ? text.substr(p) : text.substr(p, q - p));
- p = std::string::npos == q ? text.length() : q;
+ std::string::size_type q(text.find_first_not_of("0123456789", p));
+ std::string number_part(std::string::npos == q ? text.substr(p) : text.substr(p, q - p));
+ p = std::string::npos == q ? text.length() : q;
- if (number_part.size() > 8)
- Log::get_instance()->message(ll_qa, lc_context) <<
- "Number part '" << number_part << "' exceeds 8 digit limit";
+ if (number_part.size() > 8)
+ Log::get_instance()->message(ll_qa, lc_context) <<
+ "Number part '" << number_part << "' exceeds 8 digit limit";
- if (number_part.size() > 0)
- {
- number_part = strip_leading(number_part, "0");
- if (number_part.empty())
- number_part = "0";
- }
- _imp->parts.push_back(Part(patch, number_part));
- suffix = true;
+ if (number_part.size() > 0)
+ {
+ number_part = strip_leading(number_part, "0");
+ if (number_part.empty())
+ number_part = "0";
}
+ _imp->parts.push_back(Part(patch, number_part));
+ }
- /* try */
- if (p < text.length() && 0 == text.compare(p, 4, "-try"))
- {
- p += 4;
+ /* try */
+ if (p < text.length() && 0 == text.compare(p, 4, "-try"))
+ {
+ p += 4;
- std::string::size_type q(text.find_first_not_of("0123456789", p));
- std::string number_part(std::string::npos == q ? text.substr(p) : text.substr(p, q - p));
- p = std::string::npos == q ? text.length() : q;
+ std::string::size_type q(text.find_first_not_of("0123456789", p));
+ std::string number_part(std::string::npos == q ? text.substr(p) : text.substr(p, q - p));
+ p = std::string::npos == q ? text.length() : q;
- if (number_part.size() > 8)
- Log::get_instance()->message(ll_qa, lc_context) <<
- "Number part '" << number_part << "' exceeds 8 digit limit";
+ if (number_part.size() > 8)
+ Log::get_instance()->message(ll_qa, lc_context) <<
+ "Number part '" << number_part << "' exceeds 8 digit limit";
- if (number_part.size() > 0)
- {
- number_part = strip_leading(number_part, "0");
- if (number_part.empty())
- number_part = "0";
- }
- _imp->parts.push_back(Part(trypart, number_part));
- suffix = true;
+ if (number_part.size() > 0)
+ {
+ number_part = strip_leading(number_part, "0");
+ if (number_part.empty())
+ number_part = "0";
}
+ _imp->parts.push_back(Part(trypart, number_part));
}
/* scm */
@@ -257,7 +255,7 @@ VersionSpec::VersionSpec(const std::string & text) :
p += 4;
/* _suffix-scm? */
if (_imp->parts.back().value.empty())
- _imp->parts.back().value = "MAX";
+ _imp->parts.back().value = "MAX";
_imp->parts.push_back(Part(scm, ""));
}
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index fd19318..3b2ecfe 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -90,6 +90,13 @@ namespace test_cases
TEST_CHECK_THROWS(VersionSpec v1("1_blah"), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1_pre-r2b"), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1_pre-r2-r2"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1_p_p"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1_p_alpha"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1-try-try"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1-try_alpha"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1-scm-scm"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1-scm-try"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1-scm_alpha"), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1-r2_pre"), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1."), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1.1."), BadVersionSpecError);