diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-08-04 20:33:09 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-08-04 20:33:09 +0300 |
commit | 4fa713a22e1634c82e67bb78219524839b3c2997 (patch) | |
tree | 00c622d32bdd22f947fad8628718e66751dcf0d0 | |
parent | dbb56f2986eefd0ffb1350ab1ff0cb47ad5e7918 (diff) |
Make use of libbpkg's extract_package_name() and extract_package_version() functions
-rw-r--r-- | bpkg/manifest-utility.cxx | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx index 0332f4d..6ca9e18 100644 --- a/bpkg/manifest-utility.cxx +++ b/bpkg/manifest-utility.cxx @@ -40,29 +40,14 @@ namespace bpkg package_name parse_package_name (const char* s, bool allow_version) { - if (!allow_version) try { - return package_name (s); + return extract_package_name (s, allow_version); } catch (const invalid_argument& e) { - fail << "invalid package name '" << s << "': " << e; - } - - // Calculate the package name length as a length of the prefix that - // doesn't contain spaces, slashes and the version constraint starting - // characters. Note that none of them are valid package name characters. - // - size_t n (strcspn (s, " /=<>([~^")); - - try - { - return package_name (string (s, n)); - } - catch (const invalid_argument& e) - { - fail << "invalid package name in '" << s << "': " << e << endf; + fail << "invalid package name " << (allow_version ? "in " : "") + << "'" << s << "': " << e << endf; } } @@ -83,15 +68,7 @@ namespace bpkg try { - version r (p, fold_zero_revision); - - if (r.release && r.release->empty ()) - throw invalid_argument ("earliest version"); - - if (r.compare (wildcard_version, true /* ignore_revision */) == 0) - throw invalid_argument ("stub version"); - - return r; + return extract_package_version (s, fold_zero_revision); } catch (const invalid_argument& e) { |