This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make the expensive ckWARN() be called as late as possible
[perl5.git] / Porting / checkAUTHORS.pl
CommitLineData
5649b9c9
NC
1#!/usr/bin/perl -w
2use strict;
3use Text::Wrap;
4$Text::Wrap::columns = 80;
5my ($committer, $patch, $log);
6use Getopt::Long;
7
8my ($rank, @authors, %authors, %untraced, %patchers);
9my $result = GetOptions ("rank" => \$rank, # rank authors
10 "acknowledged=s" => \@authors); # authors files
11
12if (!$result or !($rank xor @authors) or !@ARGV) {
13 die <<"EOS";
14$0 --rank Changelogs # rank authors by patches
15$0 --acknowledged <authors file> Changelogs # Display unacknowledged authors
16Specify stdin as - if needs be. Remember that option names can be abbreviated.
17EOS
18}
19
20my %map = reverse (
21 # "Correct" => "Alias"
22 adi => "enache\100rdslink.ro",
23 alanbur => "alan.burlison\100sun.com",
24 ams => "ams\100wiw.org",
25 chip => "chip\100pobox.com",
26 davem => "davem\100fdgroup.com",
27 doughera => " doughera\100lafayette.edu",
28 gbarr => "gbarr\100pobox.com",
29 gsar => "gsar\100activestate.com",
30 hv => "hv\100crypt.compulink.co.uk",
31 jhi => "jhi\100iki.fi",
3bd76f0a 32 merijn => "h.m.brand\100xs4all.nl",
5649b9c9
NC
33 mhx => "mhx-perl\100gmx.net",
34 nicholas => "nick\100unfortu.net",
35 nick => "nick\100ing-simmons.net",
36 pudge => "pudge\100pobox.com",
37 rgs => "rgarciasuarez\100free.fr",
38 sky => "sky\100nanisky.com",
39 "abigail\100abigail.nl"=> "abigail\100foad.org",
40 "chromatic\100wgz.org" => "chromatic\100rmci.net",
41 "slaven\100rezic.de" => "slaven.rezic\100berlin.de",
42 "mjtg\100cam.ac.uk" => "mjtg\100cus.cam.ac.uk",
43 "robin.barker\100npl.co.uk" => "rmb1\100cise.npl.co.uk",
44 "paul.marquess\100btinternet.com"
45 => "paul_marquess\100yahoo.co.uk",
46 "wolfgang.laun\100chello.at" =>
47 "wolfgang.laun\100alcatel.at",
48 "t.jenness\100jach.hawaii.edu" => "timj\100jach.hawaii.edu",
49 "abe\100ztreet.demon.nl" => "abeltje\100cpan.org",
50 "perl_dummy\100bloodgate.com" => "tels\100bloodgate.com",
51 "jfriedl\100yahoo.com" => "jfriedl\100yahoo-inc.com",
52 "japhy\100pobox.com" => "japhy\100pobox.org",
53 "gellyfish\100gellyfish.com" => "jns\100gellyfish.com",
54 );
55
56# Make sure these are all lower case.
57
58$map{"alan.burlison\100uk.sun.com"} = "alanbur";
59$map{"artur\100contiller.se"} = $map{"arthur\100contiller.se"} = "sky";
60$map{"autrijus\100egb.elixus.org"} = $map{"autrijus\100geb.elixus.org"}
61 = "autrijus\100autrijus.org";
62$map{"craig.berry\100psinetcs.com"} = $map{"craig.berry\100metamorgs.com"}
63 = $map{"craig.berry\100signaltreesolutions.com"} = "craigberry\100mac.com";
64$map{"davem\100fdgroup.co.uk"} = "davem";
65$map{"ilya\100math.ohio-state.edu"} = $map{"ilya\100math.berkeley.edu"}
66 = $map{"ilya\100math.berkeley.edu"} = "nospam-abuse\100ilyaz.org";
67$map{"jhi\100kosh.hut.fi"} = $map{"jhi\100cc.hut.fi"} = "jhi";
68$map{"nick\100ccl4.org"} = $map{"nick\100talking.bollo.cx"}
69 = $map{"nick\100plum.flirble.org"} = $map{"nick\100babyhippo.co.uk"}
70 = $map{"nick\100bagpuss.unfortu.net"} = "nicholas";
71$map{"philip.newton\100gmx.net"} = $map{"philip.newton\100datenrevision.de"}
72 = "pnewton\100gmx.de",
73$map{"raphel.garcia-suarez\100hexaflux.com"} = "rgs";
74$map{"simon\100pembro4.pmb.ox.ac.uk"} = $map{"simon\100brecon.co.uk"}
75 = $map{"simon\100othersideofthe.earth.li"} = $map{"simon\100cozens.net"}
76 = $map{"simon\100netthink.co.uk"} = "simon\100simon-cozens.org";
77$map{"spider\100web.zk3.dec.com"} = $map{"spider\100leggy.zk3.dec.com"}
78 = $map{"spider-perl\100orb.nashua.nh.us"}
79 = $map{"spider\100peano.zk3.dec.com"}
80 = "spider\100orb.nashua.nh.us";
81$map{"nik\100tiuk.ti.com"} = "nick";
82
83$map{"a.koenig\100mind.de"} = "andreas.koenig\100anima.de";
84$map{"japhy\100perlmonk.org"} = $map{"japhy\100cpan.org"}
85 = "japhy\100pobox.com";
86$map{"rmbarker\100cpan.org"} = "robin.barker\100npl.co.uk";
87
88if (@authors) {
89 my %raw;
90 foreach my $filename (@authors) {
91 open FH, "<$filename" or die "Can't open $filename: $!";
92 while (<FH>) {
93 next if /^\#/;
94 next if /^-- /;
95 if (/<([^>]+)>/) {
96 # Easy line.
97 $raw{$1}++;
98 } elsif (/^([-A-Za-z0-9 .\'À-ÖØöø-ÿ]+)[\t\n]/) {
99 # Name only
100 $untraced{$1}++;
101 } else {
102 chomp;
103 warn "Can't parse line '$_'";
104 }
105 }
106 }
107 foreach (keys %raw) {
108 print "E-mail $_ occurs $raw{$_} times\n" if $raw{$_} > 1;
109 $_ = lc $_;
110 $authors{$map{$_} || $_}++;
111 }
112}
113
114while (<>) {
115 next if /^-+/;
116 if (m!^\[\s+(\d+)\]\s+By:\s+(\S+)\s+on!) {
117 # new patch
118 my @new = ($1, $2);
119 &process ($committer, $patch, $log);
120 ($patch, $committer) = @new;
121 undef $log;
122 } elsif (s/^(\s+Log: )//) {
123 die "Duplicate Log:" if $log;
124 $log = $_;
125 my $prefix = " " x length $1;
126 LOG: while (<>) {
127 if (s/^$prefix//) {
128 $log .= $_;
129 } elsif (/^\s+Branch:/) {
130 last LOG;
131 } else {
132 die "Malformed log end with $_";
133 }
134 }
135 }
136}
137
138&process ($committer, $patch, $log);
139
140if ($rank) {
141 &display_ordered;
142} elsif (%authors) {
143 my %missing;
144 foreach (sort keys %patchers) {
145 next if $authors{$_};
146 # Sort by number of patches, then name.
147 $missing{$patchers{$_}}->{$_}++;
148 }
149 foreach my $patches (sort {$b <=> $a} keys %missing) {
150 print "$patches patch(es)\n";
151 foreach my $author (sort keys %{$missing{$patches}}) {
152 print " $author\n";
153 }
154 }
155}
156
157sub display_ordered {
158 my @sorted;
159 while (my ($name, $count) = each %patchers) {
160 push @{$sorted[$count]}, $name;
161 }
162
163 my $i = @sorted;
164 while (--$i) {
165 next unless $sorted[$i];
166 print wrap ("$i:\t", "\t", join (" ", sort @{$sorted[$i]}), "\n");
167 }
168}
169
170sub process {
171 my ($committer, $patch, $log) = @_;
172 return unless $committer;
173 my @authors = $log =~ /From:.+\s+([^\@ \t\n]+\@[^\@ \t\n]+)/gm;
174
175 if (@authors) {
176 foreach (@authors) {
177 s/^<//;
178 s/>$//;
179 $_ = lc $_;
180 $patchers{$map{$_} || $_}++;
181 }
182 # print "$patch: @authors\n";
183 } else {
184 # print "$patch: $committer\n";
185 # Not entirely fair as this means that the maint pumpking scores for
186 # everything intergrated that wasn't a third party patch in blead
187 $patchers{$committer}++;
188 }
189}
190
191