diff options
Diffstat (limited to 'bpkg')
-rw-r--r-- | bpkg/manifest | 21 | ||||
-rw-r--r-- | bpkg/manifest.cxx | 19 |
2 files changed, 26 insertions, 14 deletions
diff --git a/bpkg/manifest b/bpkg/manifest index 35ff650..47b8d76 100644 --- a/bpkg/manifest +++ b/bpkg/manifest @@ -321,20 +321,24 @@ namespace bpkg // repository_location () = default; - // Creates remote/absolute repository location. Throws invalid_argument - // if the location is a relative path. + // If the argument is not empty, creates remote/absolute repository + // location. Throws invalid_argument if the location is a relative + // path. If the argument is empty, then creates the special empty + // location. // explicit repository_location (const std::string&); // Creates a potentially relative repository location. If base is not // empty, use it to complete the relative location to remote/absolute. - // Throws invalid_argument if base itself is relative or the resulting - // completed location is invalid. + // Throws invalid_argument if base is not empty but the location is + // empty, base itself is relative, or the resulting completed location + // is invalid. // repository_location (const std::string&, const repository_location& base); - // Note that relative locations have no canonical name. + // Note that relative locations have no canonical name. Canonical + // name of an empty location is the empty name. // const std::string& canonical_name () const noexcept {return canonical_name_;} @@ -409,9 +413,10 @@ namespace bpkg return port_; } - // Note that this is not necessarily syntactically the same - // string as what was used to initialize this location. But - // it should be semantically equivalent. + // Note that this is not necessarily syntactically the same string + // as what was used to initialize this location. But it should be + // semantically equivalent. String representation of an empty + // location is the empty string. // std::string string () const; diff --git a/bpkg/manifest.cxx b/bpkg/manifest.cxx index b66d5d4..1034fe3 100644 --- a/bpkg/manifest.cxx +++ b/bpkg/manifest.cxx @@ -832,7 +832,7 @@ namespace bpkg repository_location (const std::string& l) : repository_location (l, repository_location ()) // Delegate. { - if (relative ()) + if (!empty () && relative ()) throw invalid_argument ("relative filesystem path"); } @@ -843,6 +843,14 @@ namespace bpkg // using std::string; + if (l.empty ()) + { + if (!b.empty ()) + throw invalid_argument ("empty location"); + + return; + } + // Base repository location can not be a relative path. // if (!b.empty () && b.relative ()) @@ -971,9 +979,6 @@ namespace bpkg { path_ = dir_path (l); - if (path_.empty ()) - throw invalid_argument ("empty location"); - // Complete if we are relative and have base. // if (!b.empty () && path_.relative ()) @@ -1052,13 +1057,15 @@ namespace bpkg string repository_location:: string () const { + using std::string; // Also function name. + if (empty ()) - return ""; + return string (); if (local ()) return path_.string (); - std::string p ("http://" + host_); + string p ("http://" + host_); if (port_ != 0) p += ":" + to_string (port_); |