blib/lib/IO/Uncompress/Base.pm

filter: Statementstmt 94.7% 670 / 707 Branchbran 81.6% 312 / 382 Conditioncond 78.7% 89 / 113 MC/DCmcdc 64.1% 43 / 67 Subroutinesub 97.2% 71 / 73 Podpod 17.0% 8 / 47 totaltotal 85.8% 1193 / 1389 CC 233 SCAR 26.5
CC
233
Cov
89%
read
30.1
smartRead
29.3
_create
25.4
CRAP 14.1
« blib/lib/IO/Uncompress/Gunzip.pm ↑ Summary blib/lib/IO/Compress/Gzip.pm »
1  
2 package IO::Uncompress::Base ;
3  
4 100 ▶use strict ;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 100 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 100 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 100 our (@ISA, $VERSION, @EXPORT_OK, %EXPORT_TAGS);
9 100 @ISA = qw(IO::File Exporter);
10  
11  
12 100 $VERSION = '2.224';
13  
14 100 ▶use constant G_EOF => 0 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 100 ▶use constant G_ERR => -1 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 100 ▶use IO::Compress::Base::Common 2.224 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 100 ▶use IO::File ;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 100 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 100 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 100 ▶use List::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 100 ▶use Carp ;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 100 %EXPORT_TAGS = ( );
26 100 ▶$EXPORT_TAGS{all} = [ defined $EXPORT_TAGS{all} ? @{ $EXPORT_TAGS{all} } : (), @EXPORT_OK ] ;
Branch: 1 branch
BranchTrueFalseTotal
defined $IO::Uncompress::Base::EXPORT_TAGS{'all'} ? : 0 100 100
27  
28 sub smartRead
29 43323 ▶{
Subroutine smartRead: called CC=20 SCAR=33.8
Pod undocumented
30 43323 my $self = $_[0];
31 43323 my $out = $_[1];
32 43323 my $size = $_[2];
33 43323 $$out = "" ;
34  
35 43323 my $offset = 0 ;
36 43323 my $status = 1;
37  
38  
39 43323 ▶ if (defined *$self->{InputLength}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{"InputLength"}) 441 42882 43323
40 return 0
41 441 ▶ if *$self->{InputLengthRemaining} <= 0 ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"InputLengthRemaining"} <= 0 173 268 441
42 268 $size = List::Util::min($size, *$self->{InputLengthRemaining});
43 }
44  
45 43150 ▶ if ( length *$self->{Prime} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length *$self->{"Prime"}) 13659 29491 43150
46 13659 $$out = substr(*$self->{Prime}, 0, $size) ;
47 13659 substr(*$self->{Prime}, 0, $size) = '' ;
48 13659 ▶ if (length $$out == $size) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $$out == $size) 11355 2304 13659
49 *$self->{InputLengthRemaining} -= length $$out
50 11355 ▶ if defined *$self->{InputLength};
Branch: 1 branch
BranchTrueFalseTotal
if defined *$self->{"InputLength"} 136 11219 11355
51  
52 11355 return length $$out ;
53 }
54 2304 $offset = length $$out ;
55 }
56  
57 31795 my $get_size = $size - $offset ;
58  
59 31795 ▶ if (defined *$self->{FH}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined *$self->{'FH'}) { } 15396 16399 31795
elsif (defined *$self->{'InputEvent'}) { } 0 16399 16399
60 15396 ▶ if ($offset) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset) { } 2304 13092 15396
61 # Not using this
62 #
63 # *$self->{FH}->read($$out, $get_size, $offset);
64 #
65 # because the filehandle may not support the offset parameter
66 # An example is Net::FTP
67 2304 my $tmp = '';
68 2304 $status = *$self->{FH}->read($tmp, $get_size) ;
69 2304 ▶ substr($$out, $offset) = $tmp
Branch: 1 branch
BranchTrueFalseTotal
if defined $status and $status > 0 731 1573 2304
Condition66%2/3
defined $status and $status > 0
!ll&&!rl&&r
01573731
MC/DC50%1/2
defined $status and $status > 0
defined $status $status > 0
Truth table66%2/3
A and B
A= defined $statusB= $status > 0
ABresult
0X0
100
111
70 if defined $status && $status > 0 ;
71 }
72 else
73 13092 { $status = *$self->{FH}->read($$out, $get_size) }
74 }
75 elsif (defined *$self->{InputEvent}) {
76 0 my $got = 1 ;
77 0 ▶ while (length $$out < $size) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $$out < $size) 0 0 0
78 last
79 0 ▶ if ($got = *$self->{InputEvent}->($$out, $get_size)) <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if ($got = *$self->{"InputEvent"}->($$out, $get_size)) <= 0 0 0 0
80 }
81  
82 0 ▶ if (length $$out > $size ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $$out > $size) 0 0 0
83 0 *$self->{Prime} = substr($$out, $size, length($$out));
84 0 substr($$out, $size, length($$out)) = '';
85 }
86  
87 0 ▶ *$self->{EventEof} = 1 if $got <= 0 ;
Branch: 1 branch
BranchTrueFalseTotal
if $got <= 0 0 0 0
88 }
89 else {
90 100 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
91 16399 my $buf = *$self->{Buffer} ;
92 16399 ▶ $$buf = '' unless defined $$buf ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$buf 0 16399 16399
93 16399 substr($$out, $offset) = substr($$buf, *$self->{BufferOffset}, $get_size);
94 16399 ▶ if (*$self->{ConsumeInput})
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{'ConsumeInput'}) { } 0 16399 16399
95 0 { substr($$buf, 0, $get_size) = '' }
96 else
97 16399 { *$self->{BufferOffset} += length($$out) - $offset }
98 }
99  
100 *$self->{InputLengthRemaining} -= length($$out) #- $offset
101 31795 ▶ if defined *$self->{InputLength};
Branch: 1 branch
BranchTrueFalseTotal
if defined *$self->{"InputLength"} 132 31663 31795
102  
103 31795 ▶ if (! defined $status) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $status) 0 31795 31795
104 0 $self->saveStatus($!) ;
105 0 return STATUS_ERROR;
106 }
107  
108 31795 ▶ $self->saveStatus(length $$out < 0 ? STATUS_ERROR : STATUS_OK) ;
Branch: 1 branch
BranchTrueFalseTotal
length $$out < 0 ? : 0 31795 31795
109  
110 31795 return length $$out;
111 }
112  
113 sub pushBack
114 11615 ▶{
Subroutine pushBack: called CC=6 SCAR=18.8
Pod undocumented
115 11615 my $self = shift ;
116  
117 11615 ▶ return if ! defined $_[0] || length $_[0] == 0 ;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $_[0] or length $_[0] == 0 3274 8341 11615
Condition66%2/3
not defined $_[0] or length $_[0] == 0
l!l&&r!l&&!r
032748341
MC/DC50%1/2
not defined $_[0] or length $_[0] == 0
not defined $_[0] length $_[0] == 0
Truth table66%2/3
not(A) or B
A= not defined $_[0]B= length $_[0] == 0
ABresult
1X1
011
000
118  
119 8341 ▶ if (defined *$self->{FH} || defined *$self->{InputEvent} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{'FH'} or defined *$self->{'InputEvent'}) { } 4533 3808 8341
Condition66%2/3
defined *$self->{"FH"} or defined *$self->{"InputEvent"}
l!l&&r!l&&!r
453303808
MC/DC50%1/2
defined *$self->{"FH"} or defined *$self->{"InputEvent"}
defined *$self->{"FH"} defined *$self->{"InputEvent"}
Truth table66%2/3
A or B
A= defined *$self->{"FH"}B= defined *$self->{"InputEvent"}
ABresult
1X1
011
000
120 4533 *$self->{Prime} = $_[0] . *$self->{Prime} ;
121 4533 *$self->{InputLengthRemaining} += length($_[0]);
122 }
123 else {
124 3808 my $len = length $_[0];
125  
126 3808 ▶ if($len > *$self->{BufferOffset}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len > *$self->{'BufferOffset'}) { } 0 3808 3808
127 0 *$self->{Prime} = substr($_[0], 0, $len - *$self->{BufferOffset}) . *$self->{Prime} ;
128 0 *$self->{InputLengthRemaining} = *$self->{InputLength};
129 0 *$self->{BufferOffset} = 0
130 }
131 else {
132 3808 *$self->{InputLengthRemaining} += length($_[0]);
133 3808 *$self->{BufferOffset} -= length($_[0]) ;
134 }
135 }
136 }
137  
138 sub smartSeek
139 120 ▶{
Subroutine smartSeek: called CC=6 SCAR=19.7
Pod undocumented
140 120 my $self = shift ;
141 120 my $offset = shift ;
142 120 my $truncate = shift;
143 120 ▶ my $position = shift || SEEK_SET;
Condition50%1/2
shift() || 0
l!l
0120
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
144  
145 # TODO -- need to take prime into account
146 120 *$self->{Prime} = '';
147 120 ▶ if (defined *$self->{FH})
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{'FH'}) { } 72 48 120
148 72 { *$self->{FH}->seek($offset, $position) }
149 else {
150 48 ▶ if ($position == SEEK_END) {
Branch: 2 branches
BranchTrueFalseTotal
if ($position == 2) { } 0 48 48
elsif ($position == 1) { } 0 48 48
151 0 *$self->{BufferOffset} = length(${ *$self->{Buffer} }) + $offset ;
152 }
153 elsif ($position == SEEK_CUR) {
154 0 *$self->{BufferOffset} += $offset ;
155 }
156 else {
157 48 *$self->{BufferOffset} = $offset ;
158 }
159  
160 48 ▶ substr(${ *$self->{Buffer} }, *$self->{BufferOffset}) = ''
Branch: 1 branch
BranchTrueFalseTotal
if $truncate 0 48 48
161 if $truncate;
162 48 return 1;
163 }
164 }
165  
166 sub smartTell
167 0 ▶{
Subroutine smartTell: not called CC=2 SCAR=17.9
Pod undocumented
168 0 my $self = shift ;
169  
170 0 ▶ if (defined *$self->{FH})
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{'FH'}) { } 0 0 0
171 0 { return *$self->{FH}->tell() }
172 else
173 0 { return *$self->{BufferOffset} }
174 }
175  
176 sub smartWrite
177 60 ▶{
Subroutine smartWrite: called CC=3 SCAR=11.0
Pod undocumented
178 60 my $self = shift ;
179 60 my $out_data = shift ;
180  
181 60 ▶ if (defined *$self->{FH}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{'FH'}) { } 36 24 60
182 # flush needed for 5.8.0
183 defined *$self->{FH}->write($out_data, length $out_data) &&
184 36 ▶ defined *$self->{FH}->flush() ;
Branch: 1 branch
BranchTrueFalseTotal
defined *$self->{"FH"}->write($out_data, length $out_data) and defined *$self->{"FH"}->flush 36 0 36
185 }
186 else {
187 24 my $buf = *$self->{Buffer} ;
188 24 substr($$buf, *$self->{BufferOffset}, length $out_data) = $out_data ;
189 24 *$self->{BufferOffset} += length($out_data) ;
190 24 return 1;
191 }
192 }
193  
194 sub smartReadExact
195 22282 ▶{
Subroutine smartReadExact: called CC=1 SCAR=0.0
Pod undocumented
196 22282 return $_[0]->smartRead($_[1], $_[2]) == $_[2];
197 }
198  
199 sub smartEof
200 14962 ▶{
Subroutine smartEof: called CC=6 SCAR=18.0
Pod undocumented
201 14962 my ($self) = $_[0];
202 14962 local $.;
203  
204 14962 ▶ return 0 if length *$self->{Prime} || *$self->{PushMode};
Branch: 1 branch
BranchTrueFalseTotal
if length *$self->{"Prime"} or *$self->{"PushMode"} 1479 13483 14962
Condition66%2/3
length *$self->{"Prime"} or *$self->{"PushMode"}
l!l&&r!l&&!r
1479013483
MC/DC50%1/2
length *$self->{"Prime"} or *$self->{"PushMode"}
length *$self->{"Prime"} *$self->{"PushMode"}
Truth table66%2/3
A or B
A= length *$self->{"Prime"}B= *$self->{"PushMode"}
ABresult
1X1
011
000
205  
206 13483 ▶ if (defined *$self->{FH})
Branch: 2 branches
BranchTrueFalseTotal
if (defined *$self->{'FH'}) { } 7378 6105 13483
elsif (defined *$self->{'InputEvent'}) { } 0 6105 6105
207 {
208 # Could use
209 #
210 # *$self->{FH}->eof()
211 #
212 # here, but this can cause trouble if
213 # the filehandle is itself a tied handle, but it uses sysread.
214 # Then we get into mixing buffered & non-buffered IO,
215 # which will cause trouble
216  
217 7378 my $info = $self->getErrInfo();
218  
219 7378 my $buffer = '';
220 7378 my $status = $self->smartRead(\$buffer, 1);
221 7378 ▶ $self->pushBack($buffer) if length $buffer;
Branch: 1 branch
BranchTrueFalseTotal
if length $buffer 104 7274 7378
222 7378 $self->setErrInfo($info);
223  
224 7378 return $status == 0 ;
225 }
226 elsif (defined *$self->{InputEvent})
227 0 { *$self->{EventEof} }
228 else
229 6105 { *$self->{BufferOffset} >= length(${ *$self->{Buffer} }) }
230 }
231  
232 sub clearError
233 273 ▶{
Subroutine clearError: called CC=1 SCAR=0.0
Pod undocumented
234 273 my $self = shift ;
235  
236 273 *$self->{ErrorNo} = 0 ;
237 273 ${ *$self->{Error} } = '' ;
238 }
239  
240 sub getErrInfo
241 7378 ▶{
Subroutine getErrInfo: called CC=1 SCAR=0.0
Pod undocumented
242 7378 my $self = shift ;
243  
244 7378 return [ *$self->{ErrorNo}, ${ *$self->{Error} } ] ;
245 }
246  
247 sub setErrInfo
248 7378 ▶{
Subroutine setErrInfo: called CC=1 SCAR=0.0
Pod undocumented
249 7378 my $self = shift ;
250 7378 my $ref = shift;
251  
252 7378 *$self->{ErrorNo} = $ref->[0] ;
253 7378 ${ *$self->{Error} } = $ref->[1] ;
254 }
255  
256 sub saveStatus
257 43070 ▶{
Subroutine saveStatus: called CC=1 SCAR=0.0
Pod undocumented
258 43070 my $self = shift ;
259 43070 my $errno = shift() + 0 ;
260  
261 43070 *$self->{ErrorNo} = $errno;
262 43070 ${ *$self->{Error} } = '' ;
263  
264 43070 return *$self->{ErrorNo} ;
265 }
266  
267  
268 sub saveErrorString
269 3418 ▶{
Subroutine saveErrorString: called CC=2 SCAR=6.9
Pod undocumented
270 3418 my $self = shift ;
271 3418 my $retval = shift ;
272  
273 3418 ${ *$self->{Error} } = shift ;
274 3418 ▶ *$self->{ErrorNo} = @_ ? shift() + 0 : STATUS_ERROR ;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3323 95 3418
275  
276 3418 return $retval;
277 }
278  
279 sub croakError
280 95 ▶{
Subroutine croakError: called CC=1 SCAR=0.0
Pod undocumented
281 95 my $self = shift ;
282 95 $self->saveErrorString(0, $_[0]);
283 95 croak $_[0];
284 }
285  
286  
287 sub closeError
288 18 ▶{
Subroutine closeError: called CC=1 SCAR=0.0
Pod undocumented
289 18 my $self = shift ;
290 18 my $retval = shift ;
291  
292 18 my $errno = *$self->{ErrorNo};
293 18 my $error = ${ *$self->{Error} };
294  
295 18 $self->close();
296  
297 18 *$self->{ErrorNo} = $errno ;
298 18 ${ *$self->{Error} } = $error ;
299  
300 18 return $retval;
301 }
302  
303 sub error
304 2110 ▶{
Subroutine error: called CC=1 SCAR=0.0
Pod documented
305 2110 my $self = shift ;
306 2110 return ${ *$self->{Error} } ;
307 }
308  
309 sub errorNo
310 212 ▶{
Subroutine errorNo: called CC=1 SCAR=0.0
Pod undocumented
311 212 my $self = shift ;
312 212 return *$self->{ErrorNo};
313 }
314  
315 sub HeaderError
316 2060 ▶{
Subroutine HeaderError: called CC=1 SCAR=0.0
Pod undocumented
317 2060 my ($self) = shift;
318 2060 return $self->saveErrorString(undef, "Header Error: $_[0]", STATUS_ERROR);
319 }
320  
321 sub TrailerError
322 18 ▶{
Subroutine TrailerError: called CC=1 SCAR=0.0
Pod undocumented
323 18 my ($self) = shift;
324 18 return $self->saveErrorString(G_ERR, "Trailer Error: $_[0]", STATUS_ERROR);
325 }
326  
327 sub TruncatedHeader
328 16 ▶{
Subroutine TruncatedHeader: called CC=1 SCAR=0.0
Pod undocumented
329 16 my ($self) = shift;
330 16 return $self->HeaderError("Truncated in $_[0] Section");
331 }
332  
333 sub TruncatedTrailer
334 0 ▶{
Subroutine TruncatedTrailer: not called CC=1 SCAR=6.9
Pod undocumented
335 0 my ($self) = shift;
336 0 return $self->TrailerError("Truncated in $_[0] Section");
337 }
338  
339 sub postCheckParams
340 3526 ▶{
Subroutine postCheckParams: called CC=1 SCAR=0.0
Pod undocumented
341 3526 return 1;
342 }
343  
344 sub checkParams
345 3558 ▶{
Subroutine checkParams: called CC=5 SCAR=16.4
Pod undocumented
346 3558 my $self = shift ;
347 3558 my $class = shift ;
348  
349 3558 ▶ my $got = shift || IO::Compress::Base::Parameters::new();
Condition33%1/3
shift() || IO::Compress::Base::Parameters::new()
l!l&&r!l&&!r
035580
MC/DC0%0/2
shift() || IO::Compress::Base::Parameters::new()
shift() IO::Compress::Base::Parameters::new()
Truth table33%1/3
A || B
A= shift()B= IO::Compress::Base::Parameters::new()
ABresult
1X1
011
000
350  
351 3558 my $Valid = {
352 'blocksize' => [IO::Compress::Base::Common::Parse_unsigned, 16 * 1024],
353 'autoclose' => [IO::Compress::Base::Common::Parse_boolean, 0],
354 'strict' => [IO::Compress::Base::Common::Parse_boolean, 0],
355 'append' => [IO::Compress::Base::Common::Parse_boolean, 0],
356 'prime' => [IO::Compress::Base::Common::Parse_any, undef],
357 'multistream' => [IO::Compress::Base::Common::Parse_boolean, 0],
358 'transparent' => [IO::Compress::Base::Common::Parse_any, 1],
359 'scan' => [IO::Compress::Base::Common::Parse_boolean, 0],
360 'inputlength' => [IO::Compress::Base::Common::Parse_unsigned, undef],
361 'binmodeout' => [IO::Compress::Base::Common::Parse_boolean, 0],
362 #'decode' => [IO::Compress::Base::Common::Parse_any, undef],
363  
364 #'consumeinput' => [IO::Compress::Base::Common::Parse_boolean, 0],
365  
366 $self->getExtraParams(),
367  
368 #'Todo - Revert to ordinary file on end Z_STREAM_END'=> 0,
369 # ContinueAfterEof
370 } ;
371  
372 $Valid->{trailingdata} = [IO::Compress::Base::Common::Parse_writable_scalar, undef]
373 3558 ▶ if *$self->{OneShot} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"OneShot"} 568 2990 3558
374  
375 3558 ▶ $got->parse($Valid, @_ )
Branch: 1 branch
BranchTrueFalseTotal
$got->parse($Valid, @_) or $self->croakError("${class}: " . $got->getError) 3526 32 3558
376 or $self->croakError("${class}: " . $got->getError()) ;
377  
378 3526 ▶ $self->postCheckParams($got)
Branch: 1 branch
BranchTrueFalseTotal
$self->postCheckParams($got) or $self->croakError("${class}: " . $self->error) 3526 0 3526
379 or $self->croakError("${class}: " . $self->error()) ;
380  
381 3526 return $got;
382 }
383  
384 sub _create
385 3673 ▶{
Subroutine _create: called CC=25 SCAR=32.4
386 3673 my $obj = shift;
387 3673 my $got = shift;
388 3673 my $append_mode = shift ;
389  
390 3673 my $class = ref $obj;
391 3673 ▶ $obj->croakError("$class: Missing Input parameter")
Branch: 1 branch
BranchTrueFalseTotal
unless @_ or $got 5 3668 3673
Condition66%2/3
@_ or $got
l!l&&r!l&&!r
366805
MC/DC50%1/2
@_ or $got
@_ $got
Truth table66%2/3
A or B
A= @_B= $got
ABresult
1X1
011
000
392 if ! @_ && ! $got ;
393  
394 3668 my $inValue = shift ;
395  
396 3668 *$obj->{OneShot} = 0 ;
397  
398 3668 ▶ if (! $got)
Branch: 1 branch
BranchTrueFalseTotal
unless ($got) 2990 678 3668
399 {
400 2990 ▶ $got = $obj->checkParams($class, undef, @_)
Branch: 1 branch
BranchTrueFalseTotal
$got = $obj->checkParams($class, undef, @_) or return undef 2978 0 2978
401 or return undef ;
402 }
403  
404 3656 my $inType = whatIsInput($inValue, 1);
405  
406 3656 ▶ $obj->ckInputParam($class, $inValue, 1)
Branch: 1 branch
BranchTrueFalseTotal
$obj->ckInputParam($class, $inValue, 1) or return undef 3651 0 3651
407 or return undef ;
408  
409 3651 *$obj->{InNew} = 1;
410  
411 $obj->ckParams($got)
412 3651 ▶ or $obj->croakError("${class}: " . *$obj->{Error});
Branch: 1 branch
BranchTrueFalseTotal
$obj->ckParams($got) or $obj->croakError("${class}: " . *$obj->{"Error"}) 3651 0 3651
413  
414 3651 ▶ if ($inType eq 'buffer' || $inType eq 'code') {
Branch: 1 branch
BranchTrueFalseTotal
if ($inType eq 'buffer' or $inType eq 'code') { } 1450 2201 3651
Condition66%2/3
$inType eq "buffer" or $inType eq "code"
l!l&&r!l&&!r
145002201
MC/DC50%1/2
$inType eq "buffer" or $inType eq "code"
$inType eq "buffer" $inType eq "code"
Truth table66%2/3
A or B
A= $inType eq "buffer"B= $inType eq "code"
ABresult
1X1
011
000
415 1450 *$obj->{Buffer} = $inValue ;
416 1450 ▶ *$obj->{InputEvent} = $inValue
Branch: 1 branch
BranchTrueFalseTotal
if $inType eq "code" 0 1450 1450
417 if $inType eq 'code' ;
418 }
419 else {
420 2201 ▶ if ($inType eq 'handle') {
Branch: 1 branch
BranchTrueFalseTotal
if ($inType eq 'handle') { } 474 1727 2201
421 474 *$obj->{FH} = $inValue ;
422 474 *$obj->{Handle} = 1 ;
423  
424 # Need to rewind for Scan
425 474 ▶ *$obj->{FH}->seek(0, SEEK_SET)
Branch: 1 branch
BranchTrueFalseTotal
if $got->getValue("scan") 18 456 474
426 if $got->getValue('scan');
427 }
428 else {
429 100 ▶ no warnings ;
Subroutine BEGIN: called CC=1 SCAR=0.0
430 1727 my $mode = '<';
431 1727 ▶ $mode = '+<' if $got->getValue('scan');
Branch: 1 branch
BranchTrueFalseTotal
if $got->getValue("scan") 30 1697 1727
432 1727 *$obj->{StdIO} = ($inValue eq '-');
433 1727 ▶ *$obj->{FH} = IO::File->new( "$mode $inValue" )
Branch: 1 branch
BranchTrueFalseTotal
*$obj->{"FH"} = "IO::File"->new("$mode $inValue") or return $obj->saveErrorString(undef, "cannot open file '${inValue}': $!", $!) 1719 8 1727
434 or return $obj->saveErrorString(undef, "cannot open file '$inValue': $!", $!) ;
435 }
436  
437 2193 *$obj->{LineNo} = $. = 0;
438 2193 setBinModeInput(*$obj->{FH}) ;
439  
440 2193 my $buff = "" ;
441 2193 *$obj->{Buffer} = \$buff ;
442 }
443  
444 # if ($got->getValue('decode')) {
445 # my $want_encoding = $got->getValue('decode');
446 # *$obj->{Encoding} = IO::Compress::Base::Common::getEncoding($obj, $class, $want_encoding);
447 # }
448 # else {
449 # *$obj->{Encoding} = undef;
450 # }
451  
452 3643 ▶ *$obj->{InputLength} = $got->parsed('inputlength')
Branch: 1 branch
BranchTrueFalseTotal
$got->parsed('inputlength') ? : 70 3573 3643
453 ? $got->getValue('inputlength')
454 : undef ;
455 3643 *$obj->{InputLengthRemaining} = $got->getValue('inputlength');
456 3643 *$obj->{BufferOffset} = 0 ;
457 3643 *$obj->{AutoClose} = $got->getValue('autoclose');
458 3643 *$obj->{Strict} = $got->getValue('strict');
459 3643 *$obj->{BlockSize} = $got->getValue('blocksize');
460 3643 *$obj->{Append} = $got->getValue('append');
461 3643 ▶ *$obj->{AppendOutput} = $append_mode || $got->getValue('append');
Condition100%3/3
$append_mode || $got->getValue('append')
l!l&&r!l&&!r
6782207758
MC/DC100%2/2
$append_mode || $got->getValue('append')
$append_mode $got->getValue('append')
Truth table100%3/3
A || B
A= $append_modeB= $got->getValue('append')
ABresult
1X1
011
000
462 3643 *$obj->{ConsumeInput} = $got->getValue('consumeinput');
463 3643 *$obj->{Transparent} = $got->getValue('transparent');
464 3643 *$obj->{MultiStream} = $got->getValue('multistream');
465  
466 # TODO - move these two into RawDeflate
467 3643 *$obj->{Scan} = $got->getValue('scan');
468 3643 ▶ *$obj->{ParseExtra} = $got->getValue('parseextra')
Condition100%3/3
$got->getValue('parseextra') || $got->getValue('strict')
l!l&&r!l&&!r
1412952334
MC/DC100%2/2
$got->getValue('parseextra') || $got->getValue('strict')
$got->getValue('parseextra') $got->getValue('strict')
Truth table100%3/3
A || B
A= $got->getValue('parseextra')B= $got->getValue('strict')
ABresult
1X1
011
000
469 || $got->getValue('strict') ;
470 3643 *$obj->{Type} = '';
471 3643 ▶ *$obj->{Prime} = $got->getValue('prime') || '' ;
Condition50%1/2
$got->getValue('prime') || ''
l!l
03643
MC/DC0%0/1
$got->getValue('prime') || ''
$got->getValue('prime')
Truth table50%1/2
A
A= $got->getValue('prime')
Aresult
11
00
472 3643 *$obj->{Pending} = '';
473 3643 *$obj->{Plain} = 0;
474 3643 *$obj->{PlainBytesRead} = 0;
475 3643 *$obj->{InflatedBytesRead} = 0;
476 3643 *$obj->{UnCompSize} = U64->new;
477 3643 *$obj->{CompSize} = U64->new;
478 3643 *$obj->{TotalInflatedBytesRead} = 0;
479 3643 *$obj->{NewStream} = 0 ;
480 3643 *$obj->{EventEof} = 0 ;
481 3643 *$obj->{ClassName} = $class ;
482 3643 *$obj->{Params} = $got ;
483  
484 3643 ▶ if (*$obj->{ConsumeInput}) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$obj->{"ConsumeInput"}) 0 3643 3643
485 0 *$obj->{InNew} = 0;
486 0 *$obj->{Closed} = 0;
487 0 return $obj
488 }
489  
490 3643 my $status = $obj->mkUncomp($got);
491  
492 return undef
493 3642 ▶ unless defined $status;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $status 27 3615 3642
494  
495 3615 *$obj->{InNew} = 0;
496 3615 *$obj->{Closed} = 0;
497  
498 return $obj
499 3615 ▶ if *$obj->{Pause} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$obj->{"Pause"} 0 3615 3615
500  
501 3615 ▶ if ($status) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status) { } 3312 303 3615
502 # Need to try uncompressing to catch the case
503 # where the compressed file uncompresses to an
504 # empty string - so eof is set immediately.
505  
506 3312 my $out_buffer = '';
507  
508 3312 $status = $obj->read(\$out_buffer);
509  
510 3312 ▶ if ($status < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status < 0) 7 3305 3312
511 7 *$obj->{ReadStatus} = [ $status, $obj->error(), $obj->errorNo() ];
512 }
513  
514 3312 ▶ $obj->ungetc($out_buffer)
Branch: 1 branch
BranchTrueFalseTotal
if length $out_buffer 2841 471 3312
515 if length $out_buffer;
516 }
517 else {
518 return undef
519 303 ▶ unless *$obj->{Transparent};
Branch: 1 branch
BranchTrueFalseTotal
unless *$obj->{"Transparent"} 33 270 303
520  
521 270 $obj->clearError();
522 270 *$obj->{Type} = 'plain';
523 270 *$obj->{Plain} = 1;
524 270 $obj->pushBack(*$obj->{HeaderPending}) ;
525 }
526  
527 3582 push @{ *$obj->{InfoList} }, *$obj->{Info} ;
528  
529 3582 $obj->saveStatus(STATUS_OK) ;
530 3582 *$obj->{InNew} = 0;
531 3582 *$obj->{Closed} = 0;
532  
533 3582 return $obj;
534 }
535  
536 sub ckInputParam
537 3656 ▶{
Subroutine ckInputParam: called CC=2 SCAR=6.9
Pod undocumented
538 3656 my $self = shift ;
539 3656 my $from = shift ;
540 3656 my $inType = whatIsInput($_[0], $_[1]);
541  
542 3656 ▶ $self->croakError("$from: input parameter not a filename, filehandle, array ref or scalar ref")
Branch: 1 branch
BranchTrueFalseTotal
unless $inType 5 3651 3656
543 if ! $inType ;
544  
545 # if ($inType eq 'filename' )
546 # {
547 # return $self->saveErrorString(1, "$from: input filename is undef or null string", STATUS_ERROR)
548 # if ! defined $_[0] || $_[0] eq '' ;
549 #
550 # if ($_[0] ne '-' && ! -e $_[0] )
551 # {
552 # return $self->saveErrorString(1,
553 # "input file '$_[0]' does not exist", STATUS_ERROR);
554 # }
555 # }
556  
557 3651 return 1;
558 }
559  
560  
561 sub _inf
562 728 ▶{
Subroutine _inf: called CC=16 SCAR=28.1
563 728 my $obj = shift ;
564  
565 728 my $class = (caller)[0] ;
566 728 my $name = (caller(1))[3] ;
567  
568 728 ▶ $obj->croakError("$name: expected at least 1 parameters\n")
Branch: 1 branch
BranchTrueFalseTotal
unless @_ >= 1 10 718 728
569 unless @_ >= 1 ;
570  
571 718 my $input = shift ;
572 718 my $haveOut = @_ ;
573 718 my $output = shift ;
574  
575  
576 718 ▶ my $x = IO::Compress::Base::Validator->new($class, *$obj->{Error}, $name, $input, $output)
Branch: 1 branch
BranchTrueFalseTotal
my $x = "IO::Compress::Base::Validator"->new($class, *$obj->{"Error"}, $name, $input, $output) or return undef 568 50 618
577 or return undef ;
578  
579 568 ▶ push @_, $output if $haveOut && $x->{Hash};
Branch: 1 branch
BranchTrueFalseTotal
if $haveOut and $x->{"Hash"} 0 568 568
Condition33%1/3
$haveOut and $x->{"Hash"}
!ll&&!rl&&r
05680
MC/DC0%0/2
$haveOut and $x->{"Hash"}
$haveOut $x->{"Hash"}
Truth table33%1/3
A and B
A= $haveOutB= $x->{"Hash"}
ABresult
0X0
100
111
580  
581 568 *$obj->{OneShot} = 1 ;
582  
583 568 ▶ my $got = $obj->checkParams($name, undef, @_)
Branch: 1 branch
BranchTrueFalseTotal
my $got = $obj->checkParams($name, undef, @_) or return undef 548 0 548
584 or return undef ;
585  
586 548 ▶ if ($got->parsed('trailingdata'))
Branch: 1 branch
BranchTrueFalseTotal
if ($got->parsed("trailingdata")) 10 538 548
587 {
588 # my $value = $got->valueRef('TrailingData');
589 # warn "TD $value ";
590 # #$value = $$value;
591 ## warn "TD $value $$value ";
592 #
593 # return retErr($obj, "Parameter 'TrailingData' not writable")
594 # if readonly $$value ;
595 #
596 # if (ref $$value)
597 # {
598 # return retErr($obj,"Parameter 'TrailingData' not a scalar reference")
599 # if ref $$value ne 'SCALAR' ;
600 #
601 # *$obj->{TrailingData} = $$value ;
602 # }
603 # else
604 # {
605 # return retErr($obj,"Parameter 'TrailingData' not a scalar")
606 # if ref $value ne 'SCALAR' ;
607 #
608 # *$obj->{TrailingData} = $value ;
609 # }
610  
611 10 *$obj->{TrailingData} = $got->getValue('trailingdata');
612 }
613  
614 548 *$obj->{MultiStream} = $got->getValue('multistream');
615 548 $got->setValue('multistream', 0);
616  
617 548 $x->{Got} = $got ;
618  
619 # if ($x->{Hash})
620 # {
621 # while (my($k, $v) = each %$input)
622 # {
623 # $v = \$input->{$k}
624 # unless defined $v ;
625 #
626 # $obj->_singleTarget($x, $k, $v, @_)
627 # or return undef ;
628 # }
629 #
630 # return keys %$input ;
631 # }
632  
633 548 ▶ if ($x->{GlobMap})
Branch: 1 branch
BranchTrueFalseTotal
if ($x->{"GlobMap"}) 10 538 548
634 {
635 10 $x->{oneInput} = 1 ;
636 10 foreach my $pair (@{ $x->{Pairs} })
637 {
638 30 my ($from, $to) = @$pair ;
639 30 ▶ $obj->_singleTarget($x, $from, $to, @_)
Branch: 1 branch
BranchTrueFalseTotal
$obj->_singleTarget($x, $from, $to, @_) or return undef 30 0 30
640 or return undef ;
641 }
642  
643 10 return scalar @{ $x->{Pairs} } ;
644 }
645  
646 538 ▶ if (! $x->{oneOutput} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($x->{"oneOutput"}) 40 498 538
647 {
648 my $inFile = ($x->{inType} eq 'filenames'
649 40 ▶ || $x->{inType} eq 'filename');
Condition66%2/3
$x->{'inType'} eq 'filenames' || $x->{'inType'} eq 'filename'
l!l&&r!l&&!r
20020
MC/DC50%1/2
$x->{'inType'} eq 'filenames' || $x->{'inType'} eq 'filename'
$x->{'inType'} eq 'filenames' $x->{'inType'} eq 'filename'
Truth table66%2/3
A || B
A= $x->{'inType'} eq 'filenames'B= $x->{'inType'} eq 'filename'
ABresult
1X1
011
000
650  
651 40 ▶ $x->{inType} = $inFile ? 'filename' : 'buffer';
Branch: 1 branch
BranchTrueFalseTotal
$inFile ? : 20 20 40
652  
653 40 ▶ foreach my $in ($x->{oneInput} ? $input : @$input)
Branch: 1 branch
BranchTrueFalseTotal
$x->{'oneInput'} ? : 20 20 40
654 {
655 70 my $out ;
656 70 $x->{oneInput} = 1 ;
657  
658 70 ▶ $obj->_singleTarget($x, $in, $output, @_)
Branch: 1 branch
BranchTrueFalseTotal
$obj->_singleTarget($x, $in, $output, @_) or return undef 70 0 70
659 or return undef ;
660 }
661  
662 40 return 1 ;
663 }
664  
665 # finally the 1 to 1 and n to 1
666 498 return $obj->_singleTarget($x, $input, $output, @_);
667  
668 0 croak "should not be here" ;
669 }
670  
671 sub retErr
672 10 ▶{
Subroutine retErr: called CC=1 SCAR=0.0
Pod undocumented
673 10 my $x = shift ;
674 10 my $string = shift ;
675  
676 10 ${ $x->{Error} } = $string ;
677  
678 10 return undef ;
679 }
680  
681 sub _singleTarget
682 598 ▶{
Subroutine _singleTarget: called CC=19 SCAR=29.5
683 598 my $self = shift ;
684 598 my $x = shift ;
685 598 my $input = shift;
686 598 my $output = shift;
687  
688 598 my $buff = '';
689 598 $x->{buff} = \$buff ;
690  
691 598 my $fh ;
692 598 ▶ if ($x->{outType} eq 'filename') {
Branch: 3 branches
BranchTrueFalseTotal
if ($x->{'outType'} eq 'filename') { } 130 468 598
elsif ($x->{'outType'} eq 'handle') { } 85 383 468
elsif ($x->{'outType'} eq 'buffer') { } 313 70 383
693 130 my $mode = '>' ;
694 $mode = '>>'
695 130 ▶ if $x->{Got}->getValue('append') ;
Branch: 1 branch
BranchTrueFalseTotal
if $x->{"Got"}->getValue("append") 30 100 130
696 130 ▶ $x->{fh} = IO::File->new( "$mode $output" )
Branch: 1 branch
BranchTrueFalseTotal
$x->{"fh"} = "IO::File"->new("$mode $output") or return retErr($x, "cannot open file '${output}': $!") 120 10 130
697 or return retErr($x, "cannot open file '$output': $!") ;
698 120 binmode $x->{fh} ;
699  
700 }
701  
702 elsif ($x->{outType} eq 'handle') {
703 85 $x->{fh} = $output;
704 85 binmode $x->{fh} ;
705 85 ▶ if ($x->{Got}->getValue('append')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x->{"Got"}->getValue("append")) 30 55 85
706 30 ▶ seek($x->{fh}, 0, SEEK_END)
Branch: 1 branch
BranchTrueFalseTotal
CORE::seek $x->{"fh"}, 0, 2 or return retErr($x, "Cannot seek to end of output filehandle: $!") 30 0 30
707 or return retErr($x, "Cannot seek to end of output filehandle: $!") ;
708 }
709 }
710  
711  
712 elsif ($x->{outType} eq 'buffer' )
713 {
714 $$output = ''
715 313 ▶ unless $x->{Got}->getValue('append');
Branch: 1 branch
BranchTrueFalseTotal
unless $x->{"Got"}->getValue("append") 273 40 313
716 313 $x->{buff} = $output ;
717 }
718  
719 588 ▶ if ($x->{oneInput})
Branch: 1 branch
BranchTrueFalseTotal
if ($x->{'oneInput'}) { } 528 60 588
720 {
721 528 ▶ defined $self->_rd2($x, $input, $output)
Branch: 1 branch
BranchTrueFalseTotal
defined $self->_rd2($x, $input, $output) or return undef 496 32 528
722 or return undef;
723 }
724 else
725 {
726 60 ▶ for my $element ( ($x->{inType} eq 'hash') ? keys %$input : @$input)
Branch: 1 branch
BranchTrueFalseTotal
$x->{'inType'} eq 'hash' ? : 0 60 60
727 {
728 150 ▶ defined $self->_rd2($x, $element, $output)
Branch: 1 branch
BranchTrueFalseTotal
defined $self->_rd2($x, $element, $output) or return undef 150 0 150
729 or return undef ;
730 }
731 }
732  
733  
734 556 ▶ if ( ($x->{outType} eq 'filename' && $output ne '-') ||
Branch: 1 branch
BranchTrueFalseTotal
if ($x->{"outType"} eq "filename" and $output ne "-" or $x->{"outType"} eq "handle" and $x->{"Got"}->getValue("autoclose")) 190 366 556
Condition88%8/9
$x->{"outType"} eq "filename" and $output ne "-" or $x->{"outType"} eq "handle" and $x->{"Got"}->getValue("autoclose")
l!l&&r!l&&!r
12070366
$x->{"outType"} eq "filename" and $output ne "-"
!ll&&!rl&&r
4360120
$x->{"outType"} eq "handle" and $x->{"Got"}->getValue("autoclose")
!ll&&!rl&&r
3511570
MC/DC75%3/4
$x->{"outType"} eq "filename" and $output ne "-" or $x->{"outType"} eq "handle" and $x->{"Got"}->getValue("autoclose")
$x->{"outType"} eq "filename" $output ne "-" $x->{"outType"} eq "handle" $x->{"Got"}->getValue("autoclose")
Truth table57%4/7
A and B or C and D
A= $x->{"outType"} eq "filename"B= $output ne "-"C= $x->{"outType"} eq "handle"D= $x->{"Got"}->getValue("autoclose")
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
735 ($x->{outType} eq 'handle' && $x->{Got}->getValue('autoclose'))) {
736 $x->{fh}->close()
737 190 ▶ or return retErr($x, $!);
Branch: 1 branch
BranchTrueFalseTotal
$x->{"fh"}->close or return retErr($x, $!) 190 0 190
738 190 delete $x->{fh};
739 }
740  
741 556 return 1 ;
742 }
743  
744 sub _rd2
745 678 ▶{
Subroutine _rd2: called CC=15 SCAR=27.2
746 678 my $self = shift ;
747 678 my $x = shift ;
748 678 my $input = shift;
749 678 my $output = shift;
750  
751 678 my $z = IO::Compress::Base::Common::createSelfTiedObject($x->{Class}, *$self->{Error});
752  
753 678 ▶ $z->_create($x->{Got}, 1, $input, @_)
Branch: 1 branch
BranchTrueFalseTotal
$z->_create($x->{"Got"}, 1, $input, @_) or return undef 664 14 678
754 or return undef ;
755  
756 664 my $status ;
757 664 my $fh = $x->{fh};
758  
759 664 while (1) {
760  
761 682 ▶ while (($status = $z->read($x->{buff})) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (($status = $z->read($x->{"buff"})) > 0) 728 682 1410
762 728 ▶ if ($fh) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh) 265 463 728
763 265 local $\;
764 265 ▶ print $fh ${ $x->{buff} }
Branch: 1 branch
BranchTrueFalseTotal
print $fh ${$x->{"buff"};} or return $z->saveErrorString(undef, "Error writing to output file: $!", $!) 265 0 265
765 or return $z->saveErrorString(undef, "Error writing to output file: $!", $!);
766 265 ${ $x->{buff} } = '' ;
767 }
768 }
769  
770 682 ▶ if (! $x->{oneOutput} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($x->{"oneOutput"}) 100 582 682
771 100 my $ot = $x->{outType} ;
772  
773 100 ▶ if ($ot eq 'array')
Branch: 2 branches
BranchTrueFalseTotal
if ($ot eq 'array') { } 70 30 100
elsif ($ot eq 'hash') { } 0 30 30
774 70 { push @$output, $x->{buff} }
775 elsif ($ot eq 'hash')
776 0 { $output->{$input} = $x->{buff} }
777  
778 100 my $buff = '';
779 100 $x->{buff} = \$buff;
780 }
781  
782 682 ▶ last if $status < 0 || $z->smartEof();
Branch: 1 branch
BranchTrueFalseTotal
if $status < 0 or $z->smartEof 626 56 682
Condition100%3/3
$status < 0 or $z->smartEof
l!l&&r!l&&!r
1860856
MC/DC100%2/2
$status < 0 or $z->smartEof
$status < 0 $z->smartEof
Truth table100%3/3
A or B
A= $status < 0B= $z->smartEof
ABresult
1X1
011
000
783  
784 last
785 56 ▶ unless *$self->{MultiStream};
Branch: 1 branch
BranchTrueFalseTotal
unless *$self->{"MultiStream"} 38 18 56
786  
787 18 $status = $z->nextStream();
788  
789 last
790 18 ▶ unless $status == 1 ;
Branch: 1 branch
BranchTrueFalseTotal
unless $status == 1 0 18 18
791 }
792  
793 664 ▶ return $z->closeError(undef)
Branch: 1 branch
BranchTrueFalseTotal
if $status < 0 18 646 664
794 if $status < 0 ;
795  
796 10 ${ *$self->{TrailingData} } = $z->trailingData()
797 646 ▶ if defined *$self->{TrailingData} ;
Branch: 1 branch
BranchTrueFalseTotal
if defined *$self->{"TrailingData"} 10 636 646
798  
799 646 ▶ $z->close()
Branch: 1 branch
BranchTrueFalseTotal
$z->close or return undef 646 0 646
800 or return undef ;
801  
802 646 return 1 ;
803 }
804  
805 sub TIEHANDLE
806 4401 ▶{
Subroutine TIEHANDLE: called CC=2 SCAR=9.2
807 4401 ▶ return $_[0] if ref($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] 4401 0 4401
808 0 die "OOPS\n" ;
809  
810 }
811  
812 sub UNTIE
813 3603 ▶{
Subroutine UNTIE: called CC=1 SCAR=0.0
814 3603 my $self = shift ;
815 }
816  
817  
818 sub getHeaderInfo
819 239 ▶{
Subroutine getHeaderInfo: called CC=2 SCAR=6.9
Pod undocumented
820 239 my $self = shift ;
821 239 ▶ wantarray ? @{ *$self->{InfoList} } : *$self->{Info};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 90 149 239
822 }
823  
824 sub readBlock
825 4850 ▶{
Subroutine readBlock: called CC=5 SCAR=16.1
Pod undocumented
826 4850 my $self = shift ;
827 4850 my $buff = shift ;
828 4850 my $size = shift ;
829  
830 4850 ▶ if (defined *$self->{CompressedInputLength}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{"CompressedInputLength"}) 103 4747 4850
831 103 ▶ if (*$self->{CompressedInputLengthRemaining} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{"CompressedInputLengthRemaining"} == 0) 22 81 103
832 22 delete *$self->{CompressedInputLength};
833 22 *$self->{CompressedInputLengthDone} = 1;
834 22 return STATUS_OK ;
835 }
836 81 $size = List::Util::min($size, *$self->{CompressedInputLengthRemaining} );
837 81 *$self->{CompressedInputLengthRemaining} -= $size ;
838 }
839  
840 4828 my $status = $self->smartRead($buff, $size) ;
841 4828 ▶ return $self->saveErrorString(STATUS_ERROR, "Error Reading Data: $!", $!)
Branch: 1 branch
BranchTrueFalseTotal
if $status == -1 0 4828 4828
842 if $status == STATUS_ERROR ;
843  
844 4828 ▶ if ($status == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 0) 12 4816 4828
845 12 *$self->{Closed} = 1 ;
846 12 *$self->{EndStream} = 1 ;
847 12 return $self->saveErrorString(STATUS_ERROR, "unexpected end of file", STATUS_ERROR);
848 }
849  
850 4816 return STATUS_OK;
851 }
852  
853 sub postBlockChk
854 4832 ▶{
Subroutine postBlockChk: called CC=1 SCAR=0.0
Pod undocumented
855 4832 return STATUS_OK;
856 }
857  
858 sub _raw_read
859 6567 ▶{
Subroutine _raw_read: called CC=23 SCAR=31.5
860 # return codes
861 # >0 - ok, number of bytes read
862 # =0 - ok, eof
863 # <0 - not ok
864  
865 6567 my $self = shift ;
866  
867 6567 ▶ return G_EOF if *$self->{Closed} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"Closed"} 0 6567 6567
868 6567 ▶ return G_EOF if *$self->{EndStream} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"EndStream"} 0 6567 6567
869  
870 6567 my $buffer = shift ;
871 6567 my $scan_mode = shift ;
872  
873 6567 ▶ if (*$self->{Plain}) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{"Plain"}) 541 6026 6567
874 541 my $tmp_buff ;
875 541 my $len = $self->smartRead(\$tmp_buff, *$self->{BlockSize}) ;
876  
877 541 ▶ return $self->saveErrorString(G_ERR, "Error reading data: $!", $!)
Branch: 1 branch
BranchTrueFalseTotal
if $len == -1 0 541 541
878 if $len == STATUS_ERROR ;
879  
880 541 ▶ if ($len == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len == 0) { } 260 281 541
881 260 *$self->{EndStream} = 1 ;
882 }
883 else {
884 281 *$self->{PlainBytesRead} += $len ;
885 281 $$buffer .= $tmp_buff;
886 }
887  
888 541 return $len ;
889 }
890  
891 6026 ▶ if (*$self->{NewStream}) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{"NewStream"}) 1176 4850 6026
892  
893 1176 ▶ $self->gotoNextStream() > 0
Branch: 1 branch
BranchTrueFalseTotal
$self->gotoNextStream > 0 or return -1 1176 0 1176
894 or return G_ERR;
895  
896 # For the headers that actually uncompressed data, put the
897 # uncompressed data into the output buffer.
898 1176 $$buffer .= *$self->{Pending} ;
899 1176 my $len = length *$self->{Pending} ;
900 1176 *$self->{Pending} = '';
901 1176 return $len;
902 }
903  
904 4850 my $temp_buf = '';
905 4850 my $outSize = 0;
906 4850 my $status = $self->readBlock(\$temp_buf, *$self->{BlockSize}, $outSize) ;
907  
908 4850 ▶ return G_ERR
Branch: 1 branch
BranchTrueFalseTotal
if $status == -1 12 4838 4850
909 if $status == STATUS_ERROR ;
910  
911 4838 my $buf_len = 0;
912 4838 ▶ if ($status == STATUS_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 0) 4838 0 4838
913 4838 my $beforeC_len = length $temp_buf;
914 4838 ▶ my $before_len = defined $$buffer ? length $$buffer : 0 ;
Branch: 1 branch
BranchTrueFalseTotal
defined $$buffer ? : 4838 0 4838
915 $status = *$self->{Uncomp}->uncompr(\$temp_buf, $buffer,
916 defined *$self->{CompressedInputLengthDone} ||
917 4838 ▶ $self->smartEof(), $outSize);
Condition100%3/3
defined *$self->{'CompressedInputLengthDone'} || $self->smartEof
l!l&&r!l&&!r
234145670
MC/DC100%2/2
defined *$self->{'CompressedInputLengthDone'} || $self->smartEof
defined *$self->{'CompressedInputLengthDone'} $self->smartEof
Truth table100%3/3
A || B
A= defined *$self->{'CompressedInputLengthDone'}B= $self->smartEof
ABresult
1X1
011
000
918  
919 # Remember the input buffer if it wasn't consumed completely
920 4838 ▶ $self->pushBack($temp_buf) if *$self->{Uncomp}{ConsumesInput};
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"Uncomp"}{"ConsumesInput"} 4838 0 4838
921  
922 return $self->saveErrorString(G_ERR, *$self->{Uncomp}{Error}, *$self->{Uncomp}{ErrorNo})
923 4838 ▶ if $self->saveStatus($status) == STATUS_ERROR;
Branch: 1 branch
BranchTrueFalseTotal
if $self->saveStatus($status) == -1 6 4832 4838
924  
925 4832 ▶ $self->postBlockChk($buffer, $before_len) == STATUS_OK
Branch: 1 branch
BranchTrueFalseTotal
$self->postBlockChk($buffer, $before_len) == 0 or return -1 4832 0 4832
926 or return G_ERR;
927  
928 4832 ▶ $buf_len = defined $$buffer ? length($$buffer) - $before_len : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $$buffer ? : 4832 0 4832
929  
930 4832 *$self->{CompSize}->add($beforeC_len - length $temp_buf) ;
931  
932 4832 *$self->{InflatedBytesRead} += $buf_len ;
933 4832 *$self->{TotalInflatedBytesRead} += $buf_len ;
934 4832 *$self->{UnCompSize}->add($buf_len) ;
935  
936 4832 $self->filterUncompressed($buffer, $before_len);
937  
938 # if (*$self->{Encoding}) {
939 # use Encode ;
940 # *$self->{PendingDecode} .= substr($$buffer, $before_len) ;
941 # my $got = *$self->{Encoding}->decode(*$self->{PendingDecode}, Encode::FB_QUIET) ;
942 # substr($$buffer, $before_len) = $got;
943 # }
944 }
945  
946 4832 ▶ if ($status == STATUS_ENDSTREAM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 1) 3986 846 4832
947  
948 3986 *$self->{EndStream} = 1 ;
949  
950 3986 my $trailer;
951 3986 my $trailer_size = *$self->{Info}{TrailerLength} ;
952 3986 my $got = 0;
953 3986 ▶ if (*$self->{Info}{TrailerLength})
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{"Info"}{"TrailerLength"}) 2836 1150 3986
954 {
955 2836 $got = $self->smartRead(\$trailer, $trailer_size) ;
956 }
957  
958 3986 ▶ if ($got == $trailer_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($got == $trailer_size) { } 3942 44 3986
959 3942 ▶ $self->chkTrailer($trailer) == STATUS_OK
Branch: 1 branch
BranchTrueFalseTotal
$self->chkTrailer($trailer) == 0 or return -1 3936 6 3942
960 or return G_ERR;
961 }
962 else {
963 return $self->TrailerError("trailer truncated. Expected " .
964 "$trailer_size bytes, got $got")
965 44 ▶ if *$self->{Strict};
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"Strict"} 12 32 44
966 32 $self->pushBack($trailer) ;
967 }
968  
969 # TODO - if want file pointer, do it here
970  
971 3968 ▶ if (! $self->smartEof()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->smartEof) 1378 2590 3968
972 1378 *$self->{NewStream} = 1 ;
973  
974 1378 ▶ if (*$self->{MultiStream}) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{"MultiStream"}) 942 436 1378
975 942 *$self->{EndStream} = 0 ;
976 942 return $buf_len ;
977 }
978 }
979  
980 }
981  
982  
983 # return the number of uncompressed bytes read
984 3872 return $buf_len ;
985 }
986  
987 sub reset
988 1773 ▶{
Subroutine reset: called CC=1 SCAR=0.0
Pod undocumented
989 1773 my $self = shift ;
990  
991 1773 return *$self->{Uncomp}->reset();
992 }
993  
994 sub filterUncompressed
995 3610 ▶{
Subroutine filterUncompressed: called CC=1 SCAR=0.0
Pod undocumented
996 }
997  
998 #sub isEndStream
999 #{
1000 # my $self = shift ;
1001 # return *$self->{NewStream} ||
1002 # *$self->{EndStream} ;
1003 #}
1004  
1005 sub nextStream
1006 598 ▶{
Subroutine nextStream: called CC=5 SCAR=16.1
Pod undocumented
1007 598 my $self = shift ;
1008  
1009 # An uncompressed file cannot have a next stream, so
1010 # return immediately.
1011 return 0
1012 598 ▶ if *$self->{Plain} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"Plain"} 1 597 598
1013  
1014 597 my $status = $self->gotoNextStream();
1015 597 ▶ $status == 1
Branch: 1 branch
BranchTrueFalseTotal
$status == 1 or return $status 406 191 597
1016 or return $status ;
1017  
1018 *$self->{Pending} = ''
1019 406 ▶ if $self !~ /IO::Uncompress::RawInflate/ && ! *$self->{MultiStream};
Branch: 1 branch
BranchTrueFalseTotal
unless $self =~ /IO::Uncompress::RawInflate/ or *$self->{"MultiStream"} 330 76 406
Condition66%2/3
$self =~ /IO::Uncompress::RawInflate/ or *$self->{"MultiStream"}
l!l&&r!l&&!r
760330
MC/DC50%1/2
$self =~ /IO::Uncompress::RawInflate/ or *$self->{"MultiStream"}
$self =~ /IO::Uncompress::RawInflate/ *$self->{"MultiStream"}
Truth table66%2/3
A or B
A= $self =~ /IO::Uncompress::RawInflate/B= *$self->{"MultiStream"}
ABresult
1X1
011
000
1020  
1021 406 *$self->{TotalInflatedBytesRead} = 0 ;
1022 406 *$self->{LineNo} = $. = 0;
1023  
1024 406 return 1;
1025 }
1026  
1027 sub gotoNextStream
1028 1773 ▶{
Subroutine gotoNextStream: called CC=8 SCAR=20.9
Pod undocumented
1029 1773 my $self = shift ;
1030  
1031 1773 ▶ if (! *$self->{NewStream}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (*$self->{"NewStream"}) 271 1502 1773
1032 271 my $status = 1;
1033 271 my $buffer ;
1034  
1035 # TODO - make this more efficient if know the offset for the end of
1036 # the stream and seekable
1037 271 ▶ $status = $self->read($buffer)
Branch: 1 branch
BranchTrueFalseTotal
$status > 0 and do { $status = $self->read($buffer) } 280 271 551
1038 while $status > 0 ;
1039  
1040 271 ▶ return $status
Branch: 1 branch
BranchTrueFalseTotal
if $status < 0 0 271 271
1041 if $status < 0;
1042 }
1043  
1044 1773 *$self->{NewStream} = 0 ;
1045 1773 *$self->{EndStream} = 0 ;
1046 1773 *$self->{CompressedInputLengthDone} = undef ;
1047 1773 *$self->{CompressedInputLength} = undef ;
1048 1773 $self->reset();
1049 1773 *$self->{UnCompSize}->reset();
1050 1773 *$self->{CompSize}->reset();
1051  
1052 1773 my $magic = $self->ckMagic();
1053  
1054 1773 ▶ if ( ! defined $magic) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $magic) { } 194 1579 1773
1055 194 ▶ if (! *$self->{Transparent} || $self->eof())
Branch: 1 branch
BranchTrueFalseTotal
if (not *$self->{"Transparent"} or $self->eof) 191 3 194
Condition100%3/3
not *$self->{"Transparent"} or $self->eof
l!l&&r!l&&!r
901013
MC/DC100%2/2
not *$self->{"Transparent"} or $self->eof
not *$self->{"Transparent"} $self->eof
Truth table100%3/3
not(A) or B
A= not *$self->{"Transparent"}B= $self->eof
ABresult
1X1
011
000
1056 {
1057 191 *$self->{EndStream} = 1 ;
1058 191 return 0;
1059 }
1060  
1061 # Not EOF, so Transparent mode kicks in now for trailing data
1062 # Reset member name in case anyone calls getHeaderInfo()->{Name}
1063 3 *$self->{Info} = { Name => undef, Type => 'plain' };
1064  
1065 3 $self->clearError();
1066 3 *$self->{Type} = 'plain';
1067 3 *$self->{Plain} = 1;
1068 3 $self->pushBack(*$self->{HeaderPending}) ;
1069 }
1070 else
1071 {
1072 1579 *$self->{Info} = $self->readHeader($magic);
1073  
1074 1579 ▶ if ( ! defined *$self->{Info} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined *$self->{"Info"}) 0 1579 1579
1075 0 *$self->{EndStream} = 1 ;
1076 0 return -1;
1077 }
1078 }
1079  
1080 1582 push @{ *$self->{InfoList} }, *$self->{Info} ;
1081  
1082 1582 return 1;
1083 }
1084  
1085 sub streamCount
1086 1260 ▶{
Subroutine streamCount: called CC=2 SCAR=7.0
Pod undocumented
1087 1260 my $self = shift ;
1088 1260 ▶ return 1 if ! defined *$self->{InfoList};
Branch: 1 branch
BranchTrueFalseTotal
unless defined *$self->{"InfoList"} 0 1260 1260
1089 1260 return scalar @{ *$self->{InfoList} } ;
1090 }
1091  
1092 sub read
1093 332827 ▶{
Subroutine read: called CC=30 SCAR=34.0
Pod undocumented
1094 # return codes
1095 # >0 - ok, number of bytes read
1096 # =0 - ok, eof
1097 # <0 - not ok
1098  
1099 332827 my $self = shift ;
1100  
1101 332827 ▶ if (defined *$self->{ReadStatus} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{"ReadStatus"}) 6 332821 332827
1102 6 my $status = *$self->{ReadStatus}[0];
1103 6 $self->saveErrorString( @{ *$self->{ReadStatus} } );
1104 6 delete *$self->{ReadStatus} ;
1105 6 return $status ;
1106 }
1107  
1108 332821 ▶ return G_EOF if *$self->{Closed} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"Closed"} 10 332811 332821
1109  
1110 332811 my $buffer ;
1111  
1112 332811 ▶ if (ref $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 4716 328095 332811
1113 $self->croakError(*$self->{ClassName} . "::read: buffer parameter is read-only")
1114 4716 ▶ if Scalar::Util::readonly(${ $_[0] });
Branch: 1 branch
BranchTrueFalseTotal
if &Scalar::Util::readonly(${$_[0];}) 0 4716 4716
1115  
1116 4716 ▶ $self->croakError(*$self->{ClassName} . "::read: not a scalar reference $_[0]" )
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] eq "SCALAR" 0 4716 4716
1117 unless ref $_[0] eq 'SCALAR' ;
1118 4716 $buffer = $_[0] ;
1119 }
1120 else {
1121 328095 ▶ $self->croakError(*$self->{ClassName} . "::read: buffer parameter is read-only")
Branch: 1 branch
BranchTrueFalseTotal
if &Scalar::Util::readonly($_[0]) 5 328090 328095
1122 if Scalar::Util::readonly($_[0]);
1123  
1124 328090 $buffer = \$_[0] ;
1125 }
1126  
1127 332806 my $length = $_[1] ;
1128 332806 ▶ my $offset = $_[2] || 0;
Condition100%2/2
$_[2] || 0
l!l
35332771
MC/DC100%1/1
$_[2] || 0
$_[2]
Truth table100%2/2
A
A= $_[2]
Aresult
11
00
1129  
1130 332806 ▶ if (! *$self->{AppendOutput}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not *$self->{'AppendOutput'}) { } 161661 171145 332806
elsif (not defined $$buffer) { } 2253 168892 171145
1131 161661 ▶ if (! $offset) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $offset) { } 161626 35 161661
1132  
1133 161626 $$buffer = '' ;
1134 }
1135 else {
1136 35 ▶ if ($offset > length($$buffer)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset > length $$buffer) { } 10 25 35
1137 10 $$buffer .= "\x00" x ($offset - length($$buffer));
1138 }
1139 else {
1140 25 substr($$buffer, $offset) = '';
1141 }
1142 }
1143 }
1144 elsif (! defined $$buffer) {
1145 2253 $$buffer = '' ;
1146 }
1147  
1148 332806 ▶ return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ;
Branch: 1 branch
BranchTrueFalseTotal
if not length *$self->{"Pending"} and *$self->{"EndStream"} 3282 329524 332806
Condition100%3/3
not length *$self->{"Pending"} and *$self->{"EndStream"}
!ll&&!rl&&r
32551640083282
MC/DC100%2/2
not length *$self->{"Pending"} and *$self->{"EndStream"}
not length *$self->{"Pending"} *$self->{"EndStream"}
Truth table100%3/3
not(A) and B
A= not length *$self->{"Pending"}B= *$self->{"EndStream"}
ABresult
0X0
100
111
1149  
1150 # the core read will return 0 if asked for 0 bytes
1151 329524 ▶ return 0 if defined $length && $length == 0 ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $length and $length == 0 20 329504 329524
Condition100%3/3
defined $length and $length == 0
!ll&&!rl&&r
707632242820
MC/DC100%2/2
defined $length and $length == 0
defined $length $length == 0
Truth table100%3/3
A and B
A= defined $lengthB= $length == 0
ABresult
0X0
100
111
1152  
1153 329504 ▶ $length = $length || 0;
Condition100%2/2
$length || 0
l!l
3224287076
MC/DC100%1/1
$length || 0
$length
Truth table100%2/2
A
A= $length
Aresult
11
00
1154  
1155 329504 ▶ $self->croakError(*$self->{ClassName} . "::read: length parameter is negative")
Branch: 1 branch
BranchTrueFalseTotal
if $length < 0 5 329499 329504
1156 if $length < 0 ;
1157  
1158 # Short-circuit if this is a simple read, with no length
1159 # or offset specified.
1160 329499 ▶ unless ( $length || $offset) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($length or $offset) 7076 322423 329499
Condition66%2/3
$length or $offset
l!l&&r!l&&!r
32242307076
MC/DC50%1/2
$length or $offset
$length $offset
Truth table66%2/3
A or B
A= $lengthB= $offset
ABresult
1X1
011
000
1161 7076 ▶ if (length *$self->{Pending}) {
Branch: 1 branch
BranchTrueFalseTotal
if (length *$self->{'Pending'}) { } 3454 3622 7076
1162 3454 $$buffer .= *$self->{Pending} ;
1163 3454 my $len = length *$self->{Pending};
1164 3454 *$self->{Pending} = '' ;
1165 3454 return $len ;
1166 }
1167 else {
1168 3622 my $len = 0;
1169 $len = $self->_raw_read($buffer)
1170 3622 ▶ while ! *$self->{EndStream} && $len == 0 ;
Branch: 1 branch
BranchTrueFalseTotal
not *$self->{"EndStream"} and $len == 0 and do { $len = $self->_raw_read($buffer) } 4072 3622 7694
Condition100%3/3
not *$self->{"EndStream"} and $len == 0
!ll&&!rl&&r
27039194072
MC/DC100%2/2
not *$self->{"EndStream"} and $len == 0
not *$self->{"EndStream"} $len == 0
Truth table100%3/3
not(A) and B
A= not *$self->{"EndStream"}B= $len == 0
ABresult
0X0
100
111
1171 3622 return $len ;
1172 }
1173 }
1174  
1175 # Need to jump through more hoops - either length or offset
1176 # or both are specified.
1177 322423 my $out_buffer = *$self->{Pending} ;
1178 322423 *$self->{Pending} = '';
1179  
1180  
1181 322423 ▶ while (! *$self->{EndStream} && length($out_buffer) < $length)
Branch: 1 branch
BranchTrueFalseTotal
if (not *$self->{"EndStream"} and length $out_buffer < $length) 2494 322423 324917
Condition100%3/3
not *$self->{"EndStream"} and length $out_buffer < $length
!ll&&!rl&&r
958132266102494
MC/DC100%2/2
not *$self->{"EndStream"} and length $out_buffer < $length
not *$self->{"EndStream"} length $out_buffer < $length
Truth table100%3/3
not(A) and B
A= not *$self->{"EndStream"}B= length $out_buffer < $length
ABresult
0X0
100
111
1182 {
1183 2494 my $buf_len = $self->_raw_read(\$out_buffer);
1184 2494 ▶ return $buf_len
Branch: 1 branch
BranchTrueFalseTotal
if $buf_len < 0 0 2494 2494
1185 if $buf_len < 0 ;
1186 }
1187  
1188 322423 ▶ $length = length $out_buffer
Branch: 1 branch
BranchTrueFalseTotal
if length $out_buffer < $length 787 321636 322423
1189 if length($out_buffer) < $length ;
1190  
1191 322423 ▶ return 0
Branch: 1 branch
BranchTrueFalseTotal
if $length == 0 110 322313 322423
1192 if $length == 0 ;
1193  
1194 322313 ▶ $$buffer = ''
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$buffer 0 322313 322313
1195 if ! defined $$buffer;
1196  
1197 $offset = length $$buffer
1198 322313 ▶ if *$self->{AppendOutput} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"AppendOutput"} 161609 160704 322313
1199  
1200 322313 *$self->{Pending} = $out_buffer;
1201 322313 $out_buffer = \*$self->{Pending} ;
1202  
1203 322313 substr($$buffer, $offset) = substr($$out_buffer, 0, $length) ;
1204 322313 substr($$out_buffer, 0, $length) = '' ;
1205  
1206 322313 return $length ;
1207 }
1208  
1209 sub _getline
1210 1525 ▶{
Subroutine _getline: called CC=11 SCAR=24.0
1211 1525 my $self = shift ;
1212 1525 my $status = 0 ;
1213  
1214 # Slurp Mode
1215 1525 ▶ if ( ! defined $/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $/) 55 1470 1525
1216 55 my $data ;
1217 55 ▶ 1 while ($status = $self->read($data)) > 0 ;
Branch: 1 branch
BranchTrueFalseTotal
($status = $self->read($data)) > 0 and do { '???' } 54 55 109
1218 55 return ($status, \$data);
1219 }
1220  
1221 # Record Mode
1222 1470 ▶ if ( ref $/ eq 'SCALAR' && ${$/} =~ /^\d+$/ && ${$/} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $/ eq "SCALAR" and ${$/;} =~ /^\d+$/ and ${$/;} > 0) 85 1385 1470
Condition66%4/6
ref $/ eq "SCALAR" and ${$/;} =~ /^\d+$/ and ${$/;} > 0
!ll&&!rl&&r
1385085
ref $/ eq "SCALAR" and ${$/;} =~ /^\d+$/
!ll&&!rl&&r
1385085
MC/DC33%1/3
ref $/ eq "SCALAR" and ${$/;} =~ /^\d+$/ and ${$/;} > 0
ref $/ eq "SCALAR" ${$/;} =~ /^\d+$/ ${$/;} > 0
Truth table50%2/4
A and B and C
A= ref $/ eq "SCALAR"B= ${$/;} =~ /^\d+$/C= ${$/;} > 0
ABCresult
0XX0
10X0
1100
1111
1223 85 my $reclen = ${$/} ;
1224 85 my $data ;
1225 85 $status = $self->read($data, $reclen) ;
1226 85 return ($status, \$data);
1227 }
1228  
1229 # Paragraph Mode
1230 1385 ▶ if ( ! length $/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $/) 60 1325 1385
1231 60 my $paragraph ;
1232 60 ▶ while (($status = $self->read($paragraph)) > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($status = $self->read($paragraph)) > 0) 50 10 60
1233 50 ▶ if ($paragraph =~ s/^(.*?\n\n+)//s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($paragraph =~ s/^(.*?\n\n+)//s) 50 0 50
1234 50 *$self->{Pending} = $paragraph ;
1235 50 my $par = $1 ;
1236 50 return (1, \$par);
1237 }
1238 }
1239 10 return ($status, \$paragraph);
1240 }
1241  
1242 # $/ isn't empty, or a reference, so it's Line Mode.
1243 {
1244 1325 my $line ;
1245 1325 my $p = \*$self->{Pending} ;
1246 1325 ▶ while (($status = $self->read($line)) > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($status = $self->read($line)) > 0) 1320 38 1358
1247 1320 my $offset = index($line, $/);
1248 1320 ▶ if ($offset >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset >= 0) 1287 33 1320
1249 1287 my $l = substr($line, 0, $offset + length $/ );
1250 1287 substr($line, 0, $offset + length $/) = '';
1251 1287 $$p = $line;
1252 1287 return (1, \$l);
1253 }
1254 }
1255  
1256 38 return ($status, \$line);
1257 }
1258 }
1259  
1260 sub getline
1261 2086 ▶{
Subroutine getline: called CC=7 SCAR=20.4
Pod documented
1262 2086 my $self = shift;
1263  
1264 2086 ▶ if (defined *$self->{ReadStatus} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{"ReadStatus"}) 0 2086 2086
1265 0 $self->saveErrorString( @{ *$self->{ReadStatus} } );
1266 0 delete *$self->{ReadStatus} ;
1267 0 return undef;
1268 }
1269  
1270 return undef
1271 2086 ▶ if *$self->{Closed} || (!length *$self->{Pending} && *$self->{EndStream}) ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"Closed"} or not length *$self->{"Pending"} and *$self->{"EndStream"} 561 1525 2086
Condition83%5/6
*$self->{"Closed"} or not length *$self->{"Pending"} and *$self->{"EndStream"}
l!l&&r!l&&!r
05611525
not length *$self->{"Pending"} and *$self->{"EndStream"}
!ll&&!rl&&r
1293232561
MC/DC66%2/3
*$self->{"Closed"} or not length *$self->{"Pending"} and *$self->{"EndStream"}
*$self->{"Closed"} not length *$self->{"Pending"} *$self->{"EndStream"}
Truth table75%3/4
A or not(B) and C
A= *$self->{"Closed"}B= not length *$self->{"Pending"}C= *$self->{"EndStream"}
ABCresult
1XX1
0111
00X0
0100
1272  
1273 1525 my $current_append = *$self->{AppendOutput} ;
1274 1525 *$self->{AppendOutput} = 1;
1275  
1276 1525 my ($status, $lineref) = $self->_getline();
1277 1525 *$self->{AppendOutput} = $current_append;
1278  
1279 return undef
1280 1525 ▶ if $status < 0 || length $$lineref == 0 ;
Branch: 1 branch
BranchTrueFalseTotal
if $status < 0 or length $$lineref == 0 28 1497 1525
Condition66%2/3
$status < 0 or length $$lineref == 0
l!l&&r!l&&!r
0281497
MC/DC50%1/2
$status < 0 or length $$lineref == 0
$status < 0 length $$lineref == 0
Truth table66%2/3
A or B
A= $status < 0B= length $$lineref == 0
ABresult
1X1
011
000
1281  
1282 1497 $. = ++ *$self->{LineNo} ;
1283  
1284 1497 return $$lineref ;
1285 }
1286  
1287 sub getlines
1288 110 ▶{
Subroutine getlines: called CC=3 SCAR=11.0
Pod documented
1289 110 my $self = shift;
1290 $self->croakError(*$self->{ClassName} .
1291 110 ▶ "::getlines: called in scalar context\n") unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 110 110
1292 110 my($line, @lines);
1293 110 ▶ push(@lines, $line)
Branch: 1 branch
BranchTrueFalseTotal
defined($line = $self->getline) and do { push @lines, $line } 305 110 415
1294 while defined($line = $self->getline);
1295 110 return @lines;
1296 }
1297  
1298 sub READLINE
1299 193 ▶{
Subroutine READLINE: called CC=2 SCAR=6.9
1300 193 ▶ goto &getlines if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 30 163 193
1301 163 goto &getline;
1302 }
1303  
1304 sub getc
1305 105 ▶{
Subroutine getc: called CC=2 SCAR=6.9
Pod undocumented
1306 105 my $self = shift;
1307 105 my $buf;
1308 105 ▶ return $buf if $self->read($buf, 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->read($buf, 1) 60 45 105
1309 45 return undef;
1310 }
1311  
1312 sub ungetc
1313 2941 ▶{
Subroutine ungetc: called CC=2 SCAR=7.1
Pod documented
1314 2941 my $self = shift;
1315 2941 ▶ *$self->{Pending} = "" unless defined *$self->{Pending} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined *$self->{"Pending"} 0 2941 2941
1316 2941 *$self->{Pending} = $_[0] . *$self->{Pending} ;
1317 }
1318  
1319  
1320 sub trailingData
1321 34 ▶{
Subroutine trailingData: called CC=3 SCAR=11.0
Pod undocumented
1322 34 my $self = shift ;
1323  
1324 34 ▶ if (defined *$self->{FH} || defined *$self->{InputEvent} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{'FH'} or defined *$self->{'InputEvent'}) { } 24 10 34
Condition66%2/3
defined *$self->{"FH"} or defined *$self->{"InputEvent"}
l!l&&r!l&&!r
24010
MC/DC50%1/2
defined *$self->{"FH"} or defined *$self->{"InputEvent"}
defined *$self->{"FH"} defined *$self->{"InputEvent"}
Truth table66%2/3
A or B
A= defined *$self->{"FH"}B= defined *$self->{"InputEvent"}
ABresult
1X1
011
000
1325 24 return *$self->{Prime} ;
1326 }
1327 else {
1328 10 my $buf = *$self->{Buffer} ;
1329 10 my $offset = *$self->{BufferOffset} ;
1330 10 return substr($$buf, $offset) ;
1331 }
1332 }
1333  
1334  
1335 sub eof
1336 2724 ▶{
Subroutine eof: called CC=4 SCAR=13.9
Pod undocumented
1337 2724 my $self = shift ;
1338  
1339 return (*$self->{Closed} ||
1340 (!length *$self->{Pending}
1341 2724 ▶ && ( $self->smartEof() || *$self->{EndStream}))) ;
Condition100%9/9
*$self->{'Closed'} || !length(*$self->{'Pending'}) && ($self->smartEof || *$self->{'EndStream'})
l!l&&r!l&&!r
692269386
not length *$self->{"Pending"} and $self->smartEof || *$self->{"EndStream"}
!ll&&!rl&&r
326602269
$self->smartEof or *$self->{"EndStream"}
l!l&&r!l&&!r
182444560
MC/DC100%4/4
*$self->{'Closed'} || !length(*$self->{'Pending'}) && ($self->smartEof || *$self->{'EndStream'})
*$self->{'Closed'} not length *$self->{"Pending"} $self->smartEof *$self->{"EndStream"}
Truth table100%5/5
A || not(B) and C or D
A= *$self->{'Closed'}B= not length *$self->{"Pending"}C= $self->smartEofD= *$self->{"EndStream"}
ABCDresult
1XXX1
011X1
01011
00XX0
01000
1342 }
1343  
1344 sub tell
1345 1133 ▶{
Subroutine tell: called CC=3 SCAR=11.0
Pod documented
1346 1133 my $self = shift ;
1347  
1348 1133 my $in ;
1349 1133 ▶ if (*$self->{Plain}) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{'Plain'}) { } 250 883 1133
1350 250 $in = *$self->{PlainBytesRead} ;
1351 }
1352 else {
1353 883 $in = *$self->{TotalInflatedBytesRead} ;
1354 }
1355  
1356 1133 my $pending = length *$self->{Pending} ;
1357  
1358 1133 ▶ return 0 if $pending > $in ;
Branch: 1 branch
BranchTrueFalseTotal
if $pending > $in 36 1097 1133
1359 1097 return $in - $pending ;
1360 }
1361  
1362 sub close
1363 6350 ▶{
Subroutine close: called CC=9 SCAR=22.3
Pod undocumented
1364 # todo - what to do if close is called before the end of the gzip file
1365 # do we remember any trailing data?
1366 6350 my $self = shift ;
1367  
1368 6350 ▶ return 1 if *$self->{Closed} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"Closed"} 2747 3603 6350
1369  
1370 3603 ▶ untie *$self
Branch: 1 branch
BranchTrueFalseTotal
if $] >= "5.008" 3603 0 3603
1371 if $] >= 5.008 ;
1372  
1373 3603 my $status = 1 ;
1374  
1375 3603 ▶ if (defined *$self->{FH}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{"FH"}) 2152 1451 3603
1376 2152 ▶ if ((! *$self->{Handle} || *$self->{AutoClose}) && ! *$self->{StdIO}) {
Branch: 1 branch
BranchTrueFalseTotal
if (!*$self->{"Handle"} || *$self->{"AutoClose"} and not *$self->{"StdIO"}) 1959 193 2152
Condition83%5/6
!*$self->{"Handle"} || *$self->{"AutoClose"} and not *$self->{"StdIO"}
!ll&&!rl&&r
19301959
not *$self->{"Handle"} or *$self->{"AutoClose"}
l!l&&r!l&&!r
1690269193
MC/DC66%2/3
!*$self->{"Handle"} || *$self->{"AutoClose"} and not *$self->{"StdIO"}
not *$self->{"Handle"} *$self->{"AutoClose"} not *$self->{"StdIO"}
Truth table60%3/5
not(A) or B and not(C)
A= not *$self->{"Handle"}B= *$self->{"AutoClose"}C= not *$self->{"StdIO"}
ABCresult
00X0
1X00
0100
1X11
0111
1377 1959 local $.;
1378 1959 $! = 0 ;
1379 1959 $status = *$self->{FH}->close();
1380 return $self->saveErrorString(0, $!, $!)
1381 1959 ▶ if !*$self->{InNew} && $self->saveStatus($!) != 0 ;
Branch: 1 branch
BranchTrueFalseTotal
if not *$self->{"InNew"} and $self->saveStatus($!) != 0 0 1959 1959
Condition33%1/3
not *$self->{"InNew"} and $self->saveStatus($!) != 0
!ll&&!rl&&r
019590
MC/DC0%0/2
not *$self->{"InNew"} and $self->saveStatus($!) != 0
not *$self->{"InNew"} $self->saveStatus($!) != 0
Truth table33%1/3
not(A) and B
A= not *$self->{"InNew"}B= $self->saveStatus($!) != 0
ABresult
0X0
100
111
1382 }
1383 2152 delete *$self->{FH} ;
1384 2152 $! = 0 ;
1385 }
1386 3603 *$self->{Closed} = 1 ;
1387  
1388 3603 return 1;
1389 }
1390  
1391 sub DESTROY
1392 4401 ▶{
Subroutine DESTROY: called CC=1 SCAR=0.0
1393 4401 my $self = shift ;
1394 4401 local ($., $@, $!, $^E, $?);
1395  
1396 4401 $self->close() ;
1397 }
1398  
1399 sub seek
1400 106 ▶{
Subroutine seek: called CC=11 SCAR=24.0
Pod documented
1401 106 my $self = shift ;
1402 106 my $position = shift;
1403 106 my $whence = shift ;
1404  
1405 106 my $here = $self->tell() ;
1406 106 my $target = 0 ;
1407  
1408  
1409 106 ▶ if ($whence == SEEK_SET) {
Branch: 3 branches
BranchTrueFalseTotal
if ($whence == 0) { } 21 85 106
elsif ($whence == 1) { } 63 22 85
elsif ($whence == 2) { } 11 11 22
1410 21 $target = $position ;
1411 }
1412 elsif ($whence == SEEK_CUR) {
1413 63 $target = $here + $position ;
1414 }
1415 elsif ($whence == SEEK_END) {
1416 11 $target = $position ;
1417 11 $self->croakError(*$self->{ClassName} . "::seek: SEEK_END not allowed") ;
1418 }
1419 else {
1420 11 $self->croakError(*$self->{ClassName} ."::seek: unknown value, $whence, for whence parameter");
1421 }
1422  
1423 # short circuit if seeking to current offset
1424 84 ▶ if ($target == $here) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target == $here) 26 58 84
1425 # On ordinary filehandles, seeking to the current
1426 # position also clears the EOF condition, so we
1427 # emulate this behavior locally while simultaneously
1428 # cascading it to the underlying filehandle
1429 26 ▶ if (*$self->{Plain}) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{"Plain"}) 10 16 26
1430 10 *$self->{EndStream} = 0;
1431 10 ▶ seek(*$self->{FH},0,1) if *$self->{FH};
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"FH"} 5 5 10
1432 }
1433 26 return 1;
1434 }
1435  
1436 # Outlaw any attempt to seek backwards
1437 58 ▶ $self->croakError( *$self->{ClassName} ."::seek: cannot seek backwards")
Branch: 1 branch
BranchTrueFalseTotal
if $target < $here 11 47 58
1438 if $target < $here ;
1439  
1440 # Walk the file to the new offset
1441 47 my $offset = $target - $here ;
1442  
1443 47 my $got;
1444 47 ▶ while (($got = $self->read(my $buffer, List::Util::min($offset, *$self->{BlockSize})) ) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (($got = $self->read(my $buffer, &List::Util::min($offset, *$self->{"BlockSize"}))) > 0) 47 0 47
1445 {
1446 47 $offset -= $got;
1447 47 ▶ last if $offset == 0 ;
Branch: 1 branch
BranchTrueFalseTotal
if $offset == 0 47 0 47
1448 }
1449  
1450 47 $here = $self->tell() ;
1451 47 ▶ return $offset == 0 ? 1 : 0 ;
Branch: 1 branch
BranchTrueFalseTotal
$offset == 0 ? : 47 0 47
1452 }
1453  
1454 sub fileno
1455 35 ▶{
Subroutine fileno: called CC=2 SCAR=6.9
Pod undocumented
1456 35 my $self = shift ;
1457 return defined *$self->{FH}
1458 ? fileno *$self->{FH}
1459 35 ▶ : undef ;
Branch: 1 branch
BranchTrueFalseTotal
defined *$self->{'FH'} ? : 30 5 35
1460 }
1461  
1462 sub binmode
1463 5 ▶{
Subroutine binmode: called CC=1 SCAR=0.0
Pod documented
1464 5 1;
1465 # my $self = shift ;
1466 # return defined *$self->{FH}
1467 # ? binmode *$self->{FH}
1468 # : 1 ;
1469 }
1470  
1471 sub opened
1472 10 ▶{
Subroutine opened: called CC=1 SCAR=0.0
Pod documented
1473 10 my $self = shift ;
1474 10 return ! *$self->{Closed} ;
1475 }
1476  
1477 sub autoflush
1478 10 ▶{
Subroutine autoflush: called CC=2 SCAR=7.2
Pod undocumented
1479 10 my $self = shift ;
1480 return defined *$self->{FH}
1481 10 ▶ ? *$self->{FH}->autoflush(@_)
Branch: 1 branch
BranchTrueFalseTotal
defined *$self->{'FH'} ? : 0 10 10
1482 : undef ;
1483 }
1484  
1485 sub input_line_number
1486 80 ▶{
Subroutine input_line_number: called CC=2 SCAR=7.0
Pod undocumented
1487 80 my $self = shift ;
1488 80 my $last = *$self->{LineNo};
1489 80 ▶ $. = *$self->{LineNo} = $_[1] if @_ ;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 80 80
1490 80 return $last;
1491 }
1492  
1493 sub _notAvailable
1494 600 ▶{
Subroutine _notAvailable: called CC=1 SCAR=0.0
1495 600 my $name = shift ;
1496 600 ▶ return sub { croak "$name Not Available: File opened only for intput" ; } ;
Subroutine __ANON__: called CC=1 SCAR=0.0
1497 }
1498  
1499 {
1500 100 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
1501  
1502 100 *BINMODE = \&binmode;
1503 100 *SEEK = \&seek;
1504 100 *READ = \&read;
1505 100 *sysread = \&read;
1506 100 *TELL = \&tell;
1507 100 *EOF = \&eof;
1508  
1509 100 *FILENO = \&fileno;
1510 100 *CLOSE = \&close;
1511  
1512 100 *print = _notAvailable('print');
1513 100 *PRINT = _notAvailable('print');
1514 100 *printf = _notAvailable('printf');
1515 100 *PRINTF = _notAvailable('printf');
1516 100 *write = _notAvailable('write');
1517 100 *WRITE = _notAvailable('write');
1518  
1519 #*sysread = \&read;
1520 #*syswrite = \&_notAvailable;
1521 }
1522  
1523  
1524  
1525 package IO::Uncompress::Base ;
1526  
1527  
1528 100 1 ;
1529 __END__
« blib/lib/IO/Uncompress/Gunzip.pm ↑ Summary blib/lib/IO/Compress/Gzip.pm »