Some escapes were mentioned twice, although they're not qr//-specific
[p5sagit/p5-mst-13.2.git] / Porting / checkAUTHORS.pl
1 #!/usr/bin/perl -w
2 use strict;
3 use Text::Wrap;
4 $Text::Wrap::columns = 80;
5 my ($committer, $patch, $log);
6 use Getopt::Long;
7
8 my ($rank, $percentage, $cumulative, $reverse, $ta, @authors, %authors,
9     %untraced, %patchers, %committers);
10 my $result = GetOptions ("rank" => \$rank,                  # rank authors
11                          "thanks-applied" => \$ta,          # ranks committers
12                          "acknowledged=s"   => \@authors ,  # authors files
13                          "percentage" => \$percentage,      # show as %age
14                          "cumulative" => \$cumulative,
15                          "reverse" => \$reverse,
16                         );
17
18 if (!$result or (($rank||0) + ($ta||0) + (@authors ? 1 : 0) != 1) or !@ARGV) {
19   die <<"EOS";
20 $0 --rank Changelogs                        # rank authors by patches
21 $0 --acknowledged <authors file> Changelogs # Display unacknowledged authors
22 $0 --thanks-applied Changelogs              # ranks committers
23 $0 --percentage ...                         # show rankings as percentages
24 $0 --cumulative ...                         # show rankings cumulatively
25 $0 --reverse ...                            # show rankings in reverse
26 Specify stdin as - if needs be. Remember that option names can be abbreviated.
27 EOS
28 }
29
30
31 my $prev = "";
32 my %map;
33
34 while (<DATA>) {
35     chomp;
36     s/\\100/\@/g;
37     $_ = lc;
38     if (my ($correct, $alias) = /^\s*([^#\s]\S*)\s+(.*\S)/) {
39         if ($correct eq '+') {$correct = $prev} else {$prev = $correct}
40         $map {$alias} = $correct;
41     }
42 }
43
44 #
45 # Email addresses for we do not have names.
46 #
47 $map {$_} = "?" for 
48     "alexander_bluhm\100genua.de",
49     "alexander_gernler\100genua.de",
50     "ammon\100rhythm.com",
51     "bah\100longitude.com",
52     "bbucklan\100jpl-devvax.jpl.nasa.gov",
53     "bilbo\100ua.fm",
54     "bob\100starlabs.net",
55     "bonefish\100cs.tu-berlin.de",
56     "bstrand\100switchmanagement.com",
57     "cygwin\100cygwin.com",
58     "david\100dhaller.de",
59     "dformosa\100dformosa.zeta.org.au",
60     "dgay\100acm.org",
61     "erik\100cs.uni-jena.de",
62     "glasser\100tang-eleven-seventy-nine.mit.edu",
63     "gml4410\100ggr.co.uk",
64     "grommel\100sears.com",
65     "ilya\100juil.nonet",
66     "info\100lingo.kiev.ua",
67     "jms\100mathras.comcast.net",
68     "kan\100dcit.cz",
69     "kaminsky\100math.huji.ac.il",
70     "knew-p5p\100pimb.org",
71     "kvr\100centrum.cz",
72     "mauzo\100csv.warwick.ac.uk",
73     "merijnb\100ms.com",
74     "mlelstv\100serpens.de",
75     "p.boven\100sara.nl",
76     "padre\100elte.hu",
77     "perlbug\100veggiechinese.net",
78     "pm\100capmon.dk",
79     "premchai21\100yahoo.com",
80     "pxm\100nubz.org",
81     "raf\100tradingpost.com.au",
82     "scott\100perlcode.org",
83     "smoketst\100hp46t243.cup.hp.com",
84     "yath-perlbug\100yath.de",
85 ;
86
87 #
88 # Email addresses for people that don't have an email address in AUTHORS
89 # Presumably deliberately?
90
91
92 $map {$_} = '!' for
93      # Nick Ing-Simmons has passed away (2006-09-25).
94      "nick\100ing-simmons.net",
95      "nik\100tiuk.ti.com",
96      "nick.ing-simmons\100elixent.com",
97
98      # Iain Truskett has passed away (2003-12-29).
99      "perl\100dellah.anu.edu.au",
100      "spoon\100dellah.org",
101      "spoon\100cpan.org",
102
103      # Ton Hospel
104      "me-02\100ton.iguana.be",
105      "perl-5.8.0\100ton.iguana.be",
106      "perl5-porters\100ton.iguana.be",
107
108      # Beau Cox
109      "beau\100beaucox.com",
110
111      # Randy W. Sims 
112      "ml-perl\100thepierianspring.org",
113
114      # Yuval Kogman
115      "nothingmuch\100woobling.org",
116
117 ;
118
119
120 if (@authors) {
121   my %raw;
122   foreach my $filename (@authors) {
123     open FH, "<$filename" or die "Can't open $filename: $!";
124     while (<FH>) {
125       next if /^\#/;
126       next if /^-- /;
127       if (/<([^>]+)>/) {
128         # Easy line.
129         $raw{$1}++;
130       } elsif (/^([-A-Za-z0-9 .\'À-ÖØöø-ÿ]+)[\t\n]/) {
131         # Name only
132         $untraced{$1}++;
133       } else {
134         chomp;
135         warn "Can't parse line '$_'";
136       }
137     }
138   }
139   foreach (keys %raw) {
140     print "E-mail $_ occurs $raw{$_} times\n" if $raw{$_} > 1;
141     $_ = lc $_;
142     $authors{$map{$_} || $_}++;
143   }
144   ++$authors{'!'};
145   ++$authors{'?'};
146 }
147
148 while (<>) {
149   next if /^-+/;
150   if (m!^\[\s+(\d+)\]\s+By:\s+(\S+)\s+on!) {
151     # new patch
152     my @new = ($1, $2);
153     &process ($committer, $patch, $log);
154     ($patch, $committer) = @new;
155     undef $log;
156   } elsif (s/^(\s+Log: )//) {
157     die "Duplicate Log:" if $log;
158     $log = $_;
159     my $prefix = " " x length $1;
160     LOG: while (<>) {
161       next if /^$/;
162       s/^\t/        /;
163       if (s/^$prefix//) {
164         $log .= $_;
165       } elsif (/^\s+Branch:/) {
166         last LOG;
167       } else {
168         chomp;
169         die "Malformed log end with '$_'";
170       }
171     }
172   }
173 }
174
175 &process ($committer, $patch, $log);
176
177 if ($rank) {
178   &display_ordered(\%patchers);
179 } elsif ($ta) {
180   &display_ordered(\%committers);
181 } elsif (%authors) {
182   my %missing;
183   foreach (sort keys %patchers) {
184     next if $authors{$_};
185     # Sort by number of patches, then name.
186     $missing{$patchers{$_}}->{$_}++;
187   }
188   foreach my $patches (sort {$b <=> $a} keys %missing) {
189     print "$patches patch(es)\n";
190     foreach my $author (sort keys %{$missing{$patches}}) {
191       print "  $author\n";
192     }
193   }
194 }
195
196 sub display_ordered {
197   my $what = shift;
198   my @sorted;
199   my $total;
200   while (my ($name, $count) = each %$what) {
201     push @{$sorted[$count]}, $name;
202     $total += $count;
203   }
204
205   my $i = @sorted;
206   return unless @sorted;
207   my $sum = 0;
208   foreach my $i ($reverse ? 0 .. $#sorted : reverse 0 .. $#sorted) {
209     next unless $sorted[$i];
210     my $prefix;
211     $sum += $i * @{$sorted[$i]};
212     # Value to display is either this one, or the cumulative sum.
213     my $value = $cumulative ? $sum : $i;
214     if ($percentage) {
215         $prefix = sprintf "%6.2f:\t", 100 * $value / $total;
216     } else {
217         $prefix = "$value:\t";
218     }
219     print wrap ($prefix, "\t", join (" ", sort @{$sorted[$i]}), "\n");
220   }
221 }
222
223 sub process {
224   my ($committer, $patch, $log) = @_;
225   return unless $committer;
226   my @authors = $log =~ /From:\s+.*?([^"\@ \t\n<>]+\@[^"\@ \t\n<>]+)/gm;
227
228   if (@authors) {
229     foreach (@authors) {
230       s/^<//;
231       s/>$//;
232       $_ = lc $_;
233       $patchers{$map{$_} || $_}++;
234     }
235     # print "$patch: @authors\n";
236     ++$committers{$committer};
237   } else {
238     # print "$patch: $committer\n";
239     # Not entirely fair as this means that the maint pumpking scores for
240     # everything intergrated that wasn't a third party patch in blead
241     $patchers{$committer}++;
242   }
243 }
244
245
246 __DATA__
247
248 #
249 # List of mappings. First entry the "correct" email address, as appears
250 # in the AUTHORS file. Second is any "alias" mapped to it.
251 #
252 # If the "correct" email address is a '+', the entry above is reused; 
253 # this for addresses with more than one alias.
254 #
255 # Note that all entries are in lowercase. Further, no '@' signs should
256 # appear; use \100 instead.
257 #
258 #
259 #  Committers.
260 #
261 adi                                     enache\100rdslink.ro
262 alanbur                                 alan.burlison\100sun.com
263 +                                       alan.burlison\100uk.sun.com
264 ams                                     ams\100wiw.org
265 chip                                    chip\100pobox.com
266 craigb                                  craig.berry\100psinetcs.com
267 +                                       craig.berry\100metamorgs.com
268 +                                       craig.berry\100signaltreesolutions.com
269 +                                       craigberry\100mac.com
270 davem                                   davem\100fdgroup.com
271 +                                       davem\100iabyn.nospamdeletethisbit.com
272 +                                       davem\100fdgroup.co.uk
273 +                                       davem\100fdisolutions.com
274 +                                       davem\100iabyn.com
275 demerphq                                demerphq\100gmail.com
276 +                                       yves.orton\100de.mci.com
277 +                                       yves.orton\100mciworldcom.de
278 doughera                                doughera\100lafayette.edu
279 gbarr                                   gbarr\100pobox.com
280 gisle                                   gisle\100activestate.com
281 +                                       gisle\100aas.no
282 gsar                                    gsar\100activestate.com
283 +                                       gsar\100cpan.org
284 hv                                      hv\100crypt.compulink.co.uk
285 +                                       hv\100crypt.org
286 jhi                                     jhi\100iki.fi
287 +                                       jhietaniemi\100gmail.com
288 +                                       jhi\100kosh.hut.fi
289 +                                       jhi\100cc.hut.fi
290 +                                       jarkko.hietaniemi\100nokia.com
291 merijn                                  h.m.brand\100xs4all.nl
292 +                                       h.m.brand\100hccnet.nl
293 +                                       merijn\100l1.procura.nl
294 mhx                                     mhx-perl\100gmx.net
295 nicholas                                nick\100unfortu.net
296 +                                       nick\100ccl4.org
297 +                                       nick\100talking.bollo.cx
298 +                                       nick\100plum.flirble.org
299 +                                       nick\100babyhippo.co.uk
300 +                                       nick\100bagpuss.unfortu.net
301 pudge                                   pudge\100pobox.com
302 rgs                                     rgarciasuarez\100free.fr
303 +                                       rgarciasuarez\100mandrakesoft.com
304 +                                       rgarciasuarez\100mandriva.com
305 +                                       rgarciasuarez\100gmail.com
306 +                                       raphel.garcia-suarez\100hexaflux.com
307 sky                                     sky\100nanisky.com
308 +                                       artur\100contiller.se
309 +                                       arthur\100contiller.se
310 steveh                                  stevehay\100planit.com
311 +                                       steve.hay\100uk.radan.com
312 stevep                                  steve\100fisharerojo.org
313 +                                       steve.peters\100gmail.com
314
315 #
316 # Mere mortals.
317 #
318 7k8lrvf02\100sneakemail.com             kjx9zthh3001\100sneakemail.com
319 +                                       dtr8sin02\100sneakemail.com
320 +                                       rt8363b02\100sneakemail.com
321 +                                       o6hhmk002\100sneakemail.com
322
323 abe\100ztreet.demon.nl                  abeltje\100cpan.org
324 abigail\100abigail.be                   abigail\100foad.org
325 +                                       abigail\100abigail.nl
326 ajohnson\100nvidia.com                  ajohnson\100wischip.com
327 alexm\100netli.com                      alexm\100w-m.ru
328 alian\100cpan.org                       alian\100alianwebserver.com
329 allens\100cpan.org                      easmith\100beatrice.rutgers.edu
330 andreas.koenig\100anima.de        andreas.koenig.gmwojprw\100franz.ak.mind.de
331 +                                 andreas.koenig.7os6vvqr\100franz.ak.mind.de
332 +                                       a.koenig\100mind.de
333 anno4000\100lublin.zrz.tu-berlin.de     anno4000\100mailbox.tu-berlin.de
334 +                                       siegel\100zrz.tu-berlin.de
335 ash\100cpan.org                         ash_cpan\100firemirror.com
336 avarab\100gmail.com                     avar\100cpan.org
337
338 bah\100ecnvantage.com                   bholzman\100longitude.com
339 bcarter@gumdrop.flyinganvil.org         q.eibcartereio.=~m-b.{6}-cgimosx@gumdrop.flyinganvil.org
340 ben_tilly\100operamail.com              btilly\100gmail.com
341
342 chromatic\100wgz.org                    chromatic\100rmci.net
343 clkao\100clkao.org                      clkao\100bestpractical.com
344 cp\100onsitetech.com                    publiustemp-p5p\100yahoo.com
345 +                                       publiustemp-p5p3\100yahoo.com
346 cpan\100audreyt.org                     autrijus\100egb.elixus.org
347 +                                       autrijus\100geb.elixus.org
348 +                                       autrijus\100gmail.com
349 +                                       autrijus\100ossf.iis.sinica.edu.tw
350 +                                       autrijus\100autrijus.org
351 +                                       audreyt\100audreyt.org
352
353 damian\100cs.monash.edu.au              damian\100conway.org
354 david.dyck\100fluke.com                 dcd\100tc.fluke.com
355 demerphq\100gmail.com                   demerphq\100hotmail.com
356 domo\100computer.org                    shouldbedomo\100mac.com
357
358 epeschko\100den-mdev1                   esp5\100pge.com
359
360 fugazi\100zyx.net                       larrysh\100cpan.org
361
362 gellyfish\100gellyfish.com              jns\100gellyfish.com
363 gp\100familiehaase.de                   gerrit\100familiehaase.de
364 grazz\100pobox.com                      grazz\100nyc.rr.com
365
366 hio\100ymir.co.jp                       hio\100hio.jp
367
368 japhy\100pobox.com                      japhy\100pobox.org
369 +                                       japhy\100perlmonk.org
370 +                                       japhy\100cpan.org
371 jari.aalto\100poboxes.com               jari.aalto\100cante.net
372 jcromie\100divsol.com                   jcromie\100cpan.org
373 +                                       jim.cromie\100gmail.com
374 jdhedden\100cpan.org                    jerry\100hedden.us
375 +                                       jdhedden\1001979.usna.com
376 +                                       jdhedden\100gmail.com
377 +                                       jdhedden\100yahoo.com
378 jfriedl\100yahoo.com                    jfriedl\100yahoo-inc.com
379 jjore\100cpan.org                       twists\100gmail.com
380 juerd\100cpan.org                       juerd\100convolution.nl
381
382 kane\100dwim.org                        kane\100xs4all.net
383 +                                       kane\100cpan.org
384 +                                       kane\100xs4all.nl
385 +                                       jos\100dwim.org
386 +                                       jib\100ripe.net
387 kroepke\100dolphin-services.de          kay\100dolphin-services.de
388 kstar\100wolfetech.com                  kstar\100cpan.org
389
390 mats\100sm6sxl.net                      mats\100sm5sxl.net
391 mbarbon\100dsi.unive.it                 mattia.barbon\100libero.it
392 mcmahon\100ibiblio.org                  mcmahon\100metalab.unc.edu
393 merijnb\100iloquent.nl                  merijnb\100iloquent.com
394 mgjv\100comdyn.com.au                   mgjv\100tradingpost.com.au
395 michael.schroeder\100informatik.uni-erlangen.de mls\100suse.de
396 mike\100stok.co.uk                      mike\100exegenix.com
397 mjtg\100cam.ac.uk                       mjtg\100cus.cam.ac.uk
398
399 nospam-abuse\100bloodgate.com           tels\100bloodgate.com
400 +                                       perl_dummy\100bloodgate.com
401 nospam-abuse\100ilyaz.org               ilya\100math.ohio-state.edu
402 +                                       ilya\100math.berkeley.edu
403 +                                       ilya\100math.berkeley.edu
404
405 p5-authors\100crystalflame.net          perl\100crystalflame.net
406 +                                       rs\100crystalflame.net
407 paul.green\100stratus.com               paul_greenvos\100vos.stratus.com
408 paul.marquess\100btinternet.com         paul_marquess\100yahoo.co.uk
409 +                                       paul.marquess\100ntlworld.com
410 +                                       paul.marquess\100openwave.com
411 pcg\100goof.com                         schmorp\100schmorp.de
412 # Maybe we should special case this to get real names out?
413 perlbug\100perl.org                     perlbug-followup\100perl.org
414 +                                       bugs-perl5\100bugs6.perl.org
415 phil\100perkpartners.com                phil\100finchcomputer.com
416 pimlott\100idiomtech.com                andrew\100pimlott.net
417 pne\100cpan.org                         philip.newton\100gmx.net
418 +                                       philip.newton\100datenrevision.de
419 +                                       pnewton\100gmx.de
420
421 radu\100netsoft.ro                      rgreab\100fx.ro
422 richard.foley\100ubsw.com               richard.foley\100t-online.de
423 +                                       richard.foley\100ubs.com
424 +                                       richard.foley\100rfi.net
425 rick\100consumercontact.com             rick\100bort.ca
426 +                                       rick.delaney\100rogers.com
427 rjk\100linguist.dartmouth.edu           rjk\100linguist.thayer.dartmouth.edu
428 +                                       rjk-perl-p5p\100tamias.net
429 rmgiroux\100acm.org                     rmgiroux\100hotmail.com
430 robin.barker\100npl.co.uk               rmb1\100cise.npl.co.uk
431 +                                       rmbarker\100cpan.org
432 rootbeer\100teleport.com                rootbeer\100redcat.com
433
434 schubiger\100cpan.org                   steven\100accognoscere.org
435 +                                       sts\100accognoscere.org
436 schwern\100pobox.com                    schwern\100gmail.com
437 sebastien\100aperghis.net               maddingue\100free.fr
438 +                                       saper\100cpan.org
439 simon\100simon-cozens.org               simon\100pembro4.pmb.ox.ac.uk
440 +                                       simon\100brecon.co.uk
441 +                                       simon\100othersideofthe.earth.li
442 +                                       simon\100cozens.net
443 +                                       simon\100netthink.co.uk
444 slaven\100rezic.de                      slaven.rezic\100berlin.de
445 +                                       (srezic\100iconmobile.com)
446 smcc\100mit.edu                         smcc\100ocf.berkeley.edu
447 +                                       smcc\100csua.berkeley.edu
448 spider\100orb.nashua.nh.us              spider\100web.zk3.dec.com
449 +                                       spider\100leggy.zk3.dec.com
450 +                                       spider-perl\100orb.nashua.nh.us
451 +                                       spider\100peano.zk3.dec.com
452 stef\100mongueurs.net                   stef\100payrard.net
453 +                                       s.payrard\100wanadoo.fr
454
455 tassilo.parseval\100post.rwth-aachen.de tassilo.von.parseval\100rwth-aachen.de
456 thomas.dorner\100start.de               tdorner\100amadeus.net
457 tjenness\100cpan.org                    t.jenness\100jach.hawaii.edu
458 +                                       timj\100jach.hawaii.edu
459 tom.horsley\100mail.ccur.com            tom.horsley\100ccur.com
460
461 vkonovalov\100lucent.com                vkonovalov\100peterstar.ru
462 +                                       konovalo\100mail.wplus.net
463 +                                       vadim\100vkonovalov.ru
464 +                                       vkonovalov\100spb.lucent.com
465 +                                       vkonovalov\100alcatel-lucent.com
466
467 whatever\100davidnicol.com              davidnicol\100gmail.com
468 wolfgang.laun\100alcatel.at             wolfgang.laun\100chello.at
469 +                                       wolfgang.laun\100thalesgroup.com
470 +                                       wolfgang.laun\100gmail.com