1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/usr/bin/perl -w
################################################################################
#
# scanprov -- scan Perl headers for provided macros
#
################################################################################
#
# Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
# Version 2.x, Copyright (C) 2001, Paul Marquess.
# Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
################################################################################
use strict;
use Getopt::Long;
require './parts/ppptools.pl';
our %opt = (
mode => 'check',
install => '/tmp/perl/install/default',
blead => 'bleadperl',
);
GetOptions(\%opt, qw( install=s mode=s blead=s )) or die;
my $write = $opt{mode} eq 'write';
my %embed = map { ( $_->{name} => 1 ) }
parse_embed(qw(parts/embed.fnc parts/apidoc.fnc parts/ppport.fnc ));
my @provided = grep { !exists $embed{$_} }
map { /^(\w+)/ ? $1 : () }
`$^X ppport.h --list-provided`;
my @perls = sort { $b->{version} <=> $a->{version} }
map { { version => `$_ -e 'printf "%.6f", \$]'`, path => $_ } }
($opt{blead}, glob "$opt{install}/*/bin/perl5.*");
for (1 .. $#perls) {
$perls[$_]{todo} = $perls[$_-1]{version};
}
shift @perls;
my %v;
for my $p (@perls) {
print "checking perl $p->{version}...\n";
my $archlib = `$p->{path} -MConfig -l -e 'print \$Config{archlib}'`;
chomp $archlib;
local @ARGV = glob "$archlib/CORE/*.h";
my %sym;
while (<>) { $sym{$_}++ for /(\w+)/g; }
@provided = map { $sym{$_} or $v{$p->{todo}}{$_}++; $sym{$_} ? $_ : () } @provided;
}
my $out = 'parts/base';
my $todo = parse_todo($out);
for my $v (keys %v) {
my @new = sort grep { !exists $todo->{$_} } keys %{$v{$v}};
@new or next;
my $file = $v;
$file =~ s/\.//g;
$file = "$out/$file";
-e $file or die "non-existent: $file\n";
print "-- $file --\n";
$write and (open F, ">>$file" or die "$file: $!\n");
for (@new) {
print "adding $_\n";
$write and printf F "%-30s # added by $0\n", $_;
}
$write and close F;
}
|