Skilletor/URL.pm

filter: Statementstmt 98.6% 211 / 214 Branchbran 87.1% 122 / 140 Conditioncond 80.0% 28 / 35 MC/DCmcdc 63.6% 14 / 22 Subroutinesub 100% 18 / 18 Podpod 100% 2 / 2 totaltotal 91.6% 395 / 431 CC 90 SCAR 26.4
CC
90
Cov
93%
parse_url
27.7
_authority
16.0
_ipv4_number
11.3
CRAP 14.0
« Skilletor/State.pm ↑ Summary Skilletor/FSUtil.pm »
1 package Skilletor::URL;
2 # ABSTRACT: The parts of a URL as the WHATWG URL parser (Node's new URL) gives them
3  
4 39 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 39 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 39 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 39 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 39 ▶use Skilletor::FSUtil qw( decode_utf8_lossy );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 39 ▶use Unicode::Normalize ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 39 our $VERSION = '0.001';
13  
14 39 our @EXPORT_OK = qw( parse_url punycode_encode );
15  
16 39 my %SPECIAL = map { $_ => 1 } qw( ftp file http https ws wss );
17 39 my %DEFAULT_PORT = ( ftp => 21, http => 80, https => 443, ws => 80, wss => 443 );
18  
19 # Forbidden host code points; a domain also forbids C0 controls, "%" and DEL.
20 39 my $FORBIDDEN_HOST = qr/[\x00\t\n\r #\/:<>?\@\[\\\]^|]/;
21 39 my $FORBIDDEN_DOMAIN = qr/[\x00-\x1F #%\/:<>?\@\[\\\]^|\x7F]/;
22  
23 384 ▶sub _pct_encode {
Subroutine _pct_encode: called CC=1 SCAR=0.0
24 384 my ( $s, $set ) = @_;
25 384 $s =~ s{($set)}{ join '', map { sprintf '%%%02X', $_ } unpack 'C*', Encode::encode( 'UTF-8', $1 ) }ge;
26 384 return $s;
27 }
28  
29 # The path percent-encode set: C0 controls, space, " # < > ? ` { } and everything above "~".
30 39 my $PATH_SET = qr/[\x00-\x20"#<>?`{}\x7F-\x{10FFFF}]/;
31 39 my $C0_SET = qr/[\x00-\x1F\x7F-\x{10FFFF}]/;
32  
33 185 ▶sub _pct_decode_bytes {
Subroutine _pct_decode_bytes: called CC=1 SCAR=0.0
34 185 my ( $s ) = @_;
35 185 my $bytes = Encode::encode( 'UTF-8', $s );
36 185 $bytes =~ s/%([0-9A-Fa-f]{2})/chr hex $1/ge;
37 185 return $bytes;
38 }
39  
40 241 ▶sub parse_url {
Subroutine parse_url: called CC=27 SCAR=33.2
Pod documented
41 241 my ( $input ) = @_;
42 241 my $s = $input;
43 241 $s =~ s/\A[\x00-\x20]+//;
44 241 $s =~ s/[\x00-\x20]+\z//;
45 241 $s =~ s/[\t\n\r]//g;
46 241 ▶ return undef unless $s =~ /\A([A-Za-z][A-Za-z0-9+.\-]*):(.*)\z/s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s =~ /\A([A-Za-z][A-Za-z0-9+.\-]*):(.*)\z/s 0 241 241
47 241 my ( $scheme, $rest ) = ( lc $1, $2 );
48 241 ▶ my $special = $SPECIAL{$scheme} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$SPECIAL{$scheme} ? : 201 40 241
49 241 my %url = ( protocol => $scheme.':', username => '', password => '', hostname => '', port => '', search => '', hash => '' );
50  
51 # fragment and query
52 241 ▶ if ( $rest =~ s/#(.*)\z//s ) { $url{hash} = length $1 ? '#'.$1 : '' }
Branch: 2 branches
BranchTrueFalseTotal
if ($rest =~ s/#(.*)\z//s) 4 237 241
length $1 ? : 4 0 4
53 241 ▶ if ( $rest =~ s/\?(.*)\z//s ) { $url{search} = length $1 ? '?'.$1 : '' }
Branch: 2 branches
BranchTrueFalseTotal
if ($rest =~ s/\?(.*)\z//s) 4 237 241
length $1 ? : 4 0 4
54  
55 241 ▶ my $sep = $special ? qr{[/\\]} : qr{/};
Branch: 1 branch
BranchTrueFalseTotal
$special ? : 201 40 241
56 241 my $path;
57 241 ▶ if ( $special && $scheme ne 'file' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($special and $scheme ne 'file') { } 191 50 241
elsif ($scheme eq 'file') { } 10 40 50
elsif ($rest =~ s[\A//][]) { } 40 0 40
Condition100%3/3
$special and $scheme ne "file"
!ll&&!rl&&r
4010191
MC/DC100%2/2
$special and $scheme ne "file"
$special $scheme ne "file"
Truth table100%3/3
A and B
A= $specialB= $scheme ne "file"
ABresult
0X0
100
111
58 191 $rest =~ s{\A[/\\]+}{};
59 191 my ( $authority, $p ) = $rest =~ m{\A([^/\\]*)(.*)\z}s;
60 191 ▶ return undef unless _authority( \%url, $authority, $scheme, 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless _authority(\%url, $authority, $scheme, 1) 11 180 191
61 180 ▶ return undef if $url{hostname} eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $url{"hostname"} eq "" 0 180 180
62 180 $path = $p;
63 }
64 elsif ( $scheme eq 'file' ) {
65 10 ▶ if ( $rest =~ s{\A[/\\]{2}}{} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest =~ s(\A[/\\]{2})[]) { } 10 0 10
66 10 my ( $host, $p ) = $rest =~ m{\A([^/\\]*)(.*)\z}s;
67 10 ▶ if ( length $host ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $host) 3 7 10
68 3 my $h = _host( $host, 1 );
69 3 ▶ return undef unless defined $h;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $h 0 3 3
70 3 ▶ $url{hostname} = $h eq 'localhost' ? '' : $h;
Branch: 1 branch
BranchTrueFalseTotal
$h eq 'localhost' ? : 2 1 3
71 }
72 10 $path = $p;
73 }
74 else {
75 0 $path = $rest;
76 }
77 }
78 elsif ( $rest =~ s{\A//}{} ) {
79 40 my ( $authority, $p ) = $rest =~ m{\A([^/]*)(.*)\z}s;
80 40 ▶ return undef unless _authority( \%url, $authority, $scheme, 0 );
Branch: 1 branch
BranchTrueFalseTotal
unless _authority(\%url, $authority, $scheme, 0) 1 39 40
81 39 $path = $p;
82 }
83 else {
84 # an opaque path: kept, C0 controls encoded
85 0 $url{pathname} = _pct_encode( $rest, $C0_SET );
86 0 return \%url;
87 }
88  
89 229 my @segments;
90 229 ▶ if ( $special || length $path ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($special or length $path) 216 13 229
Condition100%3/3
$special or length $path
l!l&&r!l&&!r
1902613
MC/DC100%2/2
$special or length $path
$special length $path
Truth table100%3/3
A or B
A= $specialB= length $path
ABresult
1X1
011
000
91 216 $path =~ s{\A$sep}{};
92 216 my @raw = split /$sep/, $path, -1;
93 216 ▶ @raw = ('') unless @raw;
Branch: 1 branch
BranchTrueFalseTotal
unless @raw 16 200 216
94 216 for my $i ( 0 .. $#raw ) {
95 361 my $seg = $raw[$i];
96 361 my $last = $i == $#raw;
97 361 ▶ if ( $seg =~ /\A(?:\.|%2e)(?:\.|%2e)\z/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($seg =~ /\A(?:\.|%2e)(?:\.|%2e)\z/i) { } 8 353 361
elsif ($seg =~ /\A(?:\.|%2e)\z/i) { } 6 347 353
98 8 pop @segments;
99 8 ▶ push @segments, '' if $last;
Branch: 1 branch
BranchTrueFalseTotal
if $last 2 6 8
100 }
101 elsif ( $seg =~ /\A(?:\.|%2e)\z/i ) {
102 6 ▶ push @segments, '' if $last;
Branch: 1 branch
BranchTrueFalseTotal
if $last 4 2 6
103 }
104 else {
105 347 push @segments, _pct_encode( $seg, $PATH_SET );
106 }
107 }
108 }
109 229 $url{pathname} = join '', map { '/'.$_ } @segments;
110 229 return \%url;
111 }
112  
113 231 ▶sub _authority {
Subroutine _authority: called CC=16 SCAR=27.7
114 231 my ( $url, $authority, $scheme, $special ) = @_;
115 231 my $hostport = $authority;
116 231 my $at = rindex $authority, '@';
117 231 ▶ if ( $at >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($at >= 0) 19 212 231
118 19 my $userinfo = substr $authority, 0, $at;
119 19 $hostport = substr $authority, $at + 1;
120 19 my ( $user, $pass ) = split /:/, $userinfo, 2;
121 19 ▶ $url->{username} = $user // '';
Condition50%1/2
$user // ""
l!l
190
MC/DC0%0/1
$user // ""
$user
Truth table50%1/2
A
A= $user
Aresult
11
00
122 19 ▶ $url->{password} = $pass // '';
Condition100%2/2
$pass // ""
l!l
316
MC/DC100%1/1
$pass // ""
$pass
Truth table100%2/2
A
A= $pass
Aresult
11
00
123 }
124 231 my ( $host, $port ) = ( $hostport, '' );
125 231 ▶ if ( $hostport =~ /\A(\[[^\]]*\])(?::(.*))?\z/s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hostport =~ /\A(\[[^\]]*\])(?::(.*))?\z/s) { } 4 227 231
elsif ((my $c = index($hostport, ':')) >= 0) { } 38 189 227
126 4 ▶ ( $host, $port ) = ( $1, $2 // '' );
Condition100%2/2
$2 // ""
l!l
22
MC/DC100%1/1
$2 // ""
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
127 }
128 elsif ( ( my $c = index $hostport, ':' ) >= 0 ) {
129 38 ( $host, $port ) = ( substr( $hostport, 0, $c ), substr( $hostport, $c + 1 ) );
130 }
131 231 ▶ if ( length $port ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $port) 39 192 231
132 39 ▶ return 0 unless $port =~ /\A[0-9]+\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $port =~ /\A[0-9]+\z/ 2 37 39
133 37 ▶ return 0 if $port > 65535;
Branch: 1 branch
BranchTrueFalseTotal
if $port > 65535 2 35 37
134 35 $port = 0 + $port;
135 35 ▶ $port = '' if defined $DEFAULT_PORT{$scheme} && $port == $DEFAULT_PORT{$scheme};
Branch: 1 branch
BranchTrueFalseTotal
if defined $DEFAULT_PORT{$scheme} and $port == $DEFAULT_PORT{$scheme} 1 34 35
Condition100%3/3
defined $DEFAULT_PORT{$scheme} and $port == $DEFAULT_PORT{$scheme}
!ll&&!rl&&r
3311
MC/DC100%2/2
defined $DEFAULT_PORT{$scheme} and $port == $DEFAULT_PORT{$scheme}
defined $DEFAULT_PORT{$scheme} $port == $DEFAULT_PORT{$scheme}
Truth table100%3/3
A and B
A= defined $DEFAULT_PORT{$scheme}B= $port == $DEFAULT_PORT{$scheme}
ABresult
0X0
100
111
136 }
137 227 $url->{port} = "$port";
138 227 ▶ return 0 if $special && $host eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $special and $host eq "" 2 225 227
Condition100%3/3
$special and $host eq ""
!ll&&!rl&&r
401852
MC/DC100%2/2
$special and $host eq ""
$special $host eq ""
Truth table100%3/3
A and B
A= $specialB= $host eq ""
ABresult
0X0
100
111
139 225 ▶ return 1 if $host eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $host eq "" 1 224 225
140 224 my $h = _host( $host, $special );
141 224 ▶ return 0 unless defined $h;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $h 6 218 224
142 218 $url->{hostname} = $h;
143 218 return 1;
144 }
145  
146 227 ▶sub _host {
Subroutine _host: called CC=9 SCAR=22.2
147 227 my ( $input, $special ) = @_;
148 227 ▶ if ( $input =~ /\A\[/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input =~ /\A\[/) 4 223 227
149 4 ▶ return undef unless $input =~ /\A\[([0-9A-Fa-f:.]+)\]\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $input =~ /\A\[([0-9A-Fa-f:.]+)\]\z/ 0 4 4
150 4 return '['.lc($1).']';
151 }
152 223 ▶ unless ($special) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($special) 38 185 223
153 38 ▶ return undef if $input =~ $FORBIDDEN_HOST;
Branch: 1 branch
BranchTrueFalseTotal
if $input =~ /$FORBIDDEN_HOST/ 1 37 38
154 37 return _pct_encode( $input, $C0_SET );
155 }
156 185 my $domain = decode_utf8_lossy( _pct_decode_bytes($input) );
157 185 my $ascii = _domain_to_ascii($domain);
158 185 ▶ return undef unless defined $ascii && length $ascii;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ascii and length $ascii 0 185 185
Condition33%1/3
defined $ascii and length $ascii
!ll&&!rl&&r
00185
MC/DC0%0/2
defined $ascii and length $ascii
defined $ascii length $ascii
Truth table33%1/3
A and B
A= defined $asciiB= length $ascii
ABresult
0X0
100
111
159 185 ▶ return undef if $ascii =~ $FORBIDDEN_DOMAIN;
Branch: 1 branch
BranchTrueFalseTotal
if $ascii =~ /$FORBIDDEN_DOMAIN/ 2 183 185
160 183 ▶ if ( _ends_in_number($ascii) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_ends_in_number($ascii)) 35 148 183
161 35 return _ipv4($ascii);
162 }
163 148 return $ascii;
164 }
165  
166 # UTS #46 lite: NFC and lower case, then each label holding non-ASCII as punycode.
167 185 ▶sub _domain_to_ascii {
Subroutine _domain_to_ascii: called CC=4 SCAR=13.9
168 185 my ( $domain ) = @_;
169 185 my $mapped = lc Unicode::Normalize::NFC($domain);
170 185 $mapped =~ s/[\x{3002}\x{FF0E}\x{FF61}]/./g;
171 185 my @labels = split /\./, $mapped, -1;
172 185 for my $label (@labels) {
173 411 ▶ next unless $label =~ /[^\x00-\x7F]/;
Branch: 1 branch
BranchTrueFalseTotal
unless $label =~ /[^\x00-\x7F]/ 405 6 411
174 6 my $encoded = punycode_encode($label);
175 6 ▶ return undef unless defined $encoded;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $encoded 0 6 6
176 6 $label = 'xn--'.$encoded;
177 }
178 185 return join '.', @labels;
179 }
180  
181 274 ▶sub _ipv4_number {
Subroutine _ipv4_number: called CC=11 SCAR=24.3
182 274 my ( $s ) = @_;
183 274 ▶ return undef if $s eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $s eq "" 0 274 274
184 274 my $radix = 10;
185 274 ▶ if ( $s =~ s/\A0[xX]// ) { $radix = 16 }
Branch: 2 branches
BranchTrueFalseTotal
if ($s =~ s/\A0[xX]//) { } 2 272 274
elsif (length $s > 1 and $s =~ s/\A0//) { } 1 365 366
186 1 ▶ elsif ( length $s > 1 && $s =~ s/\A0// ) { $radix = 8 }
Condition100%3/3
length $s > 1 and $s =~ s/\A0//
!ll&&!rl&&r
941771
MC/DC100%2/2
length $s > 1 and $s =~ s/\A0//
length $s > 1 $s =~ s/\A0//
Truth table100%3/3
A and B
A= length $s > 1B= $s =~ s/\A0//
ABresult
0X0
100
111
187 274 ▶ return 0 if $s eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $s eq "" 0 274 274
188 274 ▶ return $radix == 16 ? ( $s =~ /\A[0-9A-Fa-f]+\z/ ? hex $s : undef )
Branch: 5 branches
BranchTrueFalseTotal
$radix == 16 ? : 2 272 274
$s =~ /\A[0-9A-Fa-f]+\z/ ? : 2 0 2
$radix == 8 ? : 1 271 272
$s =~ /\A[0-7]+\z/ ? : 1 0 1
$s =~ /\A[0-9]+\z/ ? : 122 149 271
189 : $radix == 8 ? ( $s =~ /\A[0-7]+\z/ ? oct $s : undef )
190 : ( $s =~ /\A[0-9]+\z/ ? 0 + $s : undef );
191 }
192  
193 183 ▶sub _ends_in_number {
Subroutine _ends_in_number: called CC=8 SCAR=21.5
194 183 my ( $host ) = @_;
195 183 my @parts = split /\./, $host, -1;
196 183 ▶ if ( @parts && $parts[-1] eq '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@parts and $parts[-1] eq "") 1 182 183
Condition66%2/3
@parts and $parts[-1] eq ""
!ll&&!rl&&r
01821
MC/DC50%1/2
@parts and $parts[-1] eq ""
@parts $parts[-1] eq ""
Truth table66%2/3
A and B
A= @partsB= $parts[-1] eq ""
ABresult
0X0
100
111
197 1 ▶ return 0 if @parts == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @parts == 1 0 1 1
198 1 pop @parts;
199 }
200 183 ▶ my $last = $parts[-1] // '';
Condition50%1/2
$parts[-1] // ""
l!l
1830
MC/DC0%0/1
$parts[-1] // ""
$parts[-1]
Truth table50%1/2
A
A= $parts[-1]
Aresult
11
00
201 183 ▶ return 1 if $last ne '' && $last =~ /\A[0-9]+\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $last ne "" and $last =~ /\A[0-9]+\z/ 35 148 183
Condition66%2/3
$last ne "" and $last =~ /\A[0-9]+\z/
!ll&&!rl&&r
014835
MC/DC50%1/2
$last ne "" and $last =~ /\A[0-9]+\z/
$last ne "" $last =~ /\A[0-9]+\z/
Truth table66%2/3
A and B
A= $last ne ""B= $last =~ /\A[0-9]+\z/
ABresult
0X0
100
111
202 148 ▶ return defined _ipv4_number($last) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined _ipv4_number($last) ? : 0 148 148
203 }
204  
205 35 ▶sub _ipv4 {
Subroutine _ipv4: called CC=10 SCAR=23.1
206 35 my ( $host ) = @_;
207 35 my @parts = split /\./, $host, -1;
208 35 ▶ pop @parts if @parts > 1 && $parts[-1] eq '';
Branch: 1 branch
BranchTrueFalseTotal
if @parts > 1 and $parts[-1] eq "" 0 35 35
Condition66%2/3
@parts > 1 and $parts[-1] eq ""
!ll&&!rl&&r
2330
MC/DC0%0/2
@parts > 1 and $parts[-1] eq ""
@parts > 1 $parts[-1] eq ""
Truth table66%2/3
A and B
A= @parts > 1B= $parts[-1] eq ""
ABresult
0X0
100
111
209 35 ▶ return undef if @parts > 4;
Branch: 1 branch
BranchTrueFalseTotal
if @parts > 4 0 35 35
210 35 my @n;
211 35 for my $p (@parts) {
212 126 my $v = _ipv4_number($p);
213 126 ▶ return undef unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 1 125 126
214 125 push @n, $v;
215 }
216 34 ▶ for my $i ( 0 .. $#n - 1 ) { return undef if $n[$i] > 255 }
Branch: 1 branch
BranchTrueFalseTotal
if $n[$i] > 255 1 89 90
217 33 ▶ return undef if $n[-1] >= 256**( 5 - @n );
Branch: 1 branch
BranchTrueFalseTotal
if $n[-1] >= 256 ** (5 - @n) 1 32 33
218 32 my $ipv4 = $n[-1];
219 32 $ipv4 += $n[$_] * 256**( 3 - $_ ) for 0 .. $#n - 1;
220 32 return join '.', map { ( $ipv4 >> ( 8 * ( 3 - $_ ) ) ) & 255 } 0 .. 3;
221 }
222  
223 # RFC 3492 punycode of one label (without the xn-- prefix).
224 8 ▶sub punycode_encode {
Subroutine punycode_encode: called CC=9 SCAR=22.0
Pod documented
225 8 my ( $input ) = @_;
226 8 my ( $base, $tmin, $tmax, $skew, $damp ) = ( 36, 1, 26, 38, 700 );
227 8 my ( $n, $delta, $bias ) = ( 128, 0, 72 );
228 8 my @cp = map { ord } split //, $input;
229 8 my $output = join '', map { chr } grep { $_ < 128 } @cp;
230 8 my $basic = length $output;
231 8 my $h = $basic;
232 8 ▶ $output .= '-' if $basic > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $basic > 0 5 3 8
233 8 ▶ my $digit = sub { my $d = shift; chr( $d < 26 ? 97 + $d : 22 + $d ) };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$d < 26 ? : 25 5 30
234 10 ▶ my $adapt = sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
235 10 my ( $d, $num, $first ) = @_;
236 10 ▶ $d = $first ? int( $d / $damp ) : int( $d / 2 );
Branch: 1 branch
BranchTrueFalseTotal
$first ? : 8 2 10
237 10 $d += int( $d / $num );
238 10 my $k = 0;
239 10 ▶ while ( $d > ( ( $base - $tmin ) * $tmax ) / 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d > ($base - $tmin) * $tmax / 2) 2 10 12
240 2 $d = int( $d / ( $base - $tmin ) );
241 2 $k += $base;
242 }
243 10 return $k + int( ( ( $base - $tmin + 1 ) * $d ) / ( $d + $skew ) );
244 8 };
245 8 ▶ while ( $h < @cp ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h < @cp) 10 8 18
246 10 my ($m) = sort { $a <=> $b } grep { $_ >= $n } @cp;
247 10 $delta += ( $m - $n ) * ( $h + 1 );
248 10 $n = $m;
249 10 for my $c (@cp) {
250 42 ▶ $delta++ if $c < $n;
Branch: 1 branch
BranchTrueFalseTotal
if $c < $n 30 12 42
251 42 ▶ next unless $c == $n;
Branch: 1 branch
BranchTrueFalseTotal
unless $c == $n 32 10 42
252 10 my $q = $delta;
253 10 for ( my $k = $base ; ; $k += $base ) {
254 30 ▶ my $t = $k <= $bias ? $tmin : $k >= $bias + $tmax ? $tmax : $k - $bias;
Branch: 2 branches
BranchTrueFalseTotal
$k <= $bias ? : 16 14 30
$k >= $bias + $tmax ? : 12 2 14
255 30 ▶ last if $q < $t;
Branch: 1 branch
BranchTrueFalseTotal
if $q < $t 10 20 30
256 20 $output .= $digit->( $t + ( $q - $t ) % ( $base - $t ) );
257 20 $q = int( ( $q - $t ) / ( $base - $t ) );
258 }
259 10 $output .= $digit->($q);
260 10 $bias = $adapt->( $delta, $h + 1, $h == $basic );
261 10 $delta = 0;
262 10 $h++;
263 }
264 10 $delta++;
265 10 $n++;
266 }
267 8 return $output;
268 }
269  
270 39 1;
271  
272 __END__
« Skilletor/State.pm ↑ Summary Skilletor/FSUtil.pm »