| 1 | package PLON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 12 | ▶ | use 5.008005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use Scalar::Util qw(blessed reftype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use parent qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use B; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 12 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | our $VERSION = "0.08"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 12 | our @EXPORT = qw(encode_plon decode_pson $_perl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | our $INDENT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 12 | my $WS = qr{[ \t]*}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | sub encode_plon { PLON->new->encode(shift) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_plon: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | sub decode_pson { PLON->new->decode(shift) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_pson: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 48 | ▶ | sub mk_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_accessor: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 48 | my ($pkg, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 48 | ▶ | *{"${pkg}::${name}"} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | ▶ | my $enable = defined($_[1]) ? $_[1] : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | ▶ | if ($enable) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | $_[0]->{$name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $_[0]->{$name} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 48 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 48 | ▶ | *{"${pkg}::get_${name}"} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 137 | ▶ | $_[0]->{$name} ? 1 : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 48 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 25 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 25 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 25 | bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 12 | mk_accessor(__PACKAGE__, $_) for qw(pretty ascii deparse canonical); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 30 | ▶ | sub encode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 30 | my ($self, $stuff) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 30 | local $INDENT = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 30 | return $self->_encode($stuff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 73 | ▶ | sub _encode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 73 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 73 | local $INDENT = $INDENT + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 73 | my $blessed = blessed($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 73 | ▶ | if (defined $blessed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | 'bless(' . $self->_encode_basic($value, 1) . ',' . $self->_encode_basic($blessed) . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 70 | $self->_encode_basic($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 76 | ▶ | sub _encode_basic { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode_basic: called CC=22 SCAR=31.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 76 | my ($self, $value, $blessing) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 76 | ▶ | if (not defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | return 'undef'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 74 | my $reftype = reftype($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 74 | ▶ | if (not defined $reftype) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 42 | my $flags = B::svref_2object(\$value)->FLAGS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 42 | ▶ | return 0 + $value if $flags & (B::SVp_IOK | B::SVp_NOK) && $value * 0 == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$flags & 12288 and $value * 0 == 0
MC/DC50%1/2
$flags & 12288 and $value * 0 == 0
$flags & 12288
$value * 0 == 0
Truth table66%2/3
A and B
A= $flags & 12288B= $value * 0 == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 30 | ▶ | if ($self->{ascii}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | $value =~ s/"/\\"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | if (Encode::is_utf8($value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | my $buf = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | for (split //, $value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | ▶ | if ($_ =~ /\G[a-zA-Z0-9_ -]\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | $buf .= Encode::encode_utf8($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | $buf .= sprintf "\\x{%X}", ord $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | $value = $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $value = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | q{"} . $value . q{"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # Here is the list of special characters from perlop.pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # Sequence Note Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # \t tab (HT, TAB) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # \n newline (NL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # \r return (CR) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # \f form feed (FF) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # \b backspace (BS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # \a alarm (bell) (BEL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # \e escape (ESC) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # \x{263A} [1,8] hex char (example: SMILEY) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # \x1b [2,8] restricted range hex char (example: ESC) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # \N{name} [3] named Unicode character or character sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # \N{U+263D} [4,8] Unicode character (example: FIRST QUARTER MOON) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # \c[ [5] control char (example: chr(27)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # \o{23072} [6,8] octal char (example: SMILEY) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # \033 [7,8] restricted range octal char (example: ESC) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 28 | my %special_chars = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | qq{"} => q{\"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | qq{\t} => q{\t}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | qq{\n} => q{\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | qq{\r} => q{\r}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | qq{\f} => q{\f}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | qq{\b} => q{\b}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | qq{\a} => q{\a}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | qq{\e} => q{\e}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | q{$} => q{\$}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | q{@} => q{\@}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | q{%} => q{\%}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | q{\\} => q{\\\\}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 28 | $value =~ s/(.)/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 43 | ▶ | if (exists($special_chars{$1})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 11 | $special_chars{$1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 32 | $1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | /gexs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 28 | ▶ | $value = Encode::is_utf8($value) ? Encode::encode_utf8($value) : $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 28 | q{"} . $value . q{"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } elsif ($reftype eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | ▶ | if ($blessing) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | '\\(do {my $o=' . $self->_encode($$value) . '})'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | '\\(' . $self->_encode($$value) . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } elsif ($reftype eq 'REF') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | '\\(' . $self->_encode($$value) . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } elsif ($reftype eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | join('', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | '[', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | $self->_nl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 20 | (map { $self->_indent(1) . $self->_encode($_) . "," . $self->_nl } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | @$value), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $self->_indent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ']', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } elsif ($reftype eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | if ($self->get_deparse) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | require B::Deparse; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ▶ | my $code = B::Deparse->new($self->get_pretty ? '' : '-si0')->coderef2text($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | $code = "sub ${code}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | if ($self->get_pretty) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $indent = $self->_indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $code =~ s/^/$indent/gm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | $code =~ s/\n//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | 'sub { "DUMMY" }' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } elsif ($reftype eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5 | my @keys = keys %$value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 5 | ▶ | if ($self->get_canonical) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | @keys = sort { $a cmp $b } @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | join('', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | '{', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $self->_nl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | (map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | $self->_indent(1) . $self->_encode($_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | . $self->_before_sp . '=>' . $self->_after_sp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 7 | . $self->_encode($value->{$_}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | . "," . $self->_nl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } @keys), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | $self->_indent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | '}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } elsif ($reftype eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | "\\(" . $$value . ")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | die "Unknown type: ${reftype}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 57 | ▶ | sub _indent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_indent: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 57 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 57 | ▶ | if (not defined $n) { $n = 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 57 | ▶ | $self->get_pretty ? ' ' x ($INDENT+$n) : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 57 | ▶ | sub _nl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_nl: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 57 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 57 | ▶ | $self->get_pretty ? "\n" : '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 7 | ▶ | sub _before_sp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_before_sp: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 7 | ▶ | $self->get_pretty ? " " : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 7 | ▶ | sub _after_sp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_after_sp: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 7 | ▶ | $self->get_pretty ? " " : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 31 | ▶ | sub decode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 31 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 31 | local $_ = $src; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 31 | return $self->_decode(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 68 | ▶ | sub _decode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode: called CC=12 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 68 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 68 | ▶ | if (/\G$WS\{/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 11 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 5 | return $self->_decode_hash(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } elsif (/\G$WS\[/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 18 | return $self->_decode_array(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } elsif (/\G$WS"/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 23 | return $self->_decode_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } elsif (/\G${WS}undef/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } elsif (/\G${WS}\\\(/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 5 | return $self->_decode_scalarref(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } elsif (/\G${WS}sub\s*\{/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | return $self->_decode_code(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } elsif (/\G$WS"/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | return $self->_decode_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } elsif (/\G$WS([0-9\.]+)/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 8 | return 0+$1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } elsif (/\G${WS}bless\(/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 3 | return $self->_decode_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } elsif (/\G${WS}do \{my \$o=/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | return $self->_decode_do; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } elsif (/\G$WS\*([a-zA-Z0-9_:]+)/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | *{$1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | Carp::confess("Unexpected token: " . substr($_, pos, 9)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 5 | ▶ | sub _decode_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_hash: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 5 | my %ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | ▶ | until (/\G$WS(,$WS)?\}/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | my $k = $self->_decode(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 5 | ▶ | /\G$WS=>$WS/gc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | or _exception("Unexpected token in Hash"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 5 | my $v = $self->_decode(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 5 | $ret{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 5 | ▶ | /\G$WS,/gc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | return \%ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 18 | ▶ | sub _decode_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_array: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 18 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 18 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 18 | ▶ | until (/\G$WS,?$WS\]/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 15 | my $term = $self->_decode(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 14 | push @ret, $term; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 17 | return \@ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 2 | ▶ | sub _decode_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # We can't decode coderef. Because it makes security issue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # And, we can't detect end of code block. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 2 | Carp::confess("Cannot decode PLON contains CodeRef."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 3 | ▶ | sub _decode_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_object: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | my $body = $self->_decode; # class name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 3 | ▶ | m!\G${WS},\s*!gc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | or _exception("Missing comma after bless"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | my $str = $self->_decode; # class name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 3 | ▶ | m!\G${WS}\)!gc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | or _exception("Missing closing paren after bless"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | return bless($body, $str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 5 | ▶ | sub _decode_scalarref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_scalarref: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 5 | my $value = $self->_decode(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 5 | ▶ | /\G\s*\)/gc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | or _exception("Missing closing paren after scalarref"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 5 | return \$value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # do {my $o=3} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | sub _decode_do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_do: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | my $value = $self->_decode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | ▶ | m!\G\}!gc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | or _exception("Missing closing blace after `do {`"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 23 | ▶ | sub _decode_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_string: called CC=18 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 23 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 23 | my $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 23 | ▶ | until (/\G"/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 39 | ▶ | if (/\G\\"/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 15 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | $ret .= q{"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } elsif (/\G\\\$/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | $ret .= qq{\$}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } elsif (/\G\\t/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | $ret .= qq{\t}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } elsif (/\G\\n/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | $ret .= qq{\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } elsif (/\G\\r/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | $ret .= qq{\r}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } elsif (/\G\\f/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | $ret .= qq{\f}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } elsif (/\G\\b/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | $ret .= qq{\b}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } elsif (/\G\\a/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | $ret .= qq{\a}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } elsif (/\G\\e/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | $ret .= qq{\e}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } elsif (/\G\\$/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $ret .= qq{\$}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } elsif (/\G\\@/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | $ret .= qq{\@}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } elsif (/\G\\%/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $ret .= qq{\%}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } elsif (/\G\\\\/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 1 | $ret .= qq{\\}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } elsif (/\G\\x\{([0-9a-fA-F]+)\}/gc) { # \x{5963} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | $ret .= chr(hex $1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } elsif (/\G([^"\\]+)/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 27 | $ret .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | _exception("Unexpected EOF in string"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # If it's utf-8, it means the PLON encoded by ASCII mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # The PLON contains "\x{5963}". Then, we shouldn't decode the string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 23 | ▶ | return Encode::is_utf8($ret) ? $ret : Encode::decode_utf8($ret); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | sub _exception { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exception: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # Leading whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | m/\G$WS/gc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # Context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $context = 'Malformed PLON: ' . shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if (m/\G\z/gc) { $context .= ' before end of data' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my @lines = split "\n", substr($_, 0, pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $context .= ' at line ' . @lines . ', offset ' . length(pop @lines || ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
pop @lines || ''
MC/DC0%0/1
pop @lines || ''
pop @lines
Truth table0%0/2
A
A= pop @lines
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | die "$context\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||