diff options
author | Michael Vogt <egon@debian-devbox> | 2011-10-14 11:54:12 +0200 |
---|---|---|
committer | Michael Vogt <egon@debian-devbox> | 2011-10-14 11:54:12 +0200 |
commit | 1d51f78e9d128191ff8b2d48e42d90ebdbff2588 (patch) | |
tree | af05e41a53bcc9f22f146573ed0f1ff5311b97ad /apt-pkg/deb/debversion.cc | |
parent | 324fc8af296953857ebfc76deaadd4d224e081e3 (diff) | |
parent | f3b8d8571faf62265266ac0f9da60ad73885214b (diff) |
merged from lp:~donkult/apt/sid
Diffstat (limited to 'apt-pkg/deb/debversion.cc')
-rw-r--r-- | apt-pkg/deb/debversion.cc | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc index 755ffbe96..340403721 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 |