API3/Compat/API2/Basic/PDF/Filter.pm

filter: Statementstmt 22.6% 56 / 247 Branchbran 0.0% 0 / 98 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 51.6% 16 / 31 Podpod 50.0% 1 / 2 totaltotal 17.6% 73 / 413 CC 58 SCAR 40.2
CC
58
Cov
15%
outfilt
110.0
infilt
110.0
infilt
90.0
CRAP 55.8
« API3/Compat/API2/Basic/TTF/Anchor.pm ↑ Summary API3/Compat/API2/Resource/CIDFont/TrueType.pm »
1 #=======================================================================
2 # ____ ____ _____ _ ____ ___ ____
3 # | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \
4 # | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) |
5 # | __/| |_| | _| _ _ / ___ \| __/| | / __/
6 # |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____|
7 #
8 # A Perl Module Chain to faciliate the Creation and Modification
9 # of High-Quality "Portable Document Format (PDF)" Files.
10 #
11 #=======================================================================
12 #
13 # THIS IS A REUSED PERL MODULE, FOR PROPER LICENCING TERMS SEE BELOW:
14 #
15 #
16 # Copyright Martin Hosken <Martin_Hosken@sil.org>
17 #
18 # No warranty or expression of effectiveness, least of all regarding
19 # anyone's safety, is implied in this software or documentation.
20 #
21 # This specific module is licensed under the Perl Artistic License.
22 #
23 #
24 # $Id: Filter.pm,v 2.0 2005/11/16 02:16:00 areibens Exp $
25 #
26 #=======================================================================
27 package PDF::API3::Compat::API2::Basic::PDF::Filter;
28
29 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
30
31 =head1 NAME
32
33 PDF::API3::Compat::API2::Basic::PDF::Filter - Abstract superclass for PDF stream filters
34
35 =head1 SYNOPSIS
36
37 $f = PDF::API3::Compat::API2::Basic::PDF::Filter->new;
38 $str = $f->outfilt($str, 1);
39 print OUTFILE $str;
40
41 while (read(INFILE, $dat, 4096))
42 { $store .= $f->infilt($dat, 0); }
43 $store .= $f->infilt("", 1);
44
45 =head1 DESCRIPTION
46
47 A Filter object contains state information for the process of outputting
48 and inputting data through the filter. The precise state information stored
49 is up to the particular filter and may range from nothing to whole objects
50 created and destroyed.
51
52 Each filter stores different state information for input and output and thus
53 may handle one input filtering process and one output filtering process at
54 the same time.
55
56 =head1 METHODS
57
58 =head2 PDF::API3::Compat::API2::Basic::PDF::Filter->new
59
60 Creates a new filter object with empty state information ready for processing
61 data both input and output.
62
63 =head2 $dat = $f->infilt($str, $isend)
64
65 Filters from output to input the data. Notice that $isend == 0 implies that there
66 is more data to come and so following it $f may contain state information
67 (usually due to the break-off point of $str not being tidy). Subsequent calls
68 will incorporate this stored state information.
69
70 $isend == 1 implies that there is no more data to follow. The
71 final state of $f will be that the state information is empty. Error messages
72 are most likely to occur here since if there is required state information to
73 be stored following this data, then that would imply an error in the data.
74
75 =head2 $str = $f->outfilt($dat, $isend)
76
77 Filter stored data ready for output. Parallels C<infilt>.
78
79 =cut
80
81 sub new
82 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
83 0 my ($class) = @_;
84 0 my ($self) = {};
85
86 0 bless $self, $class;
87 }
88
89 sub release
90 0 ▶{
Subroutine release: not called CC=7 SCAR=40.3
Pod undocumented
91 0 my ($self) = @_;
92
93 0 ▶ return($self) unless(ref $self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
94 # delete stuff that we know we can, here
95
96 0 my @tofree = map { delete $self->{$_} } keys %{$self};
97
98 0 ▶ while (my $item = shift @tofree)
Branch: 1 branch
BranchTrueFalseTotal
if (my $item = shift @tofree) 0 0 0
99 {
100 0 my $ref = ref($item);
101 0 ▶ if (UNIVERSAL::can($item, 'release'))
Branch: 3 branches
BranchTrueFalseTotal
if (UNIVERSAL::can($item, 'release')) { } 0 0 0
elsif ($ref eq 'ARRAY') { } 0 0 0
elsif (UNIVERSAL::isa($ref, 'HASH')) { } 0 0 0
102 0 { $item->release(); }
103 elsif ($ref eq 'ARRAY')
104 0 { push( @tofree, @{$item} ); }
105 elsif (UNIVERSAL::isa($ref, 'HASH'))
106 0 { release($item); }
107 }
108
109 # check that everything has gone - it better had!
110 0 foreach my $key (keys %{$self})
111 { # warn ref($self) . " still has '$key' key left after release.\n";
112 0 $self->{$key}=undef;
113 0 delete($self->{$key});
114 }
115 }
116
117
118 package PDF::API3::Compat::API2::Basic::PDF::ASCII85Decode;
119
120 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
121 1 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
122 1 @ISA = qw(PDF::API3::Compat::API2::Basic::PDF::Filter);
123 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
124
125 =head1 NAME
126
127 PDF::API3::Compat::API2::Basic::PDF::ASCII85Decode - Ascii85 filter for PDF streams. Inherits from
128 L<PDF::API3::Compat::API2::Basic::PDF::Filter>
129
130 =cut
131
132 sub outfilt
133 0 ▶{
Subroutine outfilt: not called CC=10 SCAR=47.0
134 0 my ($self, $str, $isend) = @_;
135 0 my ($res, $i, $j, $b, @c);
136
137 0 ▶ if ($self->{'outcache'} ne "")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"outcache"} ne "") 0 0 0
138 {
139 0 $str = $self->{'outcache'} . $str;
140 0 $self->{'outcache'} = "";
141 }
142 0 ▶ for ($i = 0; $i < length($str); $i += 4)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $str) 0 0 0
143 {
144 0 $b = unpack("N", substr($str, $i, 4));
145 0 ▶ if ($b == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($b == 0) 0 0 0
146 {
147 0 $res .= "z";
148 0 next;
149 }
150 0 ▶ for ($j = 0; $j < 4; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 4) 0 0 0
151 0 { $c[$j] = $b - int($b / 85) * 85 + 33; $b /= 85; }
152 0 $res .= pack("C5", @c, $b + 33);
153 0 ▶ $res .= "\n" if ($i % 60 == 56);
Branch: 1 branch
BranchTrueFalseTotal
if $i % 60 == 56 0 0 0
154 }
155 0 ▶ if ($isend && $i > length($str))
Branch: 2 branches
BranchTrueFalseTotal
if ($isend and $i > length $str) { } 0 0 0
elsif ($i > length $str) { } 0 0 0
Condition0%0/3
$isend and $i > length $str
!ll&&!rl&&r
000
MC/DC0%0/2
$isend and $i > length $str
$isend $i > length $str
Truth table0%0/3
A and B
A= $isendB= $i > length $str
ABresult
0X0
100
111
156 {
157 0 $b = unpack("N", substr($str, $i - 4) . "\000\000\000");
158 0 ▶ for ($j = 0; $j < 4; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 4) 0 0 0
159 0 { $c[$j] = $b - int($b / 85) * 85 + 33; $b /= 85; }
160 0 $res .= substr(pack("C5", @c, $b), 0, $i - length($str) + 1) . "->";
161 } elsif ($i > length($str))
162 0 { $self->{'outcache'} = substr($str, $i - 4); }
163 0 $res;
164 }
165
166 sub infilt
167 0 ▶{
Subroutine infilt: not called CC=10 SCAR=47.0
168 0 my ($self, $str, $isend) = @_;
169 0 my ($res, $i, $j, @c, $b, $num);
170 0 $num=0;
171 0 ▶ if (exists($self->{'incache'}) && $self->{'incache'} ne "")
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"incache"} and $self->{"incache"} ne "") 0 0 0
Condition0%0/3
exists $self->{"incache"} and $self->{"incache"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"incache"} and $self->{"incache"} ne ""
exists $self->{"incache"} $self->{"incache"} ne ""
Truth table0%0/3
A and B
A= exists $self->{"incache"}B= $self->{"incache"} ne ""
ABresult
0X0
100
111
172 {
173 0 $str = $self->{'incache'} . $str;
174 0 $self->{'incache'} = "";
175 }
176 0 $str =~ s/(\r|\n)\n?//og;
177 0 ▶ for ($i = 0; $i < length($str); $i += 5)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $str) 0 0 0
178 {
179 0 $b = 0;
180 0 ▶ if (substr($str, $i, 1) eq "z")
Branch: 2 branches
BranchTrueFalseTotal
if (substr($str, $i, 1) eq 'z') { } 0 0 0
elsif ($isend and substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o) { } 0 0 0
181 {
182 0 $i -= 4;
183 0 $res .= pack("N", 0);
184 0 next;
185 }
186 ▶ elsif ($isend && substr($str, $i, 6) =~ m/^(.{2,4})\~\>$/o)
Condition0%0/3
$isend and substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o
!ll&&!rl&&r
000
MC/DC0%0/2
$isend and substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o
$isend substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o
Truth table0%0/3
A and B
A= $isendB= substr($str, $i, 6) =~ /^(.{2,4})\~\>$/o
ABresult
0X0
100
111
187 {
188 0 $num = 5 - length($1);
189 0 @c = unpack("C5", $1 . ("u" x (4 - $num))); # pad with 84 to sort out rounding
190 0 $i = length($str);
191 } else
192 0 { @c = unpack("C5", substr($str, $i, 5)); }
193
194 0 ▶ for ($j = 0; $j < 5; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 5) 0 0 0
195 {
196 0 $b *= 85;
197 0 $b += $c[$j] - 33;
198 }
199 0 $res .= substr(pack("N", $b), 0, 4 - $num);
200 }
201 0 ▶ if (!$isend && $i > length($str))
Branch: 1 branch
BranchTrueFalseTotal
if (not $isend and $i > length $str) 0 0 0
Condition0%0/3
not $isend and $i > length $str
!ll&&!rl&&r
000
MC/DC0%0/2
not $isend and $i > length $str
not $isend $i > length $str
Truth table0%0/3
not(A) and B
A= not $isendB= $i > length $str
ABresult
0X0
100
111
202 0 { $self->{'incache'} = substr($str, $i - 5); }
203 0 $res;
204 }
205
206
207
208 package PDF::API3::Compat::API2::Basic::PDF::RunLengthDecode;
209
210 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
211 1 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
212 1 @ISA = qw(PDF::API3::Compat::API2::Basic::PDF::Filter);
213 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
214
215 =head1 NAME
216
217 PDF::API3::Compat::API2::Basic::PDF::RunLengthDecode - Run Length encoding filter for PDF streams. Inherits from
218 L<PDF::API3::Compat::API2::Basic::PDF::Filter>
219
220 =cut
221
222 sub outfilt
223 0 ▶{
Subroutine outfilt: not called CC=6 SCAR=37.4
224 0 my ($self, $str, $isend) = @_;
225 0 my ($res, $s, $r);
226
227 # no state information, just slight inefficiency at block boundaries
228 0 ▶ while ($str ne "")
Branch: 1 branch
BranchTrueFalseTotal
if ($str ne "") 0 0 0
229 {
230 0 ▶ if ($str =~ m/^(.*?)((.)\2{2,127})(.*?)$/so)
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /^(.*?)((.)\2{2,127})(.*?)$/so) { } 0 0 0
231 {
232 0 $s = $1;
233 0 $r = $2;
234 0 $str = $3;
235 } else
236 {
237 0 $s = $str;
238 0 $r = '';
239 0 $str = '';
240 }
241 0 ▶ while (length($s) > 127)
Branch: 1 branch
BranchTrueFalseTotal
if (length $s > 127) 0 0 0
242 {
243 0 $res .= pack("C", 127) . substr($s, 0, 127);
244 0 substr($s, 0, 127) = '';
245 }
246 0 ▶ $res .= pack("C", length($s)) . $s if length($s) > 0;
Branch: 1 branch
BranchTrueFalseTotal
if length $s > 0 0 0 0
247 0 $res .= pack("C", 257 - length($r));
248 }
249 0 ▶ $res .= "\x80" if ($isend);
Branch: 1 branch
BranchTrueFalseTotal
if $isend 0 0 0
250 0 $res;
251 }
252
253 sub infilt
254 0 ▶{
Subroutine infilt: not called CC=9 SCAR=45.0
255 0 my ($self, $str, $isend) = @_;
256 0 my ($res, $l, $d);
257
258 0 ▶ if ($self->{'incache'} ne "")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"incache"} ne "") 0 0 0
259 {
260 0 $str = $self->{'incache'} . $str;
261 0 $self->{'incache'} = "";
262 }
263 0 ▶ while ($str ne "")
Branch: 1 branch
BranchTrueFalseTotal
if ($str ne "") 0 0 0
264 {
265 0 $l = unpack("C", $str);
266 0 ▶ if ($l == 128)
Branch: 1 branch
BranchTrueFalseTotal
if ($l == 128) 0 0 0
267 {
268 0 $isend = 1;
269 0 return $res;
270 }
271 0 ▶ if ($l > 128)
Branch: 1 branch
BranchTrueFalseTotal
if ($l > 128) { } 0 0 0
272 {
273 0 ▶ if (length($str) < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (length $str < 2) 0 0 0
274 {
275 0 ▶ warn "Premature end to data in RunLengthEncoded data" if $isend;
Branch: 1 branch
BranchTrueFalseTotal
if $isend 0 0 0
276 0 $self->{'incache'} = $str;
277 0 return $res;
278 }
279 0 $res .= substr($str, 1, 1) x (257 - $l);
280 0 substr($str, 0, 2) = "";
281 } else
282 {
283 0 ▶ if (length($str) < $l + 1)
Branch: 1 branch
BranchTrueFalseTotal
if (length $str < $l + 1) 0 0 0
284 {
285 0 ▶ warn "Premature end to data in RunLengthEncoded data" if $isend;
Branch: 1 branch
BranchTrueFalseTotal
if $isend 0 0 0
286 0 $self->{'incache'} = $str;
287 0 return $res;
288 }
289 0 $res .= substr($str, 1, $l);
290 0 substr($str, 0, $l + 1) = "";
291 }
292 }
293 0 $res;
294 }
295
296
297
298 package PDF::API3::Compat::API2::Basic::PDF::ASCIIHexDecode;
299
300 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
301 1 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
302 1 @ISA = qw(PDF::API3::Compat::API2::Basic::PDF::Filter);
303 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
304
305 =head1 NAME
306
307 PDF::API3::Compat::API2::Basic::PDF::ASCIIHexDecode - Ascii Hex encoding (very inefficient) for PDF streams.
308 Inherits from L<PDF::API3::Compat::API2::Basic::PDF::Filter>
309
310 =cut
311
312 sub outfilt
313 0 ▶{
Subroutine outfilt: not called CC=2 SCAR=17.9
314 0 my ($self, $str, $isend) = @_;
315
316 0 $str =~ s/(.)/sprintf("%02x", ord($1))/oge;
317 0 ▶ $str .= ">" if $isend;
Branch: 1 branch
BranchTrueFalseTotal
if $isend 0 0 0
318 0 $str;
319 }
320
321 sub infilt
322 0 ▶{
Subroutine infilt: not called CC=3 SCAR=24.8
323 0 my ($self, $str, $isend) = @_;
324
325 0 $isend = ($str =~ s/>$//og);
326 0 $str =~ s/\s//oig;
327 0 ▶ $str =~ s/([0-9a-z])/pack("C", hex($1 . "0"))/oige if ($isend && length($str) & 1);
Branch: 1 branch
BranchTrueFalseTotal
if $isend and length $str & 1 0 0 0
Condition0%0/3
$isend and length $str & 1
!ll&&!rl&&r
000
MC/DC0%0/2
$isend and length $str & 1
$isend length $str & 1
Truth table0%0/3
A and B
A= $isendB= length $str & 1
ABresult
0X0
100
111
328 0 $str =~ s/([0-9a-z]{2})/pack("C", hex($1))/oige;
329 0 $str;
330 }
331
332 package PDF::API3::Compat::API2::Basic::PDF::FlateDecode;
333
334 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
335 1 ▶use vars qw(@ISA $havezlib);
Subroutine BEGIN: called CC=1 SCAR=0.0
336 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
337 1 @ISA = qw(PDF::API3::Compat::API2::Basic::PDF::Filter);
338 BEGIN
339 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
340 1 eval {require "Compress/Zlib.pm";};
341 1 $havezlib = !$@;
342 }
343
344 sub new
345 0 ▶{
Subroutine new: not called CC=2 SCAR=17.9
346 0 ▶ return undef unless $havezlib;
Branch: 1 branch
BranchTrueFalseTotal
unless $PDF::API3::Compat::API2::Basic::PDF::FlateDecode::havezlib 0 0 0
347 0 my ($class) = @_;
348 0 my ($self) = {};
349
350 0 $self->{'outfilt'} = Compress::Zlib::deflateInit(
351 -Level=>9,
352 -Bufsize=>32768,
353 );
354 0 $self->{'infilt'} = Compress::Zlib::inflateInit();
355 0 bless $self, $class;
356 }
357
358 sub outfilt
359 0 ▶{
Subroutine outfilt: not called CC=2 SCAR=17.9
360 0 my ($self, $str, $isend) = @_;
361 0 my ($res);
362
363 0 $res = $self->{'outfilt'}->deflate($str);
364 0 ▶ $res .= $self->{'outfilt'}->flush() if ($isend);
Branch: 1 branch
BranchTrueFalseTotal
if $isend 0 0 0
365 0 $res;
366 }
367
368 sub infilt
369 0 ▶{
Subroutine infilt: not called CC=1 SCAR=6.9
370 0 my ($self, $dat, $last) = @_;
371 0 my ($res, $status) = $self->{'infilt'}->inflate("$dat");
372 0 $res;
373 }
374
375 package PDF::API3::Compat::API2::Basic::PDF::LZWDecode;
376
377 1 ▶use vars qw(@ISA @basedict);
Subroutine BEGIN: called CC=1 SCAR=0.0
378 1 @ISA = qw(PDF::API3::Compat::API2::Basic::PDF::FlateDecode);
379 1 @basedict = map {pack("C", $_)} (0 .. 255, 0, 0);
380 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
381
382 sub new
383 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
384 0 my ($class) = @_;
385 0 my ($self) = {};
386
387 0 $self->{indict} = [@basedict];
388 0 $self->{bits} = 9;
389 0 $self->{insize} = $self->{bits};
390 0 $self->{resetcode}=1<<($self->{insize}-1);
391 0 $self->{endcode}=$self->{resetcode}+1;
392 0 $self->{nextcode}=$self->{endcode}+1;
393
394 0 bless $self, $class;
395 }
396
397 sub infilt
398 0 ▶{
Subroutine infilt: not called CC=8 SCAR=42.8
399 0 my ($self, $dat, $last) = @_;
400 0 my ($num, $cache, $cache_size, $res);
401
402 0 ▶ while ($dat ne '' || $cache_size > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($dat ne "" or $cache_size > 0) 0 0 0
Condition0%0/3
$dat ne "" or $cache_size > 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$dat ne "" or $cache_size > 0
$dat ne "" $cache_size > 0
Truth table0%0/3
A or B
A= $dat ne ""B= $cache_size > 0
ABresult
1X1
011
000
403 {
404 0 ($num, $cache, $cache_size) = $self->read_dat(\$dat, $cache, $cache_size, $self->{'insize'});
405
406 # this was a little arkward to comprehand
407 # here is a better version -- fredo
408 0 ▶ $self->{'insize'}++ if($self->{nextcode} == (1<<$self->{'insize'}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"nextcode"} == 1 << $self->{"insize"} 0 0 0
409 0 ▶ if($num==$self->{resetcode}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($num == $self->{'resetcode'}) { } 0 0 0
elsif ($num == $self->{'endcode'}) { } 0 0 0
elsif ($num < $self->{'resetcode'}) { } 0 0 0
elsif ($num > $self->{'endcode'}) { } 0 0 0
410 0 $self->{'insize'}=$self->{bits};
411 0 $self->{nextcode}=$self->{endcode}+1;
412 0 next;
413 } elsif($num==$self->{endcode}) {
414 0 last;
415 } elsif($num<$self->{resetcode}) {
416 0 $self->{'indict'}[$self->{nextcode}] = $self->{'indict'}[$num];
417 0 $res.=$self->{'indict'}[$self->{nextcode}];
418 0 $self->{nextcode}++;
419 } elsif($num>$self->{endcode}) {
420 0 $self->{'indict'}[$self->{nextcode}] = $self->{'indict'}[$num];
421 0 $self->{'indict'}[$self->{nextcode}].= substr($self->{'indict'}[$num+1],0,1);
422 0 $res.=$self->{'indict'}[$self->{nextcode}];
423 0 $self->{nextcode}++;
424 } else {
425 0 die "we shouldn't be here !";
426 }
427 }
428 0 return $res;
429 }
430
431 sub infilt2
432 0 ▶{
Subroutine infilt2: not called CC=8 SCAR=42.8
433 0 my ($self, $dat, $last) = @_;
434 0 my ($num, $cache, $cache_size, $res);
435
436 0 ▶ while ($dat ne '' || $cache_size > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($dat ne "" or $cache_size > 0) 0 0 0
Condition0%0/3
$dat ne "" or $cache_size > 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$dat ne "" or $cache_size > 0
$dat ne "" $cache_size > 0
Truth table0%0/3
A or B
A= $dat ne ""B= $cache_size > 0
ABresult
1X1
011
000
437 {
438 0 ($num, $cache, $cache_size) = $self->read_dat(\$dat, $cache, $cache_size, $self->{'insize'});
439
440 # this was a little arkward to comprehand
441 # here is a better version -- fredo
442 0 ▶ if($num==$self->{resetcode}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($num == $self->{'resetcode'}) { } 0 0 0
elsif ($num == $self->{'endcode'}) { } 0 0 0
elsif ($num < $self->{'resetcode'}) { } 0 0 0
elsif ($num > $self->{'endcode'}) { } 0 0 0
443 0 $self->{'insize'}=$self->{bits};
444 0 $self->{nextcode}=$self->{endcode}+1;
445 0 next;
446 } elsif($num==$self->{endcode}) {
447 0 last;
448 } elsif($num<$self->{resetcode}) {
449 0 $self->{'indict'}[$self->{nextcode}] = $self->{'indict'}[$num];
450 0 $res.=$self->{'indict'}[$self->{nextcode}];
451 0 $self->{nextcode}++;
452 } elsif($num>$self->{endcode}) {
453 0 $self->{'indict'}[$self->{nextcode}] = $self->{'indict'}[$num];
454 0 $self->{'indict'}[$self->{nextcode}].= substr($self->{'indict'}[$num+1],0,1);
455 0 $res.=$self->{'indict'}[$self->{nextcode}];
456 0 $self->{nextcode}++;
457 } else {
458 0 die "we shouldn't be here !";
459 }
460 0 ▶ $self->{'insize'}++ if($self->{nextcode} == (1<<$self->{'insize'}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"nextcode"} == 1 << $self->{"insize"} 0 0 0
461 }
462 0 return $res;
463 }
464
465 sub read_dat
466 0 ▶{
Subroutine read_dat: not called CC=2 SCAR=17.9
467 0 my ($self, $rdat, $cache, $size, $len) = @_;
468 0 my ($res);
469
470 0 ▶ while ($size < $len)
Branch: 1 branch
BranchTrueFalseTotal
if ($size < $len) 0 0 0
471 {
472 0 $cache = ($cache << 8) + unpack("C", $$rdat);
473 0 substr($$rdat, 0, 1) = '';
474 0 $size += 8;
475 }
476
477 0 $res = $cache >> ($size - $len);
478 0 $cache &= (1 << ($size - $len)) - 1;
479 0 $size -= $len;
480 0 ($res, $cache, $size);
481 }
482
483 1 1;
484
« API3/Compat/API2/Basic/TTF/Anchor.pm ↑ Summary API3/Compat/API2/Resource/CIDFont/TrueType.pm »