line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ctflags::check; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
11
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1069
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# this package is supposed to be private to ctflags and companion |
13
|
|
|
|
|
|
|
# packages, not used from any other module so it uses directly |
14
|
|
|
|
|
|
|
# @EXPORT. |
15
|
|
|
|
|
|
|
our @EXPORT = qw( chack_identifier |
16
|
|
|
|
|
|
|
check_ns |
17
|
|
|
|
|
|
|
check_flag |
18
|
|
|
|
|
|
|
check_value |
19
|
|
|
|
|
|
|
check_flagset |
20
|
|
|
|
|
|
|
check_flagsetext |
21
|
|
|
|
|
|
|
check_alias |
22
|
|
|
|
|
|
|
check_defopt |
23
|
|
|
|
|
|
|
check_envname |
24
|
|
|
|
|
|
|
check_cntprefix |
25
|
|
|
|
|
|
|
check_package |
26
|
|
|
|
|
|
|
check_sub |
27
|
|
|
|
|
|
|
$identifier_re |
28
|
|
|
|
|
|
|
$ns_re |
29
|
|
|
|
|
|
|
$flag_re |
30
|
|
|
|
|
|
|
$value_re |
31
|
|
|
|
|
|
|
$flagset_re |
32
|
|
|
|
|
|
|
$flagsetext_re |
33
|
|
|
|
|
|
|
$alias_re |
34
|
|
|
|
|
|
|
$envname_re |
35
|
|
|
|
|
|
|
$cntprefix_re |
36
|
|
|
|
|
|
|
$package_re |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub myquote ($ ) { |
41
|
0
|
|
|
0
|
0
|
0
|
my $v=shift; |
42
|
0
|
0
|
|
|
|
0
|
defined $v ? "'$v'" : "'undef'"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $identifier_re = qr|[a-zA-Z_]\w*|; |
47
|
|
|
|
|
|
|
sub check_identifier ($ ) { |
48
|
0
|
0
|
0
|
0
|
0
|
0
|
(defined $_[0] and $_[0]=~/^$identifier_re$/o) |
49
|
|
|
|
|
|
|
or die "invalid perl identifier ".myquote($_[0])."\n"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
our $ns_re=qr|$identifier_re(?::$identifier_re)*|; |
53
|
|
|
|
|
|
|
sub check_ns ($ ) { |
54
|
27
|
50
|
33
|
27
|
0
|
215
|
(defined $_[0] and $_[0]=~/^$ns_re$/o) |
55
|
|
|
|
|
|
|
or die "invalid namespace specification ".myquote($_[0])."\n"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
our $flag_re=qr|[a-zA-Z]|; |
59
|
|
|
|
|
|
|
sub check_flag ($ ) { |
60
|
27
|
50
|
33
|
27
|
0
|
156
|
(defined $_[0] and $_[0]=~/^$flag_re$/o) |
61
|
|
|
|
|
|
|
or die "invalid ctflag specification ".myquote($_[0])."\n"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
our $value_re=qr|\d+|; |
65
|
|
|
|
|
|
|
sub check_value ($ ) { |
66
|
21
|
50
|
66
|
21
|
0
|
132
|
(!defined $_[0] or $_[0]=~/^$value_re$/o) |
67
|
|
|
|
|
|
|
or die "invalid ctflag value ".myquote($_[0])."\n"; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
our $flagset_re=qr|(?:$flag_re)*|; |
71
|
|
|
|
|
|
|
sub check_flagset ($ ) { |
72
|
0
|
0
|
0
|
0
|
0
|
0
|
(defined $_[0] and $_[0]=~/^$flagset_re$/o) |
73
|
|
|
|
|
|
|
or die "invalid ctflags set ".myquote($_[0])."\n"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
our $flagsetext_re=qr{\*|!?$flagset_re}; |
77
|
|
|
|
|
|
|
sub check_flagsetext ($) { |
78
|
0
|
0
|
0
|
0
|
0
|
0
|
(defined $_[0] and $_[0]=~/^$flagsetext_re$/o) |
79
|
|
|
|
|
|
|
or die "invalid ctflags set ".myquote($_[0])."\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
our $alias_re=$identifier_re; |
83
|
|
|
|
|
|
|
sub check_alias($ ) { |
84
|
0
|
0
|
0
|
0
|
0
|
0
|
(defined $_[0] and $_[0]=~/^$identifier_re$/o) |
85
|
|
|
|
|
|
|
or die "invalid alias specification ".myquote($_[0])."\n"; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub check_defopt($$) { |
89
|
0
|
0
|
|
0
|
0
|
0
|
defined $_[0] |
90
|
|
|
|
|
|
|
or die "'undef' is not a valid value for option '$_[1]'\n"; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
our $envname_re=$identifier_re; |
94
|
|
|
|
|
|
|
sub check_envname($ ) { |
95
|
0
|
0
|
0
|
0
|
0
|
0
|
(defined $_[0] and $_[0]=~/^$envname_re$/o) |
96
|
|
|
|
|
|
|
or die "invalid environment variable name ".myquote($_[0])."\n"; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
our $cntprefix_re=qr/(?:$identifier_re)?/; |
100
|
|
|
|
|
|
|
sub check_cntprefix ($ ) { |
101
|
1
|
50
|
33
|
1
|
0
|
36
|
(defined $_[0] and $_[0]=~/^$cntprefix_re$/o) |
102
|
|
|
|
|
|
|
or die "invalid constant prefix ".myquote($_[0])."\n"; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
our $package_re=qr|$identifier_re(?:::$identifier_re)*|; |
106
|
|
|
|
|
|
|
sub check_package ($ ) { |
107
|
0
|
0
|
0
|
0
|
0
|
|
(defined $_[0] and $_[0]=~/^$package_re$/o) |
108
|
|
|
|
|
|
|
or die "invalid package name ".myquote($_[0])."\n"; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub check_sub ($) { |
112
|
0
|
0
|
0
|
0
|
0
|
|
(defined $_[0] and UNIVERSAL::isa($_[0], 'CODE')) |
113
|
|
|
|
|
|
|
or die "invalid sub ".myquote($_[0])."\n"; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
__END__ |