| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## cdif: word context diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Copyright (c) 1992- Kazumasa Utashiro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## Original version on Mar 11 1992 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 14 | ▶ | use v5.14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 14 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 14 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 14 | ▶ | use Encode::Guess; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 14 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 14 | ▶ | use List::Util qw(first sum pairmap); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 14 | ▶ | use Text::ParseWords qw(shellwords); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 14 | ▶ | use IO::Divert; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 14 | ▶ | use Text::VisualWidth::PP qw(vwidth); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 14 | ▶ | use Data::Dumper; { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 14 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | *Data::Dumper::qquote = sub { qq["${\(shift)}"] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 14 | $Data::Dumper::Terse = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 14 | $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 14 | $Data::Dumper::Useperl = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 14 | ▶ | use App::sdif; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 14 | our $VERSION = $App::sdif::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 14 | ▶ | use App::sdif::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 14 | ▶ | use App::cdif::Command::Mecab; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ## options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 14 | ▶ | use charnames ':full'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 14 | my %visible = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | nul => [ 1, "\000" => "\N{SYMBOL FOR NULL}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | soh => [ 1, "\001" => "\N{SYMBOL FOR START OF HEADING}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | bel => [ 1, "\007" => "\N{SYMBOL FOR BELL}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | bs => [ 1, "\010" => "\N{SYMBOL FOR BACKSPACE}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ht => [ 0, "\011" => "\N{SYMBOL FOR HORIZONTAL TABULATION}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | nl => [ 0, "\012" => "\N{SYMBOL FOR NEWLINE}" . "\n" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | vt => [ 1, "\013" => "\N{SYMBOL FOR VERTICAL TABULATION}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | np => [ 1, "\014" => "\N{SYMBOL FOR FORM FEED}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | cr => [ 1, "\015" => "\N{SYMBOL FOR CARRIAGE RETURN}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | esc => [ 1, "\033" => "\N{SYMBOL FOR ESCAPE}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | sp => [ 0, "\040" => "\N{SYMBOL FOR SPACE}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | del => [ 1, "\177" => "\N{SYMBOL FOR DELETE}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | nbsp => [ 1, "\x{00A0}" => "\N{OPEN BOX}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | nnbsp => [ 1, "\x{202F}" => "\N{OPEN BOX}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ensp => [ 1, "\x{2002}" => "\N{OPEN BOX}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | emsp => [ 1, "\x{2003}" => "\N{OPEN BOX}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | thinsp => [ 1, "\x{2009}" => "\N{OPEN BOX}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | hairsp => [ 1, "\x{200A}" => "\N{OPEN BOX}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | zwsp => [ 1, "\x{200B}" => "\N{OPEN BOX}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | idesp => [ 1, "\x{3000}" => "\N{OPEN BOX}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 14 | my %opt_visible = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 14 | map { $_ => splice @{$visible{$_}}, 0, 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | keys %visible; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 14 | my @rcsopt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | my @diffopts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 14 | my @sub_diffopts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 14 | binmode STDOUT, ":encoding(utf8)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 14 | binmode STDERR, ":encoding(utf8)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 14 | ▶ | if (my $env = $ENV{'CDIFOPTS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | unshift(@ARGV, shellwords($env)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 14 | my $unit_default = 'word'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 14 | my $prefix_default = q/(?:\\| )*(?: )*/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 14 | my $app; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 14 | ▶ | use Getopt::EX::Hashed; { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 14 | Getopt::EX::Hashed->configure( DEFAULT => [ is => 'rw' ] ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 14 | has help => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 14 | has version => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 14 | has man => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 14 | has debug => ' d =s@ ' , default => [] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 14 | has diff => ' =s ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 14 | has subdiff => ' =s ' , default => 'diff' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 14 | has color => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 14 | has 256 => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 14 | has commandcolor => ' cc ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 14 | has markcolor => ' mc ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 14 | has textcolor => ' tc ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 14 | has unknowncolor => ' uc ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 14 | has colormap => ' cm =s@ ' , default => [] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 14 | has colordump => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 14 | has sdif => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 14 | has stat => ' ! ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 14 | has unit => ' by :s ' , default => $unit_default , | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | , any => [ qw(char word letter mecab 0), '' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 14 | has show_old => ' ! ' , default => 1 , alias => 'old' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 14 | has show_new => ' ! ' , default => 1 , alias => 'new' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 14 | has show_mrg => ' ! ' , default => 1 , alias => 'mrg' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 14 | has command => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 14 | has unknown => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 14 | has mark => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 14 | has prefix => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 14 | has prefix_pattern => ' =s ' , default => $prefix_default ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 14 | has visible => ' =s@ ' , default => [] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 14 | has lenience => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 14 | has limit => ' =s% ' , default => { length => 1000 } ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 14 | has linebyline => ' :2 ' , alias => 'lxl'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 14 | has style => ' =s ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 14 | has ignore_case => 'i' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 14 | has ignore_space_change => 'b' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 14 | has ignore_all_space => 'w' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 14 | has expand_tabs => 't' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 14 | has rcs => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | ▶ | has '+sdif' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | $app->commandcolor = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | $app->markcolor = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | $app->textcolor = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | $app->unknowncolor = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 14 | } ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | has mecab => '!', action => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $app->unit = $_[1] ? 'mecab' : $unit_default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 14 | } ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | has c => ' ' , action => sub { push @diffopts, "-c" } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | has u => ' ' , action => sub { push @diffopts, "-u" } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | has context => ' C =i ' , action => sub { push @diffopts, "-C" . $_[1] } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 14 | ▶ | has unified => ' U =i ' , action => sub { push @diffopts, "-U" . $_[1] } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | has r => ' =s ' , action => sub { push @rcsopt, "-r$_[1]" } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | has q => ' ' , action => sub { push @rcsopt, "-q" } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | has '+help' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | pod2usage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | -sections => [ qw(SYNOPSIS VERSION) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 14 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | has '+man' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | pod2usage -verbose => 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 14 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | has '+version' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | print "$VERSION\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 14 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 14 | ▶ | } no Getopt::EX::Hashed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 14 | ▶ | $app = Getopt::EX::Hashed->new() or die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 14 | ▶ | use Getopt::EX::Long qw(:DEFAULT Configure ExConfigure); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 14 | ExConfigure BASECLASS => [ "App::cdif", "Getopt::EX" ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 14 | Configure("bundling"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 14 | ▶ | $app->getopt || usage({status => 1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my %debug = map { $_ => 1 } map { split // } @{$app->debug}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 14 | $App::sdif::Util::NO_WARNINGS = $app->lenience; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 14 | ▶ | $App::cdif::Command::Mecab::debug = 1 if $debug{m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 14 | ▶ | $app->rcs++ if @rcsopt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 14 | ▶ | my $diff = $app->diff || ($app->rcs ? 'rcsdiff' : 'diff'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$app->diff || ($app->rcs ? 'rcsdiff' : 'diff')
MC/DC0%0/2
$app->diff || ($app->rcs ? 'rcsdiff' : 'diff')
$app->diff
($app->rcs ? 'rcsdiff' : 'diff')
Truth table33%1/3
A || B
A= $app->diffB= ($app->rcs ? 'rcsdiff' : 'diff')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | push @diffopts, map { $_->[1] } grep { $_->[0] } ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | [ $app->ignore_case, "-i" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | [ $app->ignore_space_change, "-b" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | [ $app->ignore_all_space, "-w" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | [ $app->expand_tabs, "-t" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | push @sub_diffopts, map { $_->[1] } grep { $_->[0] } ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | [ $app->ignore_case, "-i" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | [ $app->ignore_all_space, "-w" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 14 | my %colormap = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 14 | ▶ | my $col = $app->{256} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 238 | ▶ | pairmap { $a => (ref $b eq 'ARRAY') ? $b->[$col] : $b } ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 14 | UNKNOWN => "" , | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | UMARK => [ "/444" , "/w" ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | CMARK => "GS" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | OMARK => "CS" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | NMARK => "MS" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | MMARK => "YS" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | UTEXT => "" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | CTEXT => "G" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | OTEXT => "C" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | NTEXT => "M" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | MTEXT => "Y" , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | COMMAND => [ "555/222E" , "w/kE" ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | OCHANGE => [ "K/445" , "B/w" ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | NCHANGE => [ "K/445" , "B/w" ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | DELETE => [ "K/544" , "R/w" ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | APPEND => [ "K/544" , "R/w" ] , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | VISIBLE => "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 14 | ▶ | use Getopt::EX::Colormap qw(ansi_code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | my $color_handler = Getopt::EX::Colormap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | ->new(HASH => \%colormap) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 14 | ->load_params(@{$app->colormap}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 14 | for ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | [ $app->unknowncolor => q/UNKNOWN/ ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | [ $app->commandcolor => q/COMMAND/ ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | [ $app->markcolor => q/MARK/ ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | [ $app->textcolor => q/TEXT/ ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 56 | my($color, $label) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 56 | ▶ | $color and next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 16 | for (grep /$label/, keys %colormap) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 48 | $colormap{$_} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 14 | ▶ | warn 'colormap = ', Dumper \%colormap if $debug{c}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 14 | ▶ | if ($app->colordump) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | print $color_handler->colormap( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | name => '--changeme', option => '--colormap'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1414 | ▶ | sub color { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1414 | $color_handler->color(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 14 | my $prefix_re = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 14 | ▶ | if ($app->prefix) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 14 | qr/$app->{prefix_pattern}/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 14 | my $DIFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | my $OLD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 14 | my $NEW; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 14 | ▶ | if ($app->rcs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | my $rcsfile = shift || usage("No RCS filename\n\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift @ARGV || usage("No RCS filename\n\n")
MC/DC0%0/2
shift @ARGV || usage("No RCS filename\n\n")
shift @ARGV
usage("No RCS filename\n\n")
Truth table0%0/3
A || B
A= shift @ARGVB= usage("No RCS filename\n\n")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $DIFF = "$diff @diffopts @rcsopt $rcsfile|"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } elsif (@ARGV == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | ($OLD, $NEW) = splice(@ARGV, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | $DIFF = "$diff @diffopts $OLD $NEW |"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } elsif (@ARGV < 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 10 | ▶ | $DIFF = shift || '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift @ARGV || '-'
MC/DC100%1/1
shift @ARGV || '-'
shift @ARGV
Truth table100%2/2
A
A= shift @ARGV
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | usage("Arguments error.\n\n") if @ARGV; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 14 | ▶ | warn "DIFF = \"$DIFF\"\n" if $debug{f}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 14 | my %func = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 14 | ▶ | my $col = $app->color ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 70 | ▶ | pairmap { $a => $b->[$col] } ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | DELETE => [ sub { color("DELETE", @_) }, \&bd ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | APPEND => [ sub { color("APPEND", @_) }, \&bd ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 448 | ▶ | OLD => [ sub { color("OCHANGE", @_) }, \&ul ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 448 | ▶ | NEW => [ sub { color("NCHANGE", @_) }, \&ul ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 14 | ▶ | UNKNOWN => [ sub { color("UNKNOWN", @_) }, undef ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 14 | my $w_pattern = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 14 | ▶ | if ($app->unit =~ /^char/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | qr/\X/s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 14 | ▶ | my $w = $app->unit eq 'letter' ? '' : '_'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 14 | qr{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | \p{Han} | \p{InHiragana}+ | \p{InKatakana}+ | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | [$w\p{Latin}]+ | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | [$w\p{Hang}]+ | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | [$w\p{Cyrillic}]+ | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | [$w\p{Arabic}]+ | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | [$w\p{Thai}]+ | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | \d+ | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # (\p{Punct})\g{-1}* | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | [\h\r\f]*\n | \s+ | (\X)\g{-1}* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | }x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | ## Converter/Effector function for visible characters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 14 | my($converter, $effector); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 14 | ▶ | use Getopt::EX::LabeledParam; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | Getopt::EX::LabeledParam | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ->new(HASH => \%opt_visible) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 14 | ->load_params (@{$app->visible}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 14 | ▶ | if (my @names = grep $opt_visible{$_}, keys %opt_visible) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 14 | my @chars = map $visible{$_}->[0], @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 14 | my %hash = map { @$_ } values %visible; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 14 | my $re = do { local $" = ''; qr/[\Q@chars\E]/ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | my $sub0 = sub { s/($re)/$hash{$1}/g }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my $sub1 = sub { $_[0] =~ s/($re)/$hash{$1}/gr }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 92 | ▶ | my $sub2 = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 92 | my $mark_re = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 92 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 212 | ▶ | $_ // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_ // (next)
MC/DC100%1/1
$_ // (next)
$_
Truth table100%2/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 208 | s{^$mark_re\K(?=.*$re)(.*\R?)}{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $sub1->($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | }mge; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 14 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 14 | $converter = $sub2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | ## Only an effect which can be cancelled by tilde is usable here, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ## since the end sequence is built by negating each character. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ## Drop anything else, so that a wildcard spec such as `--cm *=N' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | ## does not end up asking for an impossible `~N'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 14 | ▶ | if (my $color = $colormap{'VISIBLE'} =~ s/[^DFHIPQSUX]//gir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $s = ansi_code($color); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my $e = ansi_code($color =~ s/(?=.)/~/gr); # cancel the effect | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | my $symbols = join('', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | map { $visible{$_}->[-1] =~ s/\s+//gr } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | @names); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $effector = sub { s/([\Q$symbols\E]+)/${s}${1}${e}/g }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ## Temporary files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 14 | ▶ | use Command::Run::Tmpfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 14 | my $T1 = Command::Run::Tmpfile->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 14 | my $T2 = Command::Run::Tmpfile->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ## Total statistic info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 14 | my %stat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 14 | @stat{'a', 'd', 'c', 'anl', 'dnl', 'cnl'} = (0, 0, 0, 0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 14 | @stat{'anlb', 'dnlb', 'cnlb'} = (0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 14 | ▶ | open(DIFF, $DIFF) || die "$DIFF: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 14 | binmode DIFF, ":encoding(utf8)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 14 | my $stdout = IO::Divert->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 64 | ▶ | sub sprintln { map { s/(?<=[^\n])\z/\n/r } @_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sprintln: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 64 | ▶ | sub println { print sprintln @_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
println: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub print_lxl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_lxl: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my($l1, $l2) = (sprintln($_[0]), sprintln($_[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if ($app->style eq 'diff') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | printf "1c1\n". "< $l1". "---\n". "> $l2", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | print $l1, $l2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 14 | ▶ | while (<DIFF>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # --linebyline, --lxl option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 112 | ▶ | if ($app->linebyline) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $old = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | my $new = <DIFF> // do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
readline DIFF // do {
print $old;
next
}
MC/DC0%0/2
readline DIFF // do {
print $old;
next
}
readline DIFF
do {
print $old;
next
}
Truth table0%0/3
A // B
A= readline DIFFB= do {
print $old;
next
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | print $old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | compare(\$old, \$new) if $app->unit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | print_lxl(color("OTEXT", $old), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | color("NTEXT", $new)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # normal diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | elsif (/^([\d,]+)([adc])([\d,]+)\r?$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 10 | my($left, $cmd, $right) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 10 | my $command_line = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 10 | my($old, $del, $new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 10 | ▶ | if ($cmd =~ /[cd]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 8 | $old = read_diff(*DIFF, scalar(range($left))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 8 | ▶ | $old =~ /^(?!<)/m and die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 10 | ▶ | if ($cmd =~ /[c]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 6 | $del = read_diff(*DIFF, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 6 | ▶ | $del =~ /^(?!---)/m and die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 10 | ▶ | if ($cmd =~ /[ca]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 8 | $new = read_diff(*DIFF, scalar(range($right))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 8 | ▶ | $new =~ /^(?!>)/m and die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 10 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | defined and print for ($command_line, $old, $del, $new); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 10 | print_command($command_line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 10 | ▶ | if ($converter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 10 | $converter->(qr/[<>][ \t]/, $old, $new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 10 | ▶ | if ($cmd eq 'c') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 6 | ▶ | compare(\$old, \$new, qr/<[ \t]/, qr/>[ \t]/) if $app->unit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 10 | ▶ | if ($app->color) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 10 | ▶ | $old =~ s{^(<[ \t])(.*)}{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 12 | color("OMARK", $1) . color("OTEXT", $2) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | }mge if $old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 10 | ▶ | $new =~ s{^(>[ \t])(.*)}{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 12 | color("NMARK", $1) . color("NTEXT", $2) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | }mge if $new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 10 | ▶ | println $old if $old and $app->show_old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$old and $app->show_old
MC/DC50%1/2
$old and $app->show_old
$old
$app->show_old
Truth table66%2/3
A and B
A= $oldB= $app->show_old
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 10 | ▶ | println $del if $del; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 10 | ▶ | println $new if $new and $app->show_new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$new and $app->show_new
MC/DC50%1/2
$new and $app->show_new
$new
$app->show_new
Truth table66%2/3
A and B
A= $newB= $app->show_new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # diff -c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | elsif (/^\*\*\* ([\d,]+) \*\*\*\*\r?$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 2 | my $left = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 2 | print_command($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 2 | my(@old, @new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 2 | my $oline = range($left); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2 | @old = read_diffc(*DIFF, $oline); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 2 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | ▶ | if (@old and $old[0] =~ /^--- /) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@old and $old[0] =~ /^--- /u
MC/DC0%0/2
@old and $old[0] =~ /^--- /u
@old
$old[0] =~ /^--- /u
Truth table33%1/3
A and B
A= @oldB= $old[0] =~ /^--- /u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $new = shift @old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | @old = (""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | $new = <DIFF>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | my $dline = map { /^-/mg } @old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 2 | ▶ | if ($new =~ /^--- ([\d,]+) ----$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 2 | my $right = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 2 | my $nline = range($right); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | ▶ | if (@old == 1 and $old[0] ne "" and $oline - $dline == $nline) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@old == 1 and $old[0] ne "" and $oline - $dline == $nline
@old == 1 and $old[0] ne ""
MC/DC0%0/3
@old == 1 and $old[0] ne "" and $oline - $dline == $nline
@old == 1
$old[0] ne ""
$oline - $dline == $nline
Truth table25%1/4
A and B and C
A= @old == 1B= $old[0] ne ""C= $oline - $dline == $nline
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | @new = (""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | @new = read_diffc(*DIFF, $nline); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 2 | ▶ | if ($converter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 2 | $converter->(qr/[\-\+\!\ ][ \t]/, @old, @new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 2 | my $mark_re = qr/![ \t]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | for my $i (keys @old) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 14 | my $cmark = "! "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 14 | ▶ | if ($i % 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 6 | ▶ | compare(\$old[$i], \$new[$i], $mark_re) if $app->unit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 14 | ▶ | if ($app->color) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 14 | $old[$i] =~ s{^([\-\!][ \t])(.*)}{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 12 | color("OMARK", $1) . color("OTEXT", $2) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | }mge; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 14 | $new[$i] =~ s{^([\+\!][ \t])(.*)}{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 12 | color("NMARK", $1) . color("NTEXT", $2) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | }mge; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 2 | ▶ | println @old if $app->show_old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | println $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 2 | ▶ | println @new if $app->show_new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # diff --combined (generic) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | elsif (m{^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | (?<prefix> $prefix_re) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | (?<command> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | (?<mark> \@{2,} ) [ ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | (?<lines> (?: [-+]\d+(?:,\d+)? [ ] ){2,} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | \g{mark} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | (?s:.*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | }x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 16 | my($prefix, $command, $lines) = @+{qw(prefix command lines)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 16 | my $column = length $+{mark}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | my @lines = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 16 | ▶ | $_ eq ' ' ? 1 : int $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } $lines =~ /\d+(?|,(\d+)|( ))/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 16 | ▶ | if (@lines != $column) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | print; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 16 | my($divert, %read_opt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 16 | ▶ | if ($prefix) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 8 | $read_opt{prefix} = $prefix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 8 | ▶ | $divert = IO::Divert->new(FINAL => sub { s/^/$prefix/mg }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 16 | print_command($command); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 16 | my @buf = read_unified \%read_opt, *DIFF, @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 16 | state @mark_re; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 16 | ▶ | my $mark_re = $mark_re[$column] //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$mark_re[$column] //= do {
my $mark = "." x ($column - 1);
qr/$mark/u
}
MC/DC0%0/2
$mark_re[$column] //= do {
my $mark = "." x ($column - 1);
qr/$mark/u
}
$mark_re[$column]
do {
my $mark = "." x ($column - 1);
qr/$mark/u
}
Truth table66%2/3
A //= B
A= $mark_re[$column]B= do {
my $mark = "." x ($column - 1);
qr/$mark/u
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 10 | my $mark = '.' x ($column - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 10 | qr/$mark/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 16 | ▶ | if ($converter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 80 | map { $converter->($mark_re, @$_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 16 | map { $_->lists } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | @buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 16 | for my $buf (@buf) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 36 | my @result = compare_unified($column, $buf, $mark_re); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 36 | ▶ | if (@result == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 36 | ▶ | $app->show_new or splice @result, 2, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 36 | ▶ | $app->show_old or splice @result, 1, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 36 | println @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # conflict marker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | elsif (/^<<<<<<<\s+(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | CONFLICT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $c1 = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | my @old = read_until { /^=======$/ } *DIFF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | my $c2 = pop @old // do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
pop @old // do {
print $c1, @old;
last
}
MC/DC0%0/2
pop @old // do {
print $c1, @old;
last
}
pop @old
do {
print $c1, @old;
last
}
Truth table0%0/3
A // B
A= pop @oldB= do {
print $c1, @old;
last
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | print $c1, @old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | my @new = read_until { /^>>>>>>>\s+(.*)/ } *DIFF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | my $c3 = pop @new // do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
pop @new // do {
print $c1, @old, $c2, @new;
last
}
MC/DC0%0/2
pop @new // do {
print $c1, @old, $c2, @new;
last
}
pop @new
do {
print $c1, @old, $c2, @new;
last
}
Truth table0%0/3
A // B
A= pop @newB= do {
print $c1, @old, $c2, @new;
last
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | print $c1, @old, $c2, @new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | my $i = first { $old[$_] =~ /^\Q|||||||\E/ } keys @old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | my @mrg = defined $i ? splice @old, $i : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $old = join '', @old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $new = join '', @new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | $converter->('', $old, $new) if $converter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | compare(\$old, \$new) if $app->unit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | print $c1 if $app->mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | print color("OTEXT", $old) if $app->show_old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | if (@mrg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $c4 = shift @mrg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | print $c4 if $app->mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $mrg = join '', @mrg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | $converter->('', $mrg) if $converter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | print color("MTEXT", $mrg) if $app->show_mrg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | println $c2 if $app->mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | println color("NTEXT", $new) if $app->show_new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | println $c3 if $app->mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 84 | ▶ | if ($app->unknown) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 76 | ▶ | if (my $f = $func{UNKNOWN}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 76 | print $f->($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | print; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 112 | $stdout->fh->flush; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 112 | local *_ = $stdout->buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 112 | ▶ | if (length) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 104 | $_ = decode 'utf8', $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 104 | ▶ | $effector->() if $effector; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 104 | STDOUT->printflush($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 104 | $stdout->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 14 | close DIFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 14 | ▶ | my $exit = $DIFF =~ /\|$/ ? $? >> 8 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 14 | select STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 14 | ▶ | if ($app->stat) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | select STDERR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | print("TOTAL: "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | printf("append=%d delete=%d change=%d\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $stat{'a'}, $stat{'d'}, $stat{'c'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | print("IGNORE WHITESPACE: "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | printf("append=%d delete=%d change=%d\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | $stat{'anl'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | $stat{'dnl'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $stat{'cnl'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | print("IGNORE WHITESPACE (bytes): "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | printf("append=%d delete=%d change=%d\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | $stat{'anlb'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | $stat{'dnlb'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | $stat{'cnlb'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 14 | exit($exit > 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 36 | ▶ | sub compare_unified { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_unified: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 36 | my $column = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 36 | ▶ | goto &compare_unified_3 if $column == 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 36 | goto &compare_unified_generic; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 36 | ▶ | sub compare_unified_generic { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_unified_generic: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 36 | my($buf, $mark_re) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 36 | my $c = $buf->collect(qr/^[\t ]+$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 36 | my $o = $buf->collect(qr/[-]/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 36 | my $n = $buf->collect(qr/[+]/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 36 | ▶ | compare(\$o, \$n, $mark_re) if $app->unit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 36 | ▶ | if ($app->color) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 36 | my($buf, $m, $t) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 108 | $$buf =~ s{^($mark_re)(.*)}{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 164 | ▶ | ($app->mark ? color($m, $1) : '') . color($t, $2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | }mge; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } ( [ \$c, 'UMARK', 'UTEXT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | [ \$o, 'OMARK', 'OTEXT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | [ \$n, 'NMARK', 'NTEXT' ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | map { s/^$mark_re//mg } $c, $o, $n if not $app->mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 36 | ($c, $o, $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | sub compare_unified_3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_unified_3: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | my($buf, $mark_re) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my @mark = ( " ", "--", "- ", " -", "+ ", " +", "++" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my %buf = map { $_ => scalar($buf->collect($_)) } @mark; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | goto SKIP unless $app->unit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $r[0] = compare(\@buf{q/--/, q/++/}, $mark_re); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $r[1] = compare(\@buf{q/- /, q/ -/}, $mark_re); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | if ($r[1] == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $r[2] = compare(\@buf{q/- /, q/+ /}, $mark_re); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | $r[3] = compare(\@buf{q/ -/, q/ +/}, $mark_re); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | if (sum(@r) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $r[4] = compare(\@buf{q/- /, q/++/}, $mark_re); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | $r[5] = compare(\@buf{q/ -/, q/++/}, $mark_re) unless $r[4]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $r[6] = compare(\@buf{q/--/, q/+ /}, $mark_re); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | $r[7] = compare(\@buf{q/--/, q/ +/}, $mark_re) unless $r[6]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | SKIP: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | if ($app->color) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | map { s/^$mark_re//mg } $buf{q/ /} if not $app->mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my($s, $m, $t) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | $$s =~ s{^($mark_re)(.*)}{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | ($app->mark ? color($m, $1) : '') . color($t, $2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | }mge if $$s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } ( [ \$buf{q/--/}, 'CMARK', 'CTEXT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | [ \$buf{q/- /}, 'OMARK', 'OTEXT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | [ \$buf{q/ -/}, 'NMARK', 'NTEXT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | [ \$buf{q/+ /}, 'MMARK', 'MTEXT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | [ \$buf{q/ +/}, 'MMARK', 'MTEXT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | [ \$buf{q/++/}, 'MMARK', 'MTEXT' ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | map { s/^$mark_re//mg } @buf{@mark} if not $app->mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | @buf{$buf->labels}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 28 | ▶ | sub print_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_command: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 28 | ▶ | return unless $app->command; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 24 | my $line = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 24 | ▶ | if ($app->color) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 24 | $line = color($colormap{COMMAND}, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 24 | print $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 48 | ▶ | sub compare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare: called CC=13 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 48 | my($old, $new) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 48 | ▶ | return 0 unless $old && $new && $$old && $$new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$old and $new and $$old and $$new
$old and $new and $$old
$old and $new
MC/DC50%2/4
$old and $new and $$old and $$new
$old
$new
$$old
$$new
Truth table60%3/5
A and B and C and D
A= $oldB= $newC= $$oldD= $$new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # skip word comparison for lines exceeding max length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 26 | ▶ | if (my $max = $app->limit->{length}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 25 | ▶ | return 0 if $$old =~ /^.{$max}/m or $$new =~ /^.{$max}/m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$old =~ /^.{$max}/mu or $$new =~ /^.{$max}/mu
MC/DC50%1/2
$$old =~ /^.{$max}/mu or $$new =~ /^.{$max}/mu
$$old =~ /^.{$max}/mu
$$new =~ /^.{$max}/mu
Truth table66%2/3
A or B
A= $$old =~ /^.{$max}/muB= $$new =~ /^.{$max}/mu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 25 | ▶ | my $omark_re = shift || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || undef
MC/DC0%0/1
shift() || undef
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 25 | ▶ | my $nmark_re = shift || $omark_re; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
shift() || $omark_re
MC/DC0%0/2
shift() || $omark_re
shift()
$omark_re
Truth table66%2/3
A || B
A= shift()B= $omark_re
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 25 | my(@omark, @nmark); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 25 | ▶ | if ($omark_re) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 25 | $$old =~ s/^($omark_re)/push(@omark, $1), ""/mge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 25 | $$new =~ s/^($nmark_re)/push(@nmark, $1), ""/mge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 25 | ($$old, $$new) = context($$old, $$new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 25 | ▶ | $$old =~ s/^/shift @omark/mge if @omark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 25 | ▶ | $$new =~ s/^/shift @nmark/mge if @nmark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 25 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 14 | ▶ | use Getopt::EX::Colormap qw(colorize); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | sub debug_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_list: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | my @cmap = qw( K/444 K/333 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | join "", map { colorize $cmap[$i++ % @cmap], $_ } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 25 | ▶ | sub context { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context: called CC=16 SCAR=38.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 25 | my($old, $new) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 25 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 25 | ▶ | if ($debug{s}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | print STDERR "****************************** Comparing ...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | print STDERR $old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | print STDERR "****************************** and\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | print STDERR $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | print STDERR "****************************** .\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 25 | my @owlist = wordlist($old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 25 | my @nwlist = wordlist($new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 25 | ▶ | if ($debug{w}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | print STDERR "****************************** Comparing ...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | print STDERR debug_list @owlist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | print STDERR "****************************** and\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | print STDERR debug_list @nwlist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | print STDERR "****************************** .\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 25 | maketmp($T1, @owlist); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 25 | maketmp($T2, @nwlist); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 25 | my $diff = sprintf "$app->{subdiff} @sub_diffopts %s %s", $T1->path, $T2->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 25 | ▶ | open my $cdif, "$diff |" or die "diff: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 25 | binmode $cdif, ":encoding(utf8)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 25 | my @command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 25 | my %c = (a => 0, d => 0, c => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 25 | ▶ | while (<$cdif>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 1920 | ▶ | warn $_ if $debug{d}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | ## Quick hack to read `git diff` unified output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 1920 | ▶ | if (/^\@\@ \s+ \-(\d+)(?:,(\d+))? \s+ \+(\d+)(?:,(\d+))? \s+ \@\@/x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | my($o, $ol, $n, $nl) = ($1, $2//1, $3, $4//1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$2 // 1
$4 // 1
MC/DC0%0/1
$2 // 1
$2
MC/DC0%0/1
$4 // 1
$4
Truth table0%0/2
A
A= $2
Truth table0%0/2
A
A= $4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | my $cmd = ($ol == 0) ? "a" : ($nl == 0) ? "d" : "c"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | my $old = ($ol <= 1) ? $o : sprintf "%d,%d", $o, $o + $ol - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | my $new = ($nl <= 1) ? $n : sprintf "%d,%d", $n, $n + $nl - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | $_ = sprintf "%s%s%s\n", $old, $cmd, $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1920 | ▶ | if (/^[\d,]+([adc])[\d,]+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 448 | push @command, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 448 | $c{$1}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 25 | close $cdif; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 25 | ▶ | if ($debug{d}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | printf(STDERR "old=%d new=%d command=%d\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | @owlist+0, @nwlist+0, @command+0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | printf(STDERR "append=$c{a} delete=$c{d} change=$c{c}\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 25 | my($obuf, $nbuf) = makebuf(\@owlist, \@nwlist, \@command); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 25 | my $status = $?>>8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 25 | ▶ | die "Unexpected status of subprocess ($status)\n" if $status > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 25 | ($obuf, $nbuf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 50 | ▶ | sub wordlist { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wordlist: called CC=3 SCAR=13.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 50 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 50 | ▶ | if ($app->unit eq 'mecab' and $text =~ /\P{ASCII}/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$app->unit eq "mecab" and $text =~ /\P{ASCII}/u
MC/DC0%0/2
$app->unit eq "mecab" and $text =~ /\P{ASCII}/u
$app->unit eq "mecab"
$text =~ /\P{ASCII}/u
Truth table33%1/3
A and B
A= $app->unit eq "mecab"B= $text =~ /\P{ASCII}/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | mecab_words($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 50 | normal_words($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 50 | ▶ | sub normal_words { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normal_words: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 50 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 50 | my @words; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 50 | ▶ | while ($text =~ /\G($w_pattern)/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 2368 | push @words, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 50 | @words; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | sub mecab_words { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mecab_words: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | state $mecab = App::cdif::Command::Mecab->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | $mecab->wordlist($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 50 | ▶ | sub maketmp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maketmp: called CC=5 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 50 | my($tmpfile, @list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 50 | $tmpfile->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 50 | for (@list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 2368 | ▶ | s/[ \t]+// if $app->ignore_space_change || $app->ignore_all_space; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$app->ignore_space_change or $app->ignore_all_space
MC/DC0%0/2
$app->ignore_space_change or $app->ignore_all_space
$app->ignore_space_change
$app->ignore_all_space
Truth table33%1/3
A or B
A= $app->ignore_space_changeB= $app->ignore_all_space
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 2368 | $tmpfile->write($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 2368 | ▶ | $tmpfile->write("\n") unless /\n\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 50 | $tmpfile->flush->rewind; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | ## @owlist: old word list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | ## @nwlist: new word list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | ## @command: how different these lists (`diff' result command lines) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 25 | ▶ | sub makebuf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makebuf: called CC=12 SCAR=30.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 25 | my($ol, $nl, $c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 25 | my @owlist = @$ol; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 25 | my @nwlist = @$nl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 25 | my @command = @$c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 25 | my($o, $n) = (0, 0); # pointers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 25 | my(@obuf, @nbuf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 25 | for (@command) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 448 | ▶ | my($old, $cmd, $new) = /([\d,]+)([adc])([\d,]+)/ or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | die "Panic! Unexpected diff output"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 448 | my($o1, $o2) = range($old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 448 | my($n1, $n2) = range($new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 448 | map { $_-- } $o1, $o2, $n1, $n2; # make them zero origined | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 448 | ▶ | push(@obuf, @owlist[$o .. $o1 - 1]), $o = $o1 if $o < $o1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 448 | ▶ | push(@nbuf, @nwlist[$n .. $n1 - 1]), $n = $n1 if $n < $n1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 448 | $stat{$cmd}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 448 | ▶ | if ($cmd eq 'd') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | my $os = join('', @owlist[$o1 .. $o2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | if ($owlist[$o2] =~ /\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | $stat{'dnl'}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | $stat{'dnlb'} += length($os); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | push(@obuf, $func{DELETE}->($os)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | $o = $o2 + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | elsif ($cmd eq 'c') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 448 | my $os = join('', @owlist[$o1 .. $o2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 448 | my $ns = join('', @nwlist[$n1 .. $n2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 448 | ▶ | if (($owlist[$o2] =~ /\S/) || ($nwlist[$n2] =~ /\S/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$owlist[$o2] =~ /\S/u or $nwlist[$n2] =~ /\S/u
MC/DC0%0/2
$owlist[$o2] =~ /\S/u or $nwlist[$n2] =~ /\S/u
$owlist[$o2] =~ /\S/u
$nwlist[$n2] =~ /\S/u
Truth table33%1/3
A or B
A= $owlist[$o2] =~ /\S/uB= $nwlist[$n2] =~ /\S/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 448 | $stat{'cnl'}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 448 | $stat{'cnlb'} += length($os); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 448 | $stat{'cnlb'} += length($ns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 448 | push(@obuf, $func{OLD}->($os)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 448 | push(@nbuf, $func{NEW}->($ns)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 448 | $o = $o2 + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 448 | $n = $n2 + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | elsif ($cmd eq 'a') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my $ns = join('', @nwlist[$n1 .. $n2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | ▶ | if ($nwlist[$n2] =~ /\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $stat{'anl'}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | $stat{'anlb'} += length($ns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | push(@nbuf, $func{APPEND}->($ns)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | $n = $n2 + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 25 | push(@obuf, @owlist[$o .. $#owlist]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 25 | push(@nbuf, @nwlist[$n .. $#nwlist]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 25 | (join('', @obuf), join('', @nbuf)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 22 | ▶ | sub read_diff { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_diff: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 22 | my($FH, $c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 22 | my @buf = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 22 | ▶ | while ($c-- > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 30 | push @buf, scalar <$FH>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 22 | ▶ | wantarray ? @buf : join '', @buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 4 | ▶ | sub read_diffc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_diffc: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 4 | my($FH, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 4 | my @buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 4 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 4 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 4 | ▶ | while ($n-- && ($_ = <$FH>)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$n-- and $_ = readline $FH
MC/DC50%1/2
$n-- and $_ = readline $FH
$n--
$_ = readline $FH
Truth table66%2/3
A and B
A= $n--B= $_ = readline $FH
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 56 | ▶ | $i++ if ($i % 2) != /^!/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 56 | $buf[$i] .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 56 | ▶ | last if /^--- /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 4 | ▶ | map { $_ // "" } @buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ // ""
MC/DC0%0/1
$_ // ""
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | sub ul { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ul: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | local $_ = join '', @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | s/(.)/["", "_\010", "__\010\010"]->[vwidth($1)].$1/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | ▶ | sub bd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | local $_ = join '', @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | s/(\S)/$1.["", "\010", "\010\010"]->[vwidth($1)].$1/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | ▶ | sub wc_l { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wc_l: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | $file->rewind; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | ▶ | $line++ while $file->fh->getline; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | $file->rewind; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | sub eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eval: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | ▶ | print STDERR &unctrl($_[0]), "\n" x ($_[0] !~ /\n$/) if $_[1] || $debug{e}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[1] or $debug{"e"}
MC/DC0%0/2
$_[1] or $debug{"e"}
$_[1]
$debug{"e"}
Truth table0%0/3
A or B
A= $_[1]B= $debug{"e"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | CORE::eval shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | die sprintf("eval failed in file %s on line %s\n$@", (caller)[1,2]) if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | cdif - word context diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | Version 4.49 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | cdif [option] file1 file2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | cdif [option] [diff-data] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | Options: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | -c, -Cn context diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | -u, -Un unified diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | -i ignore case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | -b ignore space change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | -w ignore whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | -t expand tabs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | --rcs use rcsdiff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | -r rev RCS revision to compare | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | -q passed through to rcsdiff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | --diff=command specify diff command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | --subdiff=command specify backend diff command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | --stat show statistical information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | --colormap=s specify color map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | --sdif sdif friendly option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | --[no]color color or not (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | --[no]256 ANSI 256 color mode (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | --[no]cc color command line (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | --[no]mc color diff mark (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | --[no]tc color normal text (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | --[no]uc color unknown text (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | --[no]old print old text (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | --[no]new print new text (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | --[no]mrg print merged text (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | --[no]command print diff command line (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | --[no]unknown print unknown line (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | --[no]mark print mark or not (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | --[no]prefix read git --graph output (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | --unit=s word/letter/char/mecab (default word) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | --[no]mecab use mecab tokenizer (default false) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | --prefix-pattern prefix pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | --visible char=? set visible attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | --[no]lenience suppress unexpected input warning (default true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | --limit length=# skip word comparison for long lines (default 1000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | --lxl compare input data line-by-line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | --style=diff print --lxl output in diff style | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | --version show version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | B<cdif> is a post-processor of the Unix diff command. It highlights | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | deleted, changed and added words based on word context (B<--unit=word> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | by default). To compare text character by character, use option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | B<--unit=char>. Option B<--unit=mecab> calls the external B<mecab> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | command as a tokenizer for Japanese text. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | Given a single file, or no file at all, B<cdif> reads that file or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | standard input as the output of a diff command. Besides normal diff, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | context diff and unified (combined) diff, the L<git(1)>-compatible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | conflict marker format is accepted as input. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | Lines that do not look like diff output are passed through untouched. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | =head2 STARTUP and MODULE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | B<cdif> uses the Perl L<Getopt::EX> module, and reads the F<~/.cdifrc> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | file at startup if there is one. You can define your own options and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | defaults there. The next line enables the B<--mecab> option and adds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | a crossed-out effect to deleted words. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | option default --mecab --cm DELETE=+X | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | Modules under B<App::cdif> can be loaded by the B<-M> option without | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | the prefix. The next command loads the B<App::cdif::colors> module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | $ cdif -Mcolors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | Options can be defined in a module file as well. See | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | L<Getopt::EX::Module> for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | =head2 COLOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | Each line is displayed in a different color. Every text segment has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | its own label, and the color for each label can be set by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | B<--colormap> option. See L<Getopt::EX::Colormap> for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | The standard module B<-Mcolors> is loaded by default, and defines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | several color maps for light and dark screens. To use CMY colors on a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | dark screen, place the next line in your F<~/.cdifrc>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | option default --dark-cmy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | Option B<--autocolor> is defined in the B<default> module to call the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | L<Getopt::EX::termcolor> module. It sets the B<--light> or B<--dark> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | option according to the brightness of the terminal screen. You can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | set your preferred colors in F<~/.cdifrc> like this: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | option --light --cmy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | option --dark --dark-cmy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | The detection is done by the L<Getopt::EX::termcolor> module, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | works with macOS Terminal.app and iTerm.app, and other XTerm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | compatible terminals. That module reads the environment variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | C<TERM_BGCOLOR> as the terminal background color. For example, use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | C<000> or C<#000000> for black and C<555> or C<#FFFFFF> for white. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | Option B<--autocolor> is set by default; to disable it, override it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | with something that does nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | option --autocolor --nop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | =head2 EXIT STATUS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | B<cdif> always exits with status zero unless an error occurs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | =head1 OPTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | =over 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | =item B<->[B<cCuUibwtT>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | Almost the same as for the B<diff> command. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | =item B<--rcs>, B<-r>I<rev>, B<-q> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | Use B<rcsdiff> instead of the normal diff command, and take the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | remaining argument as an RCS file name. Option B<-r>I<rev> names the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | revision to compare against, and B<-q> is passed to B<rcsdiff> as it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | is. B<--rcs> is not required when either of the other two is given. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | cdif -r1.3 file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | =item B<-->B<unit>=[C<word>,C<letter>,C<char>,C<mecab>,C<0>,C<>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | =item B<-->B<by>=[C<word>,C<letter>,C<char>,C<mecab>,C<0>,C<>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | Specify the unit of comparison. The default is C<word>, comparing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | each line word by word. Specify C<char> to compare character by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | character. Unit C<letter> is almost the same as C<word>, but does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | count an underscore as part of a word. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | When C<mecab> is given as the unit, the B<mecab> command is called as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | a tokenizer for non-ASCII text; ASCII text is still compared word by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | word. The external B<mecab> command has to be installed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | Given an empty string, as in C<--unit=>, or C<0>, B<cdif> does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | compare the text at all. Colorization is still applied. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | =item B<--mecab> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | Shortcut for B<--unit=mecab>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | =item B<--diff>=I<command> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | Specify the diff command to use. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | =item B<--subdiff>=I<command> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | Specify the backend diff command used to find word differences. It | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | accepts normal and unified diff format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | To use the B<git diff> command, do not forget the I<-U0> option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | --subdiff="git diff -U0 --no-index --histogram" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | =item B<-->[B<no->]B<color> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | Use ANSI color escape sequences in the output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | =item B<--colormap>=I<colormap>, B<--cm>=I<colormap> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | Basic I<colormap> format is : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | FIELD=COLOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | where the FIELD is one from these : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | COMMAND Command line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | OMARK Old mark | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | NMARK New mark | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | UTEXT Same text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | OTEXT Old text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | NTEXT New text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | OCHANGE Old change part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | NCHANGE New change part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | APPEND Appended part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | DELETE Deleted part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | =for comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | VISIBLE Visualized invisible chars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | and additional I<Common> and I<Merged> FIELDs for git-diff combined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | CMARK Common mark | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | CTEXT Common text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | MMARK Merged mark | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | MTEXT Merged text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | You can give several fields the same color by joining them with = : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | FIELD1=FIELD2=...=COLOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | A wildcard can also be used for the field name : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | *CHANGE=BDw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | Multiple fields can be specified by repeating the option : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | --cm FIELD1=COLOR1 --cm FIELD2=COLOR2 ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | or combined with comma (,) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | --cm FIELD1=COLOR1,FIELD2=COLOR2, ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | Color specification is a combination of single uppercase character | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | representing 8 colors : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | R Red | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | G Green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | B Blue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | C Cyan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | M Magenta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | Y Yellow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | K Black | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | W White | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | and alternative (usually brighter) colors in lowercase : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | r, g, b, c, m, y, k, w | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | or RGB values and 24 grey levels on an ANSI 256-color or full-color | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | terminal : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | (255,255,255) : 24bit decimal RGB colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | #000000 .. #FFFFFF : 24bit hex RGB colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | #000 .. #FFF : 12bit hex RGB 4096 colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 000 .. 555 : 6x6x6 RGB 216 colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | L00 .. L25 : Black (L00), 24 grey levels, White (L25) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | or color names enclosed in angle brackets : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | <red> <blue> <green> <cyan> <magenta> <yellow> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | <aliceblue> <honeydew> <hotpink> <moccasin> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | <medium_aqua_marine> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | with other special effects : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | D Double-struck (boldface) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | I Italic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | U Underline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | S Stand-out (reverse video) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | The above is a simplified summary; see L<Getopt::EX::Colormap> for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | complete specification. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | Defaults are : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | COMMAND => "555/222E" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | OMARK => "CS" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | NMARK => "MS" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | UTEXT => "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | OTEXT => "C" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | NTEXT => "M" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | OCHANGE => "K/445" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | NCHANGE => "K/445" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | DELETE => "K/544" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | APPEND => "K/544" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | CMARK => "GS" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | MMARK => "YS" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | CTEXT => "G" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | MTEXT => "Y" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | This is equivalent to : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | cdif --cm 'COMMAND=555/222E,OMARK=CS,NMARK=MS' \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | --cm 'UTEXT=,OTEXT=C,NTEXT=M,*CHANGE=BD/445,DELETE=APPEND=RD/544' \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | --cm 'CMARK=GS,MMARK=YS,CTEXT=G,MTEXT=Y' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | =item B<--colormap>=C<&func> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | =item B<--colormap>=C<sub{...}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | You can also give the name of a Perl subroutine, or its definition, to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | be called for the matched words. The target word is passed in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | variable C<$_>, and the return value of the subroutine is displayed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | The next option produces B<wdiff>-like output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | --cm '*'= \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | --cm DELETE=OCHANGE='sub{"[-$_-]"}' \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | --cm APPEND=NCHANGE='sub{"{+$_+}"}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | See L<Getopt::EX::Colormap/FUNCTION SPEC> for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | =item B<-->[B<no->]B<cc>, B<-->[B<no->]B<commandcolor> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | =item B<-->[B<no->]B<mc>, B<-->[B<no->]B<markcolor> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | =item B<-->[B<no->]B<tc>, B<-->[B<no->]B<textcolor> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | =item B<-->[B<no->]B<uc>, B<-->[B<no->]B<unknowncolor> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | Enable or disable color for the corresponding field. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | =item B<--sdif> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | Turn off the options that get in the way when the output is fed to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | B<sdif>: B<--commandcolor>, B<--markcolor>, B<--textcolor> and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | B<--unknowncolor>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | =item B<-->[B<no->]B<old>, B<-->[B<no->]B<new>, B<-->[B<no->]B<mrg> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | Print, or do not print, the old/new/merged text in diff output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | =item B<-->[B<no->]B<command> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | Print, or do not print, the command lines preceding diff output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | =item B<-->[B<no->]B<unknown> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | Print, or do not print, lines that do not look like diff output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | =item B<-->[B<no->]B<mark> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | Print, or do not print, the marks at the head of diff output lines. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | For now this option is effective only for unified diff. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | The next example produces output identical to F<new>, apart from the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | visual effects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | cdif -U100 --no-mark --no-old --no-command --no-unknown old new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | These options are provided for the watchdiff(1) command. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | =item B<-->[B<no->]B<prefix> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | Understand a prefix in front of the diff output, such as the one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | B<git> B<--graph> produces. True by default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | =item B<--prefix-pattern>=I<pattern> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | Specify the prefix pattern as a regular expression. Default pattern is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | (?:\| )*(?: )* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | This pattern matches B<git> graph style and whitespace indented diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | =item B<--visible> I<charname>=[0,1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | Set the visible attribute for the given characters. A visible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | character is converted to the corresponding Unicode symbol. Visible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | by default: nul, bel, bs, vt, np, cr, esc, del, and all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | non-breaking/special spaces. Invisible by default: ht, nl, sp. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | NAME CODE Unicode NAME DEFAULT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | ------ ------ -------------------------------- ------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | nul \000 SYMBOL FOR NULL YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | soh \001 SYMBOL FOR SOH YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | bel \007 SYMBOL FOR BELL YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | bs \010 SYMBOL FOR BACKSPACE YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | ht \011 SYMBOL FOR HORIZONTAL TABULATION NO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | nl \012 SYMBOL FOR NEWLINE NO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | vt \013 SYMBOL FOR VERTICAL TABULATION YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | np \014 SYMBOL FOR FORM FEED YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | cr \015 SYMBOL FOR CARRIAGE RETURN YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | esc \033 SYMBOL FOR ESCAPE YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | sp \040 SYMBOL FOR SPACE NO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | del \177 SYMBOL FOR DELETE YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | nbsp \240 OPEN BOX (No-Break Space) YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | nnbsp U+202F OPEN BOX (Narrow No-Break Space) YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | ensp U+2002 OPEN BOX (En Space) YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | emsp U+2003 OPEN BOX (Em Space) YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | thinsp U+2009 OPEN BOX (Thin Space) YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | hairsp U+200A OPEN BOX (Hair Space) YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | zwsp U+200B OPEN BOX (Zero Width Space) YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | idesp U+3000 OPEN BOX (Ideographic Space) YES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | Since there are no dedicated Unicode symbols for nbsp and other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | special space characters, OPEN BOX is used instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | Several characters can be given at once: join them with a comma | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | (C<,>), as in C<--visible ht=1,sp=1>, or with an equal sign (C<=>), as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | in C<--visible ht=sp=1>. Character names accept a wildcard, as in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | C<--visible '*=1'>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | =begin comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | Colormap label C<VISIBLE> is applied to those characters. Default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | setting is C<S>, and visible characters are displayed in reverse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | video. Unlike other colormaps, only special effects can be set to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | this label. Effect C<D> (double-struck) is exception (See | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | L<Getopt::EX::Colormap/~>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | =end comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | The B<sdif> command also supports the B<--visible> option, with better | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | visibility for horizontal tabs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | =item B<--stat> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | Print statistical information at the end of the output, showing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | total number of appended, deleted and changed words as B<cdif> counts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | them. Refilling text inserts and deletes a great many newlines, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | the figures are followed by a second set that leaves those newlines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | =item B<-->[B<no->]B<lenience> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | Suppress the warning message for unexpected input from the diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | command. True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | by default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | =item B<--limit> I<key>=I<value> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | Set resource limits. Available keys are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | =item B<length>=I<#> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | Skip word comparison for lines longer than I<#> characters. Default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | is 1000. Extremely long lines, such as those found in SVG data, can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | make word-level diff processing very slow with no useful result. When | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | this limit is exceeded, the section is still displayed with basic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | colorization but without fine-grained word highlighting. Set to 0 to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | disable this limit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | =item B<--linebyline>, B<--lxl> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | =item B<--style>=I<style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | Compare the input line by line. The input is taken as a sequence of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | line pairs, and the two lines of each pair are compared against each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | other. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | Suppose you have a document with old and new text on lines beginning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | with C<OLD:> and C<NEW:> labels. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | OLD: this is old text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | NEW: and this is updated document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | Only that old/new part can be compared, using B<greple>'s B<-Mtee> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | module as follows. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | greple -Mtee cdif --lxl -- --cm=N -GE '^OLD: (.*\n)^NEW: (.*\n)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | The B<-Mtee> module sends the matched parts to a filter command and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | replaces them with its output. See L<App::Greple::tee> for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | You can use the L<teip(1)> command as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | teip -g '^(OLD|NEW):' -- cdif --lxl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | Given the C<--style=diff> option, the two strings are printed in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | B<diff> format, which can be fed to the B<sdif> command as follows. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | cdif --lxl --style=diff ... | sdif --no-cdif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | C<diff> is currently the only valid value for C<--style>, and it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | affects nothing but the behavior of the C<--lxl> option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | =head1 MODULE OPTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | =head2 default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | default --autocolor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | --nop do nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | =head2 -Mcolors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | The following options are available by default. Run C<perldoc -m | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | App::cdif::colors> to see the actual settings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | --light | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | --green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | --cmy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | --mono | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | --dark | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | --dark-green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | --dark-cmy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | --dark-mono | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | =head1 GIT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | See L<App::sdif/GIT> for how to use the B<sdif> family under GIT. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | =head1 ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | =over 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | =item B<CDIFOPTS> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | Environment variable B<CDIFOPTS> is used to set default options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | =item B<LESS> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | =item B<LESSANSIENDCHARS> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | Since B<cdif> emits the ANSI Erase Line terminal sequence, it helps to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | let the B<less> command know about it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | LESS=-cR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | LESSANSIENDCHARS=mK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | Kazumasa Utashiro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | Copyright 1992-2026 Kazumasa Utashiro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | L<App::sdif>, L<https://github.com/kaz-utashiro/sdif-tools> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | L<sdif(1)>, L<watchdiff(1)> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | L<Getopt::EX::Colormap> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | L<App::Greple::tee> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | L<https://taku910.github.io/mecab/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | B<cdif> is not very fast by nature, because it runs the normal diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | command as a back end to compare words. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | # LocalWords: cdif diff rcs rcsdiff colormap commandcolor markcolor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | # LocalWords: textcolor stdin OMARK NMARK OTEXT NTEXT OCHANGE CMARK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | # LocalWords: NCHANGE CTEXT MMARK MTEXT Cyan RGB nomark stat cdifrc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | # LocalWords: watchdiff mecab tokenizer Unicode lenience CDIFOPTS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | # LocalWords: Kazumasa Utashiro sdif perldoc CMY cmy autocolor perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | # LocalWords: macOS XTerm subdiff LESSANSIENDCHARS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||