summaryrefslogtreecommitdiffstats
path: root/apt-pkg/deb/deblistparser.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 02:48:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 02:48:09 +0000
commit9cdf75717d2202fcae7e4cef319e3bb9ce175a71 (patch)
tree1ce23b2173cdefb82d14b99c0435bb82e1c80f80 /apt-pkg/deb/deblistparser.cc
parentAdding debian version 2.9.3. (diff)
downloadapt-9cdf75717d2202fcae7e4cef319e3bb9ce175a71.tar.xz
apt-9cdf75717d2202fcae7e4cef319e3bb9ce175a71.zip
Merging upstream version 2.9.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'apt-pkg/deb/deblistparser.cc')
-rw-r--r--apt-pkg/deb/deblistparser.cc85
1 files changed, 41 insertions, 44 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 9177d54..13e8fd0 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -635,63 +635,60 @@ const char *debListParser::ParseDepends(const char *Start, const char *Stop,
// Skip whitespace
for (;I != Stop && isspace_ascii(*I) != 0; I++);
- if (unlikely(ParseArchFlags == true))
+ // Parse architecture restrictions
+ if (ParseArchFlags && I != Stop && *I == '[')
{
+ for (++I; I != Stop && isspace_ascii(*I) != 0 && *I != ']'; ++I);
+ // malformed
+ if (unlikely(I == Stop || *I == ']'))
+ return 0;
+
APT::CacheFilter::PackageArchitectureMatchesSpecification matchesArch(Arch, false);
- // Parse an architecture
- if (I != Stop && *I == '[')
+ bool Found = false;
+ bool NegArch = false;
+ while (I < Stop && *I != ']')
{
- ++I;
- // malformed
- if (unlikely(I == Stop))
- return 0;
-
+ // look for whitespace or ending ']' to end current Arch
const char *End = I;
- bool Found = false;
- bool NegArch = false;
- while (I != Stop)
- {
- // look for whitespace or ending ']'
- for (;End != Stop && !isspace_ascii(*End) && *End != ']'; ++End);
-
- if (unlikely(End == Stop))
- return 0;
-
- if (*I == '!')
- {
- NegArch = true;
- ++I;
- }
-
- std::string const arch(I, End);
- if (arch.empty() == false && matchesArch(arch.c_str()) == true)
- {
- 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);
- }
+ for (;End < Stop && isspace_ascii(*End) == 0 && *End != ']'; ++End);
- if (*End++ == ']') {
- I = End;
- break;
- }
+ if (unlikely(End >= Stop))
+ return 0;
- I = End;
- for (;I != Stop && isspace_ascii(*I) != 0; I++);
+ bool CurNegArch = false;
+ if (*I == '!')
+ {
+ NegArch = true;
+ CurNegArch = true;
+ ++I;
}
- if (NegArch == true)
- Found = !Found;
+ if (I >= End)
+ return 0;
+ std::string const arch(I, End);
+ if (matchesArch(arch.c_str()))
+ {
+ Found = true;
+ if (not CurNegArch)
+ NegArch = false;
+ // we found a match, so fast-forward to the end of the wildcards
+ for (; End < Stop && *End != ']'; ++End);
+ }
+ else
+ for (; End < Stop && isspace_ascii(*End) != 0; ++End);
- if (Found == false)
- Package = ""; /* not for this arch */
+ I = End;
}
+ if (NegArch == true)
+ Found = not Found;
+
+ if (Found == false)
+ Package = ""; /* not for this arch */
+
// Skip whitespace
- for (;I != Stop && isspace_ascii(*I) != 0; I++);
+ for (++I; I < Stop && isspace_ascii(*I) != 0; ++I);
}
if (unlikely(ParseRestrictionsList == true))