X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/09e712b10eafd2118db23ed9821a6f75604b9db6..e426a5ff1cd02797b29f5781be4d6fc8bdf44610:/apt-pkg/deb/debversion.cc diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc index a3bb908dd..755ffbe96 100644 --- a/apt-pkg/deb/debversion.cc +++ b/apt-pkg/deb/debversion.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: debversion.cc,v 1.5 2002/11/23 07:54:36 jgg Exp $ +// $Id: debversion.cc,v 1.8 2003/09/10 23:39:49 mdz Exp $ /* ###################################################################### Debian Version - Versioning system for Debian @@ -11,9 +11,6 @@ /*}}}*/ // Include Files /*{{{*/ #define APT_COMPATIBILITY 986 -#ifdef __GNUG__ -#pragma implementation "apt-pkg/debversion.h" -#endif #include #include @@ -48,12 +45,18 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd, if (A >= AEnd && B >= BEnd) return 0; if (A >= AEnd) + { + if (*B == '~') return 1; return -1; + } if (B >= BEnd) + { + if (*A == '~') return -1; return 1; + } /* Iterate over the whole string - What this does is to spilt the whole string into groups of + What this does is to split the whole string into groups of numeric and non numeric portions. For instance: a67bhgs89 Has 4 portions 'a', '67', 'bhgs', '89'. A more normal: @@ -63,13 +66,10 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd, const char *rhs = B; while (lhs != AEnd && rhs != BEnd) { - // Starting points - const char *Slhs = lhs; - const char *Srhs = rhs; int first_diff = 0; - while ((lhs != AEnd && !isdigit(*lhs)) || - (rhs != BEnd && !isdigit(*rhs)) ) + while (lhs != AEnd && rhs != BEnd && + (!isdigit(*lhs) || !isdigit(*rhs))) { int vc = order(*lhs); int rc = order(*rhs); @@ -104,11 +104,17 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd, // lhs is shorter if (lhs == AEnd) + { + if (*rhs == '~') return 1; return -1; + } // rhs is shorter if (rhs == BEnd) + { + if (*lhs == '~') return -1; return 1; + } // Shouldnt happen return 1; @@ -131,6 +137,27 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd, if (rhs == BEnd) rhs = B; + // Special case: a zero epoch is the same as no epoch, + // so remove it. + if (lhs != A) + { + for (; *A == '0'; ++A); + if (A == lhs) + { + ++A; + ++lhs; + } + } + if (rhs != B) + { + for (; *B == '0'; ++B); + if (B == rhs) + { + ++B; + ++rhs; + } + } + // Compare the epoch int Res = CmpFragment(A,lhs,B,rhs); if (Res != 0) @@ -163,8 +190,22 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd, dlhs++; if (drhs != rhs) drhs++; - - return CmpFragment(dlhs,AEnd,drhs,BEnd); + + // no debian revision need to be treated like -0 + if (*(dlhs-1) == '-' && *(drhs-1) == '-') + return CmpFragment(dlhs,AEnd,drhs,BEnd); + else if (*(dlhs-1) == '-') + { + const char* null = "0"; + return CmpFragment(dlhs,AEnd,null, null+1); + } + else if (*(drhs-1) == '-') + { + const char* null = "0"; + return CmpFragment(null, null+1, drhs, BEnd); + } + else + return 0; } /*}}}*/ // debVS::CheckDep - Check a single dependency /*{{{*/