line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
18994
|
use 5.006; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
148
|
|
2
|
4
|
|
|
4
|
|
17
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
121
|
|
3
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
486
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Gentoo::PerlMod::Version::Error; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.7.1'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Various error message and diagnostic bits. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
8
|
for my $env (qw( opts hasopt getopt )) { |
16
|
|
|
|
|
|
|
my $code = sub { |
17
|
18
|
|
|
18
|
|
529
|
require Gentoo::PerlMod::Version::Env; |
18
|
18
|
|
|
|
|
68
|
my $sub = Gentoo::PerlMod::Version::Env->can($env); |
19
|
18
|
|
|
|
|
35
|
goto $sub; |
20
|
12
|
|
|
|
|
31
|
}; |
21
|
|
|
|
|
|
|
## no critic ( ProhibitNoStrict ) |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
|
19
|
no strict 'refs'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
163
|
|
24
|
12
|
|
|
|
|
10
|
*{ __PACKAGE__ . '::_env_' . $env } = $code; |
|
12
|
|
|
|
|
2057
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub perlver_undefined { |
38
|
2
|
|
|
2
|
1
|
541
|
my ($config) = @_; |
39
|
|
|
|
|
|
|
## no critic ( RequireInterpolationOfMetachars ) |
40
|
2
|
|
|
|
|
12
|
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
|
1576
|
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
|
1790
|
my ( $perlver, $config ) = @_; |
77
|
3
|
|
|
|
|
18
|
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
|
1719
|
my ( $char, $char_ord ) = @_; |
97
|
2
|
|
|
|
|
14
|
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
|
1140
|
my ($version) = @_; |
114
|
2
|
|
|
|
|
13
|
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
|
|
1878
|
my ($conf) = @_; |
134
|
9
|
|
|
|
|
13
|
my $message = $conf->{message}; |
135
|
9
|
100
|
|
|
|
23
|
if ( exists $conf->{want_lax} ) { |
136
|
4
|
|
|
|
|
4
|
my $lax = $conf->{want_lax}; |
137
|
4
|
|
|
|
|
9
|
$message .= qq{\n Set { lax => $lax } for more permissive behaviour. }; |
138
|
|
|
|
|
|
|
} |
139
|
9
|
50
|
|
|
|
16
|
if ( _env_hasopt('taint_safe') ) { |
140
|
0
|
|
|
|
|
0
|
return $message; |
141
|
|
|
|
|
|
|
} |
142
|
9
|
50
|
|
|
|
16
|
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
|
|
|
|
42
|
if ( exists $conf->{'message_extra_tainted'} ) { |
153
|
7
|
|
|
|
|
13
|
$message .= $conf->{'message_extra_tainted'}; |
154
|
|
|
|
|
|
|
} |
155
|
9
|
50
|
|
|
|
18
|
if ( exists $conf->{'stack'} ) { |
156
|
9
|
|
|
|
|
8
|
for ( @{ $conf->{stack} } ) { |
|
9
|
|
|
|
|
16
|
|
157
|
28
|
100
|
|
|
|
88
|
if ( $_->[0] !~ /\AGentoo::PerlMod::Version(?:|::Error|::Env)\z/msx ) { |
158
|
9
|
|
50
|
|
|
63
|
$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
|
|
|
|
|
49
|
return $message; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
4
|
|
|
4
|
|
2039
|
use overload q[""] => \&_format_error; |
|
4
|
|
|
|
|
1695
|
|
|
4
|
|
|
|
|
31
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub _fatal { |
169
|
7
|
|
|
7
|
|
7
|
my ($conf) = @_; |
170
|
7
|
|
|
|
|
23
|
require Carp; |
171
|
77
|
|
|
|
|
117
|
$conf->{stack} = [ |
172
|
77
|
|
|
|
|
260
|
map { [ $_->[0], $_->[1], $_->[2], ] } |
173
|
7
|
|
|
|
|
11
|
map { [ caller $_, ] } 0 .. 10, |
174
|
|
|
|
|
|
|
]; |
175
|
7
|
|
|
|
|
193
|
return Carp::croak( bless $conf, __PACKAGE__ ); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
__END__ |