summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorbmah <bmah@FreeBSD.org>2002-05-31 15:45:48 +0000
committerbmah <bmah@FreeBSD.org>2002-05-31 15:45:48 +0000
commite243b41ee535d9c064868bcc54344b9a8560a2aa (patch)
treed03fdd92ca769268862e1bde3d2e808fe2b949e8 /usr.sbin/pkg_install
parentaa868b9ee582ddd51a7100bb3e18c8cdc07cf5df (diff)
downloadFreeBSD-src-e243b41ee535d9c064868bcc54344b9a8560a2aa.zip
FreeBSD-src-e243b41ee535d9c064868bcc54344b9a8560a2aa.tar.gz
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
Diffstat (limited to 'usr.sbin/pkg_install')
-rwxr-xr-xusr.sbin/pkg_install/version/pkg_version.pl24
1 files changed, 24 insertions, 0 deletions
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);
OpenPOWER on IntegriCloud