version/vpp.pm

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