API2/Basic/PDF/Filter/ASCII85Decode.pm

filter: Statementstmt 82.2% 51 / 62 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 70.9% 93 / 131 SCAR 34.7
CC
23
Cov
74%
infilt
15.7
outfilt
15.2
BEGIN
1.0
CRAP 32.2
« API2/Resource/XObject/Image/JPEG.pm ↑ Summary API2/Resource/XObject/Form.pm »
1 package PDF::API2::Basic::PDF::Filter::ASCII85Decode;
2  
3 43 ▶use base 'PDF::API2::Basic::PDF::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 43 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 43 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 43 our $VERSION = '2.044'; # VERSION
9  
10 sub outfilt {
11 3 ▶ my ($self, $str, $isend) = @_;
Subroutine outfilt: called CC=12 SCAR=27.2
Pod documented
12 3 my ($res, $i, $j, $b, @c);
13  
14 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
15 0 $str = $self->{'outcache'} . $str;
16 0 $self->{'outcache'} = "";
17 }
18 3 ▶ for ($i = 0; $i + 4 <= length($str); $i += 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 4 <= length $str) 32 3 35
19 32 $b = unpack("N", substr($str, $i, 4));
20 32 ▶ if ($b == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b == 0) 0 32 32
21 0 $res .= "z";
22 0 next;
23 }
24 32 ▶ for ($j = 0; $j < 4; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 4) 128 32 160
25 128 $c[$j] = $b - int($b / 85) * 85 + 33; $b /= 85;
26 }
27 32 $res .= pack("C5", $b + 33, reverse @c);
28 32 ▶ $res .= "\n" if ($i % 60 == 56);
Branch: 1 branch
BranchTrueFalseTotal
if $i % 60 == 56 0 32 32
29 }
30 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
31 1 $str = substr($str, $i);
32 1 $b = unpack("N", $str . ("\000" x (4 - length($str))));
33 1 ▶ for ($j = 0; $j < 4; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 4) 4 1 5
34 4 $c[$j] = $b - int($b / 85) * 85 + 33; $b /= 85;
35 }
36 1 push @c, $b + 33;
37 1 $res .= substr(pack("C5", reverse @c), 0, length($str) + 1) . '~>';
38 }
39 elsif ($isend) {
40 2 $res .= '~>';
41 }
42 elsif ($i + 4 > length($str)) {
43 0 $self->{'outcache'} = substr($str, $i);
44 }
45  
46 3 return $res;
47 }
48  
49 sub infilt {
50 2 ▶ my ($self, $str, $isend) = @_;
Subroutine infilt: called CC=12 SCAR=27.5
Pod documented
51 2 my ($res, $i, $j, @c, $b, $num);
52 2 $num = 0;
53 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
54 0 $str = $self->{'incache'} . $str;
55 0 $self->{'incache'} = "";
56 }
57 2 $str =~ s/(\r|\n)\n?//og;
58 2 ▶ for ($i = 0; $i < length($str); $i += 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $str) 23 1 24
59 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
60 22 $b = 0;
61 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
62 0 $i -= 4;
63 0 $res .= pack("N", 0);
64 0 next;
65 }
66 ▶ 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
67 1 $num = 5 - length($1);
68 1 @c = unpack("C5", $1 . ("u" x (4 - $num))); # pad with 84 to sort out rounding
69 1 $i = length($str);
70 }
71 else {
72 21 @c = unpack("C5", substr($str, $i, 5));
73 }
74  
75 22 ▶ for ($j = 0; $j < 5; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 5) 110 22 132
76 110 $b *= 85;
77 110 $b += $c[$j] - 33;
78 }
79 22 $res .= substr(pack("N", $b), 0, 4 - $num);
80 }
81 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
82 0 $self->{'incache'} = substr($str, $i - 5);
83 }
84  
85 2 return $res;
86 }
87  
88 43 1;
« API2/Resource/XObject/Image/JPEG.pm ↑ Summary API2/Resource/XObject/Form.pm »