KDBX/IO.pm

filter: Statementstmt 59.6% 142 / 238 Branchbran 56.9% 41 / 72 Conditioncond 34.5% 19 / 55 MC/DCmcdc 22.5% 7 / 31 Subroutinesub 48.4% 32 / 66 Podpod 42.1% 16 / 38 totaltotal 51.4% 257 / 500 SCAR 59.1
CC
59
Cov
55%
sysread
30.0
eof
20.0
getline
19.8
CRAP 369.0
« KDBX/Group.pm ↑ Summary KDBX/Dumper/KDB.pm »
1 package File::KDBX::IO;
2 # ABSTRACT: Base IO class for KDBX-related streams
3  
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 ▶use Devel::GlobalDestruction;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use File::KDBX::Constants qw(:bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use File::KDBX::Util qw(:class :empty);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use List::Util qw(sum0);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 18 ▶use Ref::Util qw(is_blessed_ref is_ref is_scalarref);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 18 ▶use Symbol qw(gensym);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 18 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 18 extends 'IO::Handle';
16  
17 18 our $VERSION = '0.904'; # VERSION
18  
19 0 ▶sub _croak { require Carp; goto &Carp::croak }
Subroutine _croak: not called CC=1 SCAR=6.9
20  
21 my %ATTRS = (
22 _append_output => 0,
23 56 ▶ _buffer_in => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 17 ▶ _buffer_out => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
25 18 _error => undef,
26 _fh => undef,
27 _mode => '',
28 );
29 18 ▶while (my ($attr, $default) = each %ATTRS) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %ATTRS) 108 18 126
30 18 ▶ no strict 'refs'; ## no critic (ProhibitNoStrict)
Subroutine BEGIN: called CC=1 SCAR=0.0
31 *$attr = sub {
32 2590 ▶ my $self = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
33 2590 ▶ *$self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 285 2305 2590
34 2590 ▶ *$self->{$attr} //= (ref $default eq 'CODE') ? $default->($self) : $default;
Branch: 1 branch
BranchTrueFalseTotal
ref $default eq 'CODE' ? : 73 289 362
Condition100%3/3
*$self->{$attr} //= ref $default eq "CODE" ? &$default($self) : $default
l!l&&r!l&&!r
222873289
MC/DC100%2/2
*$self->{$attr} //= ref $default eq "CODE" ? &$default($self) : $default
*$self->{$attr} ref $default eq "CODE" ? &$default($self) : $default
Truth table100%3/3
A //= B
A= *$self->{$attr}B= ref $default eq "CODE" ? &$default($self) : $default
ABresult
1X1
011
000
35 108 };
36 }
37  
38 sub new {
39 94 ▶ my $class = shift || (caller)[0];
Subroutine new: called CC=4 SCAR=16.4
Pod documented
Condition33%1/3
shift() || (caller)[0]
l!l&&r!l&&!r
9400
MC/DC0%0/2
shift() || (caller)[0]
shift() (caller)[0]
Truth table33%1/3
A || B
A= shift()B= (caller)[0]
ABresult
1X1
011
000
40 94 ▶ my $self = bless gensym, ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0940
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
41 94 ▶ tie *$self, $self if 5.005 <= $];
Branch: 1 branch
BranchTrueFalseTotal
if "5.005" <= $] 94 0 94
42 94 return $self;
43 }
44  
45 sub DESTROY {
46 94 ▶ return if in_global_destruction;
Subroutine DESTROY: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
if &in_global_destruction() 0 94 94
47 94 local ($., $@, $!, $^E, $?);
48 94 my $self = shift;
49 94 $self->close;
50 }
51  
52 sub close {
53 147 ▶ my $self = shift;
Subroutine close: called CC=2 SCAR=6.9
Pod undocumented
54 147 ▶ my $fh = $self->_fh // return TRUE;
Condition100%2/2
$self->_fh // (return 1)
l!l
9453
MC/DC100%1/1
$self->_fh // (return 1)
$self->_fh
Truth table100%2/2
A
A= $self->_fh
Aresult
11
00
55 94 $self->_POPPED($fh);
56 94 $self->_fh(undef);
57 94 return $fh->close;
58 }
59 sub eof {
60 0 ▶ my $self = shift;
Subroutine eof: not called CC=4 SCAR=30.0
Pod undocumented
61 0 ▶ return FALSE if @{$self->_buffer_in};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->_buffer_in;} 0 0 0
62 0 ▶ my $fh = $self->_fh // return TRUE;
Condition0%0/2
$self->_fh // (return 1)
l!l
00
MC/DC0%0/1
$self->_fh // (return 1)
$self->_fh
Truth table0%0/2
A
A= $self->_fh
Aresult
11
00
63 0 local *$self->{_error} = *$self->{_error};
64 0 ▶ my $char = $self->getc || return TRUE;
Condition0%0/2
$self->getc || (return 1)
l!l
00
MC/DC0%0/1
$self->getc || (return 1)
$self->getc
Truth table0%0/2
A
A= $self->getc
Aresult
11
00
65 0 $self->ungetc($char);
66 }
67 321 ▶sub read { shift->sysread(@_) }
Subroutine read: called CC=1 SCAR=0.0
Pod undocumented
68 sub print {
69 86 ▶ my $self = shift;
Subroutine print: called CC=3 SCAR=11.1
Pod undocumented
70 86 for my $buf (@_) {
71 86 ▶ return FALSE if !$self->write($buf, length($buf));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->write($buf, length $buf) 0 86 86
72 }
73 86 return TRUE;
74 }
75 0 ▶sub printf { shift->print(sprintf(@_)) }
Subroutine printf: not called CC=1 SCAR=6.9
Pod undocumented
76 0 ▶sub say { shift->print(@_, "\n") }
Subroutine say: not called CC=1 SCAR=6.9
Pod undocumented
77 0 ▶sub getc { my $c; (shift->read($c, 1) // 0) == 1 ? $c : undef }
Subroutine getc: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
((shift())->read($c, 1) // 0) == 1 ? : 0 0 0
Condition0%0/2
(shift())->read($c, 1) // 0
l!l
00
MC/DC0%0/1
(shift())->read($c, 1) // 0
(shift())->read($c, 1)
Truth table0%0/2
A
A= (shift())->read($c, 1)
Aresult
11
00
78 sub sysread {
79 321 ▶ my $self = shift;
Subroutine sysread: called CC=23 SCAR=34.0
Pod undocumented
80 321 my ($out, $len, $offset) = @_;
81 321 ▶ $out = \$_[0] if !is_scalarref($out);
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_scalarref($out) 321 0 321
82 321 ▶ $offset //= 0;
Condition50%1/2
$offset //= 0
l!l
0321
MC/DC0%0/1
$offset //= 0
$offset
Truth table50%1/2
A
A= $offset
Aresult
11
00
83  
84 321 ▶ $self->_mode('r') if !$self->_mode;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_mode 56 265 321
85  
86 321 ▶ my $fh = $self->_fh or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $fh = $self->_fh or return 0 0 321 321
87 321 ▶ return 0 if defined $len && $len == 0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $len and $len == 0 0 321 321
Condition66%2/3
defined $len and $len == 0
!ll&&!rl&&r
662550
MC/DC0%0/2
defined $len and $len == 0
defined $len $len == 0
Truth table66%2/3
A and B
A= defined $lenB= $len == 0
ABresult
0X0
100
111
88  
89 321 my $append = $self->_append_output;
90 321 ▶ if (!$append) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $append) { } 255 66 321
elsif (not defined $$out) { } 11 55 66
91 255 ▶ if (!$offset) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $offset) { } 255 0 255
92 255 $$out = '';
93 }
94 else {
95 0 ▶ if (length($$out) < $offset) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $$out < $offset) { } 0 0 0
96 0 $$out .= "\0" x ($offset - length($$out));
97 }
98 else {
99 0 substr($$out, $offset) = '';
100 }
101 }
102 }
103 elsif (!defined $$out) {
104 11 $$out = '';
105 }
106  
107 321 ▶ $len ||= 0;
Condition100%2/2
$len ||= 0
l!l
25566
MC/DC100%1/1
$len ||= 0
$len
Truth table100%2/2
A
A= $len
Aresult
11
00
108  
109 321 my $buffer = $self->_buffer_in;
110 321 my $buffer_len = $self->_buffer_in_length;
111  
112 321 ▶ if (!$len && !$offset) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($len or $offset) 66 255 321
Condition66%2/3
$len or $offset
l!l&&r!l&&!r
255066
MC/DC50%1/2
$len or $offset
$len $offset
Truth table66%2/3
A or B
A= $lenB= $offset
ABresult
1X1
011
000
113 66 ▶ if (@$buffer) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$buffer) { } 0 66 66
114 0 my $blen = length($buffer->[0]);
115 0 ▶ if ($append) {
Branch: 1 branch
BranchTrueFalseTotal
if ($append) { } 0 0 0
116 0 $$out .= shift @$buffer;
117 }
118 else {
119 0 $$out = shift @$buffer;
120 }
121 0 return $blen;
122 }
123 else {
124 66 ▶ my $fill = $self->_FILL($fh) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $fill = $self->_FILL($fh) or return 0 11 55 66
125 55 ▶ if ($append) {
Branch: 1 branch
BranchTrueFalseTotal
if ($append) { } 55 0 55
126 55 $$out .= $fill;
127 }
128 else {
129 0 $$out = $fill;
130 }
131 55 return length($fill);
132 }
133 }
134  
135 255 ▶ while ($buffer_len < $len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer_len < $len) 160 147 307
136 160 my $fill = $self->_FILL($fh);
137 160 ▶ last if empty $fill;
Branch: 1 branch
BranchTrueFalseTotal
if empty($fill) 108 52 160
138 52 $self->_buffer_in_add($fill);
139 52 $buffer_len += length($fill);
140 }
141  
142 255 my $read_len = 0;
143 255 ▶ while ($read_len < $len && @$buffer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($read_len < $len and @$buffer) 182 255 437
Condition100%3/3
$read_len < $len and @$buffer
!ll&&!rl&&r
147108182
MC/DC100%2/2
$read_len < $len and @$buffer
$read_len < $len @$buffer
Truth table100%3/3
A and B
A= $read_len < $lenB= @$buffer
ABresult
0X0
100
111
144 182 my $wanted = $len - $read_len;
145 182 my $read = shift @$buffer;
146 182 ▶ if ($wanted < length($read)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wanted < length $read) { } 133 49 182
147 133 $$out .= substr($read, 0, $wanted, '');
148 133 unshift @$buffer, $read;
149 133 $read_len += $wanted;
150 }
151 else {
152 49 $$out .= $read;
153 49 $read_len += length($read);
154 }
155 }
156  
157 255 return $read_len;
158 }
159 sub syswrite {
160 116 ▶ my ($self, $buf, $len, $offset) = @_;
Subroutine syswrite: called CC=4 SCAR=14.5
Pod undocumented
161 116 ▶ $len //= length($buf);
Condition33%1/3
$len //= length $buf
l!l&&r!l&&!r
11600
MC/DC0%0/2
$len //= length $buf
$len length $buf
Truth table33%1/3
A //= B
A= $lenB= length $buf
ABresult
1X1
011
000
162 116 ▶ $offset //= 0;
Condition50%1/2
$offset //= 0
l!l
0116
MC/DC0%0/1
$offset //= 0
$offset
Truth table50%1/2
A
A= $offset
Aresult
11
00
163  
164 116 ▶ $self->_mode('w') if !$self->_mode;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_mode 38 78 116
165  
166 116 return $self->_WRITE(substr($buf, $offset, $len), $self->_fh);
167 }
168  
169 sub autoflush {
170 0 ▶ my $self = shift;
Subroutine autoflush: not called CC=2 SCAR=17.9
Pod undocumented
171 0 ▶ my $fh = $self->_fh // return FALSE;
Condition0%0/2
$self->_fh // (return !!0)
l!l
00
MC/DC0%0/1
$self->_fh // (return !!0)
$self->_fh
Truth table0%0/2
A
A= $self->_fh
Aresult
11
00
172 0 return $fh->autoflush(@_);
173 }
174  
175 sub opened {
176 0 ▶ my $self = shift;
Subroutine opened: not called CC=2 SCAR=17.9
Pod documented
177 0 ▶ my $fh = $self->_fh // return FALSE;
Condition0%0/2
$self->_fh // (return !!0)
l!l
00
MC/DC0%0/1
$self->_fh // (return !!0)
$self->_fh
Truth table0%0/2
A
A= $self->_fh
Aresult
11
00
178 0 return TRUE;
179 }
180 sub getline {
181 11 ▶ my $self = shift;
Subroutine getline: called CC=7 SCAR=29.9
Pod documented
182  
183 11 ▶ if (!defined $/) { # SLURP
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $/) { } 11 0 11
elsif (Ref::Util::XS::is_scalarref($/) and ${$/;} =~ /^\d+$/ and 0 < ${$/;}) { } 0 0 0
elsif (length $/ == 0) { } 0 0 0
184 11 local *$self->{_append_output} = 1;
185 11 my $data;
186 11 ▶ 1 while 0 < $self->read($data);
Branch: 1 branch
BranchTrueFalseTotal
0 < $self->read($data) and do { '???' } 55 11 66
187 11 return $data;
188 }
189 0 ▶ elsif (is_scalarref($/) && ${$/} =~ /^\d+$/ && 0 < ${$/}) {
Condition0%0/6
Ref::Util::XS::is_scalarref($/) and ${$/;} =~ /^\d+$/ and 0 < ${$/;}
!ll&&!rl&&r
000
Ref::Util::XS::is_scalarref($/) and ${$/;} =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/3
Ref::Util::XS::is_scalarref($/) and ${$/;} =~ /^\d+$/ and 0 < ${$/;}
Ref::Util::XS::is_scalarref($/) ${$/;} =~ /^\d+$/ 0 < ${$/;}
Truth table0%0/4
A and B and C
A= Ref::Util::XS::is_scalarref($/)B= ${$/;} =~ /^\d+$/C= 0 < ${$/;}
ABCresult
0XX0
10X0
1100
1111
190 # RECORD MODE
191 0 goto &_not_implemented;
192 }
193 elsif (length $/ == 0) {
194 # PARAGRAPH MODE
195 0 goto &_not_implemented;
196 }
197 else {
198 # LINE MODE
199 0 goto &_not_implemented;
200 }
201 }
202 sub getlines {
203 0 ▶ my $self = shift;
Subroutine getlines: not called CC=3 SCAR=24.8
Pod documented
204 0 ▶ wantarray or _croak 'Must call getlines in list context';
Branch: 1 branch
BranchTrueFalseTotal
wantarray or _croak("Must call getlines in list context") 0 0 0
205 0 my @lines;
206 0 ▶ while (defined (my $line = $self->getline)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = $self->getline)) 0 0 0
207 0 push @lines, $line;
208 }
209 0 return @lines;
210 }
211 sub ungetc {
212 0 ▶ my ($self, $ord) = @_;
Subroutine ungetc: not called CC=1 SCAR=6.9
Pod documented
213 0 unshift @{$self->_buffer_in}, chr($ord);
214 0 return;
215 }
216 sub write {
217 116 ▶ my ($self, $buf, $len, $offset) = @_;
Subroutine write: called CC=1 SCAR=0.0
Pod documented
218 116 return $self->syswrite($buf, $len, $offset) == $len;
219 }
220 sub error {
221 6 ▶ my $self = shift;
Subroutine error: called CC=1 SCAR=0.0
Pod documented
222 6 return !!$self->_error;
223 }
224 sub clearerr {
225 0 ▶ my $self = shift;
Subroutine clearerr: not called CC=2 SCAR=17.9
Pod documented
226 0 ▶ my $fh = $self->_fh // return -1;
Condition0%0/2
$self->_fh // (return -1)
l!l
00
MC/DC0%0/1
$self->_fh // (return -1)
$self->_fh
Truth table0%0/2
A
A= $self->_fh
Aresult
11
00
227 0 $self->_error(undef);
228 0 return;
229 }
230 sub sync {
231 0 ▶ my $self = shift;
Subroutine sync: not called CC=2 SCAR=17.9
Pod documented
232 0 ▶ my $fh = $self->_fh // return undef;
Condition0%0/2
$self->_fh // (return undef)
l!l
00
MC/DC0%0/1
$self->_fh // (return undef)
$self->_fh
Truth table0%0/2
A
A= $self->_fh
Aresult
11
00
233 0 return $fh->sync;
234 }
235 sub flush {
236 0 ▶ my $self = shift;
Subroutine flush: not called CC=2 SCAR=17.9
Pod documented
237 0 ▶ my $fh = $self->_fh // return undef;
Condition0%0/2
$self->_fh // (return undef)
l!l
00
MC/DC0%0/1
$self->_fh // (return undef)
$self->_fh
Truth table0%0/2
A
A= $self->_fh
Aresult
11
00
238 0 $self->_FLUSH($fh);
239 0 return $fh->flush;
240 }
241 sub printflush {
242 0 ▶ my $self = shift;
Subroutine printflush: not called CC=1 SCAR=6.9
Pod documented
243 0 my $orig = $self->autoflush;
244 0 my $r = $self->print(@_);
245 0 $self->autoflush($orig);
246 0 return $r;
247 }
248 sub blocking {
249 0 ▶ my $self = shift;
Subroutine blocking: not called CC=2 SCAR=17.9
Pod documented
250 0 ▶ my $fh = $self->_fh // return TRUE;
Condition0%0/2
$self->_fh // (return 1)
l!l
00
MC/DC0%0/1
$self->_fh // (return 1)
$self->_fh
Truth table0%0/2
A
A= $self->_fh
Aresult
11
00
251 0 return $fh->blocking(@_);
252 }
253  
254 0 ▶sub format_write { goto &_not_implemented }
Subroutine format_write: not called CC=1 SCAR=6.9
Pod undocumented
255 0 ▶sub new_from_fd { goto &_not_implemented }
Subroutine new_from_fd: not called CC=1 SCAR=6.9
Pod documented
256 0 ▶sub fcntl { goto &_not_implemented }
Subroutine fcntl: not called CC=1 SCAR=6.9
Pod undocumented
257 0 ▶sub fileno { goto &_not_implemented }
Subroutine fileno: not called CC=1 SCAR=6.9
Pod undocumented
258 0 ▶sub ioctl { goto &_not_implemented }
Subroutine ioctl: not called CC=1 SCAR=6.9
Pod undocumented
259 0 ▶sub stat { goto &_not_implemented }
Subroutine stat: not called CC=1 SCAR=6.9
Pod undocumented
260 0 ▶sub truncate { goto &_not_implemented }
Subroutine truncate: not called CC=1 SCAR=6.9
Pod undocumented
261 0 ▶sub format_page_number { goto &_not_implemented }
Subroutine format_page_number: not called CC=1 SCAR=6.9
Pod undocumented
262 0 ▶sub format_lines_per_page { goto &_not_implemented }
Subroutine format_lines_per_page: not called CC=1 SCAR=6.9
Pod undocumented
263 0 ▶sub format_lines_left { goto &_not_implemented }
Subroutine format_lines_left: not called CC=1 SCAR=6.9
Pod undocumented
264 0 ▶sub format_name { goto &_not_implemented }
Subroutine format_name: not called CC=1 SCAR=6.9
Pod undocumented
265 0 ▶sub format_top_name { goto &_not_implemented }
Subroutine format_top_name: not called CC=1 SCAR=6.9
Pod undocumented
266 0 ▶sub input_line_number { goto &_not_implemented }
Subroutine input_line_number: not called CC=1 SCAR=6.9
Pod undocumented
267 0 ▶sub fdopen { goto &_not_implemented }
Subroutine fdopen: not called CC=1 SCAR=6.9
Pod documented
268 0 ▶sub untaint { goto &_not_implemented }
Subroutine untaint: not called CC=1 SCAR=6.9
Pod documented
269  
270 ##############################################################################
271  
272 52 ▶sub _buffer_in_add { push @{shift->_buffer_in}, @_ }
Subroutine _buffer_in_add: called CC=1 SCAR=0.0
273 321 ▶sub _buffer_in_length { sum0 map { length($_) } @{shift->_buffer_in} }
Subroutine _buffer_in_length: called CC=1 SCAR=0.0
274  
275 78 ▶sub _buffer_out_add { push @{shift->_buffer_out}, @_ }
Subroutine _buffer_out_add: called CC=1 SCAR=0.0
276 0 ▶sub _buffer_out_length { sum0 map { length($_) } @{shift->_buffer_out} }
Subroutine _buffer_out_length: not called CC=1 SCAR=6.9
277  
278 0 ▶sub _not_implemented { _croak 'Operation not supported' }
Subroutine _not_implemented: not called CC=1 SCAR=6.9
279  
280 ##############################################################################
281  
282 sub TIEHANDLE {
283 94 ▶ return $_[0] if is_blessed_ref($_[0]);
Subroutine TIEHANDLE: called CC=2 SCAR=9.2
Branch: 1 branch
BranchTrueFalseTotal
if Ref::Util::XS::is_blessed_ref($_[0]) 94 0 94
284 0 die 'wat';
285 }
286  
287 sub UNTIE {
288 0 ▶ my $self = shift;
Subroutine UNTIE: not called CC=1 SCAR=6.9
289 }
290  
291 sub READLINE {
292 11 ▶ goto &getlines if wantarray;
Subroutine READLINE: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 11 11
293 11 goto &getline;
294 }
295  
296 35 ▶sub binmode { 1 }
Subroutine binmode: called CC=1 SCAR=0.0
Pod documented
297  
298 {
299 18 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
300  
301 18 *READ = \&read;
302 # *READLINE = \&getline;
303 18 *GETC = \&getc;
304 18 *FILENO = \&fileno;
305 18 *PRINT = \&print;
306 18 *PRINTF = \&printf;
307 18 *WRITE = \&syswrite;
308 # *SEEK = \&seek;
309 # *TELL = \&tell;
310 18 *EOF = \&eof;
311 18 *CLOSE = \&close;
312 18 *BINMODE = \&binmode;
313 }
314  
315 0 ▶sub _FILL { die 'Not implemented' }
Subroutine _FILL: not called CC=1 SCAR=6.9
316  
317 ##############################################################################
318  
319 18 ▶if ($ENV{DEBUG_IO}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"DEBUG_IO"}) 0 18 18
320 0 my %debug = (level => 0);
321 0 for my $method (qw{
322 new
323 new_from_fd
324 close
325 eof
326 fcntl
327 fileno
328 format_write
329 getc
330 ioctl
331 read
332 print
333 printf
334 say
335 stat
336 sysread
337 syswrite
338 truncate
339  
340 autoflush
341 format_page_number
342 format_lines_per_page
343 format_lines_left
344 format_name
345 format_top_name
346 input_line_number
347  
348 fdopen
349 opened
350 getline
351 getlines
352 ungetc
353 write
354 error
355 clearerr
356 sync
357 flush
358 printflush
359 blocking
360  
361 untaint
362 }) {
363 18 ▶ no strict 'refs'; ## no critic (ProhibitNoStrict)
Subroutine BEGIN: called CC=1 SCAR=0.0
364 18 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
365 0 my $orig = *$method{CODE};
366 *$method = sub {
367 0 ▶ local $debug{level} = $debug{level} + 2;
Subroutine __ANON__: not called CC=3 SCAR=24.8
368 0 my $indented_method = (' ' x $debug{level}) . $method;
369 0 my $self = shift;
370 print STDERR sprintf('%-20s -> %s (%s)', $indented_method, $self,
371 0 ▶ join(', ', map { defined $_ ? substr($_, 0, 16) : 'undef' } @_)), "\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
372 0 ▶ my $r = $orig->($self, @_) // 'undef';
Condition0%0/2
&$orig($self, @_) // "undef"
l!l
00
MC/DC0%0/1
&$orig($self, @_) // "undef"
&$orig($self, @_)
Truth table0%0/2
A
A= &$orig($self, @_)
Aresult
11
00
373 0 print STDERR sprintf('%-20s <- %s [%s]', $indented_method, $self, $r), "\n";
374 0 return $r;
375 0 };
376 }
377 }
378  
379 18 1;
380  
381 __END__
« KDBX/Group.pm ↑ Summary KDBX/Dumper/KDB.pm »