| 1 | package Compress::Zlib::Perl; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # use if $] > 5.006, 'warnings'; | ||||||||||||||||||||||||||||
| 6 | # use warnings; | ||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||
| 15 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||
| 16 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use constant Z_OK => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use constant Z_STREAM_END => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use constant MAX_WBITS => 16; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | @EXPORT = qw( | |||||||||||||||||||||||||||
| 23 | Z_OK Z_STREAM_END MAX_WBITS crc32 | ||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | 1 | my @crc32; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | sub _init_crc32 { | ||||||||||||||||||||||||||
|
Subroutine
_init_crc32: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 32 | # I'm not sure why Ton wanted to reverse the order of the bits in this | ||||||||||||||||||||||||||||
| 33 | # constant, rather than using the bit-reversed constant | ||||||||||||||||||||||||||||
| 34 | # my $p=oct reverse sprintf"%032bb0", 0x04C11DB7; | ||||||||||||||||||||||||||||
| 35 | # But the only 5.005 friendly way I can find is this: | ||||||||||||||||||||||||||||
| 36 | 1 | my $p | |||||||||||||||||||||||||||
| 37 | = unpack "I", pack "b*", scalar reverse unpack "b*", pack "I", 0x04C11DB7; | ||||||||||||||||||||||||||||
| 38 | 1 | ▶ | @crc32 = map{for my$s(0..7) {$_ = $_>>1 ^ ($_&1 && $p)} $_} 0..255; | ||||||||||||||||||||||||||
|
Condition66%2/3
$_ & 1 && $p
MC/DC50%1/2
$_ & 1 && $p
$_ & 1
$p
Truth table66%2/3
A && B
A= $_ & 1B= $p
| |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # Calculate gzip header 16 bit CRCs | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub _crc16 { | ||||||||||||||||||||||||||
|
Subroutine
_crc16: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 43 | 0 | my $crc16 = shift; | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | _init_crc32() unless @crc32; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | foreach my $input (@_) { | |||||||||||||||||||||||||||
| 46 | # I have no way to test this, as nothing that I can find generates | ||||||||||||||||||||||||||||
| 47 | # gzip files with the header CRC. | ||||||||||||||||||||||||||||
| 48 | # Ton's code is this: | ||||||||||||||||||||||||||||
| 49 | $crc16 = $crc16>>8^$crc32[$crc16&0xff^ord(substr $input,$_,1)] | ||||||||||||||||||||||||||||
| 50 | 0 | for 0..length($input)-1; | |||||||||||||||||||||||||||
| 51 | # I believe that the following is functionally equivalent, but should | ||||||||||||||||||||||||||||
| 52 | # be faster: | ||||||||||||||||||||||||||||
| 53 | # while ($input =~ /(.)/gs) { | ||||||||||||||||||||||||||||
| 54 | # $crc16 = $crc16 >> 8 ^ $crc32[$crc16 & 0xff ^ ord $1]; | ||||||||||||||||||||||||||||
| 55 | # } | ||||||||||||||||||||||||||||
| 56 | 0 | return $crc16; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # Public interface starts here: | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | # Calculate 32 bit CRCs | ||||||||||||||||||||||||||||
| 63 | 7411 | ▶ | sub crc32 { | ||||||||||||||||||||||||||
|
Subroutine
crc32: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 7411 | ▶ | _init_crc32() unless @crc32; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 7411 | my ($buffer, $crc32) = @_; | |||||||||||||||||||||||||||
| 66 | 7411 | ▶ | $crc32 ||= 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$crc32 ||= 0
MC/DC0%0/1
$crc32 ||= 0
$crc32
Truth table50%1/2
A
A= $crc32
| |||||||||||||||||||||||||||||
| 67 | 7411 | $crc32 ^= 0xffffffff; | |||||||||||||||||||||||||||
| 68 | 7411 | my $pos = -length $buffer; | |||||||||||||||||||||||||||
| 69 | 7411 | ▶ | $crc32 = $crc32>>8 ^ $crc32[$crc32&0xff^ord(substr($buffer, $pos++, 1))] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | while $pos; | ||||||||||||||||||||||||||||
| 71 | 7411 | $crc32 ^ 0xffffffff; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1 | ▶ | sub inflateInit { | ||||||||||||||||||||||||||
|
Subroutine
inflateInit: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 76 | 8 | my %args = @_; | |||||||||||||||||||||||||||
| 77 | die "Please specify negative window size" | ||||||||||||||||||||||||||||
| 78 | 8 | ▶ | unless $args{-WindowBits} && $args{-WindowBits} < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"-WindowBits"} and $args{"-WindowBits"} < 0
MC/DC0%0/2
$args{"-WindowBits"} and $args{"-WindowBits"} < 0
$args{"-WindowBits"}
$args{"-WindowBits"} < 0
Truth table33%1/3
A and B
A= $args{"-WindowBits"}B= $args{"-WindowBits"} < 0
| |||||||||||||||||||||||||||||
| 79 | 8 | my $self = bless {isize=>0, | |||||||||||||||||||||||||||
| 80 | osize=>0, | ||||||||||||||||||||||||||||
| 81 | result=>"", | ||||||||||||||||||||||||||||
| 82 | huffman=>"", | ||||||||||||||||||||||||||||
| 83 | type0length=>"", | ||||||||||||||||||||||||||||
| 84 | state=>\&stateReadFinal | ||||||||||||||||||||||||||||
| 85 | }; | ||||||||||||||||||||||||||||
| 86 | 8 | $self->_reset_bits_have; | |||||||||||||||||||||||||||
| 87 | 8 | ▶ | wantarray ? ($self, Z_OK) : $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub total_in { | ||||||||||||||||||||||||||
|
Subroutine
total_in: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | $_[0]->{isize}; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub total_out { | ||||||||||||||||||||||||||
|
Subroutine
total_out: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 0 | $_[0]->{osize}; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 7403 | ▶ | sub inflate { | ||||||||||||||||||||||||||
|
Subroutine
inflate: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 99 | 7403 | $_[0]->{input} = \$_[1]; | |||||||||||||||||||||||||||
| 100 | 7403 | my ($return, $status); | |||||||||||||||||||||||||||
| 101 | 7403 | $_[0]->{izize} += length $_[1]; | |||||||||||||||||||||||||||
| 102 | 7403 | ▶ | if (&{$_[0]->{state}}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | # Finished, so flush everything | ||||||||||||||||||||||||||||
| 104 | 8 | $return = length $_[0]->{result}; | |||||||||||||||||||||||||||
| 105 | 8 | $status = Z_STREAM_END; | |||||||||||||||||||||||||||
| 106 | } else { | ||||||||||||||||||||||||||||
| 107 | 7395 | ▶ | die length ($_[1]) . " input remaining" if length $_[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 7395 | $return = length ($_[0]->{result}) - 0x8000; | |||||||||||||||||||||||||||
| 109 | 7395 | ▶ | $return = 0 if $return < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 7395 | $status = Z_OK; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 7403 | $_[0]->{izize} -= length $_[1]; | |||||||||||||||||||||||||||
| 113 | 7403 | $_[0]->{osize} += $return; | |||||||||||||||||||||||||||
| 114 | wantarray ? (substr ($_[0]->{result}, 0, $return, ""), $status) | ||||||||||||||||||||||||||||
| 115 | 7403 | ▶ | : substr ($_[0]->{result}, 0, $return, ""); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | # Public interface ends here | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 16 | ▶ | sub _reset_bits_have { | ||||||||||||||||||||||||||
|
Subroutine
_reset_bits_have: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 121 | 16 | my $self = shift; | |||||||||||||||||||||||||||
| 122 | 16 | $self->{val} = $self->{have} = 0; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # get arg bits (little endian) | ||||||||||||||||||||||||||||
| 127 | 6884 | ▶ | sub _get_bits { | ||||||||||||||||||||||||||
|
Subroutine
_get_bits: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 128 | 6884 | my ($self, $want) = @_; | |||||||||||||||||||||||||||
| 129 | 6884 | my ($bits_val, $bits_have) = @{$self}{qw(val have)}; | |||||||||||||||||||||||||||
| 130 | 6884 | ▶ | while ($want > $bits_have) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | # inlined input read | ||||||||||||||||||||||||||||
| 132 | 3600 | my $byte = substr ${$_[0]->{input}}, 0, 1, ""; | |||||||||||||||||||||||||||
| 133 | 3600 | ▶ | if (!length $byte) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 756 | @{$self}{qw(val have)} = ($bits_val, $bits_have); | |||||||||||||||||||||||||||
| 135 | 756 | return; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 2844 | $bits_val |= ord($byte) << $bits_have; | |||||||||||||||||||||||||||
| 138 | 2844 | $bits_have += 8; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | 6128 | my $result = $bits_val & (1 << $want)-1; | |||||||||||||||||||||||||||
| 141 | 6128 | $bits_val >>= $want; | |||||||||||||||||||||||||||
| 142 | 6128 | $bits_have -= $want; | |||||||||||||||||||||||||||
| 143 | 6128 | @{$self}{qw(val have)} = ($bits_val, $bits_have); | |||||||||||||||||||||||||||
| 144 | 6128 | return $result; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | # Get one huffman code | ||||||||||||||||||||||||||||
| 148 | 12709 | ▶ | sub _get_huffman { | ||||||||||||||||||||||||||
|
Subroutine
_get_huffman: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 149 | 12709 | my ($self, $code) = @_; | |||||||||||||||||||||||||||
| 150 | 12709 | $code = $self->{$code}; | |||||||||||||||||||||||||||
| 151 | 12709 | my ($bits_val, $bits_have, $str) = @{$self}{qw(val have huffman)}; | |||||||||||||||||||||||||||
| 152 | do { | ||||||||||||||||||||||||||||
| 153 | 55909 | ▶ | if (--$bits_have < 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | # inlined input read | ||||||||||||||||||||||||||||
| 155 | 8537 | my $byte = substr ${$_[0]->{input}}, 0, 1, ""; | |||||||||||||||||||||||||||
| 156 | 8537 | ▶ | if (!length $byte) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | # bits_have is -1, but really should be zero, so fix in save | ||||||||||||||||||||||||||||
| 158 | 1789 | @{$self}{qw(val have huffman)} = ($bits_val, 0, $str); | |||||||||||||||||||||||||||
| 159 | 1789 | return; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | 6748 | $bits_val = ord $byte; | |||||||||||||||||||||||||||
| 162 | 6748 | $bits_have = 7; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | 54120 | $str .= $bits_val & 1; | |||||||||||||||||||||||||||
| 165 | 54120 | $bits_val >>= 1; | |||||||||||||||||||||||||||
| 166 | 12709 | ▶ | } until exists $code->{$str}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 10920 | ▶ | defined($code->{$str}) || die "Bad code $str"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 10920 | @{$self}{qw(val have huffman)} = ($bits_val, $bits_have, ""); | |||||||||||||||||||||||||||
| 169 | 10920 | return $code->{$str}; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | # construct huffman code | ||||||||||||||||||||||||||||
| 173 | 12 | ▶ | sub make_huffman { | ||||||||||||||||||||||||||
|
Subroutine
make_huffman: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 174 | 12 | my $counts = shift; | |||||||||||||||||||||||||||
| 175 | 12 | my (%code, @counts); | |||||||||||||||||||||||||||
| 176 | 12 | push @{$counts[$counts->[$_]]}, $_ for 0..$#$counts; | |||||||||||||||||||||||||||
| 177 | 12 | my $value = 0; | |||||||||||||||||||||||||||
| 178 | 12 | my $bits = -1; | |||||||||||||||||||||||||||
| 179 | 12 | for (@counts) { | |||||||||||||||||||||||||||
| 180 | 116 | $value *= 2; | |||||||||||||||||||||||||||
| 181 | 116 | ▶ | next unless ++$bits && $_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
++$bits and $_
MC/DC100%2/2
++$bits and $_
++$bits
$_
Truth table100%3/3
A and B
A= ++$bitsB= $_
| |||||||||||||||||||||||||||||
| 182 | # Ton used sprintf"%0${bits}b", $value; | ||||||||||||||||||||||||||||
| 183 | 76 | $code{reverse unpack "b$bits", pack "V", $value++} = $_ for @$_; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | # Close the code to avoid infinite loops (and out of memory) | ||||||||||||||||||||||||||||
| 186 | 12 | $code{reverse unpack "b$bits", pack "V", $value++} = undef for | |||||||||||||||||||||||||||
| 187 | $value .. (1 << $bits)-1; | ||||||||||||||||||||||||||||
| 188 | 12 | ▶ | @code{0, 1} = () unless %code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 12 | return \%code; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | # Inflate state machine. | ||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||
| 194 | 1 | my ($static_lit_code, $static_dist_code, @lit_base, @dist_base); | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 1 | my @lit_extra = (-1, | |||||||||||||||||||||||||||
| 197 | 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2, | ||||||||||||||||||||||||||||
| 198 | 3,3,3,3,4,4,4,4,5,5,5,5,0,-2,-2); | ||||||||||||||||||||||||||||
| 199 | 1 | my @dist_extra = (0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8, | |||||||||||||||||||||||||||
| 200 | 9,9,10,10,11,11,12,12,13,13,-1,-1); | ||||||||||||||||||||||||||||
| 201 | 1 | my @alpha_map = (16, 17, 18, 0, 8, 7, 9, 6, 10, | |||||||||||||||||||||||||||
| 202 | 5, 11, 4, 12, 3, 13, 2, 14, 1, 15); | ||||||||||||||||||||||||||||
| 203 | 1 | ▶ | sub prepare_tables { | ||||||||||||||||||||||||||
|
Subroutine
prepare_tables: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 204 | 1 | my $length = 3; | |||||||||||||||||||||||||||
| 205 | 1 | for (@lit_extra) { | |||||||||||||||||||||||||||
| 206 | 32 | push @lit_base, $length; | |||||||||||||||||||||||||||
| 207 | 32 | ▶ | $length += 1 << $_ if $_ >= 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | # Exceptional case | ||||||||||||||||||||||||||||
| 210 | 1 | splice(@lit_base, -3, 3, 258); | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 1 | my $dist = 1; | |||||||||||||||||||||||||||
| 213 | 1 | for (@dist_extra) { | |||||||||||||||||||||||||||
| 214 | 32 | push @dist_base, $dist; | |||||||||||||||||||||||||||
| 215 | 32 | ▶ | $dist += 1 << $_ if $_ >= 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | 1 | splice(@dist_base, -2, 2); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 8 | ▶ | sub stateReadFinal { | ||||||||||||||||||||||||||
|
Subroutine
stateReadFinal: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 221 | 8 | my $bit = _get_bits($_[0], 1); | |||||||||||||||||||||||||||
| 222 | 8 | ▶ | if (!defined $bit) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | # STALL | ||||||||||||||||||||||||||||
| 224 | 0 | return; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | 8 | $_[0]->{final} = $bit; | |||||||||||||||||||||||||||
| 227 | 8 | goto &{$_[0]->{state} = \&stateReadType}; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | 8 | ▶ | sub stateReadType { | ||||||||||||||||||||||||||
|
Subroutine
stateReadType: called CC=8 SCAR=26.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 230 | 8 | my $type = _get_bits($_[0], 2); | |||||||||||||||||||||||||||
| 231 | 8 | ▶ | if (!defined $type) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | # STALL | ||||||||||||||||||||||||||||
| 233 | 0 | return; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 8 | $_[0]->{type} = $type; | |||||||||||||||||||||||||||
| 236 | 8 | ▶ | if ($type) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 4 | ▶ | prepare_tables() unless @lit_base; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 4 | ▶ | if ($type == 1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | $_[0]->{lit} = $static_lit_code ||= | ||||||||||||||||||||||||||
|
Condition0%0/3
$static_lit_code ||= make_huffman([(8) x 144, (9) x 112, (7) x 24, (8) x 8])
MC/DC0%0/2
$static_lit_code ||= make_huffman([(8) x 144, (9) x 112, (7) x 24, (8) x 8])
$static_lit_code
make_huffman([(8) x 144, (9) x 112, (7) x 24, (8) x 8])
Truth table0%0/3
A ||= B
A= $static_lit_codeB= make_huffman([(8) x 144, (9) x 112, (7) x 24, (8) x 8])
| |||||||||||||||||||||||||||||
| 240 | make_huffman([(8)x144,(9)x112, (7)x24, (8)x8]); | ||||||||||||||||||||||||||||
| 241 | 0 | ▶ | $_[0]->{dist} = $static_dist_code ||= | ||||||||||||||||||||||||||
|
Condition0%0/3
$static_dist_code ||= make_huffman([(5) x 32])
MC/DC0%0/2
$static_dist_code ||= make_huffman([(5) x 32])
$static_dist_code
make_huffman([(5) x 32])
Truth table0%0/3
A ||= B
A= $static_dist_codeB= make_huffman([(5) x 32])
| |||||||||||||||||||||||||||||
| 242 | make_huffman([(5)x32]); | ||||||||||||||||||||||||||||
| 243 | # This is the main inflation loop. | ||||||||||||||||||||||||||||
| 244 | 0 | goto &{$_[0]->{state} = \&stateReadLit}; | |||||||||||||||||||||||||||
| 245 | } elsif ($type == 2) { | ||||||||||||||||||||||||||||
| 246 | 4 | goto &{$_[0]->{state} = \&stateReadHLit}; | |||||||||||||||||||||||||||
| 247 | } else { | ||||||||||||||||||||||||||||
| 248 | 0 | die "deflate subtype $type not supported\n"; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | 4 | goto &{$_[0]->{state} = \&stateReadUncompressedLen}; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 8 | ▶ | sub stateReadUncompressedLen { | ||||||||||||||||||||||||||
|
Subroutine
stateReadUncompressedLen: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 255 | # Not compressed; | ||||||||||||||||||||||||||||
| 256 | 8 | $_[0]->_reset_bits_have; | |||||||||||||||||||||||||||
| 257 | # inlined input read | ||||||||||||||||||||||||||||
| 258 | $_[0]->{type0length} | ||||||||||||||||||||||||||||
| 259 | 8 | .= substr ${$_[0]->{input}}, 0, 4 - length $_[0]->{type0length}, ""; | |||||||||||||||||||||||||||
| 260 | 8 | ▶ | if (length $_[0]->{type0length} < 4) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | # STALL | ||||||||||||||||||||||||||||
| 262 | 4 | return; | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | 4 | my ($len, $nlen) = unpack("vv", $_[0]->{type0length}); | |||||||||||||||||||||||||||
| 265 | 4 | $_[0]->{type0length} = ""; | |||||||||||||||||||||||||||
| 266 | 4 | ▶ | $len == (~$nlen & 0xffff) || | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | die "$len is not the 1-complement of $nlen"; | ||||||||||||||||||||||||||||
| 268 | 4 | $_[0]->{type0left} = $len; | |||||||||||||||||||||||||||
| 269 | 4 | goto &{$_[0]->{state} = \&stateReadUncompressed}; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 4850 | ▶ | sub stateReadUncompressed { | ||||||||||||||||||||||||||
|
Subroutine
stateReadUncompressed: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 273 | # inlined input read | ||||||||||||||||||||||||||||
| 274 | 4850 | my $got = substr ${$_[0]->{input}}, 0, $_[0]->{type0left}, ""; | |||||||||||||||||||||||||||
| 275 | 4850 | $_[0]->{result} .= $got; | |||||||||||||||||||||||||||
| 276 | 4850 | ▶ | if ($_[0]->{type0left} -= length $got) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | # Still need more. | ||||||||||||||||||||||||||||
| 278 | # STALL | ||||||||||||||||||||||||||||
| 279 | 4846 | return; | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | 4 | ▶ | if ($_[0]->{final}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | # Finished. | ||||||||||||||||||||||||||||
| 283 | 4 | return 1; | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | # Begin the next block | ||||||||||||||||||||||||||||
| 286 | 0 | goto &{$_[0]->{state} = \&stateReadFinal}; | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 4 | ▶ | sub stateReadHLit { | ||||||||||||||||||||||||||
|
Subroutine
stateReadHLit: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 290 | 4 | my $hlit = _get_bits($_[0], 5); | |||||||||||||||||||||||||||
| 291 | 4 | ▶ | if (!defined $hlit) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | # STALL | ||||||||||||||||||||||||||||
| 293 | 0 | return; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | 4 | $_[0]->{hlit} = $hlit + 257; | |||||||||||||||||||||||||||
| 296 | 4 | goto &{$_[0]->{state} = \&stateReadHDist}; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | 5 | ▶ | sub stateReadHDist { | ||||||||||||||||||||||||||
|
Subroutine
stateReadHDist: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 299 | 5 | my $hdist = _get_bits($_[0], 5); | |||||||||||||||||||||||||||
| 300 | 5 | ▶ | if (!defined $hdist) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | # STALL | ||||||||||||||||||||||||||||
| 302 | 1 | return; | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | 4 | $_[0]->{hdist} = $hdist + 1; | |||||||||||||||||||||||||||
| 305 | 4 | goto &{$_[0]->{state} = \&stateReadHCLen}; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | 5 | ▶ | sub stateReadHCLen { | ||||||||||||||||||||||||||
|
Subroutine
stateReadHCLen: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 308 | 5 | my $hclen = _get_bits($_[0], 4); | |||||||||||||||||||||||||||
| 309 | 5 | ▶ | if (!defined $hclen) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | # STALL | ||||||||||||||||||||||||||||
| 311 | 1 | return; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | 4 | $_[0]->{alphaleft} = $_[0]->{hclen} = $hclen + 4; | |||||||||||||||||||||||||||
| 314 | # Determine the code length huffman code | ||||||||||||||||||||||||||||
| 315 | 4 | $_[0]->{alpha_raw} = [(0) x @alpha_map]; | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 4 | goto &{$_[0]->{state} = \&stateReadAlphaCode}; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | 9 | ▶ | sub stateReadAlphaCode { | ||||||||||||||||||||||||||
|
Subroutine
stateReadAlphaCode: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 320 | 9 | my $alpha_code = $_[0]->{alpha_raw}; | |||||||||||||||||||||||||||
| 321 | 9 | ▶ | while ($_[0]->{alphaleft}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | 61 | my $code = _get_bits($_[0], 3); | |||||||||||||||||||||||||||
| 323 | 61 | ▶ | if (!defined $code) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | # STALL | ||||||||||||||||||||||||||||
| 325 | 5 | return; | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | # my $where = $_[0]->{hclen} - $_[0]->{alphaleft}; | ||||||||||||||||||||||||||||
| 328 | 56 | $alpha_code->[$alpha_map[$_[0]->{hclen} - $_[0]->{alphaleft}--]] = $code; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | 4 | $_[0]->{alpha} = make_huffman($alpha_code); | |||||||||||||||||||||||||||
| 331 | 4 | delete $_[0]->{alpha_raw}; | |||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | # Get lit/length and distance tables | ||||||||||||||||||||||||||||
| 334 | 4 | $_[0]->{code_len} = []; | |||||||||||||||||||||||||||
| 335 | 4 | goto &{$_[0]->{state} = \&stateBuildAlphaCode}; | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 89 | ▶ | sub stateBuildAlphaCode { | ||||||||||||||||||||||||||
|
Subroutine
stateBuildAlphaCode: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 339 | 89 | my $code_len = $_[0]->{code_len}; | |||||||||||||||||||||||||||
| 340 | 89 | ▶ | while (@$code_len < $_[0]->{hlit}+$_[0]->{hdist}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 565 | my $alpha = _get_huffman($_[0], 'alpha'); | |||||||||||||||||||||||||||
| 342 | 565 | ▶ | if (!defined $alpha) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | # STALL | ||||||||||||||||||||||||||||
| 344 | 57 | return; | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | 508 | ▶ | if ($alpha < 16) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 347 | 480 | push @$code_len, $alpha; | |||||||||||||||||||||||||||
| 348 | } elsif ($alpha == 16) { | ||||||||||||||||||||||||||||
| 349 | 4 | goto &{$_[0]->{state} = \&stateReadAlphaCode16}; | |||||||||||||||||||||||||||
| 350 | } elsif ($alpha == 17) { | ||||||||||||||||||||||||||||
| 351 | 16 | goto &{$_[0]->{state} = \&stateReadAlphaCode17}; | |||||||||||||||||||||||||||
| 352 | } else { | ||||||||||||||||||||||||||||
| 353 | 8 | goto &{$_[0]->{state} = \&stateReadAlphaCodeOther}; | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | 4 | ▶ | @$code_len == $_[0]->{hlit}+$_[0]->{hdist} || die "too many codes"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 357 | 4 | my @lit_len = splice(@$code_len, 0, $_[0]->{hlit}); | |||||||||||||||||||||||||||
| 358 | 4 | $_[0]->{lit} = make_huffman(\@lit_len); | |||||||||||||||||||||||||||
| 359 | 4 | $_[0]->{dist} = make_huffman($code_len); | |||||||||||||||||||||||||||
| 360 | 4 | delete $_[0]->{code_len}; | |||||||||||||||||||||||||||
| 361 | 4 | goto &{$_[0]->{state} = \&stateReadLit}; | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 5 | ▶ | sub stateReadAlphaCode16 { | ||||||||||||||||||||||||||
|
Subroutine
stateReadAlphaCode16: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 365 | 5 | my $code_len = $_[0]->{code_len}; | |||||||||||||||||||||||||||
| 366 | 5 | my $bits = _get_bits($_[0], 2); | |||||||||||||||||||||||||||
| 367 | 5 | ▶ | if (!defined $bits) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | # STALL | ||||||||||||||||||||||||||||
| 369 | 1 | return; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | 4 | push @$code_len, ($code_len->[-1]) x (3+$bits); | |||||||||||||||||||||||||||
| 372 | 4 | goto &{$_[0]->{state} = \&stateBuildAlphaCode}; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 19 | ▶ | sub stateReadAlphaCode17 { | ||||||||||||||||||||||||||
|
Subroutine
stateReadAlphaCode17: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 376 | 19 | my $code_len = $_[0]->{code_len}; | |||||||||||||||||||||||||||
| 377 | 19 | my $bits = _get_bits($_[0], 3); | |||||||||||||||||||||||||||
| 378 | 19 | ▶ | if (!defined $bits) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 379 | # STALL | ||||||||||||||||||||||||||||
| 380 | 3 | return; | |||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | 16 | push @$code_len, (0) x (3+$bits); | |||||||||||||||||||||||||||
| 383 | 16 | goto &{$_[0]->{state} = \&stateBuildAlphaCode}; | |||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 10 | ▶ | sub stateReadAlphaCodeOther { | ||||||||||||||||||||||||||
|
Subroutine
stateReadAlphaCodeOther: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 387 | 10 | my $code_len = $_[0]->{code_len}; | |||||||||||||||||||||||||||
| 388 | 10 | my $bits = _get_bits($_[0], 7); | |||||||||||||||||||||||||||
| 389 | 10 | ▶ | if (!defined $bits) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | # STALL | ||||||||||||||||||||||||||||
| 391 | 2 | return; | |||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||
| 393 | 8 | push @$code_len, (0) x (11+$bits); | |||||||||||||||||||||||||||
| 394 | 8 | goto &{$_[0]->{state} = \&stateBuildAlphaCode}; | |||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 4318 | ▶ | sub stateReadLit { | ||||||||||||||||||||||||||
|
Subroutine
stateReadLit: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 398 | 4318 | while (1) { | |||||||||||||||||||||||||||
| 399 | 8710 | my $lit = _get_huffman($_[0], 'lit'); | |||||||||||||||||||||||||||
| 400 | 8710 | ▶ | if (!defined $lit) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 401 | # STALL | ||||||||||||||||||||||||||||
| 402 | 1306 | return; | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | 7404 | ▶ | if ($lit >= 256) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | 3012 | ▶ | if ($lit_extra[$lit -= 256] < 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | 4 | ▶ | die "Invalid literal code" if $lit; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 4 | ▶ | if ($_[0]->{final}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 409 | # Finished. | ||||||||||||||||||||||||||||
| 410 | 4 | return 1; | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | # Begin the next block | ||||||||||||||||||||||||||||
| 413 | 0 | goto &{$_[0]->{state} = \&stateReadFinal}; | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | 3008 | $_[0]->{litcode} = $lit; | |||||||||||||||||||||||||||
| 416 | # BREAK | ||||||||||||||||||||||||||||
| 417 | 3008 | goto &{$_[0]->{state} = \&stateGetLength}; | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 4392 | $_[0]->{result} .= chr $lit; | |||||||||||||||||||||||||||
| 421 | # Back to the main inflation loop | ||||||||||||||||||||||||||||
| 422 | # goto &stateReadLit; | ||||||||||||||||||||||||||||
| 423 | # ie loop | ||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | 3030 | ▶ | sub stateGetLength { | ||||||||||||||||||||||||||
|
Subroutine
stateGetLength: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 428 | 3030 | my $lit = $_[0]->{litcode}; | |||||||||||||||||||||||||||
| 429 | 3030 | my $bits = _get_bits($_[0], $lit_extra[$lit]); | |||||||||||||||||||||||||||
| 430 | 3030 | ▶ | if (!defined $bits) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 431 | # STALL | ||||||||||||||||||||||||||||
| 432 | 22 | return; | |||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | 3008 | ▶ | $_[0]->{length} = $lit_base[$lit] + ($lit_extra[$lit] && $bits); | ||||||||||||||||||||||||||
|
Condition100%3/3
$lit_extra[$lit] && $bits
MC/DC100%2/2
$lit_extra[$lit] && $bits
$lit_extra[$lit]
$bits
Truth table100%3/3
A && B
A= $lit_extra[$lit]B= $bits
| |||||||||||||||||||||||||||||
| 435 | 3008 | goto &{$_[0]->{state} = \&stateGetDCode}; | |||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | 3434 | ▶ | sub stateGetDCode { | ||||||||||||||||||||||||||
|
Subroutine
stateGetDCode: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 439 | 3434 | my $d = _get_huffman($_[0], 'dist'); | |||||||||||||||||||||||||||
| 440 | 3434 | ▶ | if (!defined $d) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 441 | # STALL | ||||||||||||||||||||||||||||
| 442 | 426 | return; | |||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | 3008 | $_[0]->{dcode} = $d; | |||||||||||||||||||||||||||
| 445 | 3008 | goto &{$_[0]->{state} = \&stateGetDistDecompress}; | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | 3729 | ▶ | sub stateGetDistDecompress { | ||||||||||||||||||||||||||
|
Subroutine
stateGetDistDecompress: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 449 | 3729 | my $d = $_[0]->{dcode}; | |||||||||||||||||||||||||||
| 450 | 3729 | ▶ | die "Invalid distance code" if $d >= 30; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 451 | 3729 | my $bits = _get_bits($_[0], $dist_extra[$d]); | |||||||||||||||||||||||||||
| 452 | 3729 | ▶ | if (!defined $bits) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 453 | # STALL | ||||||||||||||||||||||||||||
| 454 | 721 | return; | |||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | 3008 | ▶ | my $dist = $dist_base[$d] + ($dist_extra[$d] && $bits); | ||||||||||||||||||||||||||
|
Condition100%3/3
$dist_extra[$d] && $bits
MC/DC100%2/2
$dist_extra[$d] && $bits
$dist_extra[$d]
$bits
Truth table100%3/3
A && B
A= $dist_extra[$d]B= $bits
| |||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | # Go for it | ||||||||||||||||||||||||||||
| 459 | 3008 | my $length = $_[0]->{length}; | |||||||||||||||||||||||||||
| 460 | 3008 | ▶ | if ($dist >= $length) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 461 | 3004 | my $section = substr ($_[0]->{result}, -$dist, $length); | |||||||||||||||||||||||||||
| 462 | 3004 | $_[0]->{result} .= $section; | |||||||||||||||||||||||||||
| 463 | } else { | ||||||||||||||||||||||||||||
| 464 | 4 | my $remaining = $length; | |||||||||||||||||||||||||||
| 465 | 4 | ▶ | while ($remaining) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 466 | 12 | ▶ | my $take | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 467 | = $dist >= $remaining ? $remaining : $dist; | ||||||||||||||||||||||||||||
| 468 | 12 | $_[0]->{result} .= substr($_[0]->{result}, -$dist, $take); | |||||||||||||||||||||||||||
| 469 | 12 | $remaining -= $take; | |||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | # Back to the main inflation loop | ||||||||||||||||||||||||||||
| 473 | 3008 | goto &{$_[0]->{state} = \&stateReadLit}; | |||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | 1 | 1; | |||||||||||||||||||||||||||
| 478 | __END__ | ||||||||||||||||||||||||||||