Browse Source

cppcheck complains about some possible speed improvements which could be

done on the mirco-optimazation level, so lets fix them:
 (performance) Possible inefficient checking for emptiness.
 (performance) Prefer prefix ++/-- operators for non-primitive types.
debian/1.8.y
David Kalnischkies 11 years ago
parent
commit
f7f0d6c756
  1. 22
      apt-pkg/acquire-item.cc
  2. 2
      apt-pkg/acquire-method.cc
  3. 20
      apt-pkg/acquire.cc
  4. 62
      apt-pkg/algorithms.cc
  5. 4
      apt-pkg/aptconfiguration.cc
  6. 26
      apt-pkg/cdrom.cc
  7. 4
      apt-pkg/clean.cc
  8. 6
      apt-pkg/contrib/configuration.cc
  9. 6
      apt-pkg/contrib/error.cc
  10. 30
      apt-pkg/contrib/strutl.cc
  11. 6
      apt-pkg/deb/debindexfile.cc
  12. 2
      apt-pkg/deb/deblistparser.cc
  13. 12
      apt-pkg/deb/debmetaindex.cc
  14. 2
      apt-pkg/deb/debrecords.cc
  15. 20
      apt-pkg/deb/dpkgpm.cc
  16. 28
      apt-pkg/depcache.cc
  17. 18
      apt-pkg/indexcopy.cc
  18. 16
      apt-pkg/orderlist.cc
  19. 20
      apt-pkg/packagemanager.cc
  20. 26
      apt-pkg/pkgcache.cc
  21. 28
      apt-pkg/pkgcachegen.cc
  22. 2
      apt-pkg/pkgrecords.cc
  23. 14
      apt-pkg/policy.cc
  24. 14
      apt-pkg/sourcelist.cc
  25. 10
      apt-pkg/srcrecords.cc
  26. 6
      apt-pkg/vendorlist.cc
  27. 6
      apt-pkg/versionmatch.cc
  28. 104
      cmdline/apt-cache.cc
  29. 56
      cmdline/apt-get.cc
  30. 16
      ftparchive/apt-ftparchive.cc
  31. 8
      ftparchive/multicompress.cc
  32. 6
      ftparchive/override.cc
  33. 4
      ftparchive/writer.cc
  34. 2
      methods/ftp.cc
  35. 6
      methods/gpgv.cc
  36. 6
      methods/http.cc
  37. 4
      methods/mirror.cc
  38. 8
      test/libapt/assert.h
  39. 7
      test/libapt/getarchitectures_test.cc
  40. 7
      test/libapt/getlanguages_test.cc
  41. 7
      test/libapt/getlistoffilesindir_test.cc
  42. 2
      test/test_udevcdrom.cc

22
apt-pkg/acquire-item.cc

