line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Maker::Tee; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
48
|
use utf8; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
61
|
|
4
|
9
|
|
|
9
|
|
420
|
use warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
223
|
|
5
|
9
|
|
|
9
|
|
49
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
597
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
56
|
use Carp; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
540
|
|
8
|
9
|
|
|
9
|
|
52
|
use Symbol(); |
|
9
|
|
|
|
|
38
|
|
|
9
|
|
|
|
|
162
|
|
9
|
9
|
|
|
9
|
|
9643
|
use Tie::Handle; |
|
9
|
|
|
|
|
24642
|
|
|
9
|
|
|
|
|
244
|
|
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
9
|
|
83
|
use Config::Maker; |
|
9
|
|
|
|
|
125
|
|
|
9
|
|
|
|
|
619
|
|
12
|
9
|
|
|
9
|
|
56
|
use Config::Maker::Encode; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
1249
|
|
13
|
9
|
|
|
9
|
|
57
|
use File::Basename 'dirname'; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
8319
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = qw(Tie::Handle); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $OUT = 1; |
18
|
|
|
|
|
|
|
our $CACHE = 1; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _new { |
21
|
8
|
|
|
8
|
|
23
|
my ($class, $fh, $cache) = @_; |
22
|
8
|
50
|
|
|
|
35
|
croak "No filehandle" unless $fh; |
23
|
8
|
50
|
|
|
|
4727
|
croak "No cache file" unless $cache; |
24
|
8
|
|
|
|
|
586
|
my $dir = dirname($cache); |
25
|
8
|
50
|
|
|
|
238
|
unless(-d $dir) { |
26
|
0
|
|
|
|
|
0
|
require File::Path; |
27
|
0
|
|
|
|
|
0
|
File::Path::mkpath($dir); # Throws on error |
28
|
|
|
|
|
|
|
} |
29
|
8
|
50
|
|
|
|
193
|
die "Can't write to cache dir $dir" unless -w $dir; |
30
|
8
|
|
33
|
|
|
61
|
my $self = bless Symbol::gensym(), ref($class) || $class; |
31
|
8
|
|
|
|
|
247
|
*$self->{fh} = $fh; |
32
|
8
|
|
|
|
|
30
|
*$self->{cache} = ''; |
33
|
8
|
|
|
|
|
30
|
*$self->{file} = $cache; |
34
|
8
|
|
|
|
|
19
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
8
|
|
|
8
|
0
|
49
|
my $self = shift->_new(@_); |
39
|
8
|
|
|
|
|
85
|
tie *$self, $self; |
40
|
8
|
|
|
|
|
47
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub cmpcache { |
44
|
8
|
|
|
8
|
0
|
17
|
my ($self) = @_; |
45
|
8
|
100
|
|
|
|
425
|
unless(-e *$self->{file}) { |
46
|
1
|
50
|
|
|
|
15
|
DBG "Cache compare result: " . (*$self->{cache} ? 0 : 1); |
47
|
1
|
50
|
|
|
|
10
|
return *$self->{cache} ? 0 : 1; |
48
|
|
|
|
|
|
|
} |
49
|
7
|
|
|
|
|
46
|
local $/; |
50
|
7
|
50
|
|
|
|
844
|
open CACHE, '<'.$utf8, *$self->{file} or die "Can't read ".*$self->{file}.": $!"; |
51
|
7
|
|
|
|
|
183
|
my $desired = ; |
52
|
7
|
|
|
|
|
85
|
close CACHE; |
53
|
7
|
|
|
|
|
60
|
DBG "Cache compare result: " . ($desired eq *$self->{cache}); |
54
|
7
|
|
|
|
|
77
|
return $desired eq *$self->{cache}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub savecache { |
58
|
4
|
|
|
4
|
0
|
9
|
my ($self) = @_; |
59
|
4
|
|
|
|
|
446
|
unlink *$self->{file}; # Don't rewrite; replace. |
60
|
4
|
50
|
|
|
|
595
|
open CACHE, '>'.$utf8, *$self->{file} or die "Can't write ".*$self->{file}.": $!"; |
61
|
4
|
|
|
|
|
10
|
local $,; |
62
|
4
|
|
|
|
|
20
|
local $\; |
63
|
4
|
|
|
|
|
35
|
print CACHE *$self->{cache}; |
64
|
4
|
|
|
|
|
256
|
close CACHE; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub TIEHANDLE { |
68
|
8
|
50
|
|
8
|
|
49
|
return $_[0] if ref $_[0]; |
69
|
0
|
|
|
|
|
0
|
return shift->_new(@_); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub PRINT { |
73
|
9
|
|
|
9
|
|
72
|
no warnings 'uninitialized'; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
2122
|
|
74
|
12
|
|
|
12
|
|
23
|
my $self = shift; |
75
|
12
|
|
50
|
|
|
233
|
my $ofs = $, || ''; |
76
|
12
|
|
50
|
|
|
159
|
my $ors = $\ || ''; |
77
|
12
|
|
|
|
|
98
|
DBG "PRINT: cache = $CACHE, out = $OUT, args = ".join(', ', @_); |
78
|
12
|
100
|
|
|
|
72
|
*$self->{cache} .= join($ofs, @_) . $ors if $CACHE; |
79
|
12
|
100
|
|
|
|
38
|
return unless $OUT; |
80
|
|
|
|
|
|
|
# *$self->{fh}->print(@_); |
81
|
10
|
|
|
|
|
27
|
my $fh = *$self->{fh}; |
82
|
10
|
|
|
|
|
248
|
print $fh @_; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub PRINTF { |
86
|
9
|
|
|
9
|
|
104
|
no warnings 'uninitialized'; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
2561
|
|
87
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
88
|
0
|
|
|
|
|
0
|
DBG "PRINTF: cache = $CACHE, out = $OUT, args = ".join(', ', @_); |
89
|
0
|
0
|
|
|
|
0
|
*$self->{cache} .= sprintf(@_) if $CACHE; |
90
|
0
|
0
|
|
|
|
0
|
return unless $OUT; |
91
|
|
|
|
|
|
|
# *$self->{fh}->printf(@_); |
92
|
0
|
|
|
|
|
0
|
my $fh = *$self->{fh}; |
93
|
0
|
|
|
|
|
0
|
printf $fh @_; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub CLOSE { |
97
|
8
|
|
|
8
|
|
17
|
my $self = shift; |
98
|
8
|
|
|
|
|
1410
|
close *$self->{fh}; |
99
|
8
|
|
|
|
|
186
|
undef *$self->{fh}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub BINMODE { |
103
|
8
|
|
|
8
|
|
23
|
my $self = shift; |
104
|
8
|
|
|
|
|
1567
|
binmode *$self->{fh}, $_[0]; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |