summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc14
-rw-r--r--apt-pkg/deb/debversion.cc11
-rw-r--r--apt-pkg/deb/dpkgpm.cc17
3 files changed, 22 insertions, 20 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index d84a6a26d..db86bd698 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -284,7 +284,7 @@ unsigned short debListParser::VersionHash()
"Replaces",0};
unsigned long Result = INIT_FCS;
char S[1024];
- for (const char **I = Sections; *I != 0; I++)
+ for (const char * const *I = Sections; *I != 0; ++I)
{
const char *Start;
const char *End;
@@ -295,13 +295,13 @@ unsigned short debListParser::VersionHash()
of certain fields. dpkg also has the rather interesting notion of
reformatting depends operators < -> <= */
char *J = S;
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
- if (isspace(*Start) == 0)
- *J++ = tolower_ascii(*Start);
- if (*Start == '<' && Start[1] != '<' && Start[1] != '=')
- *J++ = '=';
- if (*Start == '>' && Start[1] != '>' && Start[1] != '=')
+ if (isspace(*Start) != 0)
+ continue;
+ *J++ = tolower_ascii(*Start);
+
+ if ((*Start == '<' || *Start == '>') && Start[1] != *Start && Start[1] != '=')
*J++ = '=';
}
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index a02699a44..140561262 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -215,10 +215,15 @@ bool debVersioningSystem::CheckDep(const char *PkgVer,
return true;
if (PkgVer == 0 || PkgVer[0] == 0)
return false;
-
+ Op &= 0x0F;
+
+ // fast track for (equal) strings [by location] which are by definition equal versions
+ if (PkgVer == DepVer)
+ return Op == pkgCache::Dep::Equals || Op == pkgCache::Dep::LessEq || Op == pkgCache::Dep::GreaterEq;
+
// Perform the actual comparision.
- int Res = CmpVersion(PkgVer,DepVer);
- switch (Op & 0x0F)
+ int const Res = CmpVersion(PkgVer, DepVer);
+ switch (Op)
{
case pkgCache::Dep::LessEq:
if (Res <= 0)
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 6cb8bc6b6..3bc31dc37 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -147,11 +147,11 @@ static
pkgCache::VerIterator FindNowVersion(const pkgCache::PkgIterator &Pkg)
{
pkgCache::VerIterator Ver;
- for (Ver = Pkg.VersionList(); Ver.end() == false; Ver++)
+ for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
pkgCache::VerFileIterator Vf = Ver.FileList();
pkgCache::PkgFileIterator F = Vf.File();
- for (F = Vf.File(); F.end() == false; F++)
+ for (F = Vf.File(); F.end() == false; ++F)
{
if (F && F.Archive())
{
@@ -1585,12 +1585,12 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
if (!logfile_name.empty())
{
FILE *log = NULL;
- char buf[1024];
fprintf(report, "DpkgTerminalLog:\n");
log = fopen(logfile_name.c_str(),"r");
if(log != NULL)
{
+ char buf[1024];
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
fclose(log);
@@ -1609,13 +1609,11 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
// attach dmesg log (to learn about segfaults)
if (FileExists("/bin/dmesg"))
{
- FILE *log = NULL;
- char buf[1024];
-
fprintf(report, "Dmesg:\n");
- log = popen("/bin/dmesg","r");
+ FILE *log = popen("/bin/dmesg","r");
if(log != NULL)
{
+ char buf[1024];
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
pclose(log);
@@ -1625,13 +1623,12 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
// attach df -l log (to learn about filesystem status)
if (FileExists("/bin/df"))
{
- FILE *log = NULL;
- char buf[1024];
fprintf(report, "Df:\n");
- log = popen("/bin/df -l","r");
+ FILE *log = popen("/bin/df -l","r");
if(log != NULL)
{
+ char buf[1024];
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
pclose(log);