lib/ExtUtils/MakeMaker/version/vpp.pm

filter: Statementstmt 9.7% 55 / 564 Branchbran 0.3% 1 / 324 Conditioncond 0.0% 0 / 180 MC/DCmcdc 0.0% 0 / 100 Subroutinesub 28.0% 14 / 50 Podpod 0.0% 0 / 16 totaltotal 5.6% 70 / 1234 CC 223 SCAR 73.5
CC
223
Cov
5%
prescan_version
4692.0
scan_version
1806.0
vcmp
702.0
CRAP 1563.5
↑ Summary lib/ExtUtils/Liblist/Kid.pm »
1 #--------------------------------------------------------------------------#
2 # This is a modified copy of version.pm 0.9909, bundled exclusively for
3 # use by ExtUtils::Makemaker and its dependencies to bootstrap when
4 # version.pm is not available. It should not be used by ordinary modules.
5 #--------------------------------------------------------------------------#
6  
7 package ExtUtils::MakeMaker::charstar;
8 # a little helper class to emulate C char* semantics in Perl
9 # so that prescan_version can use the same code as in C
10  
11 1 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 '""' => \&thischar,
13 '0+' => \&thischar,
14 '++' => \&increment,
15 '--' => \&decrement,
16 '+' => \&plus,
17 '-' => \&minus,
18 '*' => \&multiply,
19 'cmp' => \&cmp,
20 '<=>' => \&spaceship,
21 'bool' => \&thischar,
22 '=' => \&clone,
23 1 );
24  
25 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
26 0 my ($self, $string) = @_;
27 0 ▶ my $class = ref($self) || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
28  
29 0 my $obj = {
30 string => [split(//,$string)],
31 current => 0,
32 };
33 0 return bless $obj, $class;
34 }
35  
36 0 ▶sub thischar {
Subroutine thischar: not called CC=3 SCAR=24.8
37 0 my ($self) = @_;
38 0 my $last = $#{$self->{string}};
39 0 my $curr = $self->{current};
40 0 ▶ if ($curr >= 0 && $curr <= $last) {
Branch: 1 branch
BranchTrueFalseTotal
if ($curr >= 0 and $curr <= $last) { } 0 0 0
Condition0%0/3
$curr >= 0 and $curr <= $last
!ll&&!rl&&r
000
MC/DC0%0/2
$curr >= 0 and $curr <= $last
$curr >= 0 $curr <= $last
Truth table0%0/3
A and B
A= $curr >= 0B= $curr <= $last
ABresult
0X0
100
111
41 0 return $self->{string}->[$curr];
42 }
43 else {
44 0 return '';
45 }
46 }
47  
48 0 ▶sub increment {
Subroutine increment: not called CC=1 SCAR=6.9
49 0 my ($self) = @_;
50 0 $self->{current}++;
51 }
52  
53 0 ▶sub decrement {
Subroutine decrement: not called CC=1 SCAR=6.9
54 0 my ($self) = @_;
55 0 $self->{current}--;
56 }
57  
58 0 ▶sub plus {
Subroutine plus: not called CC=1 SCAR=6.9
59 0 my ($self, $offset) = @_;
60 0 my $rself = $self->clone;
61 0 $rself->{current} += $offset;
62 0 return $rself;
63 }
64  
65 0 ▶sub minus {
Subroutine minus: not called CC=1 SCAR=6.9
66 0 my ($self, $offset) = @_;
67 0 my $rself = $self->clone;
68 0 $rself->{current} -= $offset;
69 0 return $rself;
70 }
71  
72 0 ▶sub multiply {
Subroutine multiply: not called CC=1 SCAR=6.9
73 0 my ($left, $right, $swapped) = @_;
74 0 my $char = $left->thischar();
75 0 return $char * $right;
76 }
77  
78 0 ▶sub spaceship {
Subroutine spaceship: not called CC=2 SCAR=17.9
79 0 my ($left, $right, $swapped) = @_;
80 0 ▶ unless (ref($right)) { # not an object already
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $right) 0 0 0
81 0 $right = $left->new($right);
82 }
83 0 return $left->{current} <=> $right->{current};
84 }
85  
86 0 ▶sub cmp {
Subroutine cmp: not called CC=3 SCAR=24.8
87 0 my ($left, $right, $swapped) = @_;
88 0 ▶ unless (ref($right)) { # not an object already
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $right) 0 0 0
89 0 ▶ if (length($right) == 1) { # comparing single character only
Branch: 1 branch
BranchTrueFalseTotal
if (length $right == 1) 0 0 0
90 0 return $left->thischar cmp $right;
91 }
92 0 $right = $left->new($right);
93 }
94 0 return $left->currstr cmp $right->currstr;
95 }
96  
97 0 ▶sub bool {
Subroutine bool: not called CC=1 SCAR=6.9
98 0 my ($self) = @_;
99 0 my $char = $self->thischar;
100 0 return ($char ne '');
101 }
102  
103 0 ▶sub clone {
Subroutine clone: not called CC=1 SCAR=6.9
104 0 my ($left, $right, $swapped) = @_;
105 $right = {
106 0 string => [@{$left->{string}}],
107 current => $left->{current},
108 0 };
109 0 return bless $right, ref($left);
110 }
111  
112 0 ▶sub currstr {
Subroutine currstr: not called CC=3 SCAR=24.8
113 0 my ($self, $s) = @_;
114 0 my $curr = $self->{current};
115 0 my $last = $#{$self->{string}};
116 0 ▶ if (defined($s) && $s->{current} < $last) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $s and $s->{"current"} < $last) 0 0 0
Condition0%0/3
defined $s and $s->{"current"} < $last
!ll&&!rl&&r
000
MC/DC0%0/2
defined $s and $s->{"current"} < $last
defined $s $s->{"current"} < $last
Truth table0%0/3
A and B
A= defined $sB= $s->{"current"} < $last
ABresult
0X0
100
111
117 0 $last = $s->{current};
118 }
119  
120 0 my $string = join('', @{$self->{string}}[$curr..$last]);
121 0 return $string;
122 }
123  
124 package ExtUtils::MakeMaker::version::vpp;
125  
126 1 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
127 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
128 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
129  
130 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
131 1 ▶use vars qw($VERSION $CLASS @ISA $LAX $STRICT);
Subroutine BEGIN: called CC=1 SCAR=0.0
132 1 $VERSION = '7.78';
133 1 $VERSION =~ tr/_//d;
134 1 $CLASS = 'ExtUtils::MakeMaker::version::vpp';
135  
136 1 require ExtUtils::MakeMaker::version::regex;
137 1 *ExtUtils::MakeMaker::version::vpp::is_strict = \&ExtUtils::MakeMaker::version::regex::is_strict;
138 1 *ExtUtils::MakeMaker::version::vpp::is_lax = \&ExtUtils::MakeMaker::version::regex::is_lax;
139 1 *LAX = \$ExtUtils::MakeMaker::version::regex::LAX;
140 1 *STRICT = \$ExtUtils::MakeMaker::version::regex::STRICT;
141  
142 1 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
143 1 '""' => \&stringify,
144 '0+' => \&numify,
145 'cmp' => \&vcmp,
146 '<=>' => \&vcmp,
147 'bool' => \&vbool,
148 '+' => \&vnoop,
149 '-' => \&vnoop,
150 '*' => \&vnoop,
151 '/' => \&vnoop,
152 '+=' => \&vnoop,
153 '-=' => \&vnoop,
154 '*=' => \&vnoop,
155 '/=' => \&vnoop,
156 'abs' => \&vnoop,
157 1 );
158  
159 1 ▶eval "use warnings";
Subroutine BEGIN: called CC=1 SCAR=0.0
160 1 ▶if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
161 0 eval '
162 package
163 warnings;
164 sub enabled {return $^W;}
165 1;
166 ';
167 }
168  
169 0 ▶sub import {
Subroutine import: not called CC=13 SCAR=48.5
170 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
171 0 my ($class) = shift;
172  
173 # Set up any derived class
174 0 ▶ unless ($class eq $CLASS) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class eq $ExtUtils::MakeMaker::version::vpp::CLASS) 0 0 0
175 1 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
176 0 *{$class.'::declare'} = \&{$CLASS.'::declare'};
177 0 *{$class.'::qv'} = \&{$CLASS.'::qv'};
178 }
179  
180 0 my %args;
181 0 ▶ if (@_) { # any remaining terms are arguments
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
182 0 map { $args{$_} = 1 } @_
183 }
184 else { # no parameters at all on use line
185 0 %args =
186 (
187 qv => 1,
188 'UNIVERSAL::VERSION' => 1,
189 );
190 }
191  
192 0 my $callpkg = caller();
193  
194 0 ▶ if (exists($args{declare})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"declare"}) 0 0 0
195 0 *{$callpkg.'::declare'} =
196 0 ▶ sub {return $class->declare(shift) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
197 0 ▶ unless defined(&{$callpkg.'::declare'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined &{$callpkg . '::declare';} 0 0 0
198 }
199  
200 0 ▶ if (exists($args{qv})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"qv"}) 0 0 0
201 0 *{$callpkg.'::qv'} =
202 0 ▶ sub {return $class->qv(shift) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
203 0 ▶ unless defined(&{$callpkg.'::qv'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined &{$callpkg . '::qv';} 0 0 0
204 }
205  
206 0 ▶ if (exists($args{'UNIVERSAL::VERSION'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"UNIVERSAL::VERSION"}) 0 0 0
207 1 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
208 *UNIVERSAL::VERSION
209 0 = \&{$CLASS.'::_VERSION'};
210 }
211  
212 0 ▶ if (exists($args{'VERSION'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"VERSION"}) 0 0 0
213 0 *{$callpkg.'::VERSION'} = \&{$CLASS.'::_VERSION'};
214 }
215  
216 0 ▶ if (exists($args{'is_strict'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"is_strict"}) 0 0 0
217 0 *{$callpkg.'::is_strict'} = \&{$CLASS.'::is_strict'}
218 0 ▶ unless defined(&{$callpkg.'::is_strict'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined &{$callpkg . '::is_strict';} 0 0 0
219 }
220  
221 0 ▶ if (exists($args{'is_lax'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"is_lax"}) 0 0 0
222 0 *{$callpkg.'::is_lax'} = \&{$CLASS.'::is_lax'}
223 0 ▶ unless defined(&{$callpkg.'::is_lax'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined &{$callpkg . '::is_lax';} 0 0 0
224 }
225 }
226  
227 1 my $VERSION_MAX = 0x7FFFFFFF;
228  
229 # implement prescan_version as closely to the C version as possible
230 1 ▶use constant TRUE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
231 1 ▶use constant FALSE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
232  
233 0 ▶sub isDIGIT {
Subroutine isDIGIT: not called CC=1 SCAR=6.9
Pod undocumented
234 0 my ($char) = shift->thischar();
235 0 return ($char =~ /\d/);
236 }
237  
238 0 ▶sub isALPHA {
Subroutine isALPHA: not called CC=1 SCAR=6.9
Pod undocumented
239 0 my ($char) = shift->thischar();
240 0 return ($char =~ /[a-zA-Z]/);
241 }
242  
243 0 ▶sub isSPACE {
Subroutine isSPACE: not called CC=1 SCAR=6.9
Pod undocumented
244 0 my ($char) = shift->thischar();
245 0 return ($char =~ /\s/);
246 }
247  
248 0 ▶sub BADVERSION {
Subroutine BADVERSION: not called CC=2 SCAR=17.9
Pod undocumented
249 0 my ($s, $errstr, $error) = @_;
250 0 ▶ if ($errstr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errstr) 0 0 0
251 0 $$errstr = $error;
252 }
253 0 return $s;
254 }
255  
256 0 ▶sub prescan_version {
Subroutine prescan_version: not called CC=68 SCAR=84.5
Pod undocumented
257 0 my ($s, $strict, $errstr, $sqv, $ssaw_decimal, $swidth, $salpha) = @_;
258 0 ▶ my $qv = defined $sqv ? $$sqv : FALSE;
Branch: 1 branch
BranchTrueFalseTotal
defined $sqv ? : 0 0 0
259 0 ▶ my $saw_decimal = defined $ssaw_decimal ? $$ssaw_decimal : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $ssaw_decimal ? : 0 0 0
260 0 ▶ my $width = defined $swidth ? $$swidth : 3;
Branch: 1 branch
BranchTrueFalseTotal
defined $swidth ? : 0 0 0
261 0 ▶ my $alpha = defined $salpha ? $$salpha : FALSE;
Branch: 1 branch
BranchTrueFalseTotal
defined $salpha ? : 0 0 0
262  
263 0 my $d = $s;
264  
265 0 ▶ if ($qv && isDIGIT($d)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qv and isDIGIT($d)) 0 0 0
Condition0%0/3
$qv and isDIGIT($d)
!ll&&!rl&&r
000
MC/DC0%0/2
$qv and isDIGIT($d)
$qv isDIGIT($d)
Truth table0%0/3
A and B
A= $qvB= isDIGIT($d)
ABresult
0X0
100
111
266 0 goto dotted_decimal_version;
267 }
268  
269 0 ▶ if ($d eq 'v') { # explicit v-string
Branch: 1 branch
BranchTrueFalseTotal
if ($d eq 'v') { } 0 0 0
270 0 $d++;
271 0 ▶ if (isDIGIT($d)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($d)) { } 0 0 0
272 0 $qv = TRUE;
273 }
274 else { # degenerate v-string
275 # requires v1.2.3
276 0 return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)");
277 }
278  
279 dotted_decimal_version:
280 0 ▶ if ($strict && $d eq '0' && isDIGIT($d+1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict and $d eq 0 and isDIGIT($d + 1)) 0 0 0
Condition0%0/6
$strict and $d eq 0 and isDIGIT($d + 1)
!ll&&!rl&&r
000
$strict and $d eq 0
!ll&&!rl&&r
000
MC/DC0%0/3
$strict and $d eq 0 and isDIGIT($d + 1)
$strict $d eq 0 isDIGIT($d + 1)
Truth table0%0/4
A and B and C
A= $strictB= $d eq 0C= isDIGIT($d + 1)
ABCresult
0XX0
10X0
1100
1111
281 # no leading zeros allowed
282 0 return BADVERSION($s,$errstr,"Invalid version format (no leading zeros)");
283 }
284  
285 0 ▶ while (isDIGIT($d)) { # integer part
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($d)) 0 0 0
286 0 $d++;
287 }
288  
289 0 ▶ if ($d eq '.')
Branch: 1 branch
BranchTrueFalseTotal
if ($d eq '.') { } 0 0 0
290 {
291 0 $saw_decimal++;
292 0 $d++; # decimal point
293 }
294 else
295 {
296 0 ▶ if ($strict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) { } 0 0 0
297 # require v1.2.3
298 0 return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)");
299 }
300 else {
301 0 goto version_prescan_finish;
302 }
303 }
304  
305 {
306 0 my $i = 0;
307 0 my $j = 0;
308 0 ▶ while (isDIGIT($d)) { # just keep reading
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($d)) 0 0 0
309 0 $i++;
310 0 ▶ while (isDIGIT($d)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($d)) 0 0 0
311 0 $d++; $j++;
312 # maximum 3 digits between decimal
313 0 ▶ if ($strict && $j > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict and $j > 3) 0 0 0
Condition0%0/3
$strict and $j > 3
!ll&&!rl&&r
000
MC/DC0%0/2
$strict and $j > 3
$strict $j > 3
Truth table0%0/3
A and B
A= $strictB= $j > 3
ABresult
0X0
100
111
314 0 return BADVERSION($s,$errstr,"Invalid version format (maximum 3 digits between decimals)");
315 }
316 }
317 0 ▶ if ($d eq '_') {
Branch: 3 branches
BranchTrueFalseTotal
if ($d eq '_') { } 0 0 0
elsif ($d eq '.') { } 0 0 0
elsif (not isDIGIT($d)) { } 0 0 0
318 0 ▶ if ($strict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) 0 0 0
319 0 return BADVERSION($s,$errstr,"Invalid version format (no underscores)");
320 }
321 0 ▶ if ( $alpha ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha) 0 0 0
322 0 return BADVERSION($s,$errstr,"Invalid version format (multiple underscores)");
323 }
324 0 $d++;
325 0 $alpha = TRUE;
326 }
327 elsif ($d eq '.') {
328 0 ▶ if ($alpha) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha) 0 0 0
329 0 return BADVERSION($s,$errstr,"Invalid version format (underscores before decimal)");
330 }
331 0 $saw_decimal++;
332 0 $d++;
333 }
334 elsif (!isDIGIT($d)) {
335 0 last;
336 }
337 0 $j = 0;
338 }
339  
340 0 ▶ if ($strict && $i < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict and $i < 2) 0 0 0
Condition0%0/3
$strict and $i < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$strict and $i < 2
$strict $i < 2
Truth table0%0/3
A and B
A= $strictB= $i < 2
ABresult
0X0
100
111
341 # requires v1.2.3
342 0 return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)");
343 }
344 }
345 } # end if dotted-decimal
346 else
347 { # decimal versions
348 0 my $j = 0;
349 # special $strict case for leading '.' or '0'
350 0 ▶ if ($strict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) 0 0 0
351 0 ▶ if ($d eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($d eq ".") 0 0 0
352 0 return BADVERSION($s,$errstr,"Invalid version format (0 before decimal required)");
353 }
354 0 ▶ if ($d eq '0' && isDIGIT($d+1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d eq 0 and isDIGIT($d + 1)) 0 0 0
Condition0%0/3
$d eq 0 and isDIGIT($d + 1)
!ll&&!rl&&r
000
MC/DC0%0/2
$d eq 0 and isDIGIT($d + 1)
$d eq 0 isDIGIT($d + 1)
Truth table0%0/3
A and B
A= $d eq 0B= isDIGIT($d + 1)
ABresult
0X0
100
111
355 0 return BADVERSION($s,$errstr,"Invalid version format (no leading zeros)");
356 }
357 }
358  
359 # and we never support negative version numbers
360 0 ▶ if ($d eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($d eq "-") 0 0 0
361 0 return BADVERSION($s,$errstr,"Invalid version format (negative version number)");
362 }
363  
364 # consume all of the integer part
365 0 ▶ while (isDIGIT($d)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($d)) 0 0 0
366 0 $d++;
367 }
368  
369 # look for a fractional part
370 0 ▶ if ($d eq '.') {
Branch: 5 branches
BranchTrueFalseTotal
if ($d eq '.') { } 0 0 0
elsif (not $d or $d eq ';' or isSPACE($d) or $d eq '}') { } 0 0 0
elsif ($d == $s) { } 0 0 0
elsif ($d eq '_') { } 0 0 0
elsif ($d) { } 0 0 0
371 # we found it, so consume it
372 0 $saw_decimal++;
373 0 $d++;
374 }
375 ▶ elsif (!$d || $d eq ';' || isSPACE($d) || $d eq '}') {
Condition0%0/9
not $d or $d eq ";" or isSPACE($d) or $d eq "}"
l!l&&r!l&&!r
000
not $d or $d eq ";" or isSPACE($d)
l!l&&r!l&&!r
000
not $d or $d eq ";"
l!l&&r!l&&!r
000
MC/DC0%0/4
not $d or $d eq ";" or isSPACE($d) or $d eq "}"
not $d $d eq ";" isSPACE($d) $d eq "}"
Truth table0%0/5
not(A) or B or C or D
A= not $dB= $d eq ";"C= isSPACE($d)D= $d eq "}"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
376 0 ▶ if ( $d == $s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d == $s) 0 0 0
377 # found nothing
378 0 return BADVERSION($s,$errstr,"Invalid version format (version required)");
379 }
380 # found just an integer
381 0 goto version_prescan_finish;
382 }
383 elsif ( $d == $s ) {
384 # didn't find either integer or period
385 0 return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)");
386 }
387 elsif ($d eq '_') {
388 # underscore can't come after integer part
389 0 ▶ if ($strict) {
Branch: 2 branches
BranchTrueFalseTotal
if ($strict) { } 0 0 0
elsif (isDIGIT($d + 1)) { } 0 0 0
390 0 return BADVERSION($s,$errstr,"Invalid version format (no underscores)");
391 }
392 elsif (isDIGIT($d+1)) {
393 0 return BADVERSION($s,$errstr,"Invalid version format (alpha without decimal)");
394 }
395 else {
396 0 return BADVERSION($s,$errstr,"Invalid version format (misplaced underscore)");
397 }
398 }
399 elsif ($d) {
400 # anything else after integer part is just invalid data
401 0 return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)");
402 }
403  
404 # scan the fractional part after the decimal point
405 0 ▶ if ($d && !isDIGIT($d) && ($strict || ! ($d eq ';' || isSPACE($d) || $d eq '}') )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d and not isDIGIT($d) and $strict || !($d eq ";" || isSPACE($d) || $d eq "}")) 0 0 0
Condition0%0/15
$d and not isDIGIT($d) and $strict || !($d eq ";" || isSPACE($d) || $d eq "}")
!ll&&!rl&&r
000
$d and not isDIGIT($d)
!ll&&!rl&&r
000
$strict or not $d eq ";" || isSPACE($d) || $d eq "}"
l!l&&r!l&&!r
000
$d eq ';' || isSPACE($d) || $d eq '}'
l!l&&r!l&&!r
000
$d eq ";" or isSPACE($d)
l!l&&r!l&&!r
000
MC/DC0%0/6
$d and not isDIGIT($d) and $strict || !($d eq ";" || isSPACE($d) || $d eq "}")
$d not isDIGIT($d) $strict $d eq ";" isSPACE($d) $d eq '}'
Truth table0%0/7
A and not(B) and C or not(D or E || F)
A= $dB= not isDIGIT($d)C= $strictD= $d eq ";"E= isSPACE($d)F= $d eq '}'
ABCDEFresult
0XXXXX0
10XXXX0
1101XX0
11001X0
1100010
111XXX1
1100001
406 # $strict or lax-but-not-the-end
407 0 return BADVERSION($s,$errstr,"Invalid version format (fractional part required)");
408 }
409  
410 0 ▶ while (isDIGIT($d)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($d)) 0 0 0
411 0 $d++; $j++;
412 0 ▶ if ($d eq '.' && isDIGIT($d-1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d eq "." and isDIGIT($d - 1)) 0 0 0
Condition0%0/3
$d eq "." and isDIGIT($d - 1)
!ll&&!rl&&r
000
MC/DC0%0/2
$d eq "." and isDIGIT($d - 1)
$d eq "." isDIGIT($d - 1)
Truth table0%0/3
A and B
A= $d eq "."B= isDIGIT($d - 1)
ABresult
0X0
100
111
413 0 ▶ if ($alpha) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha) 0 0 0
414 0 return BADVERSION($s,$errstr,"Invalid version format (underscores before decimal)");
415 }
416 0 ▶ if ($strict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) 0 0 0
417 0 return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions must begin with 'v')");
418 }
419 0 $d = $s; # start all over again
420 0 $qv = TRUE;
421 0 goto dotted_decimal_version;
422 }
423 0 ▶ if ($d eq '_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($d eq "_") 0 0 0
424 0 ▶ if ($strict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) 0 0 0
425 0 return BADVERSION($s,$errstr,"Invalid version format (no underscores)");
426 }
427 0 ▶ if ( $alpha ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha) 0 0 0
428 0 return BADVERSION($s,$errstr,"Invalid version format (multiple underscores)");
429 }
430 0 ▶ if ( ! isDIGIT($d+1) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (isDIGIT($d + 1)) 0 0 0
431 0 return BADVERSION($s,$errstr,"Invalid version format (misplaced underscore)");
432 }
433 0 $width = $j;
434 0 $d++;
435 0 $alpha = TRUE;
436 }
437 }
438 }
439  
440 version_prescan_finish:
441 0 ▶ while (isSPACE($d)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isSPACE($d)) 0 0 0
442 0 $d++;
443 }
444  
445 0 ▶ if ($d && !isDIGIT($d) && (! ($d eq ';' || $d eq '}') )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d and not isDIGIT($d) and not $d eq ";" || $d eq "}") 0 0 0
Condition0%0/9
$d and not isDIGIT($d) and not $d eq ";" || $d eq "}"
!ll&&!rl&&r
000
$d and not isDIGIT($d)
!ll&&!rl&&r
000
$d eq ';' || $d eq '}'
l!l&&r!l&&!r
000
MC/DC0%0/4
$d and not isDIGIT($d) and not $d eq ";" || $d eq "}"
$d not isDIGIT($d) $d eq ';' $d eq '}'
Truth table0%0/5
A and not(B) and not(C || D)
A= $dB= not isDIGIT($d)C= $d eq ';'D= $d eq '}'
ABCDresult
0XXX0
10XX0
111X0
11010
11001
446 # trailing non-numeric data
447 0 return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)");
448 }
449  
450 0 ▶ if (defined $sqv) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sqv) 0 0 0
451 0 $$sqv = $qv;
452 }
453 0 ▶ if (defined $swidth) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $swidth) 0 0 0
454 0 $$swidth = $width;
455 }
456 0 ▶ if (defined $ssaw_decimal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ssaw_decimal) 0 0 0
457 0 $$ssaw_decimal = $saw_decimal;
458 }
459 0 ▶ if (defined $salpha) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $salpha) 0 0 0
460 0 $$salpha = $alpha;
461 }
462 0 return $d;
463 }
464  
465 0 ▶sub scan_version {
Subroutine scan_version: not called CC=42 SCAR=75.0
Pod undocumented
466 0 my ($s, $rv, $qv) = @_;
467 0 my $start;
468 my $pos;
469 0 my $last;
470 0 my $errstr;
471 0 my $saw_decimal = 0;
472 0 my $width = 3;
473 0 my $alpha = FALSE;
474 0 my $vinf = FALSE;
475 0 my @av;
476  
477 0 $s = new ExtUtils::MakeMaker::charstar $s;
478  
479 0 ▶ while (isSPACE($s)) { # leading whitespace is OK
Branch: 1 branch
BranchTrueFalseTotal
if (isSPACE($s)) 0 0 0
480 0 $s++;
481 }
482  
483 0 $last = prescan_version($s, FALSE, \$errstr, \$qv, \$saw_decimal,
484 \$width, \$alpha);
485  
486 0 ▶ if ($errstr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errstr) 0 0 0
487 # 'undef' is a special case and not an error
488 0 ▶ if ( $s ne 'undef') {
Branch: 1 branch
BranchTrueFalseTotal
if ($s ne "undef") 0 0 0
489 0 require Carp;
490 0 Carp::croak($errstr);
491 }
492 }
493  
494 0 $start = $s;
495 0 ▶ if ($s eq 'v') {
Branch: 1 branch
BranchTrueFalseTotal
if ($s eq "v") 0 0 0
496 0 $s++;
497 }
498 0 $pos = $s;
499  
500 0 ▶ if ( $qv ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qv) 0 0 0
501 0 $$rv->{qv} = $qv;
502 }
503 0 ▶ if ( $alpha ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha) 0 0 0
504 0 $$rv->{alpha} = $alpha;
505 }
506 0 ▶ if ( !$qv && $width < 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $qv and $width < 3) 0 0 0
Condition0%0/3
not $qv and $width < 3
!ll&&!rl&&r
000
MC/DC0%0/2
not $qv and $width < 3
not $qv $width < 3
Truth table0%0/3
not(A) and B
A= not $qvB= $width < 3
ABresult
0X0
100
111
507 0 $$rv->{width} = $width;
508 }
509  
510 0 ▶ while (isDIGIT($pos)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($pos)) 0 0 0
511 0 $pos++;
512 }
513 0 ▶ if (!isALPHA($pos)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (isALPHA($pos)) 0 0 0
514 0 my $rev;
515  
516 0 for (;;) {
517 0 $rev = 0;
518 {
519 # this is atoi() that delimits on underscores
520 0 my $end = $pos;
521 0 my $mult = 1;
522 0 my $orev;
523  
524 # the following if() will only be true after the decimal
525 # point of a version originally created with a bare
526 # floating point number, i.e. not quoted in any way
527 #
528 0 ▶ if ( !$qv && $s > $start && $saw_decimal == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $qv and $s > $start and $saw_decimal == 1) { } 0 0 0
Condition0%0/6
not $qv and $s > $start and $saw_decimal == 1
!ll&&!rl&&r
000
not $qv and $s > $start
!ll&&!rl&&r
000
MC/DC0%0/3
not $qv and $s > $start and $saw_decimal == 1
not $qv $s > $start $saw_decimal == 1
Truth table0%0/4
not(A) and B and C
A= not $qvB= $s > $startC= $saw_decimal == 1
ABCresult
0XX0
10X0
1100
1111
529 0 $mult *= 100;
530 0 ▶ while ( $s < $end ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s < $end) 0 0 0
531 0 $orev = $rev;
532 0 $rev += $s * $mult;
533 0 $mult /= 10;
534 0 ▶ if ( (abs($orev) > abs($rev))
Branch: 1 branch
BranchTrueFalseTotal
if (abs $orev > abs $rev or abs $rev > $VERSION_MAX) 0 0 0
Condition0%0/3
abs $orev > abs $rev or abs $rev > $VERSION_MAX
l!l&&r!l&&!r
000
MC/DC0%0/2
abs $orev > abs $rev or abs $rev > $VERSION_MAX
abs $orev > abs $rev abs $rev > $VERSION_MAX
Truth table0%0/3
A or B
A= abs $orev > abs $revB= abs $rev > $VERSION_MAX
ABresult
1X1
011
000
535 || (abs($rev) > $VERSION_MAX )) {
536 0 warn("Integer overflow in version %d",
537 $VERSION_MAX);
538 0 $s = $end - 1;
539 0 $rev = $VERSION_MAX;
540 0 $vinf = 1;
541 }
542 0 $s++;
543 0 ▶ if ( $s eq '_' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s eq "_") 0 0 0
544 0 $s++;
545 }
546 }
547 }
548 else {
549 0 ▶ while (--$end >= $s) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$end >= $s) 0 0 0
550 0 $orev = $rev;
551 0 $rev += $end * $mult;
552 0 $mult *= 10;
553 0 ▶ if ( (abs($orev) > abs($rev))
Branch: 1 branch
BranchTrueFalseTotal
if (abs $orev > abs $rev or abs $rev > $VERSION_MAX) 0 0 0
Condition0%0/3
abs $orev > abs $rev or abs $rev > $VERSION_MAX
l!l&&r!l&&!r
000
MC/DC0%0/2
abs $orev > abs $rev or abs $rev > $VERSION_MAX
abs $orev > abs $rev abs $rev > $VERSION_MAX
Truth table0%0/3
A or B
A= abs $orev > abs $revB= abs $rev > $VERSION_MAX
ABresult
1X1
011
000
554 || (abs($rev) > $VERSION_MAX )) {
555 0 warn("Integer overflow in version");
556 0 $end = $s - 1;
557 0 $rev = $VERSION_MAX;
558 0 $vinf = 1;
559 }
560 }
561 }
562 }
563  
564 # Append revision
565 0 push @av, $rev;
566 0 ▶ if ( $vinf ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($vinf) { } 0 0 0
elsif ($pos eq '.') { } 0 0 0
elsif ($pos eq '_' and isDIGIT($pos + 1)) { } 0 0 0
elsif ($pos eq ',' and isDIGIT($pos + 1)) { } 0 0 0
elsif (isDIGIT($pos)) { } 0 0 0
567 0 $s = $last;
568 0 last;
569 }
570 elsif ( $pos eq '.' ) {
571 0 $s = ++$pos;
572 }
573 ▶ elsif ( $pos eq '_' && isDIGIT($pos+1) ) {
Condition0%0/3
$pos eq "_" and isDIGIT($pos + 1)
!ll&&!rl&&r
000
MC/DC0%0/2
$pos eq "_" and isDIGIT($pos + 1)
$pos eq "_" isDIGIT($pos + 1)
Truth table0%0/3
A and B
A= $pos eq "_"B= isDIGIT($pos + 1)
ABresult
0X0
100
111
574 0 $s = ++$pos;
575 }
576 ▶ elsif ( $pos eq ',' && isDIGIT($pos+1) ) {
Condition0%0/3
$pos eq "," and isDIGIT($pos + 1)
!ll&&!rl&&r
000
MC/DC0%0/2
$pos eq "," and isDIGIT($pos + 1)
$pos eq "," isDIGIT($pos + 1)
Truth table0%0/3
A and B
A= $pos eq ","B= isDIGIT($pos + 1)
ABresult
0X0
100
111
577 0 $s = ++$pos;
578 }
579 elsif ( isDIGIT($pos) ) {
580 0 $s = $pos;
581 }
582 else {
583 0 $s = $pos;
584 0 last;
585 }
586 0 ▶ if ( $qv ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qv) { } 0 0 0
587 0 ▶ while ( isDIGIT($pos) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($pos)) 0 0 0
588 0 $pos++;
589 }
590 }
591 else {
592 0 my $digits = 0;
593 0 ▶ while ( ( isDIGIT($pos) || $pos eq '_' ) && $digits < 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT($pos) || $pos eq "_" and $digits < 3) 0 0 0
Condition0%0/6
isDIGIT($pos) || $pos eq "_" and $digits < 3
!ll&&!rl&&r
000
isDIGIT($pos) or $pos eq "_"
l!l&&r!l&&!r
000
MC/DC0%0/3
isDIGIT($pos) || $pos eq "_" and $digits < 3
isDIGIT($pos) $pos eq "_" $digits < 3
Truth table0%0/5
A or B and C
A= isDIGIT($pos)B= $pos eq "_"C= $digits < 3
ABCresult
00X0
1X00
0100
1X11
0111
594 0 ▶ if ( $pos ne '_' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos ne "_") 0 0 0
595 0 $digits++;
596 }
597 0 $pos++;
598 }
599 }
600 }
601 }
602 0 ▶ if ( $qv ) { # quoted versions always get at least three terms
Branch: 1 branch
BranchTrueFalseTotal
if ($qv) 0 0 0
603 0 my $len = $#av;
604 # This for loop appears to trigger a compiler bug on OS X, as it
605 # loops infinitely. Yes, len is negative. No, it makes no sense.
606 # Compiler in question is:
607 # gcc version 3.3 20030304 (Apple Computer, Inc. build 1640)
608 # for ( len = 2 - len; len > 0; len-- )
609 # av_push(MUTABLE_AV(sv), newSViv(0));
610 #
611 0 $len = 2 - $len;
612 0 ▶ while ($len-- > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len-- > 0) 0 0 0
613 0 push @av, 0;
614 }
615 }
616  
617 # need to save off the current version string for later
618 0 ▶ if ( $vinf ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($vinf) { } 0 0 0
elsif ($s > $start) { } 0 0 0
619 0 $$rv->{original} = "v.Inf";
620 0 $$rv->{vinf} = 1;
621 }
622 elsif ( $s > $start ) {
623 0 $$rv->{original} = $start->currstr($s);
624 0 ▶ if ( $qv && $saw_decimal == 1 && $start ne 'v' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qv and $saw_decimal == 1 and $start ne "v") 0 0 0
Condition0%0/6
$qv and $saw_decimal == 1 and $start ne "v"
!ll&&!rl&&r
000
$qv and $saw_decimal == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$qv and $saw_decimal == 1 and $start ne "v"
$qv $saw_decimal == 1 $start ne "v"
Truth table0%0/4
A and B and C
A= $qvB= $saw_decimal == 1C= $start ne "v"
ABCresult
0XX0
10X0
1100
1111
625 # need to insert a v to be consistent
626 0 $$rv->{original} = 'v' . $$rv->{original};
627 }
628 }
629 else {
630 0 $$rv->{original} = '0';
631 0 push(@av, 0);
632 }
633  
634 # And finally, store the AV in the hash
635 0 $$rv->{version} = \@av;
636  
637 # fix RT#19517 - special case 'undef' as string
638 0 ▶ if ($s eq 'undef') {
Branch: 1 branch
BranchTrueFalseTotal
if ($s eq "undef") 0 0 0
639 0 $s += 5;
640 }
641  
642 0 return $s;
643 }
644  
645 0 ▶sub new {
Subroutine new: not called CC=17 SCAR=57.2
Pod undocumented
646 0 my $class = shift;
647 0 ▶ unless (defined $class or $#_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $class or $#_ > 1) 0 0 0
Condition0%0/3
defined $class or $#_ > 1
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $class or $#_ > 1
defined $class $#_ > 1
Truth table0%0/3
A or B
A= defined $classB= $#_ > 1
ABresult
1X1
011
000
648 0 require Carp;
649 0 Carp::croak('Usage: version::new(class, version)');
650 }
651  
652 0 ▶ my $self = bless ({}, ref ($class) || $class);
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
653 0 my $qv = FALSE;
654  
655 0 ▶ if ( $#_ == 1 ) { # must be CVS-style
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ == 1) 0 0 0
656 0 $qv = TRUE;
657 }
658 0 my $value = pop; # always going to be the last element
659  
660 0 ▶ if ( ref($value) && eval('$value->isa("version")') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value and eval "\$value->isa(\"version\")") 0 0 0
Condition0%0/3
ref $value and eval "\$value->isa(\"version\")"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $value and eval "\$value->isa(\"version\")"
ref $value eval "\$value->isa(\"version\")"
Truth table0%0/3
A and B
A= ref $valueB= eval "\$value->isa(\"version\")"
ABresult
0X0
100
111
661 # Can copy the elements directly
662 0 $self->{version} = [ @{$value->{version} } ];
663 0 ▶ $self->{qv} = 1 if $value->{qv};
Branch: 1 branch
BranchTrueFalseTotal
if $value->{"qv"} 0 0 0
664 0 ▶ $self->{alpha} = 1 if $value->{alpha};
Branch: 1 branch
BranchTrueFalseTotal
if $value->{"alpha"} 0 0 0
665 0 $self->{original} = ''.$value->{original};
666 0 return $self;
667 }
668  
669 0 ▶ if ( not defined $value or $value =~ /^undef$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value or $value =~ /^undef$/) 0 0 0
Condition0%0/3
not defined $value or $value =~ /^undef$/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $value or $value =~ /^undef$/
not defined $value $value =~ /^undef$/
Truth table0%0/3
not(A) or B
A= not defined $valueB= $value =~ /^undef$/
ABresult
1X1
011
000
670 # RT #19517 - special case for undef comparison
671 # or someone forgot to pass a value
672 0 push @{$self->{version}}, 0;
673 0 $self->{original} = "0";
674 0 return ($self);
675 }
676  
677  
678 0 ▶ if (ref($value) =~ m/ARRAY|HASH/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($value) =~ /ARRAY|HASH/) 0 0 0
679 0 require Carp;
680 0 Carp::croak("Invalid version format (non-numeric data)");
681 }
682  
683 0 $value = _un_vstring($value);
684  
685 0 ▶ if ($Config{d_setlocale} && eval { require POSIX } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ExtUtils::MakeMaker::version::vpp::Config{"d_setlocale"} and eval { do { require POSIX } }) 0 0 0
Condition0%0/3
$ExtUtils::MakeMaker::version::vpp::Config{"d_setlocale"} and eval { do { require POSIX } }
!ll&&!rl&&r
000
MC/DC0%0/2
$ExtUtils::MakeMaker::version::vpp::Config{"d_setlocale"} and eval { do { require POSIX } }
$ExtUtils::MakeMaker::version::vpp::Config{"d_setlocale"} eval { do { require POSIX } }
Truth table0%0/3
A and B
A= $ExtUtils::MakeMaker::version::vpp::Config{"d_setlocale"}B= eval { do { require POSIX } }
ABresult
0X0
100
111
686 0 require locale;
687 0 my $currlocale = POSIX::setlocale(&POSIX::LC_ALL);
688  
689 # if the current locale uses commas for decimal points, we
690 # just replace commas with decimal places, rather than changing
691 # locales
692 0 ▶ if ( POSIX::localeconv()->{decimal_point} eq ',' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (POSIX::localeconv()->{"decimal_point"} eq ",") 0 0 0
693 0 $value =~ tr/,/./;
694 }
695 }
696  
697 # exponential notation
698 0 ▶ if ( $value =~ /\d+.?\d*e[-+]?\d+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /\d+.?\d*e[-+]?\d+/) 0 0 0
699 0 $value = sprintf("%.9f",$value);
700 0 $value =~ s/(0+)$//; # trim trailing zeros
701 }
702  
703 0 my $s = scan_version($value, \$self, $qv);
704  
705 0 ▶ if ($s) { # must be something left over
Branch: 1 branch
BranchTrueFalseTotal
if ($s) 0 0 0
706 0 warn("Version string '%s' contains invalid data; "
707 ."ignoring: '%s'", $value, $s);
708 }
709  
710 0 return ($self);
711 }
712  
713 1 *parse = \&new;
714  
715 0 ▶sub numify {
Subroutine numify: not called CC=9 SCAR=45.0
Pod undocumented
716 0 my ($self) = @_;
717 0 ▶ unless (_verify($self)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_verify($self)) 0 0 0
718 0 require Carp;
719 0 Carp::croak("Invalid version object");
720 }
721 0 ▶ my $width = $self->{width} || 3;
Condition0%0/2
$self->{'width'} || 3
l!l
00
MC/DC0%0/1
$self->{'width'} || 3
$self->{'width'}
Truth table0%0/2
A
A= $self->{'width'}
Aresult
11
00
722 0 ▶ my $alpha = $self->{alpha} || "";
Condition0%0/2
$self->{'alpha'} || ''
l!l
00
MC/DC0%0/1
$self->{'alpha'} || ''
$self->{'alpha'}
Truth table0%0/2
A
A= $self->{'alpha'}
Aresult
11
00
723 0 my $len = $#{$self->{version}};
724 0 my $digit = $self->{version}[0];
725 0 my $string = sprintf("%d.", $digit );
726  
727 0 ▶ for ( my $i = 1 ; $i < $len ; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 0 0 0
728 0 $digit = $self->{version}[$i];
729 0 ▶ if ( $width < 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 3) { } 0 0 0
730 0 my $denom = 10**(3-$width);
731 0 my $quot = int($digit/$denom);
732 0 my $rem = $digit - ($quot * $denom);
733 0 $string .= sprintf("%0".$width."d_%d", $quot, $rem);
734 }
735 else {
736 0 $string .= sprintf("%03d", $digit);
737 }
738 }
739  
740 0 ▶ if ( $len > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len > 0) { } 0 0 0
741 0 $digit = $self->{version}[$len];
742 0 ▶ if ( $alpha && $width == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha and $width == 3) 0 0 0
Condition0%0/3
$alpha and $width == 3
!ll&&!rl&&r
000
MC/DC0%0/2
$alpha and $width == 3
$alpha $width == 3
Truth table0%0/3
A and B
A= $alphaB= $width == 3
ABresult
0X0
100
111
743 0 $string .= "_";
744 }
745 0 $string .= sprintf("%0".$width."d", $digit);
746 }
747 else # $len = 0
748 {
749 0 $string .= sprintf("000");
750 }
751  
752 0 return $string;
753 }
754  
755 0 ▶sub normal {
Subroutine normal: not called CC=8 SCAR=42.8
Pod undocumented
756 0 my ($self) = @_;
757 0 ▶ unless (_verify($self)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_verify($self)) 0 0 0
758 0 require Carp;
759 0 Carp::croak("Invalid version object");
760 }
761 0 ▶ my $alpha = $self->{alpha} || "";
Condition0%0/2
$self->{'alpha'} || ''
l!l
00
MC/DC0%0/1
$self->{'alpha'} || ''
$self->{'alpha'}
Truth table0%0/2
A
A= $self->{'alpha'}
Aresult
11
00
762 0 my $len = $#{$self->{version}};
763 0 my $digit = $self->{version}[0];
764 0 my $string = sprintf("v%d", $digit );
765  
766 0 ▶ for ( my $i = 1 ; $i < $len ; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 0 0 0
767 0 $digit = $self->{version}[$i];
768 0 $string .= sprintf(".%d", $digit);
769 }
770  
771 0 ▶ if ( $len > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len > 0) 0 0 0
772 0 $digit = $self->{version}[$len];
773 0 ▶ if ( $alpha ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha) { } 0 0 0
774 0 $string .= sprintf("_%0d", $digit);
775 }
776 else {
777 0 $string .= sprintf(".%0d", $digit);
778 }
779 }
780  
781 0 ▶ if ( $len <= 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len <= 2) 0 0 0
782 0 ▶ for ( $len = 2 - $len; $len != 0; $len-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len != 0) 0 0 0
783 0 $string .= sprintf(".%0d", 0);
784 }
785 }
786  
787 0 return $string;
788 }
789  
790 0 ▶sub stringify {
Subroutine stringify: not called CC=4 SCAR=30.0
Pod undocumented
791 0 my ($self) = @_;
792 0 ▶ unless (_verify($self)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_verify($self)) 0 0 0
793 0 require Carp;
794 0 Carp::croak("Invalid version object");
795 }
796 return exists $self->{original}
797 ? $self->{original}
798 : exists $self->{qv}
799 0 ▶ ? $self->normal
Branch: 2 branches
BranchTrueFalseTotal
exists $self->{'original'} ? : 0 0 0
exists $self->{'qv'} ? : 0 0 0
800 : $self->numify;
801 }
802  
803 0 ▶sub vcmp {
Subroutine vcmp: not called CC=26 SCAR=65.5
Pod undocumented
804 0 require UNIVERSAL;
805 0 my ($left,$right,$swap) = @_;
806 0 my $class = ref($left);
807 0 ▶ unless ( UNIVERSAL::isa($right, $class) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (UNIVERSAL::isa($right, $class)) 0 0 0
808 0 $right = $class->new($right);
809 }
810  
811 0 ▶ if ( $swap ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($swap) 0 0 0
812 0 ($left, $right) = ($right, $left);
813 }
814 0 ▶ unless (_verify($left)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_verify($left)) 0 0 0
815 0 require Carp;
816 0 Carp::croak("Invalid version object");
817 }
818 0 ▶ unless (_verify($right)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_verify($right)) 0 0 0
819 0 require Carp;
820 0 Carp::croak("Invalid version format");
821 }
822 0 my $l = $#{$left->{version}};
823 0 my $r = $#{$right->{version}};
824 0 ▶ my $m = $l < $r ? $l : $r;
Branch: 1 branch
BranchTrueFalseTotal
$l < $r ? : 0 0 0
825 0 my $lalpha = $left->is_alpha;
826 0 my $ralpha = $right->is_alpha;
827 0 my $retval = 0;
828 0 my $i = 0;
829 0 ▶ while ( $i <= $m && $retval == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $m and $retval == 0) 0 0 0
Condition0%0/3
$i <= $m and $retval == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$i <= $m and $retval == 0
$i <= $m $retval == 0
Truth table0%0/3
A and B
A= $i <= $mB= $retval == 0
ABresult
0X0
100
111
830 0 $retval = $left->{version}[$i] <=> $right->{version}[$i];
831 0 $i++;
832 }
833  
834 # tiebreaker for alpha with identical terms
835 0 ▶ if ( $retval == 0
Branch: 1 branch
BranchTrueFalseTotal
if ($retval == 0 and $l == $r and $left->{"version"}[$m] == $right->{"version"}[$m] and $lalpha || $ralpha) 0 0 0
Condition0%0/12
$retval == 0 and $l == $r and $left->{"version"}[$m] == $right->{"version"}[$m] and $lalpha || $ralpha
!ll&&!rl&&r
000
$retval == 0 and $l == $r and $left->{"version"}[$m] == $right->{"version"}[$m]
!ll&&!rl&&r
000
$retval == 0 and $l == $r
!ll&&!rl&&r
000
$lalpha or $ralpha
l!l&&r!l&&!r
000
MC/DC0%0/5
$retval == 0 and $l == $r and $left->{"version"}[$m] == $right->{"version"}[$m] and $lalpha || $ralpha
$retval == 0 $l == $r $left->{"version"}[$m] == $right->{"version"}[$m] $lalpha $ralpha
Truth table0%0/6
A and B and C and D or E
A= $retval == 0B= $l == $rC= $left->{"version"}[$m] == $right->{"version"}[$m]D= $lalphaE= $ralpha
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
836 && $l == $r
837 && $left->{version}[$m] == $right->{version}[$m]
838 && ( $lalpha || $ralpha ) ) {
839  
840 0 ▶ if ( $lalpha && !$ralpha ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($lalpha and not $ralpha) { } 0 0 0
elsif ($ralpha and not $lalpha) { } 0 0 0
Condition0%0/3
$lalpha and not $ralpha
!ll&&!rl&&r
000
MC/DC0%0/2
$lalpha and not $ralpha
$lalpha not $ralpha
Truth table0%0/3
A and not(B)
A= $lalphaB= not $ralpha
ABresult
0X0
100
111
841 0 $retval = -1;
842 }
843 ▶ elsif ( $ralpha && !$lalpha) {
Condition0%0/3
$ralpha and not $lalpha
!ll&&!rl&&r
000
MC/DC0%0/2
$ralpha and not $lalpha
$ralpha not $lalpha
Truth table0%0/3
A and not(B)
A= $ralphaB= not $lalpha
ABresult
0X0
100
111
844 0 $retval = +1;
845 }
846 }
847  
848 # possible match except for trailing 0's
849 0 ▶ if ( $retval == 0 && $l != $r ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retval == 0 and $l != $r) 0 0 0
Condition0%0/3
$retval == 0 and $l != $r
!ll&&!rl&&r
000
MC/DC0%0/2
$retval == 0 and $l != $r
$retval == 0 $l != $r
Truth table0%0/3
A and B
A= $retval == 0B= $l != $r
ABresult
0X0
100
111
850 0 ▶ if ( $l < $r ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l < $r) { } 0 0 0
851 0 ▶ while ( $i <= $r && $retval == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $r and $retval == 0) 0 0 0
Condition0%0/3
$i <= $r and $retval == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$i <= $r and $retval == 0
$i <= $r $retval == 0
Truth table0%0/3
A and B
A= $i <= $rB= $retval == 0
ABresult
0X0
100
111
852 0 ▶ if ( $right->{version}[$i] != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($right->{"version"}[$i] != 0) 0 0 0
853 0 $retval = -1; # not a match after all
854 }
855 0 $i++;
856 }
857 }
858 else {
859 0 ▶ while ( $i <= $l && $retval == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $l and $retval == 0) 0 0 0
Condition0%0/3
$i <= $l and $retval == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$i <= $l and $retval == 0
$i <= $l $retval == 0
Truth table0%0/3
A and B
A= $i <= $lB= $retval == 0
ABresult
0X0
100
111
860 0 ▶ if ( $left->{version}[$i] != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left->{"version"}[$i] != 0) 0 0 0
861 0 $retval = +1; # not a match after all
862 }
863 0 $i++;
864 }
865 }
866 }
867  
868 0 return $retval;
869 }
870  
871 0 ▶sub vbool {
Subroutine vbool: not called CC=1 SCAR=6.9
Pod undocumented
872 0 my ($self) = @_;
873 0 return vcmp($self,$self->new("0"),1);
874 }
875  
876 0 ▶sub vnoop {
Subroutine vnoop: not called CC=1 SCAR=6.9
Pod undocumented
877 0 require Carp;
878 0 Carp::croak("operation not supported with version object");
879 }
880  
881 0 ▶sub is_alpha {
Subroutine is_alpha: not called CC=1 SCAR=6.9
Pod undocumented
882 0 my ($self) = @_;
883 0 return (exists $self->{alpha});
884 }
885  
886 0 ▶sub qv {
Subroutine qv: not called CC=4 SCAR=30.0
Pod undocumented
887 0 my $value = shift;
888 0 my $class = $CLASS;
889 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
890 0 ▶ $class = ref($value) || $value;
Condition0%0/3
ref $value || $value
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $value || $value
ref $value $value
Truth table0%0/3
A || B
A= ref $valueB= $value
ABresult
1X1
011
000
891 0 $value = shift;
892 }
893  
894 0 $value = _un_vstring($value);
895 0 ▶ $value = 'v'.$value unless $value =~ /(^v|\d+\.\d+\.\d)/;
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /(^v|\d+\.\d+\.\d)/ 0 0 0
896 0 my $obj = $CLASS->new($value);
897 0 return bless $obj, $class;
898 }
899  
900 1 *declare = \&qv;
901  
902 0 ▶sub is_qv {
Subroutine is_qv: not called CC=1 SCAR=6.9
Pod undocumented
903 0 my ($self) = @_;
904 0 return (exists $self->{qv});
905 }
906  
907  
908 0 ▶sub _verify {
Subroutine _verify: not called CC=4 SCAR=30.0
909 0 my ($self) = @_;
910 0 ▶ if ( ref($self)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self and eval { do { exists $self->{'version'} } } and ref $self->{'version'} eq 'ARRAY') { } 0 0 0
Condition0%0/6
ref $self and eval { do { exists $self->{"version"} } } and ref $self->{"version"} eq "ARRAY"
!ll&&!rl&&r
000
ref $self and eval { do { exists $self->{"version"} } }
!ll&&!rl&&r
000
MC/DC0%0/3
ref $self and eval { do { exists $self->{"version"} } } and ref $self->{"version"} eq "ARRAY"
ref $self eval { do { exists $self->{"version"} } } ref $self->{"version"} eq "ARRAY"
Truth table0%0/4
A and B and C
A= ref $selfB= eval { do { exists $self->{"version"} } }C= ref $self->{"version"} eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
911 0 && eval { exists $self->{version} }
912 && ref($self->{version}) eq 'ARRAY'
913 ) {
914 0 return 1;
915 }
916 else {
917 0 return 0;
918 }
919 }
920  
921 0 ▶sub _is_non_alphanumeric {
Subroutine _is_non_alphanumeric: not called CC=6 SCAR=37.4
922 0 my $s = shift;
923 0 $s = new ExtUtils::MakeMaker::charstar $s;
924 0 ▶ while ($s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s) 0 0 0
925 0 ▶ return 0 if isSPACE($s); # early out
Branch: 1 branch
BranchTrueFalseTotal
if isSPACE($s) 0 0 0
926 0 ▶ return 1 unless (isALPHA($s) || isDIGIT($s) || $s =~ /[.-]/);
Branch: 1 branch
BranchTrueFalseTotal
unless isALPHA($s) or isDIGIT($s) or $s =~ /[.-]/ 0 0 0
Condition0%0/6
isALPHA($s) or isDIGIT($s) or $s =~ /[.-]/
l!l&&r!l&&!r
000
isALPHA($s) or isDIGIT($s)
l!l&&r!l&&!r
000
MC/DC0%0/3
isALPHA($s) or isDIGIT($s) or $s =~ /[.-]/
isALPHA($s) isDIGIT($s) $s =~ /[.-]/
Truth table0%0/4
A or B or C
A= isALPHA($s)B= isDIGIT($s)C= $s =~ /[.-]/
ABCresult
1XX1
01X1
0011
0000
927 0 $s++;
928 }
929 0 return 0;
930 }
931  
932 0 ▶sub _un_vstring {
Subroutine _un_vstring: not called CC=8 SCAR=42.8
933 0 my $value = shift;
934 # may be a v-string
935 0 ▶ if ( length($value) >= 3 && $value !~ /[._]/
Branch: 1 branch
BranchTrueFalseTotal
if (length $value >= 3 and not $value =~ /[._]/ and _is_non_alphanumeric($value)) 0 0 0
Condition0%0/6
length $value >= 3 and not $value =~ /[._]/ and _is_non_alphanumeric($value)
!ll&&!rl&&r
000
length $value >= 3 and not $value =~ /[._]/
!ll&&!rl&&r
000
MC/DC0%0/3
length $value >= 3 and not $value =~ /[._]/ and _is_non_alphanumeric($value)
length $value >= 3 not $value =~ /[._]/ _is_non_alphanumeric($value)
Truth table0%0/4
A and not(B) and C
A= length $value >= 3B= not $value =~ /[._]/C= _is_non_alphanumeric($value)
ABCresult
0XX0
10X0
1100
1111
936 && _is_non_alphanumeric($value)) {
937 0 my $tvalue;
938 0 ▶ if ( "$]" >= 5.008_001 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ("$]" >= 5.008001) { } 0 0 0
elsif ("$]" >= 5.006) { } 0 0 0
939 0 $tvalue = _find_magic_vstring($value);
940 0 ▶ $value = $tvalue if length $tvalue;
Branch: 1 branch
BranchTrueFalseTotal
if length $tvalue 0 0 0
941 }
942 elsif ( "$]" >= 5.006_000 ) {
943 0 $tvalue = sprintf("v%vd",$value);
944 0 ▶ if ( $tvalue =~ /^v\d+(\.\d+){2,}$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tvalue =~ /^v\d+(\.\d+){2,}$/) 0 0 0
945 # must be a v-string
946 0 $value = $tvalue;
947 }
948 }
949 }
950 0 return $value;
951 }
952  
953 0 ▶sub _find_magic_vstring {
Subroutine _find_magic_vstring: not called CC=4 SCAR=30.0
954 0 my $value = shift;
955 0 my $tvalue = '';
956 0 require B;
957 0 my $sv = B::svref_2object(\$value);
958 0 ▶ my $magic = ref($sv) eq 'B::PVMG' ? $sv->MAGIC : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $sv eq 'B::PVMG' ? : 0 0 0
959 0 ▶ while ( $magic ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($magic) 0 0 0
960 0 ▶ if ( $magic->TYPE eq 'V' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($magic->TYPE eq 'V') { } 0 0 0
961 0 $tvalue = $magic->PTR;
962 0 $tvalue =~ s/^v?(.+)$/v$1/;
963 0 last;
964 }
965 else {
966 0 $magic = $magic->MOREMAGIC;
967 }
968 }
969 0 return $tvalue;
970 }
971  
972 0 ▶sub _VERSION {
Subroutine _VERSION: not called CC=14 SCAR=51.9
973 0 my ($obj, $req) = @_;
974 0 ▶ my $class = ref($obj) || $obj;
Condition0%0/3
ref $obj || $obj
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $obj || $obj
ref $obj $obj
Truth table0%0/3
A || B
A= ref $objB= $obj
ABresult
1X1
011
000
975  
976 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
977 0 ▶ if ( exists $INC{"$class.pm"} and not %{"$class\::"} and "$]" >= 5.008) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $INC{"$class.pm"} and not %{"${class}::";} and "$]" >= "5.008") 0 0 0
Condition0%0/6
exists $INC{"$class.pm"} and not %{"${class}::";} and "$]" >= "5.008"
!ll&&!rl&&r
000
exists $INC{"$class.pm"} and not %{"${class}::";}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $INC{"$class.pm"} and not %{"${class}::";} and "$]" >= "5.008"
exists $INC{"$class.pm"} not %{"${class}::";} "$]" >= "5.008"
Truth table0%0/4
A and not(B) and C
A= exists $INC{"$class.pm"}B= not %{"${class}::";}C= "$]" >= "5.008"
ABCresult
0XX0
10X0
1100
1111
978 # file but no package
979 0 require Carp;
980 0 Carp::croak( "$class defines neither package nor VERSION"
981 ."--version check failed");
982 }
983  
984 0 my $version = eval "\$$class\::VERSION";
985 0 ▶ if ( defined $version ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $version) 0 0 0
986 0 ▶ local $^W if "$]" <= 5.008;
Branch: 1 branch
BranchTrueFalseTotal
if "$]" <= "5.008" 0 0 0
987 0 $version = ExtUtils::MakeMaker::version::vpp->new($version);
988 }
989  
990 0 ▶ if ( defined $req ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $req) 0 0 0
991 0 ▶ unless ( defined $version ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $version) 0 0 0
992 0 require Carp;
993 0 ▶ my $msg = "$]" < 5.006
Branch: 1 branch
BranchTrueFalseTotal
"$]" < 5.006 ? : 0 0 0
994 ? "$class version $req required--this is only version "
995 : "$class does not define \$$class\::VERSION"
996 ."--version check failed";
997  
998 0 ▶ if ( $ENV{VERSION_DEBUG} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'VERSION_DEBUG'}) { } 0 0 0
999 0 Carp::confess($msg);
1000 }
1001 else {
1002 0 Carp::croak($msg);
1003 }
1004 }
1005  
1006 0 $req = ExtUtils::MakeMaker::version::vpp->new($req);
1007  
1008 0 ▶ if ( $req > $version ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req > $version) 0 0 0
1009 0 require Carp;
1010 0 ▶ if ( $req->is_qv ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->is_qv) { } 0 0 0
1011 0 Carp::croak(
1012 sprintf ("%s version %s required--".
1013 "this is only version %s", $class,
1014 $req->normal, $version->normal)
1015 );
1016 }
1017 else {
1018 0 Carp::croak(
1019 sprintf ("%s version %s required--".
1020 "this is only version %s", $class,
1021 $req->stringify, $version->stringify)
1022 );
1023 }
1024 }
1025 }
1026  
1027 0 ▶ return defined $version ? $version->stringify : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $version ? : 0 0 0
1028 }
1029  
1030 1 1; #this line is important and will help the module return a true value
↑ Summary lib/ExtUtils/Liblist/Kid.pm »