Builder/Basic/PDF/Filter/ASCII85Decode.pm

filter: Statementstmt 82.5% 52 / 63 Branchbran 71.8% 23 / 32 Conditioncond 50.0% 9 / 18 MC/DCmcdc 25.0% 3 / 12 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 71.2% 94 / 132 CC 23 SCAR 26.3
CC
23
Cov
74%
infilt
15.7
outfilt
15.2
BEGIN
1.0
CRAP 13.8
« Builder/Resource/ColorSpace/Indexed/ACTFile.pm ↑ Summary Builder/Basic/PDF/Filter/LZWDecode.pm »
1 package PDF::Builder::Basic::PDF::Filter::ASCII85Decode;
2  
3 45 ▶use base 'PDF::Builder::Basic::PDF::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 45 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 45 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 45 our $VERSION = '3.028'; # VERSION
9 45 our $LAST_UPDATE = '3.027'; # manually update whenever code is changed
10  
11 =head1 NAME
12  
13 PDF::Builder::Basic::PDF::Filter::ASCII85Decode - Compress and uncompress stream filters for ASCII-85
14  
15 Inherits from L<PDF::Builder::Basic::PDF::Filter>
16  
17 =cut
18  
19 3 ▶sub outfilt {
Subroutine outfilt: called CC=12 SCAR=27.2
Pod documented
20 3 my ($self, $str, $isend) = @_;
21  
22 3 my ($res, $i, $j, $bb, @c);
23  
24 3 ▶ if (exists $self->{'outcache'} and $self->{'outcache'} ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"outcache"} and $self->{"outcache"} ne "") 0 3 3
Condition33%1/3
exists $self->{"outcache"} and $self->{"outcache"} ne ""
!ll&&!rl&&r
300
MC/DC0%0/2
exists $self->{"outcache"} and $self->{"outcache"} ne ""
exists $self->{"outcache"} $self->{"outcache"} ne ""
Truth table33%1/3
A and B
A= exists $self->{"outcache"}B= $self->{"outcache"} ne ""
ABresult
0X0
100
111
25 0 $str = $self->{'outcache'} . $str;
26 0 $self->{'outcache'} = "";
27 }
28 3 ▶ for ($i = 0; $i + 4 <= length($str); $i += 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 4 <= length $str) 32 3 35
29 32 $bb = unpack("N", substr($str, $i, 4));
30 32 ▶ if ($bb == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bb == 0) 0 32 32
31 0 $res .= "z";
32 0 next;
33 }
34 32 ▶ for ($j = 0; $j < 4; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 4) 128 32 160
35 128 $c[$j] = $bb - int($bb / 85) * 85 + 33; $bb /= 85;
36 }
37 32 $res .= pack("C5", $bb + 33, reverse @c);
38 32 ▶ $res .= "\n" if $i % 60 == 56;
Branch: 1 branch
BranchTrueFalseTotal
if $i % 60 == 56 0 32 32
39 }
40 3 ▶ if ($isend && $i < length($str)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($isend and $i < length $str) { } 1 2 3
elsif ($isend) { } 2 0 2
elsif ($i + 4 > length $str) { } 0 0 0
Condition66%2/3
$isend and $i < length $str
!ll&&!rl&&r
021
MC/DC50%1/2
$isend and $i < length $str
$isend $i < length $str
Truth table66%2/3
A and B
A= $isendB= $i < length $str
ABresult
0X0
100
111
41 1 $str = substr($str, $i);
42 1 $bb = unpack("N", $str . ("\000" x (4 - length($str))));
43 1 ▶ for ($j = 0; $j < 4; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 4) 4 1 5
44 4 $c[$j] = $bb - int($bb / 85) * 85 + 33; $bb /= 85;
45 }
46 1 push @c, $bb + 33;
47 1 $res .= substr(pack("C5", reverse @c), 0, length($str) + 1) . '~>';
48 } elsif ($isend) {
49 2 $res .= '~>';
50 } elsif ($i + 4 > length($str)) {
51 0 $self->{'outcache'} = substr($str, $i);
52 }
53  
54 3 return $res;
55 }
56  
57 2 ▶sub infilt {
Subroutine infilt: called CC=12 SCAR=27.5
Pod documented
58 2 my ($self, $str, $isend) = @_;
59  
60 2 my ($res, $i, $j, @c, $bb, $num);
61 2 $num = 0;
62 2 ▶ if (exists($self->{'incache'}) && $self->{'incache'} ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"incache"} and $self->{"incache"} ne "") 0 2 2
Condition33%1/3
exists $self->{"incache"} and $self->{"incache"} ne ""
!ll&&!rl&&r
200
MC/DC0%0/2
exists $self->{"incache"} and $self->{"incache"} ne ""
exists $self->{"incache"} $self->{"incache"} ne ""
Truth table33%1/3
A and B
A= exists $self->{"incache"}B= $self->{"incache"} ne ""
ABresult
0X0
100
111
63 0 $str = $self->{'incache'} . $str;
64 0 $self->{'incache'} = "";
65 }
66 2 $str =~ s/(\r|\n)\n?//og;
67 2 ▶ for ($i = 0; $i < length($str); $i += 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $str) 23 1 24
68 23 ▶ last if $isend and substr($str, $i, 6) eq '~>';
Branch: 1 branch
BranchTrueFalseTotal
if $isend and substr($str, $i, 6) eq "~>" 1 22 23
Condition66%2/3
$isend and substr($str, $i, 6) eq "~>"
!ll&&!rl&&r
0221
MC/DC50%1/2
$isend and substr($str, $i, 6) eq "~>"
$isend substr($str, $i, 6) eq "~>"
Truth table66%2/3
A and B
A= $isendB= substr($str, $i, 6) eq "~>"
ABresult
0X0
100
111
69 22 $bb = 0;
70 22 ▶ if (substr($str, $i, 1) eq "z") {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($str, $i, 1) eq 'z') { } 0 22 22
elsif ($isend and substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o) { } 1 21 22
71 0 $i -= 4;
72 0 $res .= pack("N", 0);
73 0 next;
74 ▶ } elsif ($isend && substr($str, $i, 6) =~ m/^(.{2,4})\~\>$/o) {
Condition66%2/3
$isend and substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o
!ll&&!rl&&r
0211
MC/DC50%1/2
$isend and substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o
$isend substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o
Truth table66%2/3
A and B
A= $isendB= substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o
ABresult
0X0
100
111
75 1 $num = 5 - length($1);
76 1 @c = unpack("C5", $1 . ("u" x (4 - $num))); # pad with 84 to sort out rounding
77 1 $i = length($str);
78 } else {
79 21 @c = unpack("C5", substr($str, $i, 5));
80 }
81  
82 22 ▶ for ($j = 0; $j < 5; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 5) 110 22 132
83 110 $bb *= 85;
84 110 $bb += $c[$j] - 33;
85 }
86 22 $res .= substr(pack("N", $bb), 0, 4 - $num);
87 }
88 2 ▶ if (!$isend && $i > length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $isend and $i > length $str) 0 2 2
Condition33%1/3
not $isend and $i > length $str
!ll&&!rl&&r
200
MC/DC0%0/2
not $isend and $i > length $str
not $isend $i > length $str
Truth table33%1/3
not(A) and B
A= not $isendB= $i > length $str
ABresult
0X0
100
111
89 0 $self->{'incache'} = substr($str, $i - 5);
90 }
91  
92 2 return $res;
93 }
94  
95 45 1;
« Builder/Resource/ColorSpace/Indexed/ACTFile.pm ↑ Summary Builder/Basic/PDF/Filter/LZWDecode.pm »