aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-10-29 12:13:20 +0100
committerAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-10-29 17:22:42 +0100
commit27d21c237352e892cd16c47060059b3f31c972fd (patch)
treed6453c5c23ab0cee698b15a484662c4e1cc3cda1
parent5a9516d4634906b3c78c9a85debef9866f0f92c5 (diff)
downloadpaludis-27d21c237352e892cd16c47060059b3f31c972fd.tar.gz
paludis-27d21c237352e892cd16c47060059b3f31c972fd.tar.xz
Better error message for cat/foo[=1.2.3]::bar
-rw-r--r--paludis/elike_package_dep_spec.cc5
-rw-r--r--paludis/user_dep_spec.cc5
2 files changed, 8 insertions, 2 deletions
diff --git a/paludis/elike_package_dep_spec.cc b/paludis/elike_package_dep_spec.cc
index 7459e7a..738d725 100644
--- a/paludis/elike_package_dep_spec.cc
+++ b/paludis/elike_package_dep_spec.cc
@@ -96,9 +96,12 @@ paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, Partial
if (std::string::npos == ((use_group_p = s.rfind('['))))
return false;
- if (s.at(s.length() - 1) != ']')
+ if (std::string::npos == s.rfind(']'))
throw PackageDepSpecError("Mismatched []");
+ if (s.at(s.length() - 1) != ']')
+ throw PackageDepSpecError("Trailing garbage after [] block");
+
std::string flag(s.substr(use_group_p + 1));
if (flag.length() < 2)
throw PackageDepSpecError("Invalid [] contents");
diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc
index bcc85e8..a36ef7d 100644
--- a/paludis/user_dep_spec.cc
+++ b/paludis/user_dep_spec.cc
@@ -98,9 +98,12 @@ namespace
if (std::string::npos == ((use_group_p = s.rfind('['))))
return false;
- if (s.at(s.length() - 1) != ']')
+ if (std::string::npos == s.rfind(']'))
throw PackageDepSpecError("Mismatched []");
+ if (s.at(s.length() - 1) != ']')
+ throw PackageDepSpecError("Trailing garbage after [] block");
+
std::string flag(s.substr(use_group_p + 1));
if (flag.length() < 2)
throw PackageDepSpecError("Invalid [] contents");