File Coverage

blib/lib/Filter/gunzip.pm
Criterion Covered Total %
statement 23 36 63.8
branch 1 14 7.1
condition 1 6 16.6
subroutine 7 7 100.0
pod n/a
total 32 63 50.7


line stmt bran cond sub pod time code
1             # Copyright 2010, 2011, 2013, 2014, 2019 Kevin Ryde
2              
3             # This file is part of Filter-gunzip.
4             #
5             # Filter-gunzip is free software; you can redistribute it and/or modify it
6             # under the terms of the GNU General Public License as published by the Free
7             # Software Foundation; either version 3, or (at your option) any later
8             # version.
9             #
10             # Filter-gunzip is distributed in the hope that it will be useful, but
11             # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12             # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13             # for more details.
14             #
15             # You should have received a copy of the GNU General Public License along
16             # with Filter-gunzip. If not, see .
17              
18             package Filter::gunzip;
19 1     1   479 use strict;
  1         1  
  1         24  
20 1     1   4 use Carp;
  1         2  
  1         44  
21 1     1   5 use DynaLoader;
  1         1  
  1         28  
22 1     1   5 use PerlIO;
  1         2  
  1         7  
23 1     1   413 use PerlIO::gzip;
  1         480  
  1         29  
24              
25 1     1   6 use vars qw($VERSION @ISA);
  1         1  
  1         244  
26             $VERSION = 7;
27             @ISA = ('DynaLoader');
28              
29             __PACKAGE__->bootstrap($VERSION);
30              
31             # uncomment this to run the ### lines
32             # use Smart::Comments;
33              
34              
35             sub import {
36 1     1   3649 my ($class) = @_;
37              
38 1         6 my $filters = _rsfp_filters();
39             ### _rsfp_filters(): scalar(@{$filters})
40              
41 1 50 33     5 if ($filters && ! @{$filters}) {
  0         0  
42 0         0 my $fh;
43             ### _rsfp(): _rsfp()
44 0 0 0     0 if (($fh = _rsfp())
45 0         0 && eval { require PerlIO;
46 0         0 require PerlIO::gzip;
47 0         0 1 }) {
48             ### fh: $fh
49             ### tell: tell($fh)
50              
51 0         0 my @layers = PerlIO::get_layers($fh);
52             ### layers: \@layers
53              
54 0 0       0 if ($layers[-1] eq 'crlf') {
55 0 0       0 binmode ($fh, ':pop')
56             or croak "Oops, cannot pop crlf layer: $!";
57             }
58              
59 0 0       0 binmode ($fh, ':gzip')
60             or croak "Cannot push gzip layer: $!";
61              
62 0 0       0 if ($layers[-1] eq 'crlf') {
63 0 0       0 binmode ($fh, ':crlf')
64             or croak "Oops, cannot re-push crlf layer: $!";
65             }
66              
67             # @layers = PerlIO::get_layers($fh);
68             # ### pushed gzip: \@layers
69 0         0 return;
70             }
71             }
72              
73 1         384 require Filter::gunzip::Filter;
74 1         8 Filter::gunzip::Filter->import;
75             }
76              
77             1;
78             __END__