aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx42
1 files changed, 28 insertions, 14 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 8af5804..e417d39 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -1757,11 +1757,18 @@ namespace build2
}
else
{
- // Note that p cannot point to the last character since then it
- // would have been a directory, not a simple name.
- //
- d = dir_path (ns[0].value, 0, p + 1);
- ns[0].value.erase (0, p + 1);
+ try
+ {
+ // Note that p cannot point to the last character since then it
+ // would have been a directory, not a simple name.
+ //
+ d = dir_path (ns[0].value, 0, p + 1);
+ ns[0].value.erase (0, p + 1);
+ }
+ catch (const invalid_path& e)
+ {
+ fail (nloc) << "invalid scope path '" << e.path << "'";
+ }
}
}
@@ -8802,15 +8809,22 @@ namespace build2
(p = path_traits::rfind_separator (ns[0].value)) !=
string::npos)
{
- // Note that p cannot point to the last character since
- // then it would have been a directory, not a simple name.
- //
- string& s (ns[0].value);
-
- name = string (s, p + 1);
- s.resize (p + 1);
- qual.push_back (name_type (dir_path (move (s))));
- qual.back ().pair = '/';
+ try
+ {
+ // Note that p cannot point to the last character since
+ // then it would have been a directory, not a simple name.
+ //
+ string& s (ns[0].value);
+
+ name = string (s, p + 1);
+ s.resize (p + 1);
+ qual.push_back (name_type (dir_path (move (s))));
+ qual.back ().pair = '/';
+ }
+ catch (const invalid_path& e)
+ {
+ fail (loc) << "invalid scope path '" << e.path << "'";
+ }
}
else
name = move (ns[n - 1].value);