| 1 | ## -*- Mode: CPerl -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## File: Lingua::TT::Diff.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Author: Bryan Jurish <TT/IO.pm> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Descript: TT I/O: Document diffs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package Lingua::TT::Diff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Lingua::TT::Document; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ## Globals & Constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our $DIFF = 'diff'; ##-- search in path | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | our $vl_silent = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | our $vl_error = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | our $vl_warn = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | our $vl_info = 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | our $vl_debug = 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | our $vl_trace = 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | our $VERBOSE = $vl_warn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ## Constructors etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ## $diff = CLASS_OR_OBJECT->new(%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ## + %$diff, %opts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ## ##-- sequences to compare | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ## seq1 => \@seq1, ##-- raw TT line data (default: EMPTY); see $diff->sequenceXYZ() methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ## seq2 => \@seq2, ##-- raw TT line data (default: EMPTY); see $diff->sequenceXYZ() methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ## file1 => $file1, ##-- source name for $seq1 (default: none) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ## file2 => $file2, ##-- source name for $seq2 (default: none) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ## key1 => \&keysub, ##-- keygen sub for $seq1 (default=\&ksText), called as $key=$keysub->($diff,$line) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ## key2 => \&keysub, ##-- keygen sub for $seq2 (default=\&ksText), called as $key=$keysub->($diff,$line) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ## aux1 => \%aux1, ##-- aux data: ($seq1i=>\@auxLinesBeforeSeq1i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ## aux2 => \%aux2, ##-- aux data: ($seq2i=>\@auxLinesBeforeSeq2i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ## auxEOS => $bool, ##-- if true, EOS lines will be considered "aux" data (default=false) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ## auxComments => $bool, ##-- if true, comment lines will be considered "aux" data (default=false) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ## diffopts => $opts, ##-- options passed to diff (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ## ##-- misc options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ## keeptmp => $bool, ##-- if true, temp files will not be unlinked (default=false) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ## verbose => $level, ##-- verbosity level (default: $vl_warn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ## ##-- cache data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ## tmpfile1 => $tmp1, ##-- filename: temporary key-file dump for $seq1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ## tmpfile2 => $tmp2, ##-- filename: temporary key-file dump for $seq2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ## ##-- diff data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ## hunks => \@hunks, ##-- difference hunks: [$hunk1,$hunk2,...] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ## ## + each $hunk is: [$opCode, $min1,$max1, $min2,$max2, $fix, $cmt] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ## ## + $opCode is as for traditional 'diff': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ## ## 'a' (add) : Add @$seq2[$min2..$max2], align after ($min1==$max1) of $seq1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ## ## 'd' (delete): Delete @$seq1[$min1..$max1], align after ($min2==$max2) of $seq2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ## ## 'c' (change): Replace @$seq1[$min1..$max1] with @$seq2[$min2..$max2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ## ## + $fix is one of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ## ## 0 : unresolved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ## ## $which : int (1 or 2): use corresponding item(s) of "seq${which}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ## ## \@items : ARRAY-ref: resolve conflict with \@items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ## ## + $cmt is a comment for the fix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $that = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my $diff = bless({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ##-- sequences to compare | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | seq1 => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | seq2 => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | file1=>undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | file2=>undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | key1 => \&ksText, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | key2 => \&ksText, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ##-- aux data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | aux1 => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | aux2 => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | auxEOS => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | auxComments => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | diffopts => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ##-- cache data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | keeptmp => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | verbose => $VERBOSE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | tmpfile1 => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | tmpfile2 => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ##-- diff data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | hunks => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ##-- user args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | }, ref($that)||$that); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ## $diff = $diff->reset() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ## + clears cache and diff data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $diff = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $diff->clearCache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | @{$diff->{seq1}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | @{$diff->{seq2}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | %{$diff->{aux1}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | %{$diff->{aux2}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | @{$diff->{hunks}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | delete(@$diff{qw(file1 file2)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ## $diff = $diff->clearCache() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ## + clears & unlinks cached temp files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub clearCache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clearCache: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $diff = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | #@{$diff->{seq1}} = qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | #@{$diff->{seq2}} = qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | unlink($_) foreach (grep {!$diff->{keeptmp} && defined($_)} @$diff{qw(tmpfile1 tmpfile2)}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
!$diff->{'keeptmp'} && defined $_
MC/DC0%0/2
!$diff->{'keeptmp'} && defined $_
!$diff->{'keeptmp'}
defined $_
Truth table0%0/3
not(A) && B
A= !$diff->{'keeptmp'}B= defined $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | delete(@$diff{qw(tmpfile1 tmpfile2)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ## Methods: Key Generation Subs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ## $key = $diff->ksText($line) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ## + key-generation sub: 'text' field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub ksText { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ksText: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | return ($_[1] =~ /^([^\t\n\r]*)/ ? $1 : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ## $key = $diff->ksTag($line) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ## + key-generation sub: 'tag' field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub ksTag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ksTag: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return ($_[1] =~ /^[^\t]*[\t\n\r][\n\r]*([^\t]*)/ ? $1 : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ## $key = $diff->ksAll($line) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ## + key-generation sub: entire line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub ksAll { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ksAll: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ## Methods: messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ## undef = $CLASS_OR_OBJECT->vmsg($min_level, @message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub vmsg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmsg: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my ($that,$level,@msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | print STDERR @msg if ((ref($that) ? $that->{verbose} : $VERBOSE) >= $level); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ## undef = $CLASS_OR_OBJECT->vmsg1($min_level, @message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub vmsg1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmsg1: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | $_[0]->vmsg($_[1], (ref($_[0])||$_[0]), ": ", @_[2..$#_], "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ## Methods: Sequence Selection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ##---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ## Methods: Sequence Selection: High-Level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ## $diff = $diff->seq1($src,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ## + wrapper for $diff->setSequence(1,...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub seq1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seq1: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | return $_[0]->setSequence(1,@_[1..$#_]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ## $diff = $diff->seq2($src,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ## + wrapper for $diff->setSequence(2,...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub seq2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seq2: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return $_[0]->setSequence(2,@_[1..$#_]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ## $diff = $diff->setSequence($which,$src,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ## + sets sequence $which (1 or 2) from $src | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ## + $src may be one of the following: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ## - a Lingua::TT::Sentence object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ## - a Lingua::TT::Document object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ## - a Lingua::TT::IO object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ## - a flat array-ref of line-strings (without terminating newlines) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ## - a filehandle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ## - a filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ## + implicitly calls $diff->setAux($which) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | BEGIN { *isa = \&UNIVERSAL::isa; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub setSequence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setSequence: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my ($diff,$i,$src,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $diff->vmsg1($vl_trace, "setSequence(i=$i, src=$src)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $i = $diff->checkWhich($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $rc = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if (isa($src,'Lingua::TT::Sentence')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $rc = $diff->sequenceSentence($i,$src,%opts); ##-- Lingua::TT::Sentence | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | elsif (isa($src,'Lingua::TT::Document')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $rc = $diff->sequenceDocument($i,$src,%opts); ##-- Lingua::TT::Document | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | elsif (isa($src,'Lingua::TT::IO')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $rc = $diff->sequenceIO($i,$src,%opts); ##-- Lingua::TT::IO | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | elsif (isa($src,'IO::Handle')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $rc = $diff->sequenceFile($i,$src,%opts); ##-- IO::Handle | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | elsif (isa($src,'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $rc = $diff->sequenceLines($i,$src,%opts); ##-- array of lines | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | elsif (!ref($src)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $rc = $diff->sequenceFile($i,$src,%opts); ##-- filename | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $rc = $diff->sequenceFile($i,$src,%opts); ##-- other ref; maybe a filehandle? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | return defined($rc) ? $rc->setAux($i,%opts) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | ##---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ## Methods: Sequence Selection: Aux data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ## $diff = $diff->setAux($which) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ## + auto-computes $diff->{"aux${which}"} from $diff->{"seq${which}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub setAux { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setAux: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my ($diff,$which) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $diff->vmsg1($vl_trace, "setAux(which=$which)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $which = $diff->checkWhich($which); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $seq = $diff->{"seq${which}"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $aux = $diff->{"aux${which}"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my @oseq = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | %$aux = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my ($i,$j); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | for ($i=$j=0; $i<=$#$seq; ++$i,++$j) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if ( ($diff->{auxEOS} && $seq->[$i]=~/^$/) || ($diff->{auxComments} && $seq->[$i]=~/^\%\%/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$diff->{"auxEOS"} and $seq->[$i] =~ /^$/ or $diff->{"auxComments"} and $seq->[$i] =~ /^\%\%/
$diff->{"auxEOS"} and $seq->[$i] =~ /^$/
$diff->{"auxComments"} and $seq->[$i] =~ /^\%\%/
MC/DC0%0/4
$diff->{"auxEOS"} and $seq->[$i] =~ /^$/ or $diff->{"auxComments"} and $seq->[$i] =~ /^\%\%/
$diff->{"auxEOS"}
$seq->[$i] =~ /^$/
$diff->{"auxComments"}
$seq->[$i] =~ /^\%\%/
Truth table0%0/7
A and B or C and D
A= $diff->{"auxEOS"}B= $seq->[$i] =~ /^$/C= $diff->{"auxComments"}D= $seq->[$i] =~ /^\%\%/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | push(@{$aux->{$j}}, $seq->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | --$j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | push(@oseq, $seq->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | @$seq = @oseq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ##---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ## Methods: Sequence Selection: Low-Level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | ## $which = $diff->checkWhich($which) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | ## + common sanity check for '$which' values (1 or 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | sub checkWhich { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkWhich: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($diff,$which) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | $which = 0 if (!defined($which)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ($which != 1 && $which != 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$which != 1 and $which != 2
MC/DC0%0/2
$which != 1 and $which != 2
$which != 1
$which != 2
Truth table0%0/3
A and B
A= $which != 1B= $which != 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | confess(ref($diff)."::checkWhich(): sequence \$which must be 1 or 2 (got='$which'): assuming '1'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return $which; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ## $diff = $diff->sequenceDocument($which,$doc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | ## + populate sequence $which (1 or 2) from Lingua::TT::Document $doc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | ## + calls $diff->sequenceSentence() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub sequenceDocument { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequenceDocument: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my ($diff,$which,$doc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $which = $diff->checkWhich($which); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $diff->{"file${which}"} = "$doc"; ##-- ugly but at least non-empty | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | @{$diff->{"seq${which}"}} = map {join("\t",@$_)} @{$doc->flat}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ## $diff = $diff->sequenceSentence($which,$sent) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ## + populate sequence $which (1 or 2) from Lingua::TT::Sentence $sent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub sequenceSentence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequenceSentence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my ($diff,$which,$sent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $which = $diff->checkWhich($which); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $diff->{"file${which}"} = "$sent"; ##-- ugly but at least non-empty | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | @{$diff->{"seq${which}"}} = map {join("\t",@$_)} @$sent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ## $diff = $diff->sequenceLines($which,\@lines) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ## + populate sequence $which (1 or 2) from \@lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub sequenceLines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequenceLines: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my ($diff,$which,$lines) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $which = $diff->checkWhich($which); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $diff->{"file${which}"} = "$lines"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | @{$diff->{"seq${which}"}} = @$lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | ## $diff = $diff->sequenceIO($which,$ttio) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ## + populate sequence $which (1 or 2) from Lingua::TT::IO $ttio | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub sequenceIO { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequenceIO: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my ($diff,$which,$ttio) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $which = $diff->checkWhich($which); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $diff->{"file${which}"} = $ttio->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | @{$diff->{"seq${which}"}} = $ttio->getLines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | ## $diff = $diff->sequenceFile($which,$filename_or_fh,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ## + generate sequence $which (1 or 2) from $filename_or_fh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | ## + %opts are passed to Lingua::TT::IO->new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub sequenceFile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequenceFile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my ($diff,$which,$file,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return $diff->sequenceIO($which,Lingua::TT::IO->fromFile($file,%opts)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ## Methods: Comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | ## $diff = $diff->compare() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ## $diff = $diff->compare($src2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ## $diff = $diff->compare($src1,$src2,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | ## + compare currently selected sequences, wrapping setSequence() calls if required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | sub compare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my ($diff,$src1,$src2,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $diff->vmsg1($vl_trace, "compare(src1=$src1, $src2=src2)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ##-- args: sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | $diff->seq1($src1,%opts) if (defined($src1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | $diff->seq2($src2,%opts) if (defined($src2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ##-- sanity check(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | confess(ref($diff)."::compare(): {seq1} undefined!") if (!$diff->{seq1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | confess(ref($diff)."::compare(): {seq2} undefined!") if (!$diff->{seq2}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ##-- create temp files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $file1 = $diff->seqTempFile(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $file2 = $diff->seqTempFile(2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | ##-- compute & parse the diff (external call) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $diff->vmsg1($vl_trace, "compare(): SYSTEM $DIFF $diff->{diffopts} $file1 $file2"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | my $fh = IO::File->new("$DIFF $diff->{diffopts} $file1 $file2|") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | or die(ref($diff)."::compare(): could not open pipe from system diff '$DIFF': $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | binmode($fh,':utf8'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my ($op,$min1,$min2,$max1,$max2) = ('',0,0,0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | @{$diff->{hunks}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $hunks = $diff->{hunks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my ($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | while (defined($line=<$fh>)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ($line =~ /^(\d+)(?:\,(\d+))?([acd])(\d+)(?:\,(\d+))?$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ($min1,$max1, $op, $min2,$max2) = ($1,$2, $3, $4,$5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | next; ##-- ignore | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if ($op eq 'a') { $max1=$min1++; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | elsif ($op eq 'd') { $max2=$min2++; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | $max1 = $min1 if (!defined($max1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | $max2 = $min2 if (!defined($max2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | push(@$hunks, [$op, map {$_-1} $min1,$max1,$min2,$max2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $fh->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ##-- unlink temp files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if (!$diff->{keeptmp}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | unlink($file1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | unlink($file2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | delete(@$diff{qw(tmpfile1 tmpfile2)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ##---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ## Methods: Comparison: Low-Level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | ## $tmpfile = $diff->seqTempFile($which) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | ## + creates temporary key-dump file $seq->{"tmpfile${which}"} for $diff->{"seq${which}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | sub seqTempFile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seqTempFile: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my ($diff,$which) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | $diff->vmsg1($vl_trace, "seqTempFile(which=$which)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | ##-- sanity check(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $which = $diff->checkWhich($which); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | confess(ref($diff)."::seqFile($which): sequence '$which' is not defined!") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | if (!$diff->{"seq${which}"}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my ($fh,$filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if (!defined($filename=$diff->{"tmpfile${which}"})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | ##-- get tempfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ($fh,$filename) = File::Temp::tempfile("ttdiff_XXXX", SUFFIX=>'.t0', UNLINK=>(!$diff->{keeptmp}) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | confess(ref($diff)."::seqFile($which): open failed for '$filename': $!") if (!defined($fh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $fh = IO::File->new(">$filename"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | confess(ref($diff)."::seqFile($which): open failed for '$filename': $!") if (!defined($fh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | binmode($fh,':utf8'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $diff->{"tmpfile${which}"} = $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ##-- dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $keysub = $diff->{"key${which}"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if (defined($keysub)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $fh->print(map {$keysub->($diff,$_)."\n"} @{$diff->{"seq${which}"}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $fh->print(@{$diff->{"seq${which}"}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $fh->close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ## Methods: Application / Resolution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | ## \@seq = $diff->apply(%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | ## + get "fixed" sequence from fully populated diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ## prefer => $which, ##-- prefer/project which sequence (1 or 2); default=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ## fix => $bool, ##-- allow fixes to override preference? default=true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | ## aux1 => $bool, ##-- include aux1 items? (default: ($prefer==1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | ## aux2 => $bool, ##-- include aux2 items? (default: ($prefer==2)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: not called CC=41 SCAR=74.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my ($diff,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ##-- defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | %opts = (prefer=>1,fix=>1,%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my $pref = $opts{prefer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $pfix = $opts{fix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | my $dump_aux1 = defined($opts{aux1}) ? $opts{aux1} : ($pref==1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | my $dump_aux2 = defined($opts{aux2}) ? $opts{aux2} : ($pref==2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | ##-- output sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $seq3 = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ##-- loop: vars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my ($seq1,$seq2,$aux1,$aux2,$hunks) = @$diff{qw(seq1 seq2 aux1 aux2 hunks)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my ($hunk,$hmax); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my ($op,$min1,$max1,$min2,$max2, $fix) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my ($i1,$i2) = (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | foreach $hunk (@$hunks) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ($op,$min1,$max1,$min2,$max2,$fix) = @$hunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ##-- leading context: shared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | if (0) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | ##-- ORIG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | push(@$seq3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | (($dump_aux1 && exists($aux1->{$i1+$_}) ? @{$aux1->{$i1+$_}} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | ($dump_aux2 && exists($aux2->{$i2+$_}) ? @{$aux2->{$i2+$_}} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | ($pref==1 ? $seq1->[$i1+$_] : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | ($pref==2 ? $seq2->[$i2+$_] : qw())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } (0..($min1-$i1-1))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | ##-- DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | foreach (0..($min1-$i1-1)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | push(@$seq3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | (($dump_aux1 && exists($aux1->{$i1+$_}) ? @{$aux1->{$i1+$_}} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dump_aux2 and exists $$aux2{$i2 + $_}
MC/DC0%0/2
$dump_aux2 and exists $$aux2{$i2 + $_}
$dump_aux2
exists $$aux2{$i2 + $_}
Truth table0%0/3
A and B
A= $dump_aux2B= exists $$aux2{$i2 + $_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | ($dump_aux2 && exists($aux2->{$i2+$_}) ? @{$aux2->{$i2+$_}} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$dump_aux1 and exists $$aux1{$i1 + $_}
MC/DC0%0/2
$dump_aux1 and exists $$aux1{$i1 + $_}
$dump_aux1
exists $$aux1{$i1 + $_}
Truth table0%0/3
A and B
A= $dump_aux1B= exists $$aux1{$i1 + $_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | ($pref==1 ? $seq1->[$i1+$_] : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ($pref==2 ? $seq2->[$i2+$_] : qw())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ##-- current item (hunk-internal) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if (!$pfix || !ref($fix)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$pfix && ref $fix
MC/DC0%0/2
$pfix && ref $fix
$pfix
ref $fix
Truth table0%0/3
A && B
A= $pfixB= ref $fix
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | $fix = [@$seq1[$min1..$max1]] if ($pfix ? (!$fix || $fix==1) : ($pref==1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $fix or $fix == 1
MC/DC0%0/2
not $fix or $fix == 1
not $fix
$fix == 1
Truth table0%0/3
not(A) or B
A= not $fixB= $fix == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | $fix = [@$seq2[$min2..$max2]] if ($pfix ? (!$fix || $fix==2) : ($pref==2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $fix or $fix == 2
MC/DC0%0/2
not $fix or $fix == 2
not $fix
$fix == 2
Truth table0%0/3
not(A) or B
A= not $fixB= $fix == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ▶ | }elsif (ref($fix) && $pref==1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $fix and $pref == 1
MC/DC0%0/2
ref $fix and $pref == 1
ref $fix
$pref == 1
Truth table0%0/3
A and B
A= ref $fixB= $pref == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $fix = [ map {s/(?:^|\t)\>[^\t]*//g; s/(^|\t)[\~\<]/$1/g; $_} @$fix ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ▶ | } elsif (ref($fix) && $pref==2) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $fix and $pref == 2
MC/DC0%0/2
ref $fix and $pref == 2
ref $fix
$pref == 2
Truth table0%0/3
A and B
A= ref $fixB= $pref == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $fix = [ map {s/(?:^|\t)\<[^\t]*//g; s/(^|\t)[\~\>]/$1/g; $_} @$fix ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $hmax = ($max1-$min1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | $hmax = ($max2-$min2) if ($hmax < $max2-$min2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | $hmax = $#$fix if ($hmax < $#$fix); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | push(@$seq3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | (($min1+$_<=$max1 && $dump_aux1 && exists($aux1->{$min1+$_}) ? @{$aux1->{$min1+$_}} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$min2 + $_ <= $max2 and $dump_aux2 and exists $$aux2{$min2 + $_}
$min2 + $_ <= $max2 and $dump_aux2
MC/DC0%0/3
$min2 + $_ <= $max2 and $dump_aux2 and exists $$aux2{$min2 + $_}
$min2 + $_ <= $max2
$dump_aux2
exists $$aux2{$min2 + $_}
Truth table0%0/4
A and B and C
A= $min2 + $_ <= $max2B= $dump_aux2C= exists $$aux2{$min2 + $_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | ($min2+$_<=$max2 && $dump_aux2 && exists($aux2->{$min2+$_}) ? @{$aux2->{$min2+$_}} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$min1 + $_ <= $max1 and $dump_aux1 and exists $$aux1{$min1 + $_}
$min1 + $_ <= $max1 and $dump_aux1
MC/DC0%0/3
$min1 + $_ <= $max1 and $dump_aux1 and exists $$aux1{$min1 + $_}
$min1 + $_ <= $max1
$dump_aux1
exists $$aux1{$min1 + $_}
Truth table0%0/4
A and B and C
A= $min1 + $_ <= $max1B= $dump_aux1C= exists $$aux1{$min1 + $_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ($_ <= $#$fix ? $fix->[$_] : qw())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } (0..$hmax)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ##-- update current position counters (with safety checks for hacked diffs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | #$max1 = $min1 if ($min1>$max1); ##-- BAD for 'a' ("add") ops: see notes.fix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | #$max2 = $min2 if ($min2>$max2); ##-- (?)BAD for 'd' ("del") ops: see notes.fix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | $i1 = $max1+1 if ($max1 >= $i1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | $i2 = $max2+1 if ($max2 >= $i2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | ##-- trailing context: shared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | push(@$seq3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | (($dump_aux1 && exists($aux1->{$i1+$_}) ? @{$aux1->{$i1+$_}} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dump_aux2 and exists $$aux2{$i2 + $_}
MC/DC0%0/2
$dump_aux2 and exists $$aux2{$i2 + $_}
$dump_aux2
exists $$aux2{$i2 + $_}
Truth table0%0/3
A and B
A= $dump_aux2B= exists $$aux2{$i2 + $_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | ($dump_aux2 && exists($aux2->{$i2+$_}) ? @{$aux2->{$i2+$_}} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$dump_aux1 and exists $$aux1{$i1 + $_}
MC/DC0%0/2
$dump_aux1 and exists $$aux1{$i1 + $_}
$dump_aux1
exists $$aux1{$i1 + $_}
Truth table0%0/3
A and B
A= $dump_aux1B= exists $$aux1{$i1 + $_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ($pref==1 ? $seq1->[$i1+$_] : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | ($pref==2 ? $seq2->[$i2+$_] : qw())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } (0..($#$seq1-$i1))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | return wantarray ? @$seq3 : $seq3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | ##-- DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | sub _strtext { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strtext: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $str =~ s/\t.*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | sub bugstr { my $s=shift; $s=~s/\t/ /g; return '"'.$s.'"'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bugstr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | sub bugline { my ($i,$i1,$i2,$seq1,$seq2) = @_; return sprintf(" %3d %d %d %-24s %s", $i, $i1+$i, $i2+$i, bugstr($seq1->[$i1+$i]), bugstr($seq2->[$i2+$i])); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bugline: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | ## Methods: Alignment extraction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ## \@alignment = $diff->alignment() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | ## + returns an array-of-arrays of alignment items \@alignment = [ \@item1, \@item2, ... ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | ## where each \@item = [ $i1, $i2, $hunk ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | ## + $hunk is undef for shared items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | ## + $i1, $i2 are indices into $diff->{seq1} and $diff->{seq2} respectively | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | sub alignment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alignment: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my $diff = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my ($i1,$i2) = (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my ($seq1,$seq2,$hunks) = @$diff{qw(seq1 seq2 hunks)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my @align = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my ($hunk, $op,$min1,$max1,$min2,$max2, $fix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | foreach $hunk (@$hunks) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ($op,$min1,$max1,$min2,$max2,$fix) = @$hunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | push(@align, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | ##-- shared preceding context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | (map {[$i1+$_, $i2+$_]} (0..($min1-$i1-1))), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ##-- hunk content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | (map {[$_, undef, $hunk]} (($min1+0)..($max1+0))), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | (map {[undef, $_, $hunk]} (($min2+0)..($max2+0))), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | ##-- update current position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ($i1,$i2) = ($max1+1,$max2+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | ##-- shared trailing context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | push(@align, map {[$i1+$_, $i2+$_]} (0..($#$seq1-$i1-1))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | return \@align; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | ## Methods: I/O | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | ##---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | ## Methods: I/O: Low-Level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ## $sharedStr = $diff->sharedString($seq1i,$seq2i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | sub sharedString { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sharedString: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my ($diff,$i1,$i2) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | my $str1 = $i1 >= 0 && $i1 <= $#{$diff->{seq1}} ? $diff->{seq1}[$i1] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$i1 >= 0 and $i1 <= $#{$$diff{"seq1"};}
MC/DC0%0/2
$i1 >= 0 and $i1 <= $#{$$diff{"seq1"};}
$i1 >= 0
$i1 <= $#{$$diff{"seq1"};}
Truth table0%0/3
A and B
A= $i1 >= 0B= $i1 <= $#{$$diff{"seq1"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | my $str2 = $i2 >= 0 && $i2 <= $#{$diff->{seq2}} ? $diff->{seq2}[$i2] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$i2 >= 0 and $i2 <= $#{$$diff{"seq2"};}
MC/DC0%0/2
$i2 >= 0 and $i2 <= $#{$$diff{"seq2"};}
$i2 >= 0
$i2 <= $#{$$diff{"seq2"};}
Truth table0%0/3
A and B
A= $i2 >= 0B= $i2 <= $#{$$diff{"seq2"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | my @w1 = defined($str1) ? split(/[\t\n\r]/,$str1) : qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | my @w2 = defined($str2) ? split(/[\t\n\r]/,$str2) : qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | my @w12 = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | (defined($w1[$_]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | ? (defined($w2[$_]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | ? ($w1[$_] eq $w2[$_] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | ? "~$w1[$_]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | : "<$w1[$_]\t>$w2[$_]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | : "<$w1[$_]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | : (defined($w2[$_]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | ? ">$w2[$_]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | : '')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } (0..($#w1 > $#w2 ? $#w1 : $#w2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | return join("\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | ($diff->{"aux1"}{$i1} ? (map {"#< $_"} @{$diff->{aux1}{$i1}}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | ($diff->{"aux2"}{$i2} ? (map {"#> $_"} @{$diff->{aux2}{$i2}}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | ('~ '.join("\t", @w12)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | )."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | ## $str = $diff->singleString($which,$i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | sub singleString { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
singleString: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my ($diff,$which,$i) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | my $chr = $which==1 ? '<' : '>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | return join("\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | ($diff->{"aux${which}"}{$i} ? (map {"#${chr} $_"} @{$diff->{"aux${which}"}{$i}}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | ($i <= $#{$diff->{"seq${which}"}} ? ("${chr} ".$diff->{"seq${which}"}[$i]) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | )."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | ##---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | ## Methods: I/O: Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | ## $diff = $diff->saveTextFile($filename_or_fh,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | ## + stores text representation of $diff to $filename_or_fh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | ## syntax => $bool, ##-- store syntax help? (default=1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | ## context => $n, ##-- number of context lines (undef or <0 for full; default=-1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | ## $diff = $diff->saveTextFile($filename_or_fh,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | ## + stores text representation of $diff to $filename_or_fh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | ## syntax => $bool, ##-- store syntax help? (default=1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | ## context => $n, ##-- number of context lines (undef or <0 for full; default=-1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | sub saveTextFile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saveTextFile: not called CC=22 SCAR=62.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my ($diff,$file,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | $diff->vmsg1($vl_trace, "saveTextFile(", ($opts{filename}||$file), ")"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{'filename'} || $file
MC/DC0%0/2
$opts{'filename'} || $file
$opts{'filename'}
$file
Truth table0%0/3
A || B
A= $opts{'filename'}B= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | my $fh = ref($file) ? $file : IO::File->new(">$file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | confess(ref($diff)."::saveTextFile(): open failed for '$file': $!") if (!defined($fh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | binmode($fh,':utf8'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | ##-- options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my @optkeys = qw(header files shared context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | %opts = ((map {($_=>$diff->{$_})} @optkeys),syntax=>1,context=>-1,%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | my $k = defined($opts{context}) ? $opts{context} : -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | ##-- dump: header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | $fh->print("%% -*- Mode: Diff; encoding: utf-8 -*-\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | (("%" x 80), "\n"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | "%% File auto-generated by ", ref($diff), "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | "%% File Format:\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | "%% \% COMMENT : comment\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | "%% \$ NAME: VALUE : ".ref($diff)." object data field\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | "%% \@ OP MIN1,MAX1 MIN2,MAX2 :FIX? CMT? : diff hunk address (0-based), fix = '0' (none), '\@' (user), '1' or '2' (file)\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | "%% < LINE1 : (\"deleted\") line in file1 only\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | "%% > LINE2 : (\"inserted\") line in file2 only\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | "%% ~ LINE_BOTH : (\"matched\") with field prefixes)\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | "%% = LINE_FIXED : (\"fixed\") conflict resolution for FIX=\@\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | "%% #< AUX1 : (\"ignored1\") diff-irrelevant line from file1\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | "%% #> AUX2 : (\"ignored2\") diff-irrelevant line from file2\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | (("%" x 80), "\n"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | ) if ($opts{syntax}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | $fh->print("\$ file1: $diff->{file1}\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | "\$ file2: $diff->{file2}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | "\$ context: $k\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | "\$ auxEOS: $diff->{auxEOS}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | "\$ auxComments: $diff->{auxComments}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | ) if (1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | ##-- get alignment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $align = $diff->alignment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ##-- dump: sequences + hunks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | my ($i1,$i2) = (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | my ($fmin1,$fmax1,$fmin2,$fmax2); ##-- finite-context vars | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my ($seq1,$seq2,$hunks) = @$diff{qw(seq1 seq2 hunks)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my ($hunk, $op,$min1,$max1,$min2,$max2,$fix,$cmt, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | ##-- dump: full context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my ($ai,$aitem); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | foreach $hunk (@{$diff->{hunks}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ($op,$min1,$max1,$min2,$max2,$fix,$cmt) = @$hunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | if ($k < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | ##-- full context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | ##-- full context: dump preceding context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $fh->print(map { $diff->sharedString($i1+$_, $i2+$_) } (0..($min1-$i1-1))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | ##-- full context: dump hunk data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $addr = "\@ $op $min1,$max1 $min2,$max2"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | $addr .= (defined($fix) ? (ref($fix) ? ' :@' : " :$fix") : ' :0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | $addr .= ' '.(defined($cmt) ? $cmt : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | $fh->print($addr, "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | (map {$diff->singleString(1, $_)} (($min1+0)..($max1+0))), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | (map {$diff->singleString(2, $_)} (($min2+0)..($max2+0))), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | (ref($fix) ? (map {"= $_\n"} @$fix) : qw()), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | ##-- full context: update current position counters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ($i1,$i2) = ($max1+1,$max2+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | ##-- finite context: positions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | $fmin1 = ($min1 >= $k ? ($min1-$k) : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | $fmin2 = ($min2 >= $k ? ($min2-$k) : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | $fmax1 = $max1+$k+1 <= $#$seq1 ? ($max1+$k+1) : $#$seq1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | $fmax2 = $max2+$k+1 <= $#$seq2 ? ($max2+$k+1) : $#$seq2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | ##-- finite context: hunk address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $addr = "\@ $op ($fmin1 $fmin2) $min1,$max1 $min2,$max2"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | $addr .= (defined($fix) ? (ref($fix) ? ' :@' : " :$fix") : ' :0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | $addr .= ' '.(defined($cmt) ? $cmt : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | ##-- finite context: dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | $fh->print( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | ##-- leading separator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | "********\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | ##-- address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | $addr, "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | ##-- leading context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | (map { $diff->sharedString($min1+$_, $min2+$_) } (-$k..-1)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | ##-- hunk data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | (map {$diff->singleString(1, $_)} (($min1+0)..($max1+0))), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | (map {$diff->singleString(2, $_)} (($min2+0)..($max2+0))), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | (ref($fix) ? (map {"= $_\n"} @$fix) : qw()), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | ##-- trailing context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | (map { $diff->sharedString($max1+$_, $max2+$_) } (1..$k)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | ##-- dump trailing context (full dump only) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | if ($k<0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | $fh->print(map { $diff->sharedString($i1+$_, $i2+$_) } (0..($#$seq1-$i1))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | ##-- final trailing separator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | $fh->print("********\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | $fh->close() if (!ref($file)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | ## $diff = $CLASS_OR_OBJ->loadTextFile($filename_or_fh,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | ## + %opts: (none) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | sub loadTextFile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadTextFile: not called CC=28 SCAR=67.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | my ($diff,$file,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | $diff = $diff->new if (!ref($diff)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | $diff->vmsg1($vl_trace, "loadTextFile($file)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | my $fh = ref($file) ? $file : IO::File->new("<$file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | confess(ref($diff)."::loadTextFile(): open failed for '$file': $!") if (!defined($fh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | binmode($fh,':utf8'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | ##-- load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | @{$diff->{hunks}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | @{$diff->{seq1}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | @{$diff->{seq2}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | %{$diff->{aux1}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | %{$diff->{aux2}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my ($hunks,$seq1,$seq2,$aux1,$aux2) = @$diff{qw(hunks seq1 seq2 aux1 aux2)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | my ($i1,$i2) = (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | my ($line, $hunk); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my (@w1,@w2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | while (defined($line=<$fh>)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | chomp($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | if ($line =~ /^\%/) { ; } ##-- comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | elsif ($line =~ /^\$\s+(\w+):\s+(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | ##-- object data field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | $diff->{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | elsif ($line =~ /^\@ ([acd]) (?:\((\-?\d+) (\-?\d+)\) )?(\-?\d+),(\-?\d+) (\-?\d+),(\-?\d+)(?: \: ?([\d\@\?]+)\s{0,1}(.*))?$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | ##-- hunk address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | ($i1,$i2) = ($2+0,$3+0) if (defined($2) && defined($3)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $2 and defined $3
MC/DC0%0/2
defined $2 and defined $3
defined $2
defined $3
Truth table0%0/3
A and B
A= defined $2B= defined $3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | push(@$hunks, $hunk=[$1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | (map {$_+0} ($4,$5,$6,$7)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $8 and $8 ne "?"
MC/DC0%0/2
defined $8 and $8 ne "?"
defined $8
$8 ne "?"
Truth table0%0/3
A and B
A= defined $8B= $8 ne "?"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | (defined($8) && $8 ne '?' ? $8 : '0'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | (defined($9) ? $9 : qw())]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | $hunk->[5] = [] if ($hunk->[5] && $hunk->[5] eq '@'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$hunk->[5] and $hunk->[5] eq "\@"
MC/DC0%0/2
$hunk->[5] and $hunk->[5] eq "\@"
$hunk->[5]
$hunk->[5] eq "\@"
Truth table0%0/3
A and B
A= $hunk->[5]B= $hunk->[5] eq "\@"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | elsif ($line =~ /^~ /) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | ##-- shared sequence item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | @w1 = @w2 = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | substr($line,0,2,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | while ($line =~ /([\=\~\<\>])([^\t\n\r]*)/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | push(@w1, $2) if ($1 ne '>'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | push(@w2, $2) if ($1 ne '<'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | $seq1->[$i1++] = join("\t",@w1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | $seq2->[$i2++] = join("\t",@w2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | elsif ($line =~ /^\< (.*)$/) { ##-- seq1-only item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | $seq1->[$i1++] = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | elsif ($line =~ /^\> (.*)$/) { ##-- seq2-only item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | $seq2->[$i2++] = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | elsif ($line =~ /^\#\< (.*)$/) { ##-- seq1-aux item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | push(@{$diff->{aux1}{$i1}}, $1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | elsif ($line =~ /^\#\> (.*)$/) { ##-- seq2-aux item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | push(@{$diff->{aux2}{$i2}}, $1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | elsif ($line =~ /^\= (.*)$/) { ##-- fix item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | warn(ref($diff)."::loadTextFile($file): ignoring fix without current hunk: '$line'") if (!$hunk); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | $hunk->[5] = [] if (!ref($hunk->[5])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | push(@{$hunk->[5]}, $1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | elsif ($line =~ /^[\-\*]+$/) { ##-- separator: ignore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | warn(ref($diff)."::loadTextFile($file): parse error at line ", $fh->input_line_number, ", ignoring: '$line'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | $fh->close() if (!ref($file)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | ## Footer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||