summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-10-30 13:48:05 -0500
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-10-30 13:48:05 -0500
commit89d88ac3ef3f82fdfeac6d8d231deddeeb0f02e9 (patch)
tree258687a5f0984f0b4edd24b52d778cf4d21c7059 /apt-pkg/deb
parentcd5e84440a9bb75a9cc2c142ac8bc214ba57685a (diff)
parent0a64ecd792b4caca519d597a69b8baeda6a1bf77 (diff)
merge with my debian-sid branch
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc21
-rw-r--r--apt-pkg/deb/debversion.cc25
-rw-r--r--apt-pkg/deb/dpkgpm.cc1
3 files changed, 18 insertions, 29 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index a36857cb5..fd3e4808d 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -522,9 +522,9 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
// Skip whitespace
for (;I != Stop && isspace(*I) != 0; I++);
Start = I;
- for (;I != Stop && *I != ')'; I++);
- if (I == Stop || Start == I)
- return 0;
+ I = (const char*) memchr(I, ')', Stop - I);
+ if (I == NULL || Start == I)
+ return 0;
// Skip trailing whitespace
const char *End = I;
@@ -797,21 +797,16 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
}
// seperate the tag from the data
- for (; buffer[len] != ':' && buffer[len] != '\0'; ++len)
- /* nothing */
- ;
- if (buffer[len] == '\0')
+ const char* dataStart = strchr(buffer + len, ':');
+ if (dataStart == NULL)
continue;
- char* dataStart = buffer + len;
+ len = dataStart - buffer;
for (++dataStart; *dataStart == ' '; ++dataStart)
/* nothing */
;
- char* dataEnd = dataStart;
- for (++dataEnd; *dataEnd != '\0'; ++dataEnd)
- /* nothing */
- ;
+ const char* dataEnd = (const char*)rawmemchr(dataStart, '\0');
// The last char should be a newline, but we can never be sure: #633350
- char* lineEnd = dataEnd;
+ const char* lineEnd = dataEnd;
for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd)
/* nothing */
;
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index bc9e13d92..a02699a44 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -127,14 +127,12 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd,
int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
const char *B,const char *BEnd)
{
- // Strip off the epoch and compare it
- const char *lhs = A;
- const char *rhs = B;
- for (;lhs != AEnd && *lhs != ':'; lhs++);
- for (;rhs != BEnd && *rhs != ':'; rhs++);
- if (lhs == AEnd)
+ // Strip off the epoch and compare it
+ const char *lhs = (const char*) memchr(A, ':', AEnd - A);
+ const char *rhs = (const char*) memchr(B, ':', BEnd - B);
+ if (lhs == NULL)
lhs = A;
- if (rhs == BEnd)
+ if (rhs == NULL)
rhs = B;
// Special case: a zero epoch is the same as no epoch,
@@ -169,15 +167,12 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
if (rhs != B)
rhs++;
- // Find the last -
- const char *dlhs = AEnd-1;
- const char *drhs = BEnd-1;
- for (;dlhs > lhs && *dlhs != '-'; dlhs--);
- for (;drhs > rhs && *drhs != '-'; drhs--);
-
- if (dlhs == lhs)
+ // Find the last -
+ const char *dlhs = (const char*) memrchr(lhs, '-', AEnd - lhs);
+ const char *drhs = (const char*) memrchr(rhs, '-', BEnd - rhs);
+ if (dlhs == NULL)
dlhs = AEnd;
- if (drhs == rhs)
+ if (drhs == NULL)
drhs = BEnd;
// Compare the main version
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 5eb6406c6..7c0ed5639 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -983,7 +983,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
char status_fd_buf[20];
snprintf(status_fd_buf,sizeof(status_fd_buf),"%i", fd[1]);
ADDARG(status_fd_buf);
-
unsigned long const Op = I->Op;
switch (I->Op)