// -*- 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
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:
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);
// 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;
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)