line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::API2::Basic::PDF::Filter::ASCII85Decode; |
2
|
|
|
|
|
|
|
|
3
|
43
|
|
|
43
|
|
68994
|
use base 'PDF::API2::Basic::PDF::Filter'; |
|
43
|
|
|
|
|
99
|
|
|
43
|
|
|
|
|
5775
|
|
4
|
|
|
|
|
|
|
|
5
|
43
|
|
|
43
|
|
385
|
use strict; |
|
43
|
|
|
|
|
129
|
|
|
43
|
|
|
|
|
860
|
|
6
|
43
|
|
|
43
|
|
239
|
use warnings; |
|
43
|
|
|
|
|
102
|
|
|
43
|
|
|
|
|
33724
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.043'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub outfilt { |
11
|
3
|
|
|
3
|
1
|
14
|
my ($self, $str, $isend) = @_; |
12
|
3
|
|
|
|
|
7
|
my ($res, $i, $j, $b, @c); |
13
|
|
|
|
|
|
|
|
14
|
3
|
50
|
33
|
|
|
13
|
if (exists $self->{'outcache'} and $self->{'outcache'} ne "") { |
15
|
0
|
|
|
|
|
0
|
$str = $self->{'outcache'} . $str; |
16
|
0
|
|
|
|
|
0
|
$self->{'outcache'} = ""; |
17
|
|
|
|
|
|
|
} |
18
|
3
|
|
|
|
|
12
|
for ($i = 0; $i + 4 <= length($str); $i += 4) { |
19
|
32
|
|
|
|
|
64
|
$b = unpack("N", substr($str, $i, 4)); |
20
|
32
|
50
|
|
|
|
57
|
if ($b == 0) { |
21
|
0
|
|
|
|
|
0
|
$res .= "z"; |
22
|
0
|
|
|
|
|
0
|
next; |
23
|
|
|
|
|
|
|
} |
24
|
32
|
|
|
|
|
67
|
for ($j = 0; $j < 4; $j++) { |
25
|
128
|
|
|
|
|
216
|
$c[$j] = $b - int($b / 85) * 85 + 33; $b /= 85; |
|
128
|
|
|
|
|
230
|
|
26
|
|
|
|
|
|
|
} |
27
|
32
|
|
|
|
|
76
|
$res .= pack("C5", $b + 33, reverse @c); |
28
|
32
|
50
|
|
|
|
83
|
$res .= "\n" if ($i % 60 == 56); |
29
|
|
|
|
|
|
|
} |
30
|
3
|
100
|
66
|
|
|
19
|
if ($isend && $i < length($str)) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
31
|
1
|
|
|
|
|
4
|
$str = substr($str, $i); |
32
|
1
|
|
|
|
|
6
|
$b = unpack("N", $str . ("\000" x (4 - length($str)))); |
33
|
1
|
|
|
|
|
5
|
for ($j = 0; $j < 4; $j++) { |
34
|
4
|
|
|
|
|
11
|
$c[$j] = $b - int($b / 85) * 85 + 33; $b /= 85; |
|
4
|
|
|
|
|
9
|
|
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
|
|
|
3
|
push @c, $b + 33; |
37
|
1
|
|
|
|
|
7
|
$res .= substr(pack("C5", reverse @c), 0, length($str) + 1) . '~>'; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($isend) { |
40
|
2
|
|
|
|
|
4
|
$res .= '~>'; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ($i + 4 > length($str)) { |
43
|
0
|
|
|
|
|
0
|
$self->{'outcache'} = substr($str, $i); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
14
|
return $res; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub infilt { |
50
|
2
|
|
|
2
|
1
|
5
|
my ($self, $str, $isend) = @_; |
51
|
2
|
|
|
|
|
4
|
my ($res, $i, $j, @c, $b, $num); |
52
|
2
|
|
|
|
|
5
|
$num = 0; |
53
|
2
|
50
|
33
|
|
|
8
|
if (exists($self->{'incache'}) && $self->{'incache'} ne "") { |
54
|
0
|
|
|
|
|
0
|
$str = $self->{'incache'} . $str; |
55
|
0
|
|
|
|
|
0
|
$self->{'incache'} = ""; |
56
|
|
|
|
|
|
|
} |
57
|
2
|
|
|
|
|
10
|
$str =~ s/(\r|\n)\n?//og; |
58
|
2
|
|
|
|
|
7
|
for ($i = 0; $i < length($str); $i += 5) { |
59
|
23
|
100
|
66
|
|
|
73
|
last if $isend and substr($str, $i, 6) eq '~>'; |
60
|
22
|
|
|
|
|
29
|
$b = 0; |
61
|
22
|
50
|
66
|
|
|
82
|
if (substr($str, $i, 1) eq "z") { |
|
|
100
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
$i -= 4; |
63
|
0
|
|
|
|
|
0
|
$res .= pack("N", 0); |
64
|
0
|
|
|
|
|
0
|
next; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
elsif ($isend && substr($str, $i, 6) =~ m/^(.{2,4})\~\>$/o) { |
67
|
1
|
|
|
|
|
3
|
$num = 5 - length($1); |
68
|
1
|
|
|
|
|
5
|
@c = unpack("C5", $1 . ("u" x (4 - $num))); # pad with 84 to sort out rounding |
69
|
1
|
|
|
|
|
2
|
$i = length($str); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
21
|
|
|
|
|
83
|
@c = unpack("C5", substr($str, $i, 5)); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
22
|
|
|
|
|
49
|
for ($j = 0; $j < 5; $j++) { |
76
|
110
|
|
|
|
|
130
|
$b *= 85; |
77
|
110
|
|
|
|
|
214
|
$b += $c[$j] - 33; |
78
|
|
|
|
|
|
|
} |
79
|
22
|
|
|
|
|
61
|
$res .= substr(pack("N", $b), 0, 4 - $num); |
80
|
|
|
|
|
|
|
} |
81
|
2
|
50
|
33
|
|
|
7
|
if (!$isend && $i > length($str)) { |
82
|
0
|
|
|
|
|
0
|
$self->{'incache'} = substr($str, $i - 5); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
2
|
|
|
|
|
11
|
return $res; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |