diff options
| author | Julian Andres Klode <jak@debian.org> | 2021-10-18 13:36:00 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2021-10-18 13:36:00 +0000 |
| commit | edf4b2169405e7ca6e21f408229e5fc4bbd4f4ed (patch) | |
| tree | 864a13dbda22e3b4de7b69600521fb7e7d8b39a2 /apt-pkg/aptconfiguration.cc | |
| parent | 883a12310a4130370965eab0a710a2c8fae6cc09 (diff) | |
| parent | 70c669e2566d119559d2986635bb6c1d0d368073 (diff) | |
Merge branch 'feature/barbarianarchs' into 'main'
Streamline access to barbarian architecture functionality
See merge request apt-team/apt!184
Diffstat (limited to 'apt-pkg/aptconfiguration.cc')
| -rw-r--r-- | apt-pkg/aptconfiguration.cc | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 671c3d553..00a97a0e7 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -315,13 +315,11 @@ bool Configuration::checkLanguage(std::string Lang, bool const All) { /*}}}*/ // getArchitectures - Return Vector of preferred Architectures /*{{{*/ std::vector<std::string> const Configuration::getArchitectures(bool const &Cached) { - using std::string; - - std::vector<string> static archs; + std::vector<std::string> static archs; if (likely(Cached == true) && archs.empty() == false) return archs; - string const arch = _config->Find("APT::Architecture"); + std::string const arch = _config->Find("APT::Architecture"); archs = _config->FindVector("APT::Architectures"); if (archs.empty() == true && _system != nullptr) @@ -331,15 +329,13 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache std::find(archs.begin(), archs.end(), arch) == archs.end()) archs.insert(archs.begin(), arch); - // erase duplicates and empty strings - for (std::vector<string>::reverse_iterator a = archs.rbegin(); - a != archs.rend(); ++a) { - if (a->empty() == true || std::find(a + 1, archs.rend(), *a) != archs.rend()) - archs.erase(a.base()-1); - if (a == archs.rend()) - break; - } - + // erase duplicates, empty strings and very foreign architectures + auto newend = std::remove_if(archs.begin(), archs.end(), [](auto const &a) { return a.empty(); }); + for (auto a = archs.begin(); a != newend; ++a) + newend = std::remove(std::next(a), newend, *a); + for (auto const &f : _config->FindVector("APT::BarbarianArchitectures")) + newend = std::remove(archs.begin(), newend, f); + archs.erase(newend, archs.end()); return archs; } /*}}}*/ |
