line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Maker::Driver; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
54
|
use utf8; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
59
|
|
4
|
9
|
|
|
9
|
|
328
|
use warnings; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
301
|
|
5
|
9
|
|
|
9
|
|
53
|
use strict; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
334
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
49
|
use Carp; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
556
|
|
8
|
9
|
|
|
9
|
|
58
|
use Parse::RecDescent; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
188
|
|
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
341
|
use Config::Maker; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
528
|
|
11
|
9
|
|
|
9
|
|
55
|
use Config::Maker::Encode; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
1409
|
|
12
|
9
|
|
|
9
|
|
54
|
use Config::Maker::Option; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
208
|
|
13
|
9
|
|
|
9
|
|
51
|
use Config::Maker::Path; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
201
|
|
14
|
9
|
|
|
9
|
|
6712
|
use Config::Maker::Tee; |
|
9
|
|
|
|
|
36
|
|
|
9
|
|
|
|
|
16104
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $parser = $Config::Maker::parser; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub apply { |
19
|
209
|
|
|
209
|
0
|
446
|
for my $e (@_) { |
20
|
497
|
100
|
|
|
|
1223
|
if(ref $e eq 'CODE') { |
|
|
50
|
|
|
|
|
|
21
|
247
|
|
|
|
|
874
|
$e->(); |
22
|
|
|
|
|
|
|
} elsif(ref $e) { |
23
|
0
|
|
|
|
|
0
|
$e->do(); |
24
|
|
|
|
|
|
|
} else { |
25
|
250
|
|
|
|
|
1745
|
print $e; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub process { |
31
|
45
|
|
|
45
|
0
|
130
|
my ($class, $file, $config, $outfh, $outenc) = @_; |
32
|
|
|
|
|
|
|
|
33
|
45
|
50
|
|
|
|
308
|
croak "Invalid config!" |
34
|
|
|
|
|
|
|
unless UNIVERSAL::isa($config, 'Config::Maker::Config'); |
35
|
|
|
|
|
|
|
|
36
|
45
|
|
|
|
|
120
|
local $Config::Maker::Eval::config = $config; |
37
|
45
|
|
|
|
|
120
|
local $_ = $config->{root}; |
38
|
|
|
|
|
|
|
|
39
|
45
|
|
|
|
|
249
|
my ($code, $enc) = $class->load($file); |
40
|
|
|
|
|
|
|
|
41
|
45
|
|
66
|
|
|
310
|
$outenc ||= $enc; |
42
|
45
|
|
|
|
|
363
|
encmode($outfh, $outenc); |
43
|
|
|
|
|
|
|
|
44
|
45
|
|
|
|
|
3226
|
LOG("Processing the template with output in $outenc"); |
45
|
45
|
|
|
|
|
219
|
my $old = select; |
46
|
45
|
|
|
|
|
147
|
select $outfh; |
47
|
45
|
|
|
|
|
89
|
eval { $code->() }; |
|
45
|
|
|
|
|
163
|
|
48
|
45
|
|
|
|
|
244
|
select $old; |
49
|
45
|
100
|
|
|
|
875
|
die $@ if $@; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
our %cache; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub load { |
55
|
46
|
|
|
46
|
0
|
111
|
my ($class, $file) = @_; |
56
|
46
|
|
|
|
|
78
|
my ($fh, $text); |
57
|
46
|
|
|
|
|
97
|
my $enc = 'system'; |
58
|
|
|
|
|
|
|
|
59
|
46
|
|
|
|
|
256
|
$file = Config::Maker::locate($file); |
60
|
|
|
|
|
|
|
|
61
|
46
|
100
|
|
|
|
265
|
if($cache{$file}) { |
62
|
9
|
|
|
|
|
563
|
DBG "Getting template $file from cache"; |
63
|
9
|
50
|
|
|
|
38
|
return wantarray ? @{$cache{$file}} : $cache{$file}[0]; |
|
9
|
|
|
|
|
56
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
37
|
50
|
|
|
|
2073
|
open($fh, '<', $file) |
67
|
|
|
|
|
|
|
or croak "Failed to open $file: $!"; |
68
|
|
|
|
|
|
|
{ |
69
|
37
|
|
|
|
|
109
|
local $/; |
|
37
|
|
|
|
|
194
|
|
70
|
37
|
|
|
|
|
2661
|
$text = <$fh>; |
71
|
|
|
|
|
|
|
} |
72
|
37
|
|
|
|
|
1303
|
close $fh; |
73
|
|
|
|
|
|
|
|
74
|
37
|
100
|
66
|
|
|
1970
|
if((substr($text, 0, 250) =~ /\[#[^#]*$Config::Maker::fenc([[:alnum:]_-]+)/) || |
75
|
|
|
|
|
|
|
(substr($text, -250) =~ /\[#[^#]*$Config::Maker::fenc([[:alnum:]_-]+)/)) { |
76
|
1
|
|
|
|
|
4
|
$enc = $1; |
77
|
|
|
|
|
|
|
} |
78
|
37
|
|
|
|
|
270
|
$text = decode($enc, $text); |
79
|
|
|
|
|
|
|
|
80
|
37
|
|
|
|
|
2739
|
LOG("Loading template $file encoded $enc"); |
81
|
37
|
|
|
|
|
481
|
my $out = $parser->template($text); |
82
|
37
|
50
|
|
|
|
905
|
croak "Template file $file contained errors" |
83
|
|
|
|
|
|
|
unless defined $out; |
84
|
|
|
|
|
|
|
|
85
|
37
|
|
|
53
|
|
238
|
my $code = sub { apply(@$out); }; |
|
53
|
|
|
|
|
250
|
|
86
|
37
|
|
|
|
|
209
|
$cache{$file} = [$code, $enc]; |
87
|
37
|
100
|
|
|
|
398
|
return wantarray ? ($code, $enc) : $code; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |