svn commit: r53009 - head/en_US.ISO8859-1/htdocs/cgi

Wolfram Schneider <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
Author: wosch
Date: Sun May 12 18:57:19 2019
New Revision: 53009
URL: https://svnweb.freebsd.org/changeset/doc/53009

Log:
  sort versions with major.minor.patch number, e.g.: 5.1.1 <> 5.2.2

Modified:
  head/en_US.ISO8859-1/htdocs/cgi/man.cgi

Modified: head/en_US.ISO8859-1/htdocs/cgi/man.cgi
==============================================================================
--- head/en_US.ISO8859-1/htdocs/cgi/man.cgi	Sun May 12 18:25:31 2019	(r53008)
+++ head/en_US.ISO8859-1/htdocs/cgi/man.cgi	Sun May 12 18:57:19 2019	(r53009)
@@ -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,18 +911,53 @@ 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
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-doc-all
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.