line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
19429
|
use 5.006; |
|
4
|
|
|
|
|
9
|
|
2
|
4
|
|
|
4
|
|
14
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
76
|
|
3
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
411
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Gentoo::PerlMod::Version::Error; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.8.0'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Various error message and diagnostic bits. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
11
|
for my $env (qw( opts hasopt getopt )) { |
16
|
|
|
|
|
|
|
my $code = sub { |
17
|
18
|
|
|
18
|
|
637
|
require Gentoo::PerlMod::Version::Env; |
18
|
18
|
|
|
|
|
69
|
my $sub = Gentoo::PerlMod::Version::Env->can($env); |
19
|
18
|
|
|
|
|
39
|
goto $sub; |
20
|
12
|
|
|
|
|
24
|
}; |
21
|
|
|
|
|
|
|
## no critic ( ProhibitNoStrict ) |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
|
13
|
no strict 'refs'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
165
|
|
24
|
12
|
|
|
|
|
8
|
*{ __PACKAGE__ . '::_env_' . $env } = $code; |
|
12
|
|
|
|
|
1946
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub perlver_undefined { |
38
|
2
|
|
|
2
|
1
|
972
|
my ($config) = @_; |
39
|
|
|
|
|
|
|
## no critic ( RequireInterpolationOfMetachars ) |
40
|
2
|
|
|
|
|
14
|
return _fatal( |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
code => 'perlver_undefined', |
43
|
|
|
|
|
|
|
config => $config, |
44
|
|
|
|
|
|
|
message => 'Argument \'$perlver\' to gentooize_version was undefined', |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub matches_trial_regex_nonlax { |
56
|
3
|
|
|
3
|
1
|
2203
|
my ( $perlver, $config, ) = @_; |
57
|
3
|
|
|
|
|
24
|
return _fatal( |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
code => 'matches_trial_regex_nonlax', |
60
|
|
|
|
|
|
|
config => $config, |
61
|
|
|
|
|
|
|
want_lax => 1, |
62
|
|
|
|
|
|
|
message => 'Invalid version format (non-numeric data, either _ or -TRIAL ).', |
63
|
|
|
|
|
|
|
message_extra_tainted => qq{ Version: >$perlver< }, |
64
|
|
|
|
|
|
|
version => $perlver, |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub not_decimal_or_trial { |
76
|
3
|
|
|
3
|
1
|
2379
|
my ( $perlver, $config ) = @_; |
77
|
3
|
|
|
|
|
22
|
return _fatal( |
78
|
|
|
|
|
|
|
{ |
79
|
|
|
|
|
|
|
code => 'not_decimal_or_trial', |
80
|
|
|
|
|
|
|
config => $config, |
81
|
|
|
|
|
|
|
want_lax => 2, |
82
|
|
|
|
|
|
|
message => 'Invalid version format (non-numeric/ASCII data).', |
83
|
|
|
|
|
|
|
message_extra_tainted => qq{ Version: >$perlver< }, |
84
|
|
|
|
|
|
|
version => $perlver, |
85
|
|
|
|
|
|
|
}, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub bad_char { |
96
|
2
|
|
|
2
|
1
|
2303
|
my ( $char, $char_ord ) = @_; |
97
|
2
|
|
|
|
|
16
|
return _fatal( |
98
|
|
|
|
|
|
|
{ |
99
|
|
|
|
|
|
|
code => 'bad_char', |
100
|
|
|
|
|
|
|
message => 'A Character in the version is not in the ascii-to-int translation table.', |
101
|
|
|
|
|
|
|
message_extra_tainted => qq{ Missing character: $char ( $char_ord )}, |
102
|
|
|
|
|
|
|
}, |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub lax_multi_underscore { |
113
|
2
|
|
|
2
|
1
|
1639
|
my ($version) = @_; |
114
|
2
|
|
|
|
|
15
|
return _fatal( |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
code => 'lax_multi_underscore', |
117
|
|
|
|
|
|
|
message => q{More than one _ in a version is not permitted}, |
118
|
|
|
|
|
|
|
message_extra_tainted => qq{ Version: >$version< }, |
119
|
|
|
|
|
|
|
version => $version, |
120
|
|
|
|
|
|
|
}, |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
# |
124
|
|
|
|
|
|
|
# _format_error({ |
125
|
|
|
|
|
|
|
# code => "some_string", |
126
|
|
|
|
|
|
|
# message => "Some message" |
127
|
|
|
|
|
|
|
# message_extra_tainted => "And $tainted " # extra data for non-taint-safe envs. |
128
|
|
|
|
|
|
|
# want_lax => n # optional |
129
|
|
|
|
|
|
|
# }) |
130
|
|
|
|
|
|
|
# |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub _format_error { |
133
|
9
|
|
|
9
|
|
3153
|
my ($conf) = @_; |
134
|
9
|
|
|
|
|
15
|
my $message = $conf->{message}; |
135
|
9
|
100
|
|
|
|
26
|
if ( exists $conf->{want_lax} ) { |
136
|
4
|
|
|
|
|
5
|
my $lax = $conf->{want_lax}; |
137
|
4
|
|
|
|
|
10
|
$message .= qq{\n Set { lax => $lax } for more permissive behaviour. }; |
138
|
|
|
|
|
|
|
} |
139
|
9
|
50
|
|
|
|
20
|
if ( _env_hasopt('taint_safe') ) { |
140
|
0
|
|
|
|
|
0
|
return $message; |
141
|
|
|
|
|
|
|
} |
142
|
9
|
50
|
|
|
|
18
|
if ( _env_hasopt('carp_debug') ) { |
143
|
0
|
|
|
|
|
0
|
$conf->{env_config} = _env_opts; |
144
|
0
|
|
|
|
|
0
|
require Data::Dumper; |
145
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Indent = 2; |
146
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Purity = 0; |
147
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Useqq = 1; |
148
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Terse = 1; |
149
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Quotekeys = 0; |
150
|
0
|
|
|
|
|
0
|
return Data::Dumper::Dumper($conf); |
151
|
|
|
|
|
|
|
} |
152
|
9
|
100
|
|
|
|
51
|
if ( exists $conf->{'message_extra_tainted'} ) { |
153
|
7
|
|
|
|
|
14
|
$message .= $conf->{'message_extra_tainted'}; |
154
|
|
|
|
|
|
|
} |
155
|
9
|
50
|
|
|
|
18
|
if ( exists $conf->{'stack'} ) { |
156
|
9
|
|
|
|
|
10
|
for ( @{ $conf->{stack} } ) { |
|
9
|
|
|
|
|
23
|
|
157
|
28
|
100
|
|
|
|
95
|
if ( $_->[0] !~ /\AGentoo::PerlMod::Version(?:|::Error|::Env)\z/msx ) { |
158
|
9
|
|
50
|
|
|
74
|
$message .= sprintf qq[\n - From %s in %s at line %s\n], $_->[0] || q[], $_->[1] || q[], $_->[2] || q[]; |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
159
|
9
|
|
|
|
|
15
|
last; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
} |
163
|
9
|
|
|
|
|
76
|
return $message; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
4
|
|
|
4
|
|
2031
|
use overload q[""] => \&_format_error; |
|
4
|
|
|
|
|
1580
|
|
|
4
|
|
|
|
|
28
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub _fatal { |
169
|
7
|
|
|
7
|
|
10
|
my ($conf) = @_; |
170
|
7
|
|
|
|
|
24
|
require Carp; |
171
|
|
|
|
|
|
|
$conf->{stack} = [ |
172
|
77
|
|
|
|
|
119
|
map { [ $_->[0], $_->[1], $_->[2], ] } |
173
|
7
|
|
|
|
|
16
|
map { [ caller $_, ] } 0 .. 10, |
|
77
|
|
|
|
|
320
|
|
174
|
|
|
|
|
|
|
]; |
175
|
7
|
|
|
|
|
218
|
return Carp::croak( bless $conf, __PACKAGE__ ); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
__END__ |