Permalink
Browse files

index-history.html: sort 5.10+ delta files properly

  • Loading branch information...
1 parent dffb50e commit 6a026a812bbb6a4eda3102189b09a31272367e90 @ysth ysth committed with Aug 12, 2010
Showing with 16 additions and 2 deletions.
  1. +16 −2 lib/Perldoc/Section.pm
View
18 lib/Perldoc/Section.pm
@@ -58,8 +58,8 @@ our @section_data = (
pages => [qw/perlhist perltodo perldelta/],
pagematch => qr/^perl\d+delta$/,
sort => sub {
- (my $c = $a) =~ s/.*?(\d)(\d+).*/$1.$2/;
- (my $d = $b) =~ s/.*?(\d)(\d+).*/$1.$2/;
+ (my $c = $a) =~ s/.*?(\d{2,}).*/_perldelta_version_to_numeric("$1")/e;
+ (my $d = $b) =~ s/.*?(\d{2,}).*/_perldelta_version_to_numeric("$1")/e;
$d <=> $c
}
},
@@ -143,4 +143,18 @@ sub pages {
#--------------------------------------------------------------------------
+sub _perldelta_version_to_numeric {
+ my $delta_version = shift;
+ # 5005 -> 5.005
+ # 56 -> 5.006
+ # 561 -> 5.006001
+ # 5101 -> 5.010001
+ # 51010 -> 5.010010 (no such delta files currently)
+ my ($revision, $version, $subversion) = $delta_version =~ /^(\d)0*(\d(?=\d?\z)|\d\d)(\d*)/;
+ return sprintf('%d.%03d%03d', $revision, $version, $subversion || 0);
+}
+
+
+#--------------------------------------------------------------------------
+
1;

0 comments on commit 6a026a8

Please sign in to comment.