From e9fadc9dc3f75131d8765e4d1c621f26909fd5b6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 17 Jan 2023 13:31:53 +0300 Subject: Review-inspired changes --- bpkg/database.cxx | 1 - bpkg/system-package-manager.cxx | 28 ++++++++-------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/bpkg/database.cxx b/bpkg/database.cxx index 6b135fc..65e3af8 100644 --- a/bpkg/database.cxx +++ b/bpkg/database.cxx @@ -349,7 +349,6 @@ namespace bpkg else config_orig = config; - string = '[' + config_orig.representation () + ']'; try diff --git a/bpkg/system-package-manager.cxx b/bpkg/system-package-manager.cxx index 3d5bda7..215ea47 100644 --- a/bpkg/system-package-manager.cxx +++ b/bpkg/system-package-manager.cxx @@ -101,17 +101,10 @@ namespace bpkg for (const distribution_name_value& nv: ap->distribution_values) { - const string& nm (nv.name); - - // @@ TODO - // - // optional - // distribution_name_value::distribution (const string& suffix); - // - if (nm.size () > 5 && nm.compare (nm.size () - 5, 5, "-name") == 0) + if (optional d = nv.distribution ("-name")) { - string dn (nm, 0, nm.size () - 5); // [_] - size_t p (dn.rfind ('_')); // Version-separating underscore. + string dn (move (*d)); // [_] + size_t p (dn.rfind ('_')); // Version-separating underscore. // If '_' separator is present, then make sure that the right-hand // part looks like a version (not empty and only contains digits @@ -147,15 +140,10 @@ namespace bpkg } catch (const invalid_argument& e) { - // @@ [] - // - const string& db (a.second.database ().string); - - fail << "invalid distribution version in value " << nm + fail << "invalid distribution version in value " << nv.name << " for package " << ap->id.name << ' ' << ap->version - << (!db.empty () ? ' ' + db : empty_string) - << " in repository " << a.second.load ()->location << ": " - << e; + << a.second.database () << " in repository " + << a.second.load ()->location << ": " << e; } dn.resize (p); @@ -163,8 +151,8 @@ namespace bpkg if (dn == n && dv <= v && find_if (r.begin (), r.end (), - [&nm, &nv] (const distribution_name_value& v) - {return v.name == nm || v.value == nv.value;}) == + [&nv] (const distribution_name_value& v) + {return v.name == nv.name || v.value == nv.value;}) == r.end ()) { r.push_back (nv); -- cgit v1.1