App-sdif
view release on metacpan or search on metacpan
script/cdif view on Meta::CPAN
my $ns = join('', @nwlist[$n1 .. $n2]);
if ($nwlist[$n2] =~ /\S/) {
$stat{'anl'}++;
$stat{'anlb'} += length($ns);
}
push(@nbuf, $func{APPEND}->($ns));
$n = $n2 + 1;
}
}
push(@obuf, @owlist[$o .. $#owlist]);
push(@nbuf, @nwlist[$n .. $#nwlist]);
(join('', @obuf), join('', @nbuf));
}
sub read_diff {
my($FH, $c) = @_;
my @buf = ();
while ($c-- > 0) {
push @buf, scalar <$FH>;
}
wantarray ? @buf : join '', @buf;
}
sub read_diffc {
my($FH, $n) = @_;
my @buf;
local $_;
my $i = 0;
while ($n-- && ($_ = <$FH>)) {
$i++ if ($i % 2) != /^!/;
$buf[$i] .= $_;
last if /^--- /;
}
map { $_ // "" } @buf;
}
sub ul {
local $_ = join '', @_;
s/(.)/["", "_\010", "__\010\010"]->[vwidth($1)].$1/ge;
$_;
}
sub bd {
local $_ = join '', @_;
s/(\S)/$1.["", "\010", "\010\010"]->[vwidth($1)].$1/ge;
$_;
}
sub wc_l {
my $file = shift;
my $line;
$file->rewind;
$line++ while $file->fh->getline;
$file->rewind;
$line;
}
sub eval {
print STDERR &unctrl($_[0]), "\n" x ($_[0] !~ /\n$/) if $_[1] || $debug{e};
CORE::eval shift;
die sprintf("eval failed in file %s on line %s\n$@", (caller)[1,2]) if $@;
}
######################################################################
=head1 NAME
cdif - word context diff
=head1 VERSION
Version 4.4501
=head1 SYNOPSIS
cdif [option] file1 file2
cdif [option] [diff-data]
Options:
-c, -Cn context diff
-u, -Un unified diff
-i ignore case
-b ignore space change
-w ignore whitespace
-t expand tabs
--diff=command specify diff command
--subdiff=command specify backend diff command
--stat show statistical information
--colormap=s specify color map
--sdif sdif friendly option
--[no]color color or not (default true)
--[no]256 ANSI 256 color mode (default true)
--[no]cc color command line (default true)
--[no]mc color diff mark (default true)
--[no]tc color normal text (default true)
--[no]uc color unknown text (default true)
--[no]old print old text (default true)
--[no]new print new text (default true)
--[no]mrg print merged text (default true)
--[no]command print diff command line (default true)
--[no]unknown print unknown line (default true)
--[no]mark print mark or not (default true)
--[no]prefix read git --graph output (default true)
--unit=s word/letter/char/mecab (default word)
--[no]mecab use mecab tokenizer (default false)
--prefix-pattern prefix pattern
--visible char=? set visible attributes
--[no]lenience suppress unexpected input warning (default true)
--limit length=# skip word comparison for long lines (default 1000)
--lxl compare input data line-by-line
--style=diff print --lxl output in diff style
--version show version
=head1 DESCRIPTION
B<cdif> is a post-processor of the Unix diff command. It highlights
deleted, changed and added words based on word context (B<--unit=word>
( run in 0.398 second using v1.01-cache-2.11-cpan-5511b514fd6 )