| 1 | package Text::Diff::Table; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Text::Diff::Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | our $VERSION = '1.46'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our @ISA = qw( Text::Diff::Base Exporter ); | |||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | our @EXPORT_OK = qw( expand_tabs ); | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | my %escapes = map { | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | my $c = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$_ eq "\"" or $_ eq "\$"
MC/DC100%2/2
$_ eq "\"" or $_ eq "\$"
$_ eq "\""
$_ eq "\$"
Truth table100%3/3
A or B
A= $_ eq "\""B= $_ eq "\$"
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | $_ eq '"' || $_ eq '$' ? qq{'$_'} | ||||||||||||||||||||||||||||||||||||||||||
| 16 | : $_ eq "\\" ? qq{"\\\\"} | ||||||||||||||||||||||||||||||||||||||||||
| 17 | : qq{"$_"}; | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 526 | ( ord eval $c => $_ ) | |||||||||||||||||||||||||||||||||||||||||
| 19 | } ( | ||||||||||||||||||||||||||||||||||||||||||
| 20 | map( chr, 32..126), | ||||||||||||||||||||||||||||||||||||||||||
| 21 | map( sprintf( "\\x%02x", $_ ), ( 0..31, 127..255 ) ), | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # map( "\\c$_", "A".."Z"), | ||||||||||||||||||||||||||||||||||||||||||
| 23 | "\\t", "\\n", "\\r", "\\f", "\\b", "\\a", "\\e" | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ## NOTE: "\\\\" is not here because some things are explicitly | ||||||||||||||||||||||||||||||||||||||||||
| 25 | ## escaped before escape() is called and we don't want to | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ## double-escape "\". Also, in most texts, leaving "\" more | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ## readable makes sense. | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 18 | ▶ | sub expand_tabs($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_tabs: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 18 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 18 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 18 | $s =~ s{(\t)(\t*)|([^\t]+)}{ | |||||||||||||||||||||||||||||||||||||||||
| 34 | 36 | ▶ | if ( $1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 12 | my $spaces = " " x ( 8 - $count % 8 + 8 * length $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 12 | $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 12 | $spaces; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 24 | $count += length $3; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 24 | $3; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | }ge; | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 18 | return $s; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub trim_trailing_line_ends($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim_trailing_line_ends: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $s =~ s/[\r\n]+(?!\n)$//; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | sub escape($); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | SCOPE: { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ## use utf8 if available. don't if not. | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | my $escaper = <<'EOCODE'; | |||||||||||||||||||||||||||||||||||||||||
| 59 | sub escape($) { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | use utf8; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | join "", map { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | my $c = $_; | ||||||||||||||||||||||||||||||||||||||||||
| 63 | $_ = ord; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | exists $escapes{$_} | ||||||||||||||||||||||||||||||||||||||||||
| 65 | ? $escapes{$_} | ||||||||||||||||||||||||||||||||||||||||||
| 66 | : $Text::Diff::Config::Output_Unicode | ||||||||||||||||||||||||||||||||||||||||||
| 67 | ? $c | ||||||||||||||||||||||||||||||||||||||||||
| 68 | : sprintf( "\\x{%04x}", $_ ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | } split //, shift; | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | EOCODE | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | ▶ | unless ( eval $escaper ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
escape: called CC=3 SCAR=11.7
Pod
undocumented
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $escaper =~ s/ *use *utf8 *;\n// or die "Can't drop use utf8;"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | eval $escaper or die $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 8 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 8 | return bless { @_ }, $proto | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | my $missing_elt = [ "", "" ]; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | ▶ | sub hunk { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hunk: called CC=36 SCAR=38.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 8 | my @seqs = ( shift, shift ); | |||||||||||||||||||||||||||||||||||||||||
| 90 | 8 | my $ops = shift; ## Leave sequences in @_[0,1] | |||||||||||||||||||||||||||||||||||||||||
| 91 | 8 | my $options = shift; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | my ( @A, @B ); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 8 | for ( @$ops ) { | |||||||||||||||||||||||||||||||||||||||||
| 95 | 15 | my $opcode = $_->[Text::Diff::OPCODE()]; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 15 | ▶ | if ( $opcode eq " " ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | push @A, $missing_elt while @A < @B; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | push @B, $missing_elt while @B < @A; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 15 | ▶ | push @A, [ $_->[0] + ( $options->{OFFSET_A} || 0), $seqs[0][$_->[0]] ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$opcode eq " " or $opcode eq "-"
$options->{'OFFSET_A'} || 0
MC/DC50%1/2
$opcode eq " " or $opcode eq "-"
$opcode eq " "
$opcode eq "-"
MC/DC0%0/1
$options->{'OFFSET_A'} || 0
$options->{'OFFSET_A'}
Truth table66%2/3
A or B
A= $opcode eq " "B= $opcode eq "-"
Truth table50%1/2
A
A= $options->{'OFFSET_A'}
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | if $opcode eq " " || $opcode eq "-"; | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 15 | ▶ | push @B, [ $_->[1] + ( $options->{OFFSET_B} || 0), $seqs[1][$_->[1]] ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$opcode eq " " or $opcode eq "+"
$options->{'OFFSET_B'} || 0
MC/DC50%1/2
$opcode eq " " or $opcode eq "+"
$opcode eq " "
$opcode eq "+"
MC/DC0%0/1
$options->{'OFFSET_B'} || 0
$options->{'OFFSET_B'}
Truth table66%2/3
A or B
A= $opcode eq " "B= $opcode eq "+"
Truth table50%1/2
A
A= $options->{'OFFSET_B'}
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | if $opcode eq " " || $opcode eq "+"; | ||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | ▶ | push @A, $missing_elt while @A < @B; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | ▶ | push @B, $missing_elt while @B < @A; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | my @elts; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 8 | for ( 0..$#A ) { | |||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | my ( $A, $B ) = (shift @A, shift @B ); | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | ## Do minimal cleaning on identical elts so these look "normal": | ||||||||||||||||||||||||||||||||||||||||||
| 113 | ## tabs are expanded, trailing newelts removed, etc. For differing | ||||||||||||||||||||||||||||||||||||||||||
| 114 | ## elts, make invisible characters visible if the invisible characters | ||||||||||||||||||||||||||||||||||||||||||
| 115 | ## differ. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | ▶ | my $elt_type = $B == $missing_elt ? "A" : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | $A == $missing_elt ? "B" : | ||||||||||||||||||||||||||||||||||||||||||
| 118 | $A->[1] eq $B->[1] ? "=" | ||||||||||||||||||||||||||||||||||||||||||
| 119 | : "*"; | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 8 | ▶ | if ( $elt_type ne "*" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | if ( $elt_type eq "=" || $A->[1] =~ /\S/ || $B->[1] =~ /\S/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$elt_type eq "=" or $A->[1] =~ /\S/ or $B->[1] =~ /\S/
$elt_type eq "=" or $A->[1] =~ /\S/
MC/DC0%0/3
$elt_type eq "=" or $A->[1] =~ /\S/ or $B->[1] =~ /\S/
$elt_type eq "="
$A->[1] =~ /\S/
$B->[1] =~ /\S/
Truth table25%1/4
A or B or C
A= $elt_type eq "="B= $A->[1] =~ /\S/C= $B->[1] =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $A->[1] = escape trim_trailing_line_ends expand_tabs $A->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $B->[1] = escape trim_trailing_line_ends expand_tabs $B->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $A->[1] = escape $A->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | $B->[1] = escape $B->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | ## not using \z here for backcompat reasons. | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 7 | $A->[1] =~ /^(\s*?)([^ \t].*?)?(\s*)(?![\n\r])$/s; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 7 | my ( $l_ws_A, $body_A, $t_ws_A ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 7 | ▶ | $body_A = "" unless defined $body_A; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 7 | $B->[1] =~ /^(\s*?)([^ \t].*?)?(\s*)(?![\n\r])$/s; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 7 | my ( $l_ws_B, $body_B, $t_ws_B ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 7 | ▶ | $body_B = "" unless defined $body_B; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | my $added_escapes; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 | ▶ | if ( $l_ws_A ne $l_ws_B ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | ## Make leading tabs visible. Other non-' ' chars | ||||||||||||||||||||||||||||||||||||||||||
| 143 | ## will be dealt with in escape(), but this prevents | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ## tab expansion from hiding tabs by making them | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ## look like ' '. | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | $added_escapes = 1 if $l_ws_A =~ s/\t/\\t/g; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | $added_escapes = 1 if $l_ws_B =~ s/\t/\\t/g; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 7 | ▶ | if ( $t_ws_A ne $t_ws_B ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | ## Only trailing whitespace gets the \s treatment | ||||||||||||||||||||||||||||||||||||||||||
| 152 | ## to make it obvious what's going on. | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | ▶ | $added_escapes = 1 if $t_ws_A =~ s/ /\\s/g; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | ▶ | $added_escapes = 1 if $t_ws_B =~ s/ /\\s/g; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 3 | ▶ | $added_escapes = 1 if $t_ws_A =~ s/\t/\\t/g; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | $added_escapes = 1 if $t_ws_B =~ s/\t/\\t/g; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | $t_ws_A = $t_ws_B = ""; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | ▶ | my $do_tab_escape = $added_escapes || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$added_escapes || do {
my $expanded_A = &expand_tabs(join($body_A, $l_ws_A, $t_ws_A));
my $expanded_B = &expand_tabs(join($body_B, $l_ws_B, $t_ws_B));
$expanded_A eq $expanded_B
}
MC/DC50%1/2
$added_escapes || do {
my $expanded_A = &expand_tabs(join($body_A, $l_ws_A, $t_ws_A));
my $expanded_B = &expand_tabs(join($body_B, $l_ws_B, $t_ws_B));
$expanded_A eq $expanded_B
}
$added_escapes
do {
my $expanded_A = &expand_tabs(join($body_A, $l_ws_A, $t_ws_A));
my $expanded_B = &expand_tabs(join($body_B, $l_ws_B, $t_ws_B));
$expanded_A eq $expanded_B
}
Truth table66%2/3
A || B
A= $added_escapesB= do {
my $expanded_A = &expand_tabs(join($body_A, $l_ws_A, $t_ws_A));
my $expanded_B = &expand_tabs(join($body_B, $l_ws_B, $t_ws_B));
$expanded_A eq $expanded_B
}
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | my $expanded_A = expand_tabs join( $body_A, $l_ws_A, $t_ws_A ); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | my $expanded_B = expand_tabs join( $body_B, $l_ws_B, $t_ws_B ); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | $expanded_A eq $expanded_B; | |||||||||||||||||||||||||||||||||||||||||
| 166 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 7 | ▶ | my $do_back_escape = $do_tab_escape || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$do_tab_escape || do {
() = map(join('', /(\\.)/g), map({$_, &escape($_);} &expand_tabs(join($body_A, $l_ws_A, $t_ws_A)), &expand_tabs(join($body_B, $l_ws_B, $t_ws_B))));
$unescaped_A ne $unescaped_B and $escaped_A eq $escaped_B
}
MC/DC50%1/2
$do_tab_escape || do {
() = map(join('', /(\\.)/g), map({$_, &escape($_);} &expand_tabs(join($body_A, $l_ws_A, $t_ws_A)), &expand_tabs(join($body_B, $l_ws_B, $t_ws_B))));
$unescaped_A ne $unescaped_B and $escaped_A eq $escaped_B
}
$do_tab_escape
do {
() = map(join('', /(\\.)/g), map({$_, &escape($_);} &expand_tabs(join($body_A, $l_ws_A, $t_ws_A)), &expand_tabs(join($body_B, $l_ws_B, $t_ws_B))));
$unescaped_A ne $unescaped_B and $escaped_A eq $escaped_B
}
Truth table66%2/3
A || B
A= $do_tab_escapeB= do {
() = map(join('', /(\\.)/g), map({$_, &escape($_);} &expand_tabs(join($body_A, $l_ws_A, $t_ws_A)), &expand_tabs(join($body_B, $l_ws_B, $t_ws_B))));
$unescaped_A ne $unescaped_B and $escaped_A eq $escaped_B
}
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | my ( $unescaped_A, $escaped_A, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | $unescaped_B, $escaped_B | ||||||||||||||||||||||||||||||||||||||||||
| 171 | ) = | ||||||||||||||||||||||||||||||||||||||||||
| 172 | map | ||||||||||||||||||||||||||||||||||||||||||
| 173 | join( "", /(\\.)/g ), | ||||||||||||||||||||||||||||||||||||||||||
| 174 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | ( $_, escape $_ ) | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | expand_tabs join( $body_A, $l_ws_A, $t_ws_A ), | ||||||||||||||||||||||||||||||||||||||||||
| 178 | expand_tabs join( $body_B, $l_ws_B, $t_ws_B ); | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | ▶ | $unescaped_A ne $unescaped_B && $escaped_A eq $escaped_B; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$unescaped_A ne $unescaped_B && $escaped_A eq $escaped_B
MC/DC0%0/2
$unescaped_A ne $unescaped_B && $escaped_A eq $escaped_B
$unescaped_A ne $unescaped_B
$escaped_A eq $escaped_B
Truth table33%1/3
A && B
A= $unescaped_A ne $unescaped_BB= $escaped_A eq $escaped_B
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 7 | ▶ | if ( $do_back_escape ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | $body_A =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | $body_B =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 7 | my $line_A = join $body_A, $l_ws_A, $t_ws_A; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 7 | my $line_B = join $body_B, $l_ws_B, $t_ws_B; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 7 | ▶ | unless ( $do_tab_escape ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 3 | $line_A = expand_tabs $line_A; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | $line_B = expand_tabs $line_B; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | $A->[1] = escape $line_A; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 7 | $B->[1] = escape $line_B; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 8 | push @elts, [ @$A, @$B, $elt_type ]; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 8 | push @{$self->{ELTS}}, @elts, ["bar"]; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 8 | return ""; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub _glean_formats { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_glean_formats: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 8 | ▶ | sub file_footer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_footer: called CC=24 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 8 | my @seqs = (shift,shift); | |||||||||||||||||||||||||||||||||||||||||
| 213 | 8 | my $options = pop; | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | my @heading_lines; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 8 | ▶ | if ( defined $options->{FILENAME_A} || defined $options->{FILENAME_B} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $options->{"FILENAME_A"} or defined $options->{"FILENAME_B"}
MC/DC0%0/2
defined $options->{"FILENAME_A"} or defined $options->{"FILENAME_B"}
defined $options->{"FILENAME_A"}
defined $options->{"FILENAME_B"}
Truth table33%1/3
A or B
A= defined $options->{"FILENAME_A"}B= defined $options->{"FILENAME_B"}
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | push @heading_lines, [ | ||||||||||||||||||||||||||||||||||||||||||
| 219 | map( | ||||||||||||||||||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | ( "", escape( defined $_ ? $_ : "<undef>" ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ( @{$options}{qw( FILENAME_A FILENAME_B)} ) | |||||||||||||||||||||||||||||||||||||||||
| 224 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 225 | "=", | ||||||||||||||||||||||||||||||||||||||||||
| 226 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 8 | ▶ | if ( defined $options->{MTIME_A} || defined $options->{MTIME_B} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $options->{"MTIME_A"} or defined $options->{"MTIME_B"}
MC/DC0%0/2
defined $options->{"MTIME_A"} or defined $options->{"MTIME_B"}
defined $options->{"MTIME_A"}
defined $options->{"MTIME_B"}
Truth table33%1/3
A or B
A= defined $options->{"MTIME_A"}B= defined $options->{"MTIME_B"}
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | push @heading_lines, [ | ||||||||||||||||||||||||||||||||||||||||||
| 231 | map( { | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | ( "", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_ and length $_
MC/DC0%0/2
defined $_ and length $_
defined $_
length $_
Truth table0%0/3
A and B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | escape( | ||||||||||||||||||||||||||||||||||||||||||
| 234 | ( defined $_ && length $_ ) | ||||||||||||||||||||||||||||||||||||||||||
| 235 | ? localtime $_ | ||||||||||||||||||||||||||||||||||||||||||
| 236 | : "" | ||||||||||||||||||||||||||||||||||||||||||
| 237 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 238 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | @{$options}{qw( MTIME_A MTIME_B )} | |||||||||||||||||||||||||||||||||||||||||
| 241 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 242 | "=", | ||||||||||||||||||||||||||||||||||||||||||
| 243 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 8 | ▶ | if ( defined $options->{INDEX_LABEL} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | push @heading_lines, [ "", "", "", "", "=" ] unless @heading_lines; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | $heading_lines[-1]->[0] = $heading_lines[-1]->[2] = | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $options->{INDEX_LABEL}; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | ## Not ushifting on to @{$self->{ELTS}} in case it's really big. Want | ||||||||||||||||||||||||||||||||||||||||||
| 253 | ## to avoid the overhead. | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 8 | my $four_column_mode = 0; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 8 | for my $cols ( @heading_lines, @{$self->{ELTS}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 257 | 15 | ▶ | next if $cols->[-1] eq "bar"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 8 | ▶ | if ( $cols->[0] ne $cols->[2] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | $four_column_mode = 1; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 8 | ▶ | unless ( $four_column_mode ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 7 | for my $cols ( @heading_lines, @{$self->{ELTS}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 266 | 14 | ▶ | next if $cols->[-1] eq "bar"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 7 | splice @$cols, 2, 1; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 8 | my @w = (0,0,0,0); | |||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | for my $cols ( @heading_lines, @{$self->{ELTS}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 273 | 16 | ▶ | next if $cols->[-1] eq "bar"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 8 | for my $i (0..($#$cols-1)) { | |||||||||||||||||||||||||||||||||||||||||
| 275 | 25 | ▶ | $w[$i] = length $cols->[$i] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $cols->[$i] and length $cols->[$i] > $w[$i]
MC/DC50%1/2
defined $cols->[$i] and length $cols->[$i] > $w[$i]
defined $cols->[$i]
length $cols->[$i] > $w[$i]
Truth table66%2/3
A and B
A= defined $cols->[$i]B= length $cols->[$i] > $w[$i]
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | if defined $cols->[$i] && length $cols->[$i] > $w[$i]; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 8 | ▶ | my %fmts = $four_column_mode | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | ? ( | ||||||||||||||||||||||||||||||||||||||||||
| 282 | "=" => "| %$w[0]s|%-$w[1]s | %$w[2]s|%-$w[3]s |\n", | ||||||||||||||||||||||||||||||||||||||||||
| 283 | "A" => "* %$w[0]s|%-$w[1]s * %$w[2]s|%-$w[3]s |\n", | ||||||||||||||||||||||||||||||||||||||||||
| 284 | "B" => "| %$w[0]s|%-$w[1]s * %$w[2]s|%-$w[3]s *\n", | ||||||||||||||||||||||||||||||||||||||||||
| 285 | "*" => "* %$w[0]s|%-$w[1]s * %$w[2]s|%-$w[3]s *\n", | ||||||||||||||||||||||||||||||||||||||||||
| 286 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 287 | : ( | ||||||||||||||||||||||||||||||||||||||||||
| 288 | "=" => "| %$w[0]s|%-$w[1]s |%-$w[2]s |\n", | ||||||||||||||||||||||||||||||||||||||||||
| 289 | "A" => "* %$w[0]s|%-$w[1]s |%-$w[2]s |\n", | ||||||||||||||||||||||||||||||||||||||||||
| 290 | "B" => "| %$w[0]s|%-$w[1]s |%-$w[2]s *\n", | ||||||||||||||||||||||||||||||||||||||||||
| 291 | "*" => "* %$w[0]s|%-$w[1]s |%-$w[2]s *\n", | ||||||||||||||||||||||||||||||||||||||||||
| 292 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 8 | my @args = ('', '', ''); | |||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | ▶ | push(@args, '') if $four_column_mode; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | $fmts{bar} = sprintf $fmts{"="}, @args; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 8 | $fmts{bar} =~ s/\S/+/g; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 8 | $fmts{bar} =~ s/ /-/g; | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | # Sometimes the sprintf has too many arguments, | ||||||||||||||||||||||||||||||||||||||||||
| 301 | # which results in a warning on Perl 5.021+ | ||||||||||||||||||||||||||||||||||||||||||
| 302 | # I really wanted to write: | ||||||||||||||||||||||||||||||||||||||||||
| 303 | # no warnings 'redundant'; | ||||||||||||||||||||||||||||||||||||||||||
| 304 | # but that causes a compilation error on older versions of perl | ||||||||||||||||||||||||||||||||||||||||||
| 305 | # where the warnings pragma doesn't know about 'redundant' | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | return join( "", | ||||||||||||||||||||||||||||||||||||||||||
| 309 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 24 | ▶ | sprintf( $fmts{$_->[-1]}, @$_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | } ( | ||||||||||||||||||||||||||||||||||||||||||
| 312 | ["bar"], | ||||||||||||||||||||||||||||||||||||||||||
| 313 | @heading_lines, | ||||||||||||||||||||||||||||||||||||||||||
| 314 | @heading_lines ? ["bar"] : (), | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 8 | @{$self->{ELTS}}, | |||||||||||||||||||||||||||||||||||||||||
| 316 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 317 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | @{$self->{ELTS}} = []; | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | __END__ | ||||||||||||||||||||||||||||||||||||||||||