Update of /cvsroot/lxr/lxr/lib/LXR/Files
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29832/lib/LXR/Files
Modified Files:
CVS.pm
Log Message:
sort CVS revisions intelligently
Index: CVS.pm
===================================================================
RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/CVS.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- CVS.pm 20 Jul 2004 20:40:21 -0000 1.29
+++ CVS.pm 21 Jul 2004 14:08:38 -0000 1.30
@@ -374,12 +374,25 @@
}
}
+# sort by CVS version
+# split rev numbers into arrays
+# compare each array element, returning as soon as we find a difference
+sub byrevision {
+ my @one = split /\./, $a;
+ my @two = split /\./, $b;
+ for (my $i = 0; $i <= $#one; $i++) {
+ my $ret = $one[$i] <=> $two[$i];
+ return $ret if $ret;
+ }
+ return $#one <=> $#two; # if still no difference after we ran through all elements of @one, compare the length of the array
+}
+
sub allrevisions {
my ( $self, $filename ) = @_;
$self->parsecvs($filename);
- return sort( keys( %{ $cvs{'branch'} } ) );
+ return sort byrevision keys( %{ $cvs{'branch'} } );
}
sub parsecvs {
|