lib/ExtUtils/MakeMaker/version/vpp.pm

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