From owner-freebsd-bugs Wed Jul 5 9:50:13 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 5E25E37B5B2 for ; Wed, 5 Jul 2000 09:50:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id JAA40879; Wed, 5 Jul 2000 09:50:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Wed, 5 Jul 2000 09:50:06 -0700 (PDT) Message-Id: <200007051650.JAA40879@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: andrew@ugh.net.au Subject: Re: bin/18030: [PATCH] pkg_version thinks 4.04 > 4.1 Reply-To: andrew@ugh.net.au Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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