| 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
Condition33%1/3
exists $self->{"outcache"} and $self->{"outcache"} ne ""
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 ""
| |||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||
| 19 | 32 | $b = unpack("N", substr($str, $i, 4)); | |||||||||||||||||||||||||||||||||||
| 20 | 32 | ▶ | if ($b == 0) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 21 | 0 | $res .= "z"; | |||||||||||||||||||||||||||||||||||
| 22 | 0 | next; | |||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||
| 24 | 32 | ▶ | for ($j = 0; $j < 4; $j++) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | if ($isend && $i < length($str)) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$isend and $i < length $str
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
| |||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
exists $self->{"incache"} and $self->{"incache"} ne ""
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 ""
| |||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||
| 59 | 23 | ▶ | last if $isend and substr($str, $i, 6) eq '~>'; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$isend and substr($str, $i, 6) eq "~>"
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 "~>"
| |||||||||||||||||||||||||||||||||||||
| 60 | 22 | $b = 0; | |||||||||||||||||||||||||||||||||||
| 61 | 22 | ▶ | if (substr($str, $i, 1) eq "z") { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
not $isend and $i > length $str
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
| |||||||||||||||||||||||||||||||||||||
| 82 | 0 | $self->{'incache'} = substr($str, $i - 5); | |||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||
| 85 | 2 | return $res; | |||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||
| 88 | 43 | 1; | |||||||||||||||||||||||||||||||||||