@ -681,17 +681,17 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/
// remove all patches until the next matching patch is found
// this requires the Index file to be ordered
for(vector<DiffInfo>::iterator I=available_patches.begin();
available_patches.size() > 0 &&
available_patches.empty() == false &&
I != available_patches.end() &&
(*I).sha1 != local_sha1;
I++)
I->sha1 != local_sha1;
++I)
{
available_patches.erase(I);
}
// error checking and falling back if no patch was found
if(available_patches.size() == 0)
{
if(available_patches.empty() == true)
{
Failed("", NULL);
return false;
}
@ -756,7 +756,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash, /*
chmod(FinalFile.c_str(),0644);
// see if there is more to download
if(available_patches.size() > 0) {
if(available_patches.empty() == false) {
new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
ExpectedHash, ServerSha1, available_patches);
return Finish();
@ -1375,7 +1375,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/
#endif
for (vector <struct IndexTarget*>::const_iterator Target = IndexTargets->begin();
Target != IndexTargets->end();
Target++)
++Target)
{
HashString ExpectedIndexHash;
if (verify)
@ -1672,7 +1672,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
// check if we have one trusted source for the package. if so, switch
// to "TrustedOnly" mode
for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; i++)
for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; ++i)
{
pkgIndexFile *Index;
if (Sources->FindIndex(i.File(),Index) == false)
@ -1709,7 +1709,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
bool pkgAcqArchive::QueueNext()
{
string const ForceHash = _config->Find("Acquire::ForceHash");
for (; Vf.end() == false; Vf++)
for (; Vf.end() == false; ++Vf)
{
// Ignore not source sources
if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0)
@ -1820,7 +1820,7 @@ bool pkgAcqArchive::QueueNext()
Desc.ShortDesc = Version.ParentPkg().Name();
QueueURI(Desc);
Vf++;
++Vf;
return true;
}
return false;
@ -1894,7 +1894,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
{
// Vf = Version.FileList();
while (Vf.end() == false) Vf++;
while (Vf.end() == false) ++Vf;
StoreFilename = string();
Item::Failed(Message,Cnf);
return;

2
apt-pkg/acquire-method.cc

@ -81,7 +81,7 @@ void pkgAcqMethod::Fail(bool Transient)
void pkgAcqMethod::Fail(string Err,bool Transient)
{
// Strip out junk from the error messages
for (string::iterator I = Err.begin(); I != Err.end(); I++)
for (string::iterator I = Err.begin(); I != Err.end(); ++I)
{
if (*I == '\r')
*I = ' ';

20
apt-pkg/acquire.cc

@ -116,7 +116,7 @@ pkgAcquire::~pkgAcquire()
/* */
void pkgAcquire::Shutdown()
{
while (Items.size() != 0)
while (Items.empty() == false)
{
if (Items[0]->Status == Item::StatFetching)
Items[0]->Status = Item::StatError;
@ -155,7 +155,7 @@ void pkgAcquire::Remove(Item *Itm)
I = Items.begin();
}
else
I++;
++I;
}
}
/*}}}*/
@ -411,7 +411,7 @@ pkgAcquire::RunResult pkgAcquire::Run(int PulseIntervall)
I->Shutdown(false);
// Shut down the items
for (ItemIterator I = Items.begin(); I != Items.end(); I++)
for (ItemIterator I = Items.begin(); I != Items.end(); ++I)
(*I)->Finished();
if (_error->PendingError())
@ -467,7 +467,7 @@ bool pkgAcquire::Clean(string Dir)
// Look in the get list
ItemCIterator I = Items.begin();
for (; I != Items.end(); I++)
for (; I != Items.end(); ++I)
if (flNotDir((*I)->DestFile) == Dir->d_name)
break;
@ -488,7 +488,7 @@ bool pkgAcquire::Clean(string Dir)
unsigned long long pkgAcquire::TotalNeeded()
{
unsigned long long Total = 0;
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++)
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
Total += (*I)->FileSize;
return Total;
}
@ -499,7 +499,7 @@ unsigned long long pkgAcquire::TotalNeeded()
unsigned long long pkgAcquire::FetchNeeded()
{
unsigned long long Total = 0;
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++)
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
if ((*I)->Local == false)
Total += (*I)->FileSize;
return Total;
@ -511,7 +511,7 @@ unsigned long long pkgAcquire::FetchNeeded()
unsigned long long pkgAcquire::PartialPresent()
{
unsigned long long Total = 0;
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++)
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
if ((*I)->Local == false)
Total += (*I)->PartialSize;
return Total;
@ -781,11 +781,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
unsigned int Unknown = 0;
unsigned int Count = 0;
for (pkgAcquire::ItemCIterator I = Owner->ItemsBegin(); I != Owner->ItemsEnd();
I++, Count++)
++I, ++Count)
{
TotalItems++;
if ((*I)->Status == pkgAcquire::Item::StatDone)
CurrentItems++;
++CurrentItems;
// Totally ignore local items
if ((*I)->Local == true)
@ -795,7 +795,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
if ((*I)->Complete == true)
CurrentBytes += (*I)->FileSize;
if ((*I)->FileSize == 0 && (*I)->Complete == false)
Unknown++;
++Unknown;
}
// Compute the current completion

62
apt-pkg/algorithms.cc

