lib/ExtUtils/MakeMaker/version/regex.pm

filter: Statementstmt 91.3% 21 / 23 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 2 totaltotal 69.7% 23 / 33 CC 3 SCAR 14.7
CC
3
Cov
78%
is_strict
6.0
is_lax
6.0
BEGIN
1.0
CRAP 4.3
« lib/ExtUtils/MM_QNX.pm ↑ Summary blib/lib/ExtUtils/MM.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::version::regex;
8  
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use vars qw($VERSION $CLASS $STRICT $LAX);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 $VERSION = '7.13_01';
14 1 $VERSION = eval $VERSION;
15  
16 #--------------------------------------------------------------------------#
17 # Version regexp components
18 #--------------------------------------------------------------------------#
19  
20 # Fraction part of a decimal version number. This is a common part of
21 # both strict and lax decimal versions
22  
23 1 my $FRACTION_PART = qr/\.[0-9]+/;
24  
25 # First part of either decimal or dotted-decimal strict version number.
26 # Unsigned integer with no leading zeroes (except for zero itself) to
27 # avoid confusion with octal.
28  
29 1 my $STRICT_INTEGER_PART = qr/0|[1-9][0-9]*/;
30  
31 # First part of either decimal or dotted-decimal lax version number.
32 # Unsigned integer, but allowing leading zeros. Always interpreted
33 # as decimal. However, some forms of the resulting syntax give odd
34 # results if used as ordinary Perl expressions, due to how perl treats
35 # octals. E.g.
36 # version->new("010" ) == 10
37 # version->new( 010 ) == 8
38 # version->new( 010.2) == 82 # "8" . "2"
39  
40 1 my $LAX_INTEGER_PART = qr/[0-9]+/;
41  
42 # Second and subsequent part of a strict dotted-decimal version number.
43 # Leading zeroes are permitted, and the number is always decimal.
44 # Limited to three digits to avoid overflow when converting to decimal
45 # form and also avoid problematic style with excessive leading zeroes.
46  
47 1 my $STRICT_DOTTED_DECIMAL_PART = qr/\.[0-9]{1,3}/;
48  
49 # Second and subsequent part of a lax dotted-decimal version number.
50 # Leading zeroes are permitted, and the number is always decimal. No
51 # limit on the numerical value or number of digits, so there is the
52 # possibility of overflow when converting to decimal form.
53  
54 1 my $LAX_DOTTED_DECIMAL_PART = qr/\.[0-9]+/;
55  
56 # Alpha suffix part of lax version number syntax. Acts like a
57 # dotted-decimal part.
58  
59 1 my $LAX_ALPHA_PART = qr/_[0-9]+/;
60  
61 #--------------------------------------------------------------------------#
62 # Strict version regexp definitions
63 #--------------------------------------------------------------------------#
64  
65 # Strict decimal version number.
66  
67 1 my $STRICT_DECIMAL_VERSION =
68 qr/ $STRICT_INTEGER_PART $FRACTION_PART? /x;
69  
70 # Strict dotted-decimal version number. Must have both leading "v" and
71 # at least three parts, to avoid confusion with decimal syntax.
72  
73 1 my $STRICT_DOTTED_DECIMAL_VERSION =
74 qr/ v $STRICT_INTEGER_PART $STRICT_DOTTED_DECIMAL_PART{2,} /x;
75  
76 # Complete strict version number syntax -- should generally be used
77 # anchored: qr/ \A $STRICT \z /x
78  
79 1 $STRICT =
80 qr/ $STRICT_DECIMAL_VERSION | $STRICT_DOTTED_DECIMAL_VERSION /x;
81  
82 #--------------------------------------------------------------------------#
83 # Lax version regexp definitions
84 #--------------------------------------------------------------------------#
85  
86 # Lax decimal version number. Just like the strict one except for
87 # allowing an alpha suffix or allowing a leading or trailing
88 # decimal-point
89  
90 1 my $LAX_DECIMAL_VERSION =
91 qr/ $LAX_INTEGER_PART (?: \. | $FRACTION_PART $LAX_ALPHA_PART? )?
92 |
93 $FRACTION_PART $LAX_ALPHA_PART?
94 /x;
95  
96 # Lax dotted-decimal version number. Distinguished by having either
97 # leading "v" or at least three non-alpha parts. Alpha part is only
98 # permitted if there are at least two non-alpha parts. Strangely
99 # enough, without the leading "v", Perl takes .1.2 to mean v0.1.2,
100 # so when there is no "v", the leading part is optional
101  
102 1 my $LAX_DOTTED_DECIMAL_VERSION =
103 qr/
104 v $LAX_INTEGER_PART (?: $LAX_DOTTED_DECIMAL_PART+ $LAX_ALPHA_PART? )?
105 |
106 $LAX_INTEGER_PART? $LAX_DOTTED_DECIMAL_PART{2,} $LAX_ALPHA_PART?
107 /x;
108  
109 # Complete lax version number syntax -- should generally be used
110 # anchored: qr/ \A $LAX \z /x
111 #
112 # The string 'undef' is a special case to make for easier handling
113 # of return values from ExtUtils::MM->parse_version
114  
115 1 $LAX =
116 qr/ undef | $LAX_DECIMAL_VERSION | $LAX_DOTTED_DECIMAL_VERSION /x;
117  
118 #--------------------------------------------------------------------------#
119  
120 # Preloaded methods go here.
121 0 ▶sub is_strict { defined $_[0] && $_[0] =~ qr/ \A $STRICT \z /x }
Subroutine is_strict: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] and $_[0] =~ qr/ \A $ExtUtils::MakeMaker::version::regex::STRICT \z /x 0 0 0
122 0 ▶sub is_lax { defined $_[0] && $_[0] =~ qr/ \A $LAX \z /x }
Subroutine is_lax: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] and $_[0] =~ qr/ \A $ExtUtils::MakeMaker::version::regex::LAX \z /x 0 0 0
123  
124 1 1;
« lib/ExtUtils/MM_QNX.pm ↑ Summary blib/lib/ExtUtils/MM.pm »