blib/lib/Crypt/Checksum.pm

filter: Statementstmt 62.5% 40 / 64 Branchbran 58.3% 7 / 12 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 38.8% 7 / 18 Podpod 0.0% 0 / 13 totaltotal 47.8% 56 / 117 CC 9 SCAR 16.5
CC
9
Cov
60%
addfile
12.0
adler32_data
2.0
adler32_data_int
2.0
CRAP 5.2
« blib/lib/Crypt/Digest/SHAKE.pm ↑ Summary blib/lib/Crypt/PRNG.pm »
1 package Crypt::Checksum;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = '0.091';
6  
7 2 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
8 2 our %EXPORT_TAGS = ( all => [qw/ adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int
9 crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int /] );
10 2 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
11 2 our @EXPORT = qw();
12  
13 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 $Carp::Internal{(__PACKAGE__)}++;
15 2 ▶use CryptX;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 # obsolete since v0.057, only for backwards compatibility
18 0 ▶sub adler32_data { require Crypt::Checksum::Adler32; goto \&Crypt::Checksum::Adler32::adler32_data }
Subroutine adler32_data: not called CC=1 SCAR=6.9
Pod undocumented
19 1 ▶sub adler32_data_hex { require Crypt::Checksum::Adler32; goto \&Crypt::Checksum::Adler32::adler32_data_hex }
Subroutine adler32_data_hex: called CC=1 SCAR=0.0
Pod undocumented
20 0 ▶sub adler32_data_int { require Crypt::Checksum::Adler32; goto \&Crypt::Checksum::Adler32::adler32_data_int }
Subroutine adler32_data_int: not called CC=1 SCAR=6.9
Pod undocumented
21 0 ▶sub adler32_file { require Crypt::Checksum::Adler32; goto \&Crypt::Checksum::Adler32::adler32_file }
Subroutine adler32_file: not called CC=1 SCAR=6.9
Pod undocumented
22 0 ▶sub adler32_file_hex { require Crypt::Checksum::Adler32; goto \&Crypt::Checksum::Adler32::adler32_file_hex }
Subroutine adler32_file_hex: not called CC=1 SCAR=6.9
Pod undocumented
23 0 ▶sub adler32_file_int { require Crypt::Checksum::Adler32; goto \&Crypt::Checksum::Adler32::adler32_file_int }
Subroutine adler32_file_int: not called CC=1 SCAR=6.9
Pod undocumented
24 0 ▶sub crc32_data { require Crypt::Checksum::CRC32; goto \&Crypt::Checksum::CRC32::crc32_data }
Subroutine crc32_data: not called CC=1 SCAR=6.9
Pod undocumented
25 1 ▶sub crc32_data_hex { require Crypt::Checksum::CRC32; goto \&Crypt::Checksum::CRC32::crc32_data_hex }
Subroutine crc32_data_hex: called CC=1 SCAR=0.0
Pod undocumented
26 0 ▶sub crc32_data_int { require Crypt::Checksum::CRC32; goto \&Crypt::Checksum::CRC32::crc32_data_int }
Subroutine crc32_data_int: not called CC=1 SCAR=6.9
Pod undocumented
27 0 ▶sub crc32_file { require Crypt::Checksum::CRC32; goto \&Crypt::Checksum::CRC32::crc32_file }
Subroutine crc32_file: not called CC=1 SCAR=6.9
Pod undocumented
28 0 ▶sub crc32_file_hex { require Crypt::Checksum::CRC32; goto \&Crypt::Checksum::CRC32::crc32_file_hex }
Subroutine crc32_file_hex: not called CC=1 SCAR=6.9
Pod undocumented
29 0 ▶sub crc32_file_int { require Crypt::Checksum::CRC32; goto \&Crypt::Checksum::CRC32::crc32_file_int }
Subroutine crc32_file_int: not called CC=1 SCAR=6.9
Pod undocumented
30  
31 14 ▶sub addfile {
Subroutine addfile: called CC=9 SCAR=24.8
Pod undocumented
32 14 my ($self, $file) = @_;
33  
34 14 my ($handle, $close_handle);
35 0 ▶ if (ref($file) && eval { defined fileno($file) }) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $file and eval { do { defined fileno $file } }) { } 0 14 14
elsif (defined $file and not ref $file) { } 14 0 14
Condition33%1/3
ref $file and eval { do { defined fileno $file } }
!ll&&!rl&&r
1400
MC/DC0%0/2
ref $file and eval { do { defined fileno $file } }
ref $file eval { do { defined fileno $file } }
Truth table33%1/3
A and B
A= ref $fileB= eval { do { defined fileno $file } }
ABresult
0X0
100
111
36 0 $handle = $file;
37 }
38 ▶ elsif (defined($file) && !ref($file)) {
Condition33%1/3
defined $file and not ref $file
!ll&&!rl&&r
0014
MC/DC0%0/2
defined $file and not ref $file
defined $file not ref $file
Truth table33%1/3
A and not(B)
A= defined $fileB= not ref $file
ABresult
0X0
100
111
39 14 ▶ open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
Branch: 1 branch
BranchTrueFalseTotal
open $handle, "<", $file or croak("FATAL: cannot open '${file}': $!") 14 0 14
40 14 binmode($handle);
41 14 $close_handle = 1;
42 }
43 else {
44 0 croak "FATAL: invalid handle";
45 }
46  
47 14 my $n;
48 14 my $buf = "";
49 {
50 14 local $SIG{__DIE__} = \&CryptX::_croak;
51 14 ▶ while (($n = read($handle, $buf, 32*1024))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n = read($handle, $buf, 32768)) 14 14 28
52 14 $self->add($buf);
53 }
54 14 ▶ croak "FATAL: read failed: $!" unless defined $n;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n 0 14 14
55 }
56 14 ▶ close($handle) if $close_handle;
Branch: 1 branch
BranchTrueFalseTotal
if $close_handle 14 0 14
57  
58 14 return $self;
59 }
60  
61 0 ▶sub CLONE_SKIP { 1 } # prevent cloning
Subroutine CLONE_SKIP: not called CC=1 SCAR=6.9
62  
63 2 1;
64  
65 =pod
66  
67 =head1 NAME
68  
69 Crypt::Checksum - [internal only]
70  
71 =head1 SYNOPSIS
72  
73 Do not use this module directly.
74  
75 Use a concrete checksum module instead.
76  
77 =head1 SEE ALSO
78  
79 =over
80  
81 =item * L<CryptX>
82  
83 =item * L<Crypt::Checksum::Adler32>, L<Crypt::Checksum::CRC32>
84  
85 =back
86  
87 =cut
« blib/lib/Crypt/Digest/SHAKE.pm ↑ Summary blib/lib/Crypt/PRNG.pm »