summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc6
-rw-r--r--apt-pkg/deb/deblistparser.cc35
-rw-r--r--apt-pkg/deb/debmetaindex.cc12
-rw-r--r--apt-pkg/deb/debrecords.cc11
-rw-r--r--apt-pkg/deb/debrecords.h3
-rw-r--r--apt-pkg/deb/dpkgpm.cc20
6 files changed, 58 insertions, 29 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 303dab796..27c1f7f32 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -354,7 +354,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
{
string FileName = IndexFile("Packages");
pkgCache::PkgFileIterator File = Cache.FileBegin();
- for (; File.end() == false; File++)
+ for (; File.end() == false; ++File)
{
if (File.FileName() == NULL || FileName != File.FileName())
continue;
@@ -542,7 +542,7 @@ pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) con
string FileName = IndexFile(Language);
pkgCache::PkgFileIterator File = Cache.FileBegin();
- for (; File.end() == false; File++)
+ for (; File.end() == false; ++File)
{
if (FileName != File.FileName())
continue;
@@ -622,7 +622,7 @@ bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
{
pkgCache::PkgFileIterator File = Cache.FileBegin();
- for (; File.end() == false; File++)
+ for (; File.end() == false; ++File)
{
if (this->File != File.FileName())
continue;
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 6b8fbce99..a4a974897 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -200,7 +200,7 @@ string debListParser::DescriptionLanguage()
std::vector<string> const lang = APT::Configuration::getLanguages(true);
for (std::vector<string>::const_iterator l = lang.begin();
- l != lang.end(); l++)
+ l != lang.end(); ++l)
if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false)
return *l;
@@ -458,7 +458,7 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
*
* The complete architecture, consisting of <kernel>-<cpu>.
*/
-static string CompleteArch(std::string& arch) {
+static string CompleteArch(std::string const &arch) {
if (arch == "armel") return "linux-arm";
if (arch == "armhf") return "linux-arm";
if (arch == "lpia") return "linux-i386";
@@ -497,9 +497,13 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
Package.assign(Start,I - Start);
// We don't want to confuse library users which can't handle MultiArch
+ string const arch = _config->Find("APT::Architecture");
if (StripMultiArch == true) {
size_t const found = Package.rfind(':');
- if (found != string::npos)
+ if (found != string::npos &&
+ (strcmp(Package.c_str() + found, ":any") == 0 ||
+ strcmp(Package.c_str() + found, ":native") == 0 ||
+ strcmp(Package.c_str() + found + 1, arch.c_str()) == 0))
Package = Package.substr(0,found);
}
@@ -540,7 +544,6 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
if (ParseArchFlags == true)
{
- string arch = _config->Find("APT::Architecture");
string completeArch = CompleteArch(arch);
// Parse an architecture
@@ -778,7 +781,9 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
size_t len = 0;
// Skip empty lines
- for (; buffer[len] == '\r' && buffer[len] == '\n'; ++len);
+ for (; buffer[len] == '\r' && buffer[len] == '\n'; ++len)
+ /* nothing */
+ ;
if (buffer[len] == '\0')
continue;
@@ -792,13 +797,25 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
}
// seperate the tag from the data
- for (; buffer[len] != ':' && buffer[len] != '\0'; ++len);
+ for (; buffer[len] != ':' && buffer[len] != '\0'; ++len)
+ /* nothing */
+ ;
if (buffer[len] == '\0')
continue;
char* dataStart = buffer + len;
- for (++dataStart; *dataStart == ' '; ++dataStart);
+ for (++dataStart; *dataStart == ' '; ++dataStart)
+ /* nothing */
+ ;
char* dataEnd = dataStart;
- for (++dataEnd; *dataEnd != '\0'; ++dataEnd);
+ for (++dataEnd; *dataEnd != '\0'; ++dataEnd)
+ /* nothing */
+ ;
+ // The last char should be a newline, but we can never be sure: #633350
+ char* lineEnd = dataEnd;
+ for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd)
+ /* nothing */
+ ;
+ ++lineEnd;
// which datastorage need to be updated
map_ptrloc* writeTo = NULL;
@@ -813,7 +830,7 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
APT_PARSER_WRITETO(FileI->Label, "Label")
#undef APT_PARSER_WRITETO
#define APT_PARSER_FLAGIT(X) else if (strncmp(#X, buffer, len) == 0) \
- pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, dataEnd-1);
+ pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, lineEnd);
APT_PARSER_FLAGIT(NotAutomatic)
APT_PARSER_FLAGIT(ButAutomaticUpgrades)
#undef APT_PARSER_FLAGIT
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index aaae906dd..1d3754b00 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -209,7 +209,7 @@ vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
for (std::set<std::string>::const_iterator s = sections.begin();
s != sections.end(); ++s) {
for (std::vector<std::string>::const_iterator l = lang.begin();
- l != lang.end(); l++) {
+ l != lang.end(); ++l) {
if (*l == "none") continue;
IndexTarget * Target = new OptionalIndexTarget();
Target->ShortDesc = "Translation-" + *l;
@@ -239,7 +239,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
// special case for --print-uris
if (GetAll) {
vector <struct IndexTarget *> *targets = ComputeIndexTargets();
- for (vector <struct IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); Target++) {
+ for (vector <struct IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); ++Target) {
new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
(*Target)->ShortDesc, HashString());
}
@@ -296,7 +296,7 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() {
if (src != ArchEntries.end()) {
vector<debSectionEntry const*> const SectionEntries = src->second;
for (vector<debSectionEntry const*>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end(); I++)
+ I != SectionEntries.end(); ++I)
Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
}
@@ -311,7 +311,7 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() {
if (a->first == "source")
continue;
for (vector<debSectionEntry const*>::const_iterator I = a->second.begin();
- I != a->second.end(); I++) {
+ I != a->second.end(); ++I) {
Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted(), a->first));
sections[(*I)->Section].insert(lang.begin(), lang.end());
}
@@ -320,7 +320,7 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() {
for (map<string, set<string> >::const_iterator s = sections.begin();
s != sections.end(); ++s)
for (set<string>::const_iterator l = s->second.begin();
- l != s->second.end(); l++) {
+ l != s->second.end(); ++l) {
if (*l == "none") continue;
Indexes->push_back(new debTranslationsIndex(URI,Dist,s->first,(*l).c_str()));
}
@@ -369,7 +369,7 @@ class debSLTypeDebian : public pkgSourceList::Type
map<string, string>::const_iterator const trusted = Options.find("trusted");
for (vector<metaIndex *>::const_iterator I = List.begin();
- I != List.end(); I++)
+ I != List.end(); ++I)
{
// We only worry about debian entries here
if (strcmp((*I)->GetType(), "deb") != 0)
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index db62d6c45..4dfc8b56a 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -103,6 +103,15 @@ string debRecordParser::Maintainer()
return Section.FindS("Maintainer");
}
/*}}}*/
+// RecordParser::RecordField - Return the value of an arbitrary field /*{{*/
+// ---------------------------------------------------------------------
+/* */
+string debRecordParser::RecordField(const char *fieldName)
+{
+ return Section.FindS(fieldName);
+}
+
+ /*}}}*/
// RecordParser::ShortDesc - Return a 1 line description /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -128,7 +137,7 @@ string debRecordParser::LongDesc()
{
vector<string> const lang = APT::Configuration::getLanguages();
for (vector<string>::const_iterator l = lang.begin();
- orig.empty() && l != lang.end(); l++)
+ orig.empty() && l != lang.end(); ++l)
orig = Section.FindS(string("Description-").append(*l).c_str());
}
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index 9692ac94c..7868bfa3d 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -50,6 +50,9 @@ class debRecordParser : public pkgRecords::Parser
virtual string Name();
virtual string Homepage();
+ // An arbitrary custom field
+ virtual string RecordField(const char *fieldName);
+
virtual void GetRec(const char *&Start,const char *&Stop);
debRecordParser(string FileName,pkgCache &Cache);
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 7733390c0..2c34465c0 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -230,7 +230,7 @@ bool pkgDPkgPM::SendV2Pkgs(FILE *F)
fprintf(F,"\n");
// Write out the package actions in order.
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
{
if(I->Pkg.end() == true)
continue;
@@ -352,7 +352,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
// Feed it the filenames.
if (Version <= 1)
{
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
{
// Only deal with packages to be installed from .deb
if (I->Op != Item::Install)
@@ -707,7 +707,7 @@ bool pkgDPkgPM::OpenLog()
chmod(history_name.c_str(), 0644);
fprintf(d->history_out, "\nStart-Date: %s\n", timestr);
string remove, purge, install, reinstall, upgrade, downgrade;
- for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+ for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
enum { CANDIDATE, CANDIDATE_AUTO, CURRENT_CANDIDATE, CURRENT } infostring;
string *line = NULL;
@@ -885,14 +885,14 @@ bool pkgDPkgPM::Go(int OutStatusFd)
// that will be [installed|configured|removed|purged] and add
// them to the PackageOps map (the dpkg states it goes through)
// and the PackageOpsTranslations (human readable strings)
- for (vector<Item>::const_iterator I = List.begin(); I != List.end();I++)
+ for (vector<Item>::const_iterator I = List.begin(); I != List.end(); ++I)
{
if((*I).Pkg.end() == true)
continue;
string const name = (*I).Pkg.Name();
PackageOpsDone[name] = 0;
- for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL; i++)
+ for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL; ++i)
{
PackageOps[name].push_back(DpkgStatesOpMap[(*I).Op][i]);
PackagesTotal++;
@@ -910,7 +910,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
// Do all actions with the same Op in one run
vector<Item>::const_iterator J = I;
if (TriggersPending == true)
- for (; J != List.end(); J++)
+ for (; J != List.end(); ++J)
{
if (J->Op == I->Op)
continue;
@@ -922,7 +922,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
break;
}
else
- for (; J != List.end() && J->Op == I->Op; J++)
+ for (; J != List.end() && J->Op == I->Op; ++J)
/* nothing */;
// Generate the argument list
@@ -1028,7 +1028,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
// Write in the file or package names
if (I->Op == Item::Install)
{
- for (;I != J && Size < MaxArgBytes; I++)
+ for (;I != J && Size < MaxArgBytes; ++I)
{
if (I->File[0] != '/')
return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str());
@@ -1040,7 +1040,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
{
string const nativeArch = _config->Find("APT::Architecture");
unsigned long const oldSize = I->Op == Item::Configure ? Size : 0;
- for (;I != J && Size < MaxArgBytes; I++)
+ for (;I != J && Size < MaxArgBytes; ++I)
{
if((*I).Pkg.end() == true)
continue;
@@ -1478,7 +1478,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
// log the ordering
const char *ops_str[] = {"Install", "Configure","Remove","Purge"};
fprintf(report, "AptOrdering:\n");
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
fprintf(report, " %s: %s\n", (*I).Pkg.Name(), ops_str[(*I).Op]);
// attach dmesg log (to learn about segfaults)