summaryrefslogtreecommitdiff
path: root/apt-pkg/cdrom.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/cdrom.cc')
-rw-r--r--apt-pkg/cdrom.cc34
1 files changed, 13 insertions, 21 deletions
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 96d4e9c91..83165c6c0 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -6,6 +6,8 @@
#include<apt-pkg/cdromutl.h>
#include<apt-pkg/strutl.h>
#include<apt-pkg/cdrom.h>
+#include<apt-pkg/aptconfiguration.h>
+
#include<sstream>
#include<fstream>
#include<config.h>
@@ -216,33 +218,23 @@ int pkgCdrom::Score(string Path)
/* Here we drop everything that is not this machines arch */
bool pkgCdrom::DropBinaryArch(vector<string> &List)
{
- char S[300];
- snprintf(S,sizeof(S),"/binary-%s/",
- _config->Find("Apt::Architecture").c_str());
-
+
for (unsigned int I = 0; I < List.size(); I++)
{
const char *Str = List[I].c_str();
-
- const char *Res;
- if ((Res = strstr(Str,"/binary-")) == 0)
+ const char *Start, *End;
+ if ((Start = strstr(Str,"/binary-")) == 0)
continue;
- // Weird, remove it.
- if (strlen(Res) < strlen(S))
- {
- List.erase(List.begin() + I);
- I--;
- continue;
- }
-
- // See if it is our arch
- if (stringcmp(Res,Res + strlen(S),S) == 0)
- continue;
-
- // Erase it
+ // Between Start and End is the architecture
+ Start += 8;
+ if ((End = strstr(Start,"/")) != 0 && Start != End &&
+ APT::Configuration::checkArchitecture(string(Start, --End)) == true)
+ continue; // okay, architecture is accepted
+
+ // not accepted -> Erase it
List.erase(List.begin() + I);
- I--;
+ --I; // the next entry is at the same index after the erase
}
return true;