summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/deblistparser.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-06-14 15:46:49 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-06-14 15:46:49 +0200
commitcd9694bf7c962b1938690a96017afba54028488a (patch)
treea7db815e228f3a1a87af0b8054c8229c1c0fe9e0 /apt-pkg/deb/deblistparser.cc
parent82c6f7528d583431722ef180b6064b86b644ad85 (diff)
* deb/deblistparser.cc:
- ensure that mixed positive/negative architecture wildcards are handled in the same way as dpkg handles them
Diffstat (limited to 'apt-pkg/deb/deblistparser.cc')
-rw-r--r--apt-pkg/deb/deblistparser.cc53
1 files changed, 30 insertions, 23 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 4948c9be4..d29b28d48 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -561,28 +561,27 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
// Parse an architecture
if (I != Stop && *I == '[')
{
+ ++I;
// malformed
- I++;
- if (I == Stop)
- return 0;
-
- const char *End = I;
- bool Found = false;
- bool NegArch = false;
- while (I != Stop)
+ if (unlikely(I == Stop))
+ return 0;
+
+ const char *End = I;
+ bool Found = false;
+ bool NegArch = false;
+ while (I != Stop)
{
- // look for whitespace or ending ']'
- while (End != Stop && !isspace(*End) && *End != ']')
- End++;
-
- if (End == Stop)
+ // look for whitespace or ending ']'
+ for (;End != Stop && !isspace(*End) && *End != ']'; ++End);
+
+ if (unlikely(End == Stop))
return 0;
if (*I == '!')
- {
+ {
NegArch = true;
- I++;
- }
+ ++I;
+ }
if (stringcmp(arch,I,End) == 0) {
Found = true;
@@ -591,23 +590,31 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
if (fnmatch(wildcard.c_str(), completeArch.c_str(), 0) == 0)
Found = true;
}
-
+
+ if (Found == true)
+ {
+ if (I[-1] != '!')
+ NegArch = false;
+ // we found a match, so fast-forward to the end of the wildcards
+ for (; End != Stop && *End != ']'; ++End);
+ }
+
if (*End++ == ']') {
I = End;
break;
}
-
+
I = End;
for (;I != Stop && isspace(*I) != 0; I++);
- }
+ }
- if (NegArch)
+ if (NegArch == true)
Found = !Found;
-
- if (Found == false)
+
+ if (Found == false)
Package = ""; /* not for this arch */
}
-
+
// Skip whitespace
for (;I != Stop && isspace(*I) != 0; I++);
}