diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-05-20 15:59:59 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-05-28 10:10:44 +0200 |
commit | 7d0cbd244d218bca8b806c283a5ae095f221b324 (patch) | |
tree | 4f6ca70bcc25cec76b5fd32555e4dfb23dda6692 /libbuild2/scope.cxx | |
parent | ff428efce81c7632724fd24028430523bb1e8fce (diff) |
Make notion of name pattern explicit, fix various related loose ends
Diffstat (limited to 'libbuild2/scope.cxx')
-rw-r--r-- | libbuild2/scope.cxx | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx index c5eb17e..e16e773 100644 --- a/libbuild2/scope.cxx +++ b/libbuild2/scope.cxx @@ -327,7 +327,7 @@ namespace build2 // If we are still looking for the cache, see if the original comes from // this scope. We check this before the overrides since it can come from // the target type/patter-specific variables, which is "more inner" than - // normal scope variables (see find_original()). + // normal scope variables (see lookup_original()). // if (inner_vars == nullptr && orig.defined () && belongs (orig)) { @@ -684,33 +684,26 @@ namespace build2 else if (!v.empty ()) { // Split the path into its directory part (if any) the name part, and - // the extension (if any). We cannot assume the name part is a valid - // filesystem name so we will have to do the splitting manually. + // the extension (if any). // // See also parser::expand_name_pattern() if changing anything here. // - size_t p (path::traits_type::rfind_separator (v)); - - if (p != string::npos) + try { - try - { - n.dir /= dir_path (v, p != 0 ? p : 1); // Special case: "/". - } - catch (const invalid_path& e) - { - fail (loc) << "invalid path '" << e.path << "'"; - } - - // This is probably too general of a place to ignore multiple trailing - // slashes and treat it as a directory (e.g., we don't want to - // encourage this sloppiness in buildfiles). We could, however, do it - // for certain contexts, such as buildspec. Maybe a lax flag? + n.canonicalize (); + } + catch (const invalid_path& e) + { + fail (loc) << "invalid path '" << e.path << "'"; + } + catch (const invalid_argument&) + { + // This is probably too general of a place to ignore multiple + // trailing slashes and treat it as a directory (e.g., we don't want + // to encourage this sloppiness in buildfiles). We could, however, + // do it for certain contexts, such as buildspec. Maybe a lax flag? // - if (++p == v.size ()) - fail (loc) << "invalid name '" << v << "'"; - - v.erase (0, p); + fail (loc) << "invalid name '" << v << "'"; } // Extract the extension. |