aboutsummaryrefslogtreecommitdiff
path: root/bpkg/manifest-utility.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-05-21 21:10:09 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-05-24 17:39:13 +0300
commit3a6c4ab1b6fc79a6a543088553cdd6bc8cb0a1dd (patch)
tree1ca0c3b9ef763276ff45c20a62d2504833e5f67d /bpkg/manifest-utility.cxx
parent1cab4fbd051ee5a71f073446ad5ad1b3d79f1031 (diff)
Adapt to inventing package_name type
Diffstat (limited to 'bpkg/manifest-utility.cxx')
-rw-r--r--bpkg/manifest-utility.cxx26
1 files changed, 14 insertions, 12 deletions
diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx
index defa675..fcda389 100644
--- a/bpkg/manifest-utility.cxx
+++ b/bpkg/manifest-utility.cxx
@@ -35,32 +35,34 @@ namespace bpkg
return package_scheme::none;
}
- string
- parse_package_name (const char* s)
+ package_name
+ parse_package_name (const char* s, bool allow_version)
{
using traits = string::traits_type;
+ if (!allow_version)
+ try
+ {
+ return package_name (s);
+ }
+ catch (const invalid_argument& e)
+ {
+ fail << "invalid package name '" << s << "': " << e;
+ }
+
size_t n (traits::length (s));
if (const char* p = traits::find (s, n, '/'))
n = static_cast<size_t> (p - s);
- string nm (s, n);
-
- // The package name may be a part of some compound argument. So while the
- // invalid package name would likely result in the operation failure, the
- // validating can ease the troubleshooting.
- //
try
{
- validate_package_name (nm);
+ return package_name (string (s, n));
}
catch (const invalid_argument& e)
{
- fail << "invalid package name in '" << s << "': " << e;
+ fail << "invalid package name in '" << s << "': " << e << endf;
}
-
- return nm;
}
version