[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Summary[2]: dpkg and alpha/beta versioning



On 7 Jul 1998, Adam P. Harris wrote:

> 
> Yann, following your summary of alpha/beta versioning, it seems to me
> that a best practiced has arised and reached some consensus.  I wasn't
> following too closely, but I thought I saw this happening.  Did it?
> 
> If so, could you just take the best practice, and, if it's something
> requiring dpkg changes, raise discussion in dpkg-dev@lists.debian.org.
> If the best practices (hope hope) does *not* require dpkg changes, how
> about submitting a bug against the pacakging manual to document the
> best practice?
> 
> Then I could feel like we've accomplished something, instead of just
> being a debating society.

Here is a new version compare function that takes into account the ~
feature. My tests were:

# ver1 ver2 result
# -ve = < +ve = >
1.1~pre 1.1 -1
1.1~1pre 1.1~pre -1
1.1~1pre 1.1 -1
1.1~2 1.1~3 1
1.foo~boo 1.fooboo -1
1.foo~1boo 1.foo~boo -1 

It's a bit late so I didn't do any more than that. Someone else should
look at this then send it over to the dpkg list. (James?)

The exact syntax it expects is ~xx where xx is an optional digit string. ~
alone acts like a single character and compares less than any other
character including eos. ~xx acts like a negative digit and compares as
you would expect to other digits, ~xx also compares less than eos.

-- snip --
static int verrevcmp(const char *val, const char *ref)
{
   int vc, rc;
   long vl, rl;
   const char *vp, *rp;

   if (!val) val= "";
   if (!ref) ref= "";
   for (;;)
   {
      vp= val;  while (*vp && !isdigit(*vp) && *vp != '~') vp++;
      rp= ref;  while (*rp && !isdigit(*rp) && *rp != '~') rp++;
      for (;;)
      {
         vc= val == vp ? 0 : *val++;
         rc= ref == rp ? 0 : *ref++;
         if (!rc && !vc) break;
         if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
         if (rc && !isalpha(rc)) rc += 256;
         if (vc != rc) return vc - rc;
      }

      val= vp;
      ref= rp;
      if (*vp == '~') val++;
      if (*rp == '~') ref++;
      vl=0;  if (isdigit(*val)) vl= strtol(val,(char**)&val,10);
      rl=0;  if (isdigit(*ref)) rl= strtol(ref,(char**)&ref,10);
      if (vl == 0 && rl == 0)
      {
         if (*vp == '~' && *rp != '~') return -1;
         if (*vp != '~' && *rp == '~') return +1;
      }
      if (*vp == '~')
         vl *= -1;
      if (*rp == '~')
         rl *= -1;
      if (vl != rl) return vl - rl;
      if (!*val && !*ref) return 0;
      if (!*val)
      {
         if (*ref == '~')
            return +1;
         else
            return -1;
      }

      if (!*ref)
      {
         if (*val == '~')
            return -1;
         else
            return +1;
      }
   }
} 


--  
To UNSUBSCRIBE, email to debian-policy-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: