From owner-freebsd-bugs Sat Apr 15 19:50: 9 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 C107537B818 for ; Sat, 15 Apr 2000 19:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id TAA09928; Sat, 15 Apr 2000 19:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from starbug.ugh.net.au (starbug.ugh.net.au [203.31.238.37]) by hub.freebsd.org (Postfix) with ESMTP id E3B4037B736 for ; Sat, 15 Apr 2000 19:47:29 -0700 (PDT) (envelope-from root@ugh.net.au) Received: by starbug.ugh.net.au (Postfix, from userid 0) id 95336A818; Sun, 16 Apr 2000 12:47:28 +1000 (EST) Message-Id: <20000416024728.95336A818@starbug.ugh.net.au> Date: Sun, 16 Apr 2000 12:47:28 +1000 (EST) From: andrew@ugh.net.au Reply-To: andrew@ugh.net.au To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/18030: [PATCH] pkg_version thinks 4.04 > 4.1 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 18030 >Category: bin >Synopsis: [PATCH] pkg_version thinks 4.04 > 4.1 >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Apr 15 19:50:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Andrew >Release: FreeBSD 4.0-STABLE i386 >Organization: UgH! >Environment: 4.0-STABLE as of yesterday >Description: pkg_version thinks 4.04 > 4.1. It does this becasue it splits version numbers up as if they were . delimited. It then tries to comapre each group. The second comparison is 04 <=> 1. Perl treats 04 as 4 and so it becomes bigger. >How-To-Repeat: Run pkg_version with an old port (such as analog 4.04) installed. >Fix: Force a . on the front of the numbers. This seems to work. I have also changed the variables $p1 and $p2 to my from local as per perlsub(1) and changed a little bit of indenting to make it more logical (IMHO) and closer to style(9). --- pkg_version.pl.orig Mon Dec 6 13:19:16 1999 +++ pkg_version.pl Sun Apr 16 12:32:36 2000 @@ -57,36 +57,39 @@ # 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]; # Short-cut in case of equality if ($v1 eq $v2) { - return 0; + return 0; } # Loop over different components (the parts separated by dots). # If any component differs, we have the basis for an inequality. while (1) { - ($p1, $v1) = split(/\./, $v1, 2); - ($p2, $v2) = split(/\./, $v2, 2); + ($p1, $v1) = split(/\./, $v1, 2); + ($p2, $v2) = split(/\./, $v2, 2); - # If we\'re out of components, they\'re equal (this probably won\'t - # happen, since the short-cut case above should get this). - if (($p1 eq "") && ($p2 eq "")) { - return 0; - } - # Check for numeric inequality. We assume here that (for example) - # 3.09 < 3.10. - elsif ($p1 != $p2) { - return $p1 <=> $p2; - } - # Check for string inequality, given numeric equality. This - # handles version numbers of the form 3.4j < 3.4k. - elsif ($p1 ne $p2) { - return $p1 cmp $p2; - } + # If we\'re out of components, they\'re equal (this probably won\'t + # happen, since the short-cut case above should get this). + if (($p1 eq "") && ($p2 eq "")) { + return 0; + } + # Check for numeric inequality. We assume here that (for example) + # 3.09 < 3.10. We force a . on the front of $p1 and $p2 so that + # 4.1 > 4.04 + elsif ($p1 != $p2) { + $p1 = '.' . $p1; + $p2 = '.' . $p2; + return $p1 <=> $p2; + } + # Check for string inequality, given numeric equality. This + # handles version numbers of the form 3.4j < 3.4k. + elsif ($p1 ne $p2) { + return $p1 cmp $p2; + } } } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message