From e243b41ee535d9c064868bcc54344b9a8560a2aa Mon Sep 17 00:00:00 2001 From: bmah Date: Fri, 31 May 2002 15:45:48 +0000 Subject: pkg_version was incorrectly claiming that 1.5 == 1.5.0.1, because we weren't properly checking for the case that the two version strings being compared had different numbers of components. This has been fixed. Pointed out by: sobomax Reviewed by: silence on -ports --- usr.sbin/pkg_install/version/pkg_version.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'usr.sbin/pkg_install') diff --git a/usr.sbin/pkg_install/version/pkg_version.pl b/usr.sbin/pkg_install/version/pkg_version.pl index c65d2d4..86c6547 100755 --- a/usr.sbin/pkg_install/version/pkg_version.pl +++ b/usr.sbin/pkg_install/version/pkg_version.pl @@ -127,6 +127,15 @@ sub CompareNumbers { } else { # Neither component begins with a leading letter. + # See if either component has no characters left. If so, + # let the other component win. + if ($c1 eq "") { + return -1; + } + if ($c2 eq "") { + return 1; + } + # Check for numeric inequality. We assume here that (for example) # "3.09" < "3.10", and that we aren't going to be asked to # decide between "3.010" and "3.10". @@ -193,6 +202,21 @@ sub CompareVersions { ($v1, $r1, $e1) = &GetVersionComponents($fv1); ($v2, $r2, $e2) = &GetVersionComponents($fv2); + # Port revision and port epoch numbers default to zero if not + # specified. + if ($r1 eq "") { + $r1 = "0"; + } + if ($r2 eq "") { + $r2 = "0"; + } + if ($e1 eq "") { + $e1 = "0"; + } + if ($e2 eq "") { + $e2 = "0"; + } + # Check epoch, port version, and port revision, in that # order. $rc = &CompareNumbers($e1, $e2); -- cgit v1.1