summaryrefslogtreecommitdiff
path: root/Porting/manisort
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2016-06-21 09:07:48 +0200
committerYves Orton <demerphq@gmail.com>2016-06-22 18:21:33 +0200
commit3dfcef7e97bf1b516f2ff2b33a39a1fd2d816236 (patch)
treee7b694c75f1161ff3b72e9c39867afab8daf8f6a /Porting/manisort
parent8bf4c4010cc474d4000c2a8c78f6890fa5f1e577 (diff)
downloadperl-3dfcef7e97bf1b516f2ff2b33a39a1fd2d816236.tar.gz
change manisort to produce a more intuitive order
Dictionary sort order on filenames is very counter-intuitive, and produces surprising sort orders. What this patch does is sort things so that the following should always be true: 1. Case insensitive textual order Eg: Foo and foo and FOO should sort together in ascibetical order 2. Shorter dirs go before longer dirs with a common prefix Eg: lib/Foo/ should go before lib/Foo-Thing/ 3. Base filename goes before dir of the same name Eg: lib/Foo.pm should sort before lib/Foo/Bar.pm This also refactors the MANIFEST sort code in Porting/manisort and Porting/pod_rules.pm files into Porting/pod_lib.pl
Diffstat (limited to 'Porting/manisort')
-rw-r--r--Porting/manisort12
1 files changed, 5 insertions, 7 deletions
diff --git a/Porting/manisort b/Porting/manisort
index 6cf7d92717..72cbb9c455 100644
--- a/Porting/manisort
+++ b/Porting/manisort
@@ -14,6 +14,7 @@ $| = 1;
# Get command line options
use Getopt::Long;
+require "Porting/pod_lib.pl";
my $outfile;
my $check_only = 0;
my $quiet = 0;
@@ -30,13 +31,10 @@ my @manifest = <$IN>;
close($IN) or die($!);
chomp(@manifest);
-# Sort by dictionary order (ignore-case and
-# consider whitespace and alphanumeric only)
-my @sorted = sort {
- (my $aa = $a) =~ s/[^\s\da-zA-Z]//g;
- (my $bb = $b) =~ s/[^\s\da-zA-Z]//g;
- uc($aa) cmp uc($bb)
- } @manifest;
+my %seen= ( '' => 1 ); # filter out blank lines
+my @sorted = grep { !$seen{$_}++ }
+ sort_manifest(@manifest)
+;
# Check if the file is sorted or not
my $exit_code = 0;