| 1 | package Catmandu::Fix::substring; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 1 | ▶ | use Catmandu::Sane; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 1 | our $VERSION = '1.2025'; | |||||||||||||
| 6 | |||||||||||||||
| 7 | 1 | ▶ | use Catmandu::Util qw(as_utf8); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | ▶ | use Catmandu::Util::Path qw(as_path); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 1 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 1 | ▶ | use namespace::clean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 1 | ▶ | use Catmandu::Fix::Has; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | has path => (fix_arg => 1); | |||||||||||||
| 14 | 1 | has args => (fix_arg => 'collect'); | |||||||||||||
| 15 | |||||||||||||||
| 16 | 1 | with 'Catmandu::Fix::Builder'; | |||||||||||||
| 17 | |||||||||||||||
| 18 | 5 | ▶ | sub _build_fixer { | ||||||||||||
|
Subroutine
_build_fixer: called CC=3 SCAR=11.0
| |||||||||||||||
| 19 | 5 | my ($self) = @_; | |||||||||||||
| 20 | 5 | my $args = $self->args; | |||||||||||||
| 21 | 5 | my $cb; | |||||||||||||
| 22 | |||||||||||||||
| 23 | 5 | ▶ | if (@$args == 1) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 24 | 2 | ▶ | $cb = sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||
| 25 | 2 | my $val = $_[0]; | |||||||||||||
| 26 | 2 | my $new_val; | |||||||||||||
| 27 | 2 | eval { | |||||||||||||
| 28 | 1 | ▶ | no warnings 'substr'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 29 | 2 | $new_val = substr(as_utf8($val), $args->[0]); | |||||||||||||
| 30 | }; | ||||||||||||||
| 31 | 2 | ▶ | return $new_val if defined $new_val; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | 0 | return undef, 1, 0; | |||||||||||||
| 33 | 1 | }; | |||||||||||||
| 34 | } | ||||||||||||||
| 35 | elsif (@$args == 2) { | ||||||||||||||
| 36 | 3 | ▶ | $cb = sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||
| 37 | 3 | my $val = $_[0]; | |||||||||||||
| 38 | 3 | my $new_val; | |||||||||||||
| 39 | 3 | eval { | |||||||||||||
| 40 | 1 | ▶ | no warnings 'substr'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 41 | 3 | $new_val = substr(as_utf8($val), $args->[0], $args->[1]); | |||||||||||||
| 42 | }; | ||||||||||||||
| 43 | 3 | ▶ | return $new_val if defined $new_val; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 44 | 2 | return undef, 1, 0; | |||||||||||||
| 45 | 3 | }; | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | else { | ||||||||||||||
| 48 | 1 | ▶ | $cb = sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||
| 49 | 1 | my $val = $_[0]; | |||||||||||||
| 50 | 1 | my $new_val = as_utf8($val); | |||||||||||||
| 51 | 1 | ▶ | eval { | ||||||||||||
|
Condition50%1/2
eval {
do {
BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"}
substr($new_val, $args->[0], $args->[1]) = $args->[2]
}
} // (return undef, 1, 0)
MC/DC0%0/1
eval {
do {
BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"}
substr($new_val, $args->[0], $args->[1]) = $args->[2]
}
} // (return undef, 1, 0)
eval {
do {
BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"}
substr($new_val, $args->[0], $args->[1]) = $args->[2]
}
}
Truth table50%1/2
A
A= eval {
do {
BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"}
substr($new_val, $args->[0], $args->[1]) = $args->[2]
}
}
| |||||||||||||||
| 52 | 1 | ▶ | no warnings 'substr'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 53 | 1 | substr($new_val, $args->[0], $args->[1]) = $args->[2]; | |||||||||||||
| 54 | } // return undef, 1, 0; | ||||||||||||||
| 55 | 1 | $new_val; | |||||||||||||
| 56 | 1 | }; | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 5 | as_path($self->path)->updater(if_value => $cb); | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | 1 | 1; | |||||||||||||
| 63 | |||||||||||||||
| 64 | __END__ | ||||||||||||||