@ -91,7 +91,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
Sim.MarkInstall(Pkg,false);
// Look for broken conflicts+predepends.
for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I)
{
if (Sim[I].InstallVer == 0)
continue;
@ -140,7 +140,7 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
Sim.Update();
// Print out each package and the failed dependencies
for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; D++)
for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; ++D)
{
if (Sim.IsImportantDep(D) == false ||
(Sim[D] & pkgDepCache::DepInstall) != 0)
@ -204,7 +204,7 @@ bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge)
void pkgSimulate::ShortBreaks()
{
cout << " [";
for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I)
{
if (Sim[I].InstBroken() == true)
{
@ -226,7 +226,7 @@ bool pkgApplyStatus(pkgDepCache &Cache)
{
pkgDepCache::ActionGroup group(Cache);
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (I->VersionList == 0)
continue;
@ -295,13 +295,13 @@ bool pkgFixBroken(pkgDepCache &Cache)
pkgDepCache::ActionGroup group(Cache);
// Auto upgrade all broken packages
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
if (Cache[I].NowBroken() == true)
Cache.MarkInstall(I, true, 0, false);
/* Fix packages that are in a NeedArchive state but don't have a
downloadable install version */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (I.State() != pkgCache::PkgIterator::NeedsUnpack ||
Cache[I].Delete() == true)
@ -338,19 +338,19 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
/* Auto upgrade all installed packages, this provides the basis
for the installation */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
if (I->CurrentVer != 0)
Cache.MarkInstall(I, true, 0, false);
/* Now, auto upgrade all essential packages - this ensures that
the essential packages are present and working */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
Cache.MarkInstall(I, true, 0, false);
/* We do it again over all previously installed packages to force
conflict resolution on them all. */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
if (I->CurrentVer != 0)
Cache.MarkInstall(I, false, 0, false);
@ -359,7 +359,7 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
// Hold back held packages.
if (_config->FindB("APT::Ignore-Hold",false) == false)
{
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (I->SelectedState == pkgCache::State::Hold)
{
@ -387,7 +387,7 @@ bool pkgAllUpgrade(pkgDepCache &Cache)
return false;
// Upgrade all installed packages
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (Cache[I].Install() == true)
Fix.Protect(I);
@ -421,7 +421,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache)
do
{
Change = false;
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
// Not interesting
if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true)
@ -438,7 +438,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache)
Change = true;
}
}
Count++;
++Count;
}
while (Change == true && Count < 10);
@ -525,7 +525,7 @@ void pkgProblemResolver::MakeScores()
<< " AddEssential => " << AddEssential << endl;
// Generate the base scores for a package based on its properties
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (Cache[I].InstallVer == 0)
continue;
@ -552,12 +552,12 @@ void pkgProblemResolver::MakeScores()
}
// Now that we have the base scores we go and propogate dependencies
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (Cache[I].InstallVer == 0)
continue;
for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++)
for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D)
{
if (D->Type == pkgCache::Dep::Depends ||
D->Type == pkgCache::Dep::PreDepends)
@ -574,12 +574,12 @@ void pkgProblemResolver::MakeScores()
/* Now we cause 1 level of dependency inheritance, that is we add the
score of the packages that depend on the target Package. This
fortifies high scoring packages */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (Cache[I].InstallVer == 0)
continue;
for (pkgCache::DepIterator D = I.RevDependsList(); D.end() == false; D++)
for (pkgCache::DepIterator D = I.RevDependsList(); D.end() == false; ++D)
{
// Only do it for the install version
if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer ||
@ -594,9 +594,9 @@ void pkgProblemResolver::MakeScores()
/* Now we propogate along provides. This makes the packages that
provide important packages extremely important */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
for (pkgCache::PrvIterator P = I.ProvidesList(); P.end() == false; P++)
for (pkgCache::PrvIterator P = I.ProvidesList(); P.end() == false; ++P)
{
// Only do it once per package
if ((pkgCache::Version *)P.OwnerVer() != Cache[P.OwnerPkg()].InstallVer)
@ -607,7 +607,7 @@ void pkgProblemResolver::MakeScores()
/* Protected things are pushed really high up. This number should put them
ahead of everything */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if ((Flags[I->ID] & Protected) != 0)
Scores[I->ID] += AddProtected;
@ -704,7 +704,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
if (Start == End)
break;
Start++;
++Start;
}
if (Fail == true)
break;
@ -750,7 +750,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
do
{
Again = false;
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (Cache[I].Install() == true)
Flags[I->ID] |= PreInstalled;
@ -781,7 +781,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
would cause the removal of even lower score packages. */
SPtrArray<pkgCache::Package *> PList = new pkgCache::Package *[Size];
pkgCache::Package **PEnd = PList;
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
*PEnd++ = I;
This = this;
qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
@ -901,7 +901,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
}
else
{
Start++;
++Start;
// We only worry about critical deps.
if (Start.IsCritical() != true)
continue;
@ -1150,7 +1150,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
{
// See if this is the result of a hold
pkgCache::PkgIterator I = Cache.PkgBegin();
for (;I.end() != true; I++)
for (;I.end() != true; ++I)
{
if (Cache[I].InstBroken() == false)
continue;
@ -1162,7 +1162,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
// set the auto-flags (mvo: I'm not sure if we _really_ need this)
pkgCache::PkgIterator I = Cache.PkgBegin();
for (;I.end() != true; I++) {
for (;I.end() != true; ++I) {
if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) {
if(_config->FindI("Debug::pkgAutoRemove",false)) {
std::clog << "Resolve installed new pkg: " << I.FullName(false)
@ -1220,7 +1220,7 @@ bool pkgProblemResolver::ResolveByKeep()
would cause the removal of even lower score packages. */
pkgCache::Package **PList = new pkgCache::Package *[Size];
pkgCache::Package **PEnd = PList;
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
*PEnd++ = I;
This = this;
qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
@ -1317,7 +1317,7 @@ bool pkgProblemResolver::ResolveByKeep()
if (Start == End)
break;
Start++;
++Start;
}
if (InstOrNewPolicyBroken(I) == false)
@ -1344,7 +1344,7 @@ void pkgProblemResolver::InstallProtect()
{
pkgDepCache::ActionGroup group(Cache);
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if ((Flags[I->ID] & Protected) == Protected)
{
@ -1424,7 +1424,7 @@ bool ListUpdate(pkgAcquireStatus &Stat,
bool Failed = false;
bool TransientNetworkFailure = false;
for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin();
I != Fetcher.ItemsEnd(); I++)
I != Fetcher.ItemsEnd(); ++I)
{
if ((*I)->Status == pkgAcquire::Item::StatDone)
continue;

4
apt-pkg/aptconfiguration.cc

@ -53,7 +53,7 @@ const Configuration::getCompressionTypes(bool const &Cached) {
// load the order setting into our vector
std::vector<std::string> const order = _config->FindVector("Acquire::CompressionTypes::Order");
for (std::vector<std::string>::const_iterator o = order.begin();
o != order.end(); o++) {
o != order.end(); ++o) {
if ((*o).empty() == true)
continue;
// ignore types we have no method ready to use
@ -274,7 +274,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
// then needed and ensure the codes are not listed twice.
bool noneSeen = false;
for (std::vector<string>::const_iterator l = lang.begin();
l != lang.end(); l++) {
l != lang.end(); ++l) {
if (*l == "environment") {
for (std::vector<string>::const_iterator e = environment.begin();
e != environment.end(); ++e) {

26
apt-pkg/cdrom.cc

@ -310,7 +310,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector<string> &List)
sort(List.begin(),List.end());
// Collect similar entries
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
// Find a space..
string::size_type Space = (*I).find(' ');
@ -322,7 +322,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector<string> &List)
string Word1 = string(*I,Space,SSpace-Space);
string Prefix = string(*I,0,Space);
for (vector<string>::iterator J = List.begin(); J != I; J++)
for (vector<string>::iterator J = List.begin(); J != I; ++J)
{
// Find a space..
string::size_type Space2 = (*J).find(' ');
@ -405,7 +405,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf)
that were the same. */
bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
{
if (List.size() == 0)
if (List.empty() == true)
return true;
string File = _config->FindFile("Dir::Etc::sourcelist");
@ -455,7 +455,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
if (First == true)
{
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@ -489,7 +489,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
// Just in case the file was empty
if (First == true)
{
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@ -661,13 +661,13 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if (_config->FindB("Debug::aptcdrom",false) == true)
{
cout << "I found (binary):" << endl;
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
cout << *I << endl;
cout << "I found (source):" << endl;
for (vector<string>::iterator I = SourceList.begin(); I != SourceList.end(); I++)
for (vector<string>::iterator I = SourceList.begin(); I != SourceList.end(); ++I)
cout << *I << endl;
cout << "I found (Signatures):" << endl;
for (vector<string>::iterator I = SigList.begin(); I != SigList.end(); I++)
for (vector<string>::iterator I = SigList.begin(); I != SigList.end(); ++I)
cout << *I << endl;
}
@ -688,7 +688,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
log->Update(msg.str(), STEP_SCAN);
}
if (List.size() == 0 && SourceList.size() == 0)
if (List.empty() == true && SourceList.empty() == true)
{
if (_config->FindB("APT::CDROM::NoMount",false) == false)
UnmountCdrom(CDROM);
@ -712,7 +712,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
{
// Escape special characters
string::iterator J = Name.begin();
for (; J != Name.end(); J++)
for (; J != Name.end(); ++J)
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
@ -757,7 +757,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
// Escape special characters
string::iterator J = Name.begin();
for (; J != Name.end(); J++)
for (; J != Name.end(); ++J)
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
@ -804,7 +804,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if(log != NULL)
log->Update(_("Source list entries for this disc are:\n"));
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@ -823,7 +823,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
}
}
for (vector<string>::iterator I = SourceList.begin(); I != SourceList.end(); I++)
for (vector<string>::iterator I = SourceList.begin(); I != SourceList.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)

4
apt-pkg/clean.cc

@ -85,12 +85,12 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
if (P.end() != true)
{
pkgCache::VerIterator V = P.VersionList();
for (; V.end() == false; V++)
for (; V.end() == false; ++V)
{
// See if we can fetch this version at all
bool IsFetchable = false;
for (pkgCache::VerFileIterator J = V.FileList();
J.end() == false; J++)
J.end() == false; ++J)
{
if (CleanInstalled == true &&
(J.File()->Flags & pkgCache::Flag::NotSource) != 0)

6
apt-pkg/contrib/configuration.cc

@ -672,9 +672,9 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
// Put the last fragment into the buffer
std::string::const_iterator NonWhitespaceStart = Start;
std::string::const_iterator NonWhitespaceStop = I;
for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; NonWhitespaceStart++)
for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; ++NonWhitespaceStart)
;
for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; NonWhitespaceStop--)
for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; --NonWhitespaceStop)
;
if (LineBuffer.empty() == false && NonWhitespaceStop - NonWhitespaceStart != 0)
LineBuffer += ' ';
@ -850,7 +850,7 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir,
vector<string> const List = GetListOfFilesInDir(Dir, "conf", true, true);
// Read the files
for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false)
return false;
return true;

6
apt-pkg/contrib/error.cc

@ -193,7 +193,7 @@ bool GlobalError::PopMessage(std::string &Text) {
// check if another error message is pending
for (std::list<Item>::const_iterator m = Messages.begin();
m != Messages.end(); m++)
m != Messages.end(); ++m)
if (m->Type == ERROR || m->Type == FATAL)
return Ret;
@ -210,7 +210,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end());
for (std::list<Item>::const_iterator m = Messages.begin();
m != Messages.end(); m++)
m != Messages.end(); ++m)
if (m->Type >= threshold)
out << (*m) << std::endl;
Discard();
@ -231,7 +231,7 @@ bool GlobalError::empty(MsgType const &trashhold) const {
return true;
for (std::list<Item>::const_iterator m = Messages.begin();
m != Messages.end(); m++)
m != Messages.end(); ++m)
if (m->Type >= trashhold)
return false;

30
apt-pkg/contrib/strutl.cc

@ -271,7 +271,7 @@ bool ParseCWord(const char *&String,string &Res)
string QuoteString(const string &Str, const char *Bad)
{
string Res;
for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
{
if (strchr(Bad,*I) != 0 || isprint(*I) == 0 ||
*I == 0x25 || // percent '%' char
@ -298,7 +298,7 @@ string DeQuoteString(string::const_iterator const &begin,
string::const_iterator const &end)
{
string Res;
for (string::const_iterator I = begin; I != end; I++)
for (string::const_iterator I = begin; I != end; ++I)
{
if (*I == '%' && I + 2 < end &&
isxdigit(I[1]) && isxdigit(I[2]))
@ -632,7 +632,7 @@ string LookupTag(const string &Message,const char *Tag,const char *Default)
{
// Look for a matching tag.
int Length = strlen(Tag);
for (string::const_iterator I = Message.begin(); I + Length < Message.end(); I++)
for (string::const_iterator I = Message.begin(); I + Length < Message.end(); ++I)
{
// Found the tag
if (I[Length] == ':' && stringcasecmp(I,I+Length,Tag) == 0)
@ -640,14 +640,14 @@ string LookupTag(const string &Message,const char *Tag,const char *Default)
// Find the end of line and strip the leading/trailing spaces
string::const_iterator J;
I += Length + 1;
for (; isspace(*I) != 0 && I < Message.end(); I++);
for (J = I; *J != '\n' && J < Message.end(); J++);
for (; J > I && isspace(J[-1]) != 0; J--);
for (; isspace(*I) != 0 && I < Message.end(); ++I);
for (J = I; *J != '\n' && J < Message.end(); ++J);
for (; J > I && isspace(J[-1]) != 0; --J);
return string(I,J);
}
for (; *I != '\n' && I < Message.end(); I++);
for (; *I != '\n' && I < Message.end(); ++I);
}
// Failed to find a match
@ -1224,7 +1224,7 @@ int tolower_ascii(int const c)
bool CheckDomainList(const string &Host,const string &List)
{
string::const_iterator Start = List.begin();
for (string::const_iterator Cur = List.begin(); Cur <= List.end(); Cur++)
for (string::const_iterator Cur = List.begin(); Cur <= List.end(); ++Cur)
{
if (Cur < List.end() && *Cur != ',')
continue;
@ -1248,7 +1248,7 @@ string DeEscapeString(const string &input)
char tmp[3];
string::const_iterator it, escape_start;
string output, octal, hex;
for (it = input.begin(); it != input.end(); it++)
for (it = input.begin(); it != input.end(); ++it)
{
// just copy non-escape chars
if (*it != '\\')
@ -1264,7 +1264,7 @@ string DeEscapeString(const string &input)
// copy
output += *it;
// advance iterator one step further
it += 1;
++it;
continue;
}
@ -1273,7 +1273,7 @@ string DeEscapeString(const string &input)
continue;
// read it
it++;
++it;
switch (*it)
{
case '0':
@ -1310,7 +1310,7 @@ void URI::CopyFrom(const string &U)
string::const_iterator I = U.begin();
// Locate the first colon, this separates the scheme
for (; I < U.end() && *I != ':' ; I++);
for (; I < U.end() && *I != ':' ; ++I);
string::const_iterator FirstColon = I;
/* Determine if this is a host type URI with a leading double //
@ -1322,7 +1322,7 @@ void URI::CopyFrom(const string &U)
/* Find the / indicating the end of the hostname, ignoring /'s in the
square brackets */
bool InBracket = false;
for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); SingleSlash++)
for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); ++SingleSlash)
{
if (*SingleSlash == '[')
InBracket = true;
@ -1355,11 +1355,11 @@ void URI::CopyFrom(const string &U)
I = FirstColon + 1;
if (I > SingleSlash)
I = SingleSlash;
for (; I < SingleSlash && *I != ':'; I++);
for (; I < SingleSlash && *I != ':'; ++I);
string::const_iterator SecondColon = I;
// Search for the @ after the colon
for (; I < SingleSlash && *I != '@'; I++);
for (; I < SingleSlash && *I != '@'; ++I);
string::const_iterator At = I;
// Now write the host and user/pass

6
apt-pkg/deb/debindexfile.cc

@ -352,7 +352,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;
@ -540,7 +540,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;
@ -620,7 +620,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;

2
apt-pkg/deb/deblistparser.cc

@ -203,7 +203,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;

12
apt-pkg/deb/debmetaindex.cc

@ -206,7 +206,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;
@ -236,7 +236,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());
}
@ -279,7 +279,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()));
}
@ -294,7 +294,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());
}
@ -303,7 +303,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()));
}
@ -351,7 +351,7 @@ class debSLTypeDebian : public pkgSourceList::Type
APT::Configuration::getArchitectures();
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)

2
apt-pkg/deb/debrecords.cc

@ -118,7 +118,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());
}

20
apt-pkg/deb/dpkgpm.cc

@ -213,7 +213,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;
@ -335,7 +335,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)
@ -690,7 +690,7 @@ bool pkgDPkgPM::OpenLog()
chmod(history_name.c_str(), 0644);
fprintf(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;
@ -868,14 +868,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++;
@ -893,7 +893,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;
@ -905,7 +905,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
@ -1011,7 +1011,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());
@ -1023,7 +1023,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;
@ -1461,7 +1461,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)

