| Summary: | [PATCH] pkg_version thinks 4.04 > 4.1 | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Andrew Stevenson <andrew> | ||||
| Component: | bin | Assignee: | Bruce A. Mah <bmah> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 4.0-STABLE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
|
Description
Andrew Stevenson
2000-04-16 03:50:01 UTC
<<On Sun, 16 Apr 2000 12:47:28 +1000 (EST), andrew@ugh.net.au said: >> Synopsis: [PATCH] pkg_version thinks 4.04 > 4.1 That's because it is. Version numbers, by tradition, are not reals; 4.10 comes nine revisions after 4.1. -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick On 16/04, andrew@ugh.net.au wrote: | Force a . on the front of the numbers. This seems to work. a2ps 4.12 > a2ps 4.3, and your patch will break it. There is no way to make this fully automated. On Mon, 17 Apr 2000, Samuel Tardieu wrote:
> On 16/04, andrew@ugh.net.au wrote:
>
> | Force a . on the front of the numbers. This seems to work.
>
> a2ps 4.12 > a2ps 4.3, and your patch will break it. There is no way to make
> this fully automated.
Garrett Wollman pointed this out...I suggested only forcing a . infront of
version numbers beggining with 0? I think that should fix things but
perhaps I'm missing something else...
Thanks,
Andrew
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
Responsible Changed From-To: freebsd-bugs->billf Over to the maintainer. State Changed From-To: open->closed I think that pkg_version is doing the right thing; if a port has version numbers that work like decimals, we ought to change the metadata in the port's Makefile. Responsible Changed From-To: billf->bmah MAINTAINER change. |