From owner-freebsd-ports Wed Mar 28 15:47:50 2001 Delivered-To: freebsd-ports@freebsd.org Received: from heechee.tobez.org (254.adsl0.ryv.worldonline.dk [213.237.10.254]) by hub.freebsd.org (Postfix) with ESMTP id CE5A437B71B; Wed, 28 Mar 2001 15:47:46 -0800 (PST) (envelope-from tobez@tobez.org) Received: by heechee.tobez.org (Postfix, from userid 1001) id AE1BE545C; Thu, 29 Mar 2001 01:47:45 +0200 (CEST) Date: Thu, 29 Mar 2001 01:47:45 +0200 From: Anton Berezin To: "Bruce A. Mah" Cc: freebsd-ports@freebsd.org, knu@freebsd.org Subject: Re: pkg_version comparison routine Message-ID: <20010329014745.E34676@heechee.tobez.org> Mail-Followup-To: Anton Berezin , "Bruce A. Mah" , freebsd-ports@freebsd.org, knu@freebsd.org References: <200103280237.f2S2bUP02277@bmah-freebsd-0.cisco.com> <20010328231956.B34676@heechee.tobez.org> <200103282335.f2SNZ2526600@bmah-freebsd-0.cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200103282335.f2SNZ2526600@bmah-freebsd-0.cisco.com>; from bmah@freebsd.org on Wed, Mar 28, 2001 at 03:35:02PM -0800 Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Wed, Mar 28, 2001 at 03:35:02PM -0800, Bruce A. Mah wrote: > If memory serves me right, Anton Berezin wrote: > > On Tue, Mar 27, 2001 at 06:37:30PM -0800, Bruce A. Mah wrote: > > > > > I'm going to revisit an issue long overdue...the fact that the > > > algorithm used by pkg_version(1) for comparing versions doesn't work > > > in all the cases specified by the Porter's Handbook. knu tried to get > > > my attention on this issue a number of months ago, even going so far > > > as to submit some patches to fix this problem. Unfortunately I > > > dropped the ball on this, and I'm sure he's understandably annoyed at > > > me. > > > > We not just steal a little snippet from devel/p5-Sort-Versions? > > > > I believe it handles most insane possibilities. > > Hmmm. Well, for starters I didn't know this existed. I'm not sure I > understand all of it, but it looks like it handles pretty much every > case in the Porter's Handbook (plus others from our own Ports > Collection). > > What's the licensing on this thing? (pkg_version is part of the base > system now, for better or worse, so we'd need to import this code into > src/.) The usual `same as perl' thingy. I.e., either GPL or Artistic, user's choice. If necessary, I am sure it is possible to negotiate with the author, Kenneth J. Albanowski . > Other than that the only thing that comes to mind is NIH, which I'll > freely admit to. :-) Heh. First I encountered similar code in Mandrake (!) rpm tools or something. It was GPL and it was was *horribly* twisted: sub version_compare { my ($a, $b) = @_; $a = $a.' '; $b = $b.' '; local $_; while ($a || $b) { my ($sb, $sa) = map { $1 if /^\W*\d/ ? s/^\W*0*(\d+)// : s/^\W*(\D+)// } ($b, $a); $_ = length($sa) cmp length($sb) || $sa cmp $sb and return $_; } } I needed something to compare versions, and was specifically looking for a non-GPL thingy, I looked more, and to my surprise found this old rusty module in *our* port collection. :-) Cheers, &Anton. -- May the tuna salad be with you. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message