Subject: Re: Comparing version numbers
To: Alistair Crooks <>
From: Rene Hexel <>
List: tech-pkg
Date: 08/02/2002 10:47:14
On Fri, 2002-08-02 at 06:58, Alistair Crooks wrote:

> Basically, all of the comparison work is done in
> 	pkg_install/lib/str.c
> An array of 64-bit integers is constructed, using the rules in the comment
> in line 156 (ish).

  Thanks, Al, that was a good pointer.  I always had some sort of fuzzy
intuitive understanding of what's actually used for comparison, but it's
good to have a look at the real code.

> '_' encodes as 'patchlevel', or '0'

  I'm not sure I understand this part, though.  Here is a sniplet from
the code that does the encoding:

        if (*num == '_') {
                num += 1;
                if (isdigit(*(num + 1))) {
                        ap->v[ap->c++] = Dot;
                        return 1;

  Shouldn't that isdigit() part read

               if (isdigit(*num)) {

  instead?  'num' has already been incremented in the preceding line, so
that would check whether the next character is actually a digit.  The
original code actually checks the 2nd character after the '_'.  Maybe
I'm missing something here ...