28
apt-pkg/depcache.cc

@ -129,7 +129,7 @@ bool pkgDepCache::Init(OpProgress *Prog)
/* Set the current state of everything. In this state all of the
packages are kept exactly as is. See AllUpgrade */
int Done = 0;
for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
for (PkgIterator I = PkgBegin(); I.end() != true; ++I, ++Done)
{
if (Prog != 0 && Done%20 == 0)
Prog->Progress(Done);
@ -292,7 +292,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/
// then write the ones we have not seen yet
std::ostringstream ostr;
for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) {
for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); ++pkg) {
StateCache const &P = PkgState[pkg->ID];
if(P.Flags & Flag::Auto) {
if (pkgs_seen.find(pkg.FullName()) != pkgs_seen.end()) {
@ -365,7 +365,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
// Check the providing packages
PrvIterator P = Dep.TargetPkg().ProvidesList();
PkgIterator Pkg = Dep.ParentPkg();
for (; P.end() != true; P++)
for (; P.end() != true; ++P)
{
/* Provides may never be applied against the same package (or group)
if it is a conflicts. See the comment above. */
@ -585,7 +585,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
{
unsigned char Group = 0;
for (DepIterator D = V.DependsList(); D.end() != true; D++)
for (DepIterator D = V.DependsList(); D.end() != true; ++D)
{
// Build the dependency state.
unsigned char &State = DepState[D->ID];
@ -625,7 +625,7 @@ unsigned char pkgDepCache::VersionState(DepIterator D,unsigned char Check,
// Compute a single dependency element (glob or)
DepIterator Start = D;
unsigned char State = 0;
for (bool LastOR = true; D.end() == false && LastOR == true; D++)
for (bool LastOR = true; D.end() == false && LastOR == true; ++D)
{
State |= DepState[D->ID];
LastOR = (D->CompareOp & Dep::Or) == Dep::Or;
@ -715,15 +715,15 @@ void pkgDepCache::Update(OpProgress *Prog)
// Perform the depends pass
int Done = 0;
for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
for (PkgIterator I = PkgBegin(); I.end() != true; ++I, ++Done)
{
if (Prog != 0 && Done%20 == 0)
Prog->Progress(Done);
for (VerIterator V = I.VersionList(); V.end() != true; V++)
for (VerIterator V = I.VersionList(); V.end() != true; ++V)
{
unsigned char Group = 0;
for (DepIterator D = V.DependsList(); D.end() != true; D++)
for (DepIterator D = V.DependsList(); D.end() != true; ++D)
{
// Build the dependency state.
unsigned char &State = DepState[D->ID];
@ -760,7 +760,7 @@ void pkgDepCache::Update(OpProgress *Prog)
void pkgDepCache::Update(DepIterator D)
{
// Update the reverse deps
for (;D.end() != true; D++)
for (;D.end() != true; ++D)
{
unsigned char &State = DepState[D->ID];
State = DependencyState(D);
@ -793,13 +793,13 @@ void pkgDepCache::Update(PkgIterator const &Pkg)
// Update the provides map for the current ver
if (Pkg->CurrentVer != 0)
for (PrvIterator P = Pkg.CurrentVer().ProvidesList();
P.end() != true; P++)
P.end() != true; ++P)
Update(P.ParentPkg().RevDependsList());
// Update the provides map for the candidate ver
if (PkgState[Pkg->ID].CandidateVer != 0)
for (PrvIterator P = PkgState[Pkg->ID].CandidateVerIter(*this).ProvidesList();
P.end() != true; P++)
P.end() != true; ++P)
Update(P.ParentPkg().RevDependsList());
}
/*}}}*/
@ -1059,7 +1059,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
DepIterator Start = Dep;
bool Result = true;
unsigned Ors = 0;
for (bool LastOR = true; Dep.end() == false && LastOR == true; Dep++,Ors++)
for (bool LastOR = true; Dep.end() == false && LastOR == true; ++Dep, ++Ors)
{
LastOR = (Dep->CompareOp & Dep::Or) == Dep::Or;
@ -1522,12 +1522,12 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pk
unless they are already installed */
VerIterator Last(*(pkgCache *)this,0);
for (VerIterator I = Pkg.VersionList(); I.end() == false; I++)
for (VerIterator I = Pkg.VersionList(); I.end() == false; ++I)
{
if (Pkg.CurrentVer() == I)
return I;
for (VerFileIterator J = I.FileList(); J.end() == false; J++)
for (VerFileIterator J = I.FileList(); J.end() == false; ++J)
{
if ((J.File()->Flags & Flag::NotSource) != 0)
continue;

18
apt-pkg/indexcopy.cc

@ -43,7 +43,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
pkgCdromStatus *log)
{
OpProgress *Progress = NULL;
if (List.size() == 0)
if (List.empty() == true)
return true;
if(log)
@ -54,7 +54,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,