line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Maker; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
37571
|
use utf8; |
|
9
|
|
|
|
|
32
|
|
|
9
|
|
|
|
|
68
|
|
4
|
9
|
|
|
9
|
|
264
|
use warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
504
|
|
5
|
9
|
|
|
9
|
|
107
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
295
|
|
6
|
9
|
|
|
9
|
|
369
|
use 5.006_001; |
|
9
|
|
|
|
|
32
|
|
|
9
|
|
|
|
|
397
|
|
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
52
|
use Carp; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
698
|
|
9
|
9
|
|
|
9
|
|
7009
|
use Config::Maker::Encode; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
4568
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require overload; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# DEBUG |
14
|
|
|
|
|
|
|
sub LOG; |
15
|
|
|
|
|
|
|
sub DBG; |
16
|
|
|
|
|
|
|
sub DUMP; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
BEGIN { |
19
|
9
|
50
|
|
9
|
|
40
|
if($::QUIET) { |
|
|
0
|
|
|
|
|
|
20
|
9
|
|
|
280
|
|
49
|
*LOG = sub {}; |
|
280
|
|
|
|
|
902
|
|
21
|
9
|
|
|
1432
|
|
39
|
*DBG = sub {}; |
|
1432
|
|
|
|
|
3132
|
|
22
|
|
|
|
|
|
|
} elsif(!$::VERBOSE) { |
23
|
0
|
|
|
|
|
0
|
*LOG = sub { print STDERR @_, "\n"; }; |
|
0
|
|
|
|
|
0
|
|
24
|
0
|
|
|
|
|
0
|
*DBG = sub {}; |
|
0
|
|
|
|
|
0
|
|
25
|
|
|
|
|
|
|
} else { # VERBOSE |
26
|
0
|
|
|
|
|
0
|
*LOG = \&Carp::carp; |
27
|
0
|
|
|
|
|
0
|
*DBG = \&Carp::carp; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
9
|
50
|
|
|
|
56
|
if($::DEBUG) { |
31
|
0
|
|
|
|
|
0
|
require Data::Dumper; |
32
|
|
|
|
|
|
|
*DUMP = sub { |
33
|
0
|
|
|
|
|
0
|
print STDERR '>' x 40, ' ', shift, "\n", |
34
|
|
|
|
|
|
|
Data::Dumper::Dumper(@_), |
35
|
|
|
|
|
|
|
'<' x 40, "\n"; |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
0
|
} else { |
38
|
9
|
|
|
0
|
|
39
|
*DUMP = sub {}; |
|
0
|
|
|
|
|
0
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
9
|
50
|
|
|
|
40
|
LOG($::ENCODING_LOG) if $::ENCODING_LOG; |
42
|
9
|
50
|
|
|
|
216
|
if($::ENCODING) { |
43
|
9
|
|
|
|
|
57
|
LOG("Selected $::ENCODING as system encoding"); |
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
0
|
LOG("Charset conversion not available!"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
# /DEBUG |
49
|
|
|
|
|
|
|
|
50
|
9
|
|
|
9
|
|
8699
|
use Config::Maker::Value; # overloading... |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
234
|
|
51
|
9
|
|
|
9
|
|
67101
|
use Config::Maker::Grammar; # Build the parser... |
|
9
|
|
|
|
|
61
|
|
|
9
|
|
|
|
|
1992
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our $parser = Config::Maker::Grammar->new(); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
9
|
|
123
|
use Exporter; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
7861
|
|
58
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
59
|
|
|
|
|
|
|
our @EXPORT = qw(LOG DBG DUMP); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# This must be after "constants" |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
require Config::Maker::Config; |
64
|
|
|
|
|
|
|
require Config::Maker::Driver; |
65
|
|
|
|
|
|
|
require Config::Maker::Schema; |
66
|
|
|
|
|
|
|
require Config::Maker::Metaconfig; |
67
|
|
|
|
|
|
|
require Config::Maker::Eval; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
our $fenc = qr/(?:(?:(?:file)?en)coding|fenc)[:=]\s*/; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub unbackslash { |
72
|
0
|
|
|
0
|
0
|
0
|
eval qq{"\\$_[0]"} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub environment { |
76
|
0
|
0
|
|
0
|
0
|
0
|
if(defined $ENV{$_[0]}) { |
77
|
0
|
|
|
|
|
0
|
return $ENV{$_[0]}; |
78
|
|
|
|
|
|
|
} else { |
79
|
0
|
|
|
|
|
0
|
warn "Undefined environment variable $_[0] used"; |
80
|
0
|
|
|
|
|
0
|
return ''; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub unquote_single { |
85
|
239
|
|
|
239
|
0
|
486
|
local $_ = $_[0]; |
86
|
239
|
|
|
|
|
1633
|
s/\A'//; |
87
|
239
|
|
|
|
|
1215
|
s/'\Z//; |
88
|
239
|
|
|
|
|
487
|
s/\\'/'/g; |
89
|
239
|
|
|
|
|
855
|
return $_; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub unquote_double { |
93
|
5
|
|
|
5
|
0
|
15
|
local $_ = $_[0]; |
94
|
5
|
|
|
|
|
35
|
s/\A"//; |
95
|
5
|
|
|
|
|
33
|
s/"\Z//; |
96
|
5
|
|
|
|
|
32
|
s/\\( # Backslashed stuff: |
97
|
|
|
|
|
|
|
["\$\\] # Things to escape |
98
|
|
|
|
|
|
|
| [tnrfbae] # Simple escape codes |
99
|
|
|
|
|
|
|
| x[[:xdigit:]]{2} # Hex-code |
100
|
|
|
|
|
|
|
| x\{[[:xdigit:]]{1,8}\} # Wide hex-code |
101
|
|
|
|
|
|
|
| [0-7]{1,3} # Octal-code |
102
|
|
|
|
|
|
|
| c[@-_] # Control-char |
103
|
|
|
|
|
|
|
| N\{\w*\} # Named char |
104
|
|
|
|
|
|
|
) | |
105
|
|
|
|
|
|
|
\$ (\w+) | # Undelimited substitution |
106
|
|
|
|
|
|
|
\$ \{ (\w+) \} # Delimited substitution |
107
|
0
|
0
|
|
|
|
0
|
/ $1 ? unbackslash($1) : |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$2 ? environment($2) : |
109
|
|
|
|
|
|
|
$3 ? environment($3) : die "This match does not work"/xe; |
110
|
5
|
|
|
|
|
20
|
return $_; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub truecmp { |
114
|
338
|
100
|
|
338
|
0
|
2229
|
$_[2] ? overload::StrVal($_[1]) cmp overload::StrVal($_[0]) |
115
|
|
|
|
|
|
|
: overload::StrVal($_[0]) cmp overload::StrVal($_[1]); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub limit { |
119
|
53
|
|
|
53
|
0
|
105
|
my ($num, $min, $max) = @_; |
120
|
53
|
50
|
|
|
|
148
|
return undef if $num < $min; |
121
|
53
|
50
|
33
|
|
|
762
|
return undef if $max && $num > $max; |
122
|
53
|
|
|
|
|
193
|
return $num; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# A non-catching eval... |
126
|
|
|
|
|
|
|
sub exe { |
127
|
9
|
|
|
9
|
|
124
|
no warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
615
|
|
128
|
9
|
|
|
9
|
|
58
|
no strict; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
3953
|
|
129
|
32
|
50
|
|
32
|
0
|
246
|
DBG "Evaluating qq{$_[0]} in " . (wantarray ? "list" : (defined wantarray ? "scalar" : "void")) . " context"; |
|
|
100
|
|
|
|
|
|
130
|
32
|
100
|
|
|
|
99
|
if(wantarray) { |
|
|
50
|
|
|
|
|
|
131
|
18
|
|
|
|
|
2192
|
my @r = eval qq/package Config::Maker::Eval; $_[0]/; |
132
|
18
|
100
|
|
|
|
119
|
die $@ if $@; |
133
|
16
|
|
|
|
|
223
|
return @r; |
134
|
|
|
|
|
|
|
} elsif(defined wantarray) { |
135
|
14
|
|
|
|
|
2261
|
my $r = eval qq/package Config::Maker::Eval; $_[0]/; |
136
|
14
|
50
|
|
|
|
60
|
die $@ if $@; |
137
|
14
|
|
|
|
|
56
|
return $r; |
138
|
|
|
|
|
|
|
} else { |
139
|
0
|
|
|
|
|
0
|
eval qq/package Config::Maker::Eval; $_[0]/; |
140
|
0
|
0
|
|
|
|
0
|
die $@ if $@; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
our @path = ('.'); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub locate { |
147
|
144
|
|
|
144
|
0
|
454
|
my ($file) = @_; |
148
|
144
|
50
|
|
|
|
1949
|
if(File::Spec->file_name_is_absolute($file)) { |
149
|
0
|
|
|
|
|
0
|
return $file; |
150
|
|
|
|
|
|
|
} else { |
151
|
144
|
|
|
|
|
549
|
for(@path) { |
152
|
144
|
|
|
|
|
16504
|
my $f = File::Spec->rel2abs($file, $_); |
153
|
144
|
|
|
|
|
739
|
DBG "Trying: $f"; |
154
|
144
|
50
|
|
|
|
12867
|
return $f if -r $f; |
155
|
|
|
|
|
|
|
} |
156
|
0
|
|
|
|
|
|
local $" = ', '; |
157
|
0
|
|
|
|
|
|
croak "Can't find $file in @path"; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
$::RD_HINT = 1; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
__END__ |