This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
prctl needs unistd on Android
[metaconfig.git] / bin / diff2unit.pl
CommitLineData
f83b5b07
MB
1#!/pro/bin/perl
2
3use strict;
4use warnings;
5
6use File::Find;
7
8print STDERR "Reading Units ...";
9my (%U, %P);
10local $/ = undef;
11find (sub {
12 -f && m/\.U$/ or return;
13 -l and return;
14 my $pri = 0;
15 $File::Find::dir =~ m:^metaconfig/dist-3.0at70b: and $pri = 1;
16 $File::Find::dir =~ m:^metaconfig/U: and $pri = 2;
17 exists $U{$_} && $pri < $P{$_} and return;
18 open my $U, "< $_" or die "$_: $!";
19 $P{$_} = $pri;
20 $U{$_} = [ $File::Find::name, <$U> ];
21 }, "metaconfig");
22my @U = sort keys %U;
23print STDERR "\b\b\b", scalar @U, "\n";
24
25for (@ARGV) {
26 s:^(\d\d)(\d+)$:gzcat perl-current-diffs/${1}000/$1$2.gz |:;
27 }
28
29my $patch_nr = 0;
30local $/ = "\n+++";
31while (<>) {
32 if (m/^Change (\d+) by/) {
33 $patch_nr = $1;
34 next;
35 }
36 m:^ perl/Configure\b: or next;
37 print STDERR "Patch accepted ...\n";
38 s:End of Patch\b.*::;
39
40 my $part = 0;
41 foreach my $patch (split m:\@\@[-\s\d,+]+\@\@\n:) {
42 $patch =~ m:^ perl/Configure\b: and next;
43 my $org = join "\n", grep s/^[- ]//, split m/\n/, $patch;
44 print STDERR "Search for:\n--8<---\n$org\n-->8---\n";
45 my @units;
46 foreach my $U (@U) {
47 index ($U{$U}[1], $org) >= 0 and push @units, $U{$U}[0];
48 }
49 printf "%5d/%03d %s\n", $patch_nr, ++$part, join ", ", @units;
50 }
51 }