summaryrefslogtreecommitdiff
path: root/cmdline/apt-sortpkgs.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2024-11-14 14:54:40 +0000
committerJulian Andres Klode <jak@debian.org>2024-11-14 14:54:40 +0000
commit82752f6e0c65541244c2607e5dedf437701e07dc (patch)
tree9f8a63e33e05350551919c0c6f66340820303120 /cmdline/apt-sortpkgs.cc
parent8f10ee850db3892bc979694864451be3a73ad1e8 (diff)
parent36998f582e211f745799ddc2a8bc286541e56689 (diff)
Merge branch 'svequiv' into 'main'
Internally replace APT::StringView with std::string_view where it doesn't affect the ABI, with implementations that support both std::string_view and APT::StringView with new shims. ReportMirrorFailureToCentral: fix use-after-free See merge request apt-team/apt!394
Diffstat (limited to 'cmdline/apt-sortpkgs.cc')
-rw-r--r--cmdline/apt-sortpkgs.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc
index acbb2832e..8442a959d 100644
--- a/cmdline/apt-sortpkgs.cc
+++ b/cmdline/apt-sortpkgs.cc
@@ -1,13 +1,13 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
/* ######################################################################
-
+
APT Sort Packages - Program to sort Package and Source files
This program is quite simple, it just sorts the package files by
package and sorts the fields inside by the internal APT sort order.
Input is taken from a named file and sent to stdout.
-
+
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
@@ -46,7 +46,7 @@ struct PkgName /*{{{*/
string Arch;
unsigned long Offset;
unsigned long Length;
-
+
inline int Compare3(const PkgName &x) const
{
int A = stringcasecmp(Name,x.Name);
@@ -58,7 +58,7 @@ struct PkgName /*{{{*/
}
return A;
}
-
+
bool operator <(const PkgName &x) const {return Compare3(x) < 0;};
bool operator >(const PkgName &x) const {return Compare3(x) > 0;};
bool operator ==(const PkgName &x) const {return Compare3(x) == 0;};
@@ -73,7 +73,7 @@ static bool DoIt(string InFile)
pkgTagFile Tags(&Fd);
if (_error->PendingError() == true)
return false;
-
+
// Parse.
vector<PkgName> List;
pkgTagSection Section;
@@ -83,28 +83,28 @@ static bool DoIt(string InFile)
while (Tags.Step(Section) == true)
{
PkgName Tmp;
-
- /* Fetch the name, auto-detecting if this is a source file or a
+
+ /* Fetch the name, auto-detecting if this is a source file or a
package file */
- Tmp.Name = Section.Find(pkgTagSection::Key::Package).to_string();
- Tmp.Ver = Section.Find(pkgTagSection::Key::Version).to_string();
- Tmp.Arch = Section.Find(pkgTagSection::Key::Architecture).to_string();
-
+ Tmp.Name = Section.Find(pkgTagSection::Key::Package);
+ Tmp.Ver = Section.Find(pkgTagSection::Key::Version);
+ Tmp.Arch = Section.Find(pkgTagSection::Key::Architecture);
+
if (Tmp.Name.empty() == true)
return _error->Error(_("Unknown package record!"));
-
+
Tmp.Offset = Offset;
Tmp.Length = Section.size();
if (Largest < Tmp.Length)
Largest = Tmp.Length;
-
+
List.push_back(Tmp);
-
+
Offset = Tags.Offset();
}
if (_error->PendingError() == true)
return false;
-
+
// Sort it
sort(List.begin(),List.end());