blob: 95ec93010e56f2304f86ed399a71ba8edc4a24fb (
plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
#!/usr/local/bin/perl
#
# $FML: show_hierarchy.pl,v 1.2 2001/08/19 16:11:28 fukachan Exp $
#
use lib qw(./lib/3RDPARTY ./lib/fml5 ./lib/CPAN ./lib);
use strict;
use vars qw($Count %Count $debug $verbose %IgnoreList);
%IgnoreList = (
'Carp' => 1,
'Exporter' => 1,
'FileHandle' => 1,
'DynaLoader' => 1,
'AutoLoader' => 1,
);
for (@ARGV) { load( $_ );}
sub load
{
my ($f) = @_;
my $name = $f;
return if $IgnoreList{ $name };
$Count++;
if ($Count > 32) { die("infinite loop!\n");}
$f =~ s@::@/@g;
for my $dir (@INC) {
if (-f "$dir/$f.pm") {
$f = "$dir/$f.pm";
last;
}
if (-f "$dir/$f.pl") {
$f = "$dir/$f.pl";
last;
}
}
unless (-f $f) {
P( "not found: $f" ) if $debug;;
$Count--;
return;
}
if ( $Count{ $f } ) {
P( "$f is recursive" ) if $debug;;
$Count--;
return;
}
else {
$Count{ $f } = 1;
}
use FileHandle;
my $fh = new FileHandle $f;
print "--- open $f\n" if $debug;
### dynamic scope to count up recursive conditions
local(%Count) if $Count == 2;
if (defined $fh) {
my $file = '';
my $comment = '';
my $current_function = '';
my %function_hach = ();
my $pat = '$0 eq __FILE__';
while (<$fh>) {
last if /$pat/;
last if /__END__/;
next if /^\s*\#/;
next if /^\s*Log/;
# ignore comments
$comment = 1 if /^=/;
$comment = 0 if /^=cut/;
next if $comment;
chop;
if (/^sub (\S+)/) {
$current_function = $1;
}
# ignore these since they are too many.
if (/(use|require)\s+(Carp|Exporter|DynaLoader|AutoLoader)/) {
next;
}
if (/(use|require)\s+([A-Z]\S+[a-zA-Z0-9])/) {
unless ( $function_hach{ $current_function } ) {
if ($verbose) {
&Print();
&Print( "${name}::". $current_function );
}
$function_hach{ $current_function } = 1;
}
&Print() if $Count == 1;
&Print() if $Count == 2;
$verbose ? &Print( $_ , $. ) : &Print( $_ );
$file = $2;
$file =~ s/\"//g;
$file =~ s/\'//g;
if ($file =~ /^[a-z]/) {
;
}
else {
P( "\t($Count)load $file" ) if $debug;
load($file);
}
}
}
$fh->close if defined $fh;
}
$Count--;
}
sub Print
{
my ($s, $lc) = @_;
$s =~ s/^\s+//o;
print " " x ( $Count - 1 );
printf "%4d> ", $lc if $lc;
print $s, "\n";
}
1;
|