| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
WWW::Link::Reporter::Compile - report link errors suitably for use in emacs |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use WWW::Link; |
|
8
|
|
|
|
|
|
|
use WWW::Link::Reporter::Compile; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$link=new WWW::Link; |
|
11
|
|
|
|
|
|
|
#over time do things to the link ...... |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$::reporter=new WWW::Link::Reporter::Compile; |
|
14
|
|
|
|
|
|
|
$::reporter->examine($link) |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
or see WWW::Link::Selector for a way to recurse through all of the links. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This is designed for reporting errors in a specific file. It prints |
|
21
|
|
|
|
|
|
|
out an report which is suitable for use by emacs' compile mode. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package WWW::Link::Reporter::Compile; |
|
26
|
|
|
|
|
|
|
$REVISION=q$Revision: 1.8 $ ; $VERSION = sprintf ( "%d.%02d", $REVISION =~ /(\d+).(\d+)/ ); |
|
27
|
1
|
|
|
1
|
|
841
|
use WWW::Link::Reporter; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
21
|
|
|
28
|
1
|
|
|
1
|
|
864
|
use English; |
|
|
1
|
|
|
|
|
5846
|
|
|
|
1
|
|
|
|
|
8
|
|
|
29
|
|
|
|
|
|
|
@ISA = qw(WWW::Link::Reporter); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub broken { |
|
32
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
33
|
0
|
|
|
|
|
|
my $link=shift; |
|
34
|
0
|
|
|
|
|
|
my $url=$link->url(); |
|
35
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
36
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
37
|
0
|
|
|
|
|
|
print "$filename:$INPUT_LINE_NUMBER: broken link $url\n"; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 okay |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
I don't see any reason to call the okay function.. however for |
|
43
|
|
|
|
|
|
|
information? We avoid giving a line number so that this doesn't stop |
|
44
|
|
|
|
|
|
|
emacs compile. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub okay { |
|
49
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
50
|
0
|
|
|
|
|
|
my $link=shift; |
|
51
|
0
|
|
|
|
|
|
my $redir=shift; |
|
52
|
0
|
|
|
|
|
|
my $url=$link->url(); |
|
53
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
54
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
55
|
0
|
0
|
|
|
|
|
$redir && print "$filename:$INPUT_LINE_NUMBER: "; |
|
56
|
0
|
|
|
|
|
|
print "tested okay $url\n"; |
|
57
|
0
|
0
|
|
|
|
|
$redir && $self->redirections($link); |
|
58
|
0
|
|
|
|
|
|
$self->suggestions($link); |
|
59
|
0
|
|
|
|
|
|
return 1; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub damaged { |
|
63
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
64
|
0
|
|
|
|
|
|
my $link=shift; |
|
65
|
0
|
|
|
|
|
|
my $redir=shift; |
|
66
|
0
|
|
|
|
|
|
my $url=$link->url(); |
|
67
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
68
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
69
|
0
|
|
|
|
|
|
print "$filename:$INPUT_LINE_NUMBER: _may_ be broken link $url\n"; |
|
70
|
0
|
0
|
|
|
|
|
$redir && $self->redirections($link); |
|
71
|
0
|
|
|
|
|
|
$self->suggestions($link); |
|
72
|
0
|
|
|
|
|
|
return 1; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub not_checked { |
|
76
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
77
|
0
|
|
|
|
|
|
my $link=shift; |
|
78
|
0
|
|
|
|
|
|
my $url=$link->url(); |
|
79
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
80
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
81
|
0
|
|
|
|
|
|
print "$filename:$INPUT_LINE_NUMBER: have not yet checked $url\n"; |
|
82
|
0
|
|
|
|
|
|
$self->suggestions($link); |
|
83
|
0
|
|
|
|
|
|
return 1; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub disallowed { |
|
87
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
88
|
0
|
|
|
|
|
|
my $link=shift; |
|
89
|
0
|
|
|
|
|
|
my $url=$link->url(); |
|
90
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
91
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
92
|
0
|
|
|
|
|
|
print "$filename:$INPUT_LINE_NUMBER: checking of link not allowed $url\n"; |
|
93
|
0
|
|
|
|
|
|
$self->suggestions($link); |
|
94
|
0
|
|
|
|
|
|
return 1; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub unsupported { |
|
98
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
99
|
0
|
|
|
|
|
|
my $link=shift; |
|
100
|
0
|
|
|
|
|
|
my $url=$link->url(); |
|
101
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
102
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
103
|
0
|
|
|
|
|
|
print "$filename:$INPUT_LINE_NUMBER: link uses unsupported protocol $url\n"; |
|
104
|
0
|
|
|
|
|
|
$self->suggestions($link); |
|
105
|
0
|
|
|
|
|
|
return 1; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub unknown { |
|
109
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
110
|
0
|
|
|
|
|
|
my $link=shift; |
|
111
|
0
|
|
|
|
|
|
my $url=$link->url(); |
|
112
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
113
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
114
|
0
|
|
|
|
|
|
print "$filename:$INPUT_LINE_NUMBER: unknown link status; error?? $url\n"; |
|
115
|
0
|
|
|
|
|
|
$self->suggestions($link); |
|
116
|
0
|
|
|
|
|
|
return 1; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub not_found { |
|
120
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
121
|
0
|
|
|
|
|
|
my $url=shift; |
|
122
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
123
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
124
|
0
|
|
|
|
|
|
print "$filename:$INPUT_LINE_NUMBER: no info for $url\n"; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub invalid { |
|
128
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
129
|
0
|
|
|
|
|
|
my $url=shift; |
|
130
|
0
|
|
|
|
|
|
my $filename=$self->filename(); |
|
131
|
0
|
0
|
|
|
|
|
$INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER; |
|
132
|
0
|
|
|
|
|
|
print "$filename:$INPUT_LINE_NUMBER: non valid url $url\n"; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub redirections { |
|
136
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
137
|
0
|
|
|
|
|
|
my $link=shift; |
|
138
|
0
|
|
|
|
|
|
my @redirects=$link->redirect_urls(); |
|
139
|
0
|
|
|
|
|
|
foreach my $redir ( @redirects ) { |
|
140
|
0
|
|
|
|
|
|
print " redirected to $redir\n"; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub suggestions { |
|
145
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
146
|
0
|
|
|
|
|
|
my $link=shift; |
|
147
|
0
|
|
|
|
|
|
my $suggestions=$link->fix_suggestions(); |
|
148
|
0
|
0
|
|
|
|
|
if ($suggestions) { |
|
149
|
0
|
|
|
|
|
|
foreach $suggest ( @{$suggestions} ) { |
|
|
0
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
print " suggest $suggest\n"; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
} |
|
153
|
0
|
|
|
|
|
|
return 1; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 filename |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The filename function can be called with one argument to set the |
|
159
|
|
|
|
|
|
|
filename or will return the current idea of the filename if none is |
|
160
|
|
|
|
|
|
|
given. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Until the filename is set, filename will return the current contents |
|
163
|
|
|
|
|
|
|
of C<$ARGV>. After it has been set it will return whatever value was |
|
164
|
|
|
|
|
|
|
last given. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub filename { |
|
169
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
|
170
|
0
|
|
|
|
|
|
my $name=shift; |
|
171
|
0
|
0
|
|
|
|
|
$self->{filename}=$name if defined $name; |
|
172
|
0
|
0
|
|
|
|
|
return $self->{filename} if defined $self->{filename}; |
|
173
|
0
|
0
|
|
|
|
|
return $ARGV if defined $ARGV; |
|
174
|
0
|
|
|
|
|
|
return "unknown file"; |
|
175
|
|
|
|
|
|
|
} |