diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2010-05-28 23:11:36 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2010-05-28 23:11:36 +0200 |
commit | 3152f4aa4a97ad06ef1073aabe137f999f787ee1 (patch) | |
tree | a58dfe4029ba6f551b3d4f06632d43b9ef9c3570 /apt-pkg/aptconfiguration.cc | |
parent | 392a882ad8a299d55889e9c0fa581a266d6dd2c9 (diff) |
* apt-pkg/aptconfiguration.cc:
- remove duplicate architectures in getArchitectures()
Diffstat (limited to 'apt-pkg/aptconfiguration.cc')
-rw-r--r-- | apt-pkg/aptconfiguration.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 2acf8dd9f..0c050d9dc 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -327,11 +327,24 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache if (likely(Cached == true) && archs.empty() == false) return archs; - string const arch = _config->Find("APT::Architecture"); archs = _config->FindVector("APT::Architectures"); + string const arch = _config->Find("APT::Architecture"); + if (unlikely(arch.empty() == true)) + return archs; + if (archs.empty() == true || std::find(archs.begin(), archs.end(), arch) == archs.end()) archs.push_back(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; + } + return archs; } /*}}}*/ |