line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package C::Template; |
2
|
1
|
|
|
1
|
|
44076
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
58
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
11648
|
use Template; |
|
1
|
|
|
|
|
73606
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
14776
|
use Template::Filters; |
|
1
|
|
|
|
|
11741
|
|
|
1
|
|
|
|
|
40
|
|
8
|
1
|
|
|
1
|
|
12
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
107
|
|
9
|
1
|
|
|
1
|
|
8175
|
use C::Utility qw/convert_to_c_string convert_to_c_string_pc add_lines/; |
|
1
|
|
|
|
|
9564
|
|
|
1
|
|
|
|
|
802
|
|
10
|
1
|
|
|
1
|
|
5710
|
use FindBin; |
|
1
|
|
|
|
|
4909
|
|
|
1
|
|
|
|
|
581
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $filters = Template::Filters->new ({ |
13
|
|
|
|
|
|
|
FILTERS => { |
14
|
|
|
|
|
|
|
# Convert but do not convert % -> %% |
15
|
|
|
|
|
|
|
'c' => \&convert_to_c_string, |
16
|
|
|
|
|
|
|
# Convert with additionally % -> %% |
17
|
|
|
|
|
|
|
'cpc' => \&convert_to_c_string_pc, |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
}); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new |
22
|
|
|
|
|
|
|
{ |
23
|
1
|
|
|
1
|
1
|
18
|
my ($package, $options) = @_; |
24
|
1
|
|
|
|
|
4
|
my $o = {}; |
25
|
1
|
|
|
|
|
7
|
$o->{include_path} = ['.', $FindBin::Bin, $options->{include_path}]; |
26
|
1
|
|
|
|
|
18
|
my $tt = Template->new ( |
27
|
|
|
|
|
|
|
ABSOLUTE => 1, |
28
|
|
|
|
|
|
|
INCLUDE_PATH => $o->{include_path}, |
29
|
|
|
|
|
|
|
# STRICT => 1, |
30
|
|
|
|
|
|
|
ENCODING => 'utf8', |
31
|
|
|
|
|
|
|
LOAD_FILTERS => $filters, |
32
|
|
|
|
|
|
|
); |
33
|
1
|
|
|
|
|
116605
|
$o->{tt} = $tt; |
34
|
1
|
|
|
|
|
2
|
bless $o; |
35
|
1
|
|
|
|
|
7
|
return $o; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub process |
39
|
|
|
|
|
|
|
{ |
40
|
2
|
|
|
2
|
1
|
77352
|
my ($o, $in, $vars_ref, $out) = @_; |
41
|
2
|
|
|
|
|
7
|
my $input = $in; |
42
|
2
|
|
|
|
|
4
|
my $text; |
43
|
2
|
100
|
|
|
|
11
|
if (! ref $in) { |
44
|
1
|
50
|
|
|
|
18
|
if (! -f $in) { |
45
|
1
|
|
|
|
|
4
|
for my $dir (@{$o->{include_path}}) { |
|
1
|
|
|
|
|
4
|
|
46
|
2
|
|
|
|
|
7
|
my $in_dir = "$dir/$in"; |
47
|
2
|
100
|
|
|
|
48
|
if (-f $in_dir) { |
48
|
1
|
|
|
|
|
3
|
$in = $in_dir; |
49
|
1
|
|
|
|
|
8
|
goto found; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
0
|
croak "Input file $in not found"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
found: |
55
|
1
|
|
|
|
|
6
|
$text = add_lines ($in); |
56
|
1
|
|
|
|
|
22473
|
$input = \$text; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
# print "$input $text $out @{$vars_ref->{fixed_texts}}\n"; |
59
|
2
|
50
|
|
|
|
26
|
$o->{tt}->process ($input, $vars_ref, $out, {binmode => 'utf8'}) |
60
|
|
|
|
|
|
|
or die ''. $o->{tt}->error (); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |