On Fri, 9 Jan 1998, David Frey wrote:

> Hello collegues,
> 
> I don't understand dpkg's version compare algorithm:
> ([EMAIL PROTECTED]) /var/debian/unstable/binary-i386/math$dpkg 
> --compare-versions 1.15  lt 1.2-1; echo $?
> 1
> ([EMAIL PROTECTED]) /var/debian/unstable/binary-i386/math$dpkg 
> --compare-versions 1.15  lt 1.20-1; echo $?
> 0
> ([EMAIL PROTECTED]) /var/debian/unstable/binary-i386/math$dpkg --version
> Debian Linux `dpkg' package management program version 1.4.0.19 (i386 elf).
> Copyright 1994-1996 Ian Jackson, Bruce Perens.  This is free software;
> see the GNU General Public Licence version 2 or later for copying
> conditions.  There is NO warranty.  See dpkg --licence for details.
> ([EMAIL PROTECTED]) /var/debian/unstable/binary-i386/math$
> 
> Why is 1.15 > 1.2 ? Is it necessary to fill in trailing zeroes?

Yes. Dpkg splits a version into number and not number compontents, so it
would look at 1.15 as '1' '.' '15' and 1.2 as '1' '.' '2'. It then
compares the number components as numbers and the non numbers as strings
(kinda, there are some special rules for -/.). 

I suspect this is so that:
 1-15 > 1-2
 1.15 > 1.2

Which is more consistant, you would never expect 1-15 < 1-2. Don't think
of the dot as a decimal but mearly as a separator, it doesn't give special
meaning to what follows.

Jason


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .

Reply via email to