aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1
diff options
context:
space:
mode:
authorWolfram Schneider <wosch@FreeBSD.org>2019-05-12 18:57:19 +0000
committerWolfram Schneider <wosch@FreeBSD.org>2019-05-12 18:57:19 +0000
commitd2227d7bcedc75e01623edc58b2df9bd70b3601f (patch)
tree1360d3ffebcf5bc83ccc65ef48fafc7026622d0d /en_US.ISO8859-1
parent5712cd7e23ac2ef12bf05c22dbf8057038c48cf9 (diff)
downloaddoc-d2227d7bcedc75e01623edc58b2df9bd70b3601f.tar.gz
doc-d2227d7bcedc75e01623edc58b2df9bd70b3601f.zip
sort versions with major.minor.patch number, e.g.: 5.1.1 <> 5.2.2
Notes
Notes: svn path=/head/; revision=53009
Diffstat (limited to 'en_US.ISO8859-1')
-rwxr-xr-xen_US.ISO8859-1/htdocs/cgi/man.cgi45
1 files changed, 40 insertions, 5 deletions
diff --git a/en_US.ISO8859-1/htdocs/cgi/man.cgi b/en_US.ISO8859-1/htdocs/cgi/man.cgi
index 700b552fc0..293f65e942 100755
--- a/en_US.ISO8859-1/htdocs/cgi/man.cgi
+++ b/en_US.ISO8859-1/htdocs/cgi/man.cgi
@@ -672,7 +672,7 @@ $manPathDefault = 'FreeBSD 12.0-RELEASE and Ports';
'HP-UX 10.01', "$manLocalDir/HP-UX-10.01",
'HP-UX 9.07', "$manLocalDir/HP-UX-9.07",
- 'IRIX-6.5.30', "$manLocalDir/IRIX-6.5.30/catman/a_man:$manLocalDir/IRIX-6.5.30/catman/p_man:$manLocalDir/IRIX-6.5.30/catman/u_man:$manLocalDir/IRIX-6.5.30/dt",
+ 'IRIX 6.5.30', "$manLocalDir/IRIX-6.5.30/catman/a_man:$manLocalDir/IRIX-6.5.30/catman/p_man:$manLocalDir/IRIX-6.5.30/catman/u_man:$manLocalDir/IRIX-6.5.30/dt",
'SunOS 5.10', "$manLocalDir/SunOS-5.10",
'SunOS 5.9', "$manLocalDir/SunOS-5.9",
@@ -911,20 +911,55 @@ sub sort_versions {
my @b = ( lc($b) =~ m,^(\D+)([\d\.]+)(\D*)$, );
if (@a and @b) {
- return $a[0] cmp $b[0] || (-1 * ($a[1] <=> $b[1])) || $a[2] cmp $a[2] || $a cmp $b;
+ return $a[0] cmp $b[0] || # FreeBDS <=> IRIX
+ &version($a[1], $b[1]) || # 6.5.30 <=> 6.5.31
+ $a[2] cmp $a[2] || # RELEASE <=> ports
+ $a cmp $b; # rest
}
# 2.9.1 BSD
- @a = ( lc($a) =~ m,^(\d\.+)(.*)$, );
- @b = ( lc($b) =~ m,^(\d\.+)(.*)$, );
+ @a = ( lc($a) =~ m,^([\d\.]+)(.*)$, );
+ @b = ( lc($b) =~ m,^([\d\.]+)(.*)$, );
if (@a and @b) {
- return (-1 * ( $a[0] <=> $b[0])) || $a[1] <=> $b[1] || $a cmp $b;
+ return &version($a[0], $b[0]) || # 2.9.1BSD
+ $a[1] <=> $b[1] || # BSD
+ $a cmp $b; # rest
}
# rest
return $a cmp $b;
}
+sub version {
+ return &version_compare(@_) * -1;
+}
+
+# compare two versions, e.g.: 5.1.1 <> 5.2.2
+sub version_compare {
+ my $a = shift;
+ my $b = shift;
+
+ my @a = split( '\.', $a );
+ my @b = split( '\.', $b );
+
+ my $max = @a >= @b ? @a : @b;
+
+ for ( my $i = 0 ; $i < $max ; $i++ ) {
+
+ # 5.1 <=> 5.1.1
+ return -1 if !defined $a[$i];
+
+ # 5.1.1 <=> 5.1
+ return +1 if !defined $b[$i];
+
+ if ( ( $a[$i] <=> $b[$i] ) != 0 ) {
+ return $a[$i] <=> $b[$i];
+ }
+ }
+
+ return 0;
+}
+
# FreeBSD manual pages first before any other manual pages
sub freebsd_first {
my @list = @_;