lib/Archive/Tar/Constant.pm

filter: Statementstmt 99.5% 206 / 207 Branchbran 62.5% 25 / 40 Conditioncond 39.3% 13 / 33 MC/DCmcdc 5.2% 1 / 19 Subroutinesub 100% 64 / 64 Podpod n/a totaltotal 85.1% 309 / 363 CC 32 SCAR 8.3
CC
32
Cov
87%
_list_consts
6.0
BEGIN
4.7
BEGIN
4.5
CRAP 2.3
« lib/Archive/Tar/File.pm ↑ Summary bin/ptardiff »
1 package Archive::Tar::Constant;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 ▶use vars qw[$VERSION @ISA @EXPORT];
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 18 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
9 18 require Exporter;
10  
11 18 $VERSION = '3.14';
12 18 @ISA = qw[Exporter];
13  
14 18 ▶ require Time::Local if $^O eq "MacOS";
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MacOS" 0 18 18
15 }
16  
17 18 @EXPORT = Archive::Tar::Constant->_list_consts( __PACKAGE__ );
18  
19 18 ▶use constant FILE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 18 ▶use constant HARDLINK => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 18 ▶use constant SYMLINK => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 18 ▶use constant CHARDEV => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 18 ▶use constant BLOCKDEV => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 18 ▶use constant DIR => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 18 ▶use constant FIFO => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 18 ▶use constant SOCKET => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 18 ▶use constant UNKNOWN => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 18 ▶use constant LONGLINK => 'L';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 18 ▶use constant LABEL => 'V';
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 18 ▶use constant BUFFER => 4096;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 18 ▶use constant HEAD => 512;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 18 ▶use constant BLOCK => 512;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 18 ▶use constant COMPRESS_GZIP => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 18 ▶use constant COMPRESS_BZIP => 'bzip2';
Subroutine BEGIN: called CC=1 SCAR=0.0
37 18 ▶use constant COMPRESS_XZ => 'xz';
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 18 ▶use constant BLOCK_SIZE => sub { my $n = int($_[0]/BLOCK); $n++ if $_[0] % BLOCK; $n * BLOCK };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] % 512 210 9 219
40 18 ▶use constant TAR_PAD => sub { my $x = shift || return; return "\0" x (BLOCK - ($x % BLOCK) ) };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=7.0
Condition50%1/2
shift() || (return)
l!l
860
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
41 18 ▶use constant TAR_END => "\0" x BLOCK;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 18 ▶use constant READ_ONLY => sub { shift() ? 'rb' : 'r' };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
shift() ? : 79 0 79
44 18 ▶use constant WRITE_ONLY => sub { $_[0] ? 'wb' . shift : 'w' };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 17 18 35
45 18 ▶use constant MODE_READ => sub { $_[0] =~ /^r/ ? 1 : 0 };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /^r/ ? : 212 88 300
46  
47 # Pointless assignment to make -w shut up
48 18 ▶my $getpwuid; $getpwuid = 'unknown' unless eval { my $f = getpwuid (0); };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { my $f = getpwuid 0 } } 0 18 18
49 18 ▶my $getgrgid; $getgrgid = 'unknown' unless eval { my $f = getgrgid (0); };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { my $f = getgrgid 0 } } 0 18 18
50 18 ▶use constant UNAME => sub { $getpwuid || scalar getpwuid( shift() ) || '' };
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: called CC=3 SCAR=11.4
Branch: 1 branch
BranchTrueFalseTotal
$getpwuid or scalar getpwuid shift() or "" 62 0 62
Condition50%1/2
$getpwuid or scalar getpwuid shift()
l!l
062
MC/DC0%0/1
$getpwuid or scalar getpwuid shift()
$getpwuid
Truth table50%1/2
A
A= $getpwuid
Aresult
11
00
51 18 ▶use constant GNAME => sub { $getgrgid || scalar getgrgid( shift() ) || '' };
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: called CC=3 SCAR=11.4
Branch: 1 branch
BranchTrueFalseTotal
$getgrgid or scalar getgrgid shift() or "" 62 0 62
Condition50%1/2
$getgrgid or scalar getgrgid shift()
l!l
062
MC/DC0%0/1
$getgrgid or scalar getgrgid shift()
$getgrgid
Truth table50%1/2
A
A= $getgrgid
Aresult
11
00
52 18 ▶use constant UID => $>;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 18 ▶use constant GID => (split ' ', $) )[0];
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 18 ▶use constant MODE => do { 0666 & (0777 & ~umask) };
Subroutine BEGIN: called CC=1 SCAR=0.0
56 18 ▶use constant STRIP_MODE => sub { shift() & 0777 };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
57 18 ▶use constant CHECK_SUM => " ";
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 18 ▶use constant UNPACK => 'a100 a8 a8 a8 a12 a12 a8 a1 a100 A6 a2 a32 a32 a8 a8 a155 x12'; # cdrake - size must be a12 - not A12 - or else screws up huge file sizes (>8gb)
Subroutine BEGIN: called CC=1 SCAR=0.0
60 18 ▶use constant PACK => 'a100 a8 a8 a8 a12 a12 A8 a1 a100 a6 a2 a32 a32 a8 a8 a155 x12';
Subroutine BEGIN: called CC=1 SCAR=0.0
61 18 ▶use constant NAME_LENGTH => 100;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 18 ▶use constant PREFIX_LENGTH => 155;
Subroutine BEGIN: called CC=1 SCAR=0.0
63  
64 18 ▶use constant TIME_OFFSET => ($^O eq "MacOS") ? Time::Local::timelocal(0,0,0,1,0,1970) : 0;
Subroutine BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MacOS' ? : 0 18 18
65 18 ▶use constant MAGIC => "ustar";
Subroutine BEGIN: called CC=1 SCAR=0.0
66 18 ▶use constant TAR_VERSION => "00";
Subroutine BEGIN: called CC=1 SCAR=0.0
67 18 ▶use constant LONGLINK_NAME => '././@LongLink';
Subroutine BEGIN: called CC=1 SCAR=0.0
68 18 ▶use constant PAX_HEADER => 'pax_global_header';
Subroutine BEGIN: called CC=1 SCAR=0.0
69  
70 ### allow ZLIB to be turned off using ENV: DEBUG only
71 18 ▶use constant ZLIB => do { !$ENV{'PERL5_AT_NO_ZLIB'} and
Subroutine BEGIN: called CC=4 SCAR=15.0
72 18 ▶ eval { require IO::Zlib };
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"PERL5_AT_NO_ZLIB"} or eval { do { require IO::Zlib } } 0 18 18
73 18 ▶ $ENV{'PERL5_AT_NO_ZLIB'} || $@ ? 0 : 1
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL5_AT_NO_ZLIB'} || $@ ? : 0 18 18
Condition33%1/3
$ENV{"PERL5_AT_NO_ZLIB"} or $@
l!l&&r!l&&!r
0018
MC/DC0%0/2
$ENV{"PERL5_AT_NO_ZLIB"} or $@
$ENV{"PERL5_AT_NO_ZLIB"} $@
Truth table33%1/3
A or B
A= $ENV{"PERL5_AT_NO_ZLIB"}B= $@
ABresult
1X1
011
000
74 18 };
75  
76 ### allow BZIP to be turned off using ENV: DEBUG only
77 18 ▶use constant BZIP => do { !$ENV{'PERL5_AT_NO_BZIP'} and
Subroutine BEGIN: called CC=4 SCAR=14.8
78 18 ▶ eval { require IO::Uncompress::Bunzip2;
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"PERL5_AT_NO_BZIP"} or eval { do { require IO::Uncompress::Bunzip2; require IO::Compress::Bzip2 } } 0 18 18
79 18 require IO::Compress::Bzip2; };
80 18 ▶ $ENV{'PERL5_AT_NO_BZIP'} || $@ ? 0 : 1
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL5_AT_NO_BZIP'} || $@ ? : 0 18 18
Condition33%1/3
$ENV{"PERL5_AT_NO_BZIP"} or $@
l!l&&r!l&&!r
0018
MC/DC0%0/2
$ENV{"PERL5_AT_NO_BZIP"} or $@
$ENV{"PERL5_AT_NO_BZIP"} $@
Truth table33%1/3
A or B
A= $ENV{"PERL5_AT_NO_BZIP"}B= $@
ABresult
1X1
011
000
81 18 };
82  
83 ### allow XZ to be turned off using ENV: DEBUG only
84 18 ▶use constant XZ => do { !$ENV{'PERL5_AT_NO_XZ'} and
Subroutine BEGIN: called CC=4 SCAR=15.5
85 18 ▶ eval { require IO::Compress::Xz;
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"PERL5_AT_NO_XZ"} or eval { do { require IO::Compress::Xz; require IO::Uncompress::UnXz } } 0 18 18
86 0 require IO::Uncompress::UnXz; };
87 18 ▶ $ENV{'PERL5_AT_NO_XZ'} || $@ ? 0 : 1
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL5_AT_NO_XZ'} || $@ ? : 18 0 18
Condition33%1/3
$ENV{"PERL5_AT_NO_XZ"} or $@
l!l&&r!l&&!r
0180
MC/DC0%0/2
$ENV{"PERL5_AT_NO_XZ"} or $@
$ENV{"PERL5_AT_NO_XZ"} $@
Truth table33%1/3
A or B
A= $ENV{"PERL5_AT_NO_XZ"}B= $@
ABresult
1X1
011
000
88 18 };
89  
90 18 ▶use constant GZIP_MAGIC_NUM => qr/^(?:\037\213|\037\235)/;
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 # ASCII: B Z h 0 9
93 18 ▶use constant BZIP_MAGIC_NUM => qr/^\x42\x5A\x68[\x30-\x39]/;
Subroutine BEGIN: called CC=1 SCAR=0.0
94  
95 18 ▶use constant XZ_MAGIC_NUM => qr/^\xFD\x37\x7A\x58\x5A\x00/;
Subroutine BEGIN: called CC=1 SCAR=0.0
96  
97 18 ▶use constant CAN_CHOWN => sub { ($> == 0 and $^O ne "MacOS" and $^O ne "MSWin32") };
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine __ANON__: called CC=3 SCAR=12.0
Branch: 1 branch
BranchTrueFalseTotal
$> == 0 and $^O ne "MacOS" and $^O ne "MSWin32" 0 267 267
Condition33%1/3
$> == 0 and $^O ne "MacOS"
!ll&&!rl&&r
26700
MC/DC0%0/2
$> == 0 and $^O ne "MacOS"
$> == 0 $^O ne "MacOS"
Truth table33%1/3
A and B
A= $> == 0B= $^O ne "MacOS"
ABresult
0X0
100
111
98 18 ▶use constant CAN_READLINK => ($^O ne 'MSWin32' and $^O !~ /RISC(?:[ _])?OS/i and $^O ne 'VMS');
Subroutine BEGIN: called CC=3 SCAR=13.3
Condition33%2/6
$^O ne 'MSWin32' && !($^O =~ /RISC(?:[ _])?OS/i) && $^O ne 'VMS'
!ll&&!rl&&r
0018
$^O ne "MSWin32" and not $^O =~ /RISC(?:[ _])?OS/i
!ll&&!rl&&r
0018
MC/DC0%0/3
$^O ne 'MSWin32' && !($^O =~ /RISC(?:[ _])?OS/i) && $^O ne 'VMS'
$^O ne "MSWin32" not $^O =~ /RISC(?:[ _])?OS/i $^O ne 'VMS'
Truth table25%1/4
A and not(B) && C
A= $^O ne "MSWin32"B= not $^O =~ /RISC(?:[ _])?OS/iC= $^O ne 'VMS'
ABCresult
0XX0
10X0
1100
1111
99 18 ▶use constant ON_UNIX => ($^O ne 'MSWin32' and $^O ne 'MacOS' and $^O ne 'VMS');
Subroutine BEGIN: called CC=3 SCAR=13.3
Condition33%2/6
$^O ne 'MSWin32' && $^O ne 'MacOS' && $^O ne 'VMS'
!ll&&!rl&&r
0018
$^O ne "MSWin32" and $^O ne "MacOS"
!ll&&!rl&&r
0018
MC/DC0%0/3
$^O ne 'MSWin32' && $^O ne 'MacOS' && $^O ne 'VMS'
$^O ne "MSWin32" $^O ne "MacOS" $^O ne 'VMS'
Truth table25%1/4
A and B && C
A= $^O ne "MSWin32"B= $^O ne "MacOS"C= $^O ne 'VMS'
ABCresult
0XX0
10X0
1100
1111
100 18 ▶use constant ON_VMS => $^O eq 'VMS';
Subroutine BEGIN: called CC=1 SCAR=0.0
101  
102 18 ▶sub _list_consts {
Subroutine _list_consts: called CC=6 SCAR=18.0
103 18 my $class = shift;
104 18 my $pkg = shift;
105 18 ▶ return unless defined $pkg; # some joker might use '0' as a pkg...
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pkg 0 18 18
106  
107 18 my @rv;
108 18 ▶ { no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
109 18 my $stash = $pkg . '::';
110  
111 18 for my $name (sort keys %$stash ) {
112  
113 ### is it a subentry?
114 990 my $sub = $pkg->can( $name );
115 990 ▶ next unless defined $sub;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sub 72 918 990
116  
117 918 ▶ next unless defined prototype($sub) and
Branch: 1 branch
BranchTrueFalseTotal
unless defined prototype $sub and not length prototype $sub 36 882 918
Condition66%2/3
defined prototype $sub and not length prototype $sub
!ll&&!rl&&r
360882
MC/DC50%1/2
defined prototype $sub and not length prototype $sub
defined prototype $sub not length prototype $sub
Truth table66%2/3
A and not(B)
A= defined prototype $subB= not length prototype $sub
ABresult
0X0
100
111
118 not length prototype($sub);
119  
120 882 push @rv, $name;
121 }
122 }
123  
124 18 return sort @rv;
125 }
126  
127 18 1;
« lib/Archive/Tar/File.pm ↑ Summary bin/ptardiff »