develooper Front page | perl.perl5.porters | Postings from March 2012

patch to Porting/checkAUTHORS.pl

Thread Next
From:
Tom Christiansen
Date:
March 29, 2012 12:30
Subject:
patch to Porting/checkAUTHORS.pl
Message ID:
14238.1333049389@chthon
Especially given that v5.16 has fc, it's a bit embarrassing to see 

    sort { lc $a cmp lc $b } 

But even better than faking it with fc is using the real thing.

--tom

--- Porting/checkAUTHORS.pl-ORIG	2012-03-29 13:21:37.000000000 -0600
+++ Porting/checkAUTHORS.pl	2012-03-29 13:25:50.000000000 -0600
@@ -2,10 +2,13 @@
 use strict;
 my ($committer, $patch, $author);
 use utf8;
+use Unicode::Collate;
 use Getopt::Long;
 use Text::Wrap;
 $Text::Wrap::columns = 80;
 
+sub unisort;
+
 my ($rank, $ta, $ack, $who, $tap) = (0) x 5;
 my ($author_file, $percentage, $cumulative, $reverse);
 my (%authors, %untraced, %patchers, %committers, %real_names);
@@ -84,7 +87,7 @@
 sub list_authors {
     my ($patchers, $authors) = @_;
     binmode(STDOUT, ":utf8");
-    print wrap '', '', join(', ', sort { lc $a cmp lc $b }
+    print wrap '', '', join(', ', unisort
                       map { $authors->{$_} }
                       keys %$patchers) . ".\n";
 }
@@ -249,7 +252,7 @@
     my $real_names = shift;
     my $count = 0;
     printf "1..%d\n", scalar keys %$patchers;
-    foreach ( sort keys %$patchers ) {
+    foreach ( unisort keys %$patchers ) {
         $count++;
         if ($authors->{$_}) {
             print "ok $count - ".$real_names->{$_} ." $_\n";
@@ -265,7 +268,7 @@
     my $authors    = shift;
     my $real_names = shift;
     my %missing;
-    foreach ( sort keys %$patchers ) {
+    foreach ( unisort keys %$patchers ) {
         next if $authors->{$_};
 
         # Sort by number of patches, then name.
@@ -273,7 +276,7 @@
     }
     foreach my $patches ( sort { $b <=> $a } keys %missing ) {
         print "\n\n=head1 $patches patch(es)\n\n";
-        foreach my $author ( sort keys %{ $missing{$patches} } ) {
+        foreach my $author ( unisort keys %{ $missing{$patches} } ) {
             my $xauthor = $author;
             $xauthor =~ s/@/\\100/g;    # xxx temp hack
             print "" . ( $real_names->{$author} || $author ) . "\t\t\t<" . $xauthor . ">\n";
@@ -310,6 +313,11 @@
     }
 }
 
+sub unisort {
+    my $collator = Unicode::Collate->new("upper_before_lower" => 1);
+    return $collator->sort(@_);
+} 
+
 sub process {
     my ( $committer, $patch, $author ) = @_;
     return unless $author;

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About