Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jul 2000 09:50:06 -0700 (PDT)
From:      andrew@ugh.net.au
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/18030: [PATCH] pkg_version thinks 4.04 > 4.1
Message-ID:  <200007051650.JAA40879@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/18030; it has been noted by GNATS.

From: andrew@ugh.net.au
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/18030: [PATCH] pkg_version thinks 4.04 > 4.1
Date: Thu, 6 Jul 2000 02:47:14 +1000 (EST)

 Well no one said anything about my leading 0 suggestion so I have coded
 it. It seems to get everything right on my system and I'm guessing even if
 it now gets some wrong that it used to get right it will get more right
 overall.
 
 I guess it will have trouble if anyone puts a leading 0 on their version
 numbers just to pad the field. Hopefully not too many of them.
 
 Thanks,
 
 Andrew
 
 --- /usr/src/usr.sbin/pkg_install/version/pkg_version.pl.orig	Mon Dec  6 13:19:16 1999
 +++ pkg_version.pl	Thu Jul  6 00:39:22 2000
 @@ -57,7 +57,7 @@
  # This function returns -1, 0, or 1, in the same manner as <=> or cmp.
  #
  sub CompareVersions {
 -    local($v1, $v2);
 +    my($v1, $v2);
      $v1 = $_[0];
      $v2 = $_[1];
  
 @@ -77,9 +77,14 @@
  	if (($p1 eq "") && ($p2 eq "")) {
  	    return 0;
  	}
 -	# Check for numeric inequality.  We assume here that (for example)
 -	# 3.09 < 3.10.
 +		# Check for numeric inequality.  We assume here that if the number
 +		# begins with a 0 then it is a decimal, else it is natural.
 +		# 3.09 < 3.10, 4.03 < 4.1
  	elsif ($p1 != $p2) {
 +			if ((index($p1, '0') == 0) or (index($p2, '0') == 0)) {
 +				$p1 = '.' . $p1;
 +				$p2 = '.' . $p2;
 +			}
  	    return $p1 <=> $p2;
  	}
  	# Check for string inequality, given numeric equality.  This
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007051650.JAA40879>