view release on metacpan or search on metacpan
b) You must cause any work that you distribute or publish, that in whole or in
part contains or is derived from the Program or any part thereof, to be licensed
as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you
must cause it, when started running for such interactive use in the most ordinary
way, to print or display an announcement including an appropriate copyright
notice and a notice that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these conditions,
and telling the user how to view a copy of this License. (Exception: if the
Program itself is interactive but does not normally print such an announcement,
view all matches for this distribution
view release on metacpan or search on metacpan
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Diff/Apply.pm view on Meta::CPAN
}
# Converts all the hunks in an Algorithm::Diff-style diff to a
# normalised form in which all hunks are a) still internally
# contiguous, and b) have start indices which refer to items in the
# original array, before any diffs are applied. Normally, hunks
# consisting of only inserts don't meet criterion b).
#
# Allso attaches hash data if the hashing function is defined.
lib/Algorithm/Diff/Apply.pm view on Meta::CPAN
my ($orig_diff, %opt) = @_;
my @hdiff = ();
my $delta = 0; # difference between orig and resultant
foreach my $orig_hunk (@$orig_diff)
{
my ($first_op, $start) = @{$orig_hunk->[0]} [0, 1];
$start -= $delta if $first_op eq '+';
my $hhunk = {
start => $start,
changes => [],
};
foreach my $change (@$orig_hunk)
{
my ($op, $data);
lib/Algorithm/Diff/Apply.pm view on Meta::CPAN
$cflict{$id} = [ $hunk ];
# Seed range with $hunk:
my @ch = @{$hunk->{changes}};
my $span = grep { $_->[0] eq '-' } @ch;
$cflict_min = $hunk->{start};
$cflict_max = $cflict_min + $span;
# Detect conflicting hunks, and add those in too.
my %ignore;
while (my $tmp_id = __next_hunk_id($diffset, %ignore))
{
my $tmp_hunk = $diffset->{$tmp_id}->[0];
@ch = @{$tmp_hunk->{changes}};
my $tmp_span = grep { $_->[0] eq '-' } @ch;
my $tmp_max = $tmp_hunk->{start} + $tmp_span;
if ($tmp_hunk->{start} <= $cflict_max)
{
exists $cflict{$tmp_id} or $cflict{$tmp_id} = [];
shift @{$diffset->{$tmp_id}};
push @{$cflict{$tmp_id}}, $tmp_hunk;
$cflict_max = $tmp_max if $tmp_max > $cflict_max;
lib/Algorithm/Diff/Apply.pm view on Meta::CPAN
return ($cflict_min, $cflict_max, %cflict);
}
# Returns the ID of the hunk in %$diffset whose ->{start} is lowest,
# or undef. %ignore{SOMEID} can be set to a true value to cause a
# given sequence to be skipped over.
sub __next_hunk_id
{
my ($diffset, %ignore) = @_;
my ($lo_id, $lo_start);
foreach my $id (keys %$diffset)
{
next if $ignore{$id};
my $diff = $diffset->{$id};
next if $#$diff < 0;
my $start = $diff->[0]->{start};
if ((! defined($lo_start))
|| $start < $lo_start)
{
$lo_id = $id;
$lo_start = $start;
}
}
return $lo_id;
}
lib/Algorithm/Diff/Apply.pm view on Meta::CPAN
@replacement = @$r;
}
else
{
@replacement = $resolver->(src_range_end => $max,
src_range_start => $min,
src_range => \@orig,
alt_txts => \%alt_txts,
invoc_opts => \%opt);
}
splice(@$ary, $min + $delta, $#orig+1, @replacement);
lib/Algorithm/Diff/Apply.pm view on Meta::CPAN
# by doing so.
sub __apply_hunk
{
my ($ary, $rdelta, $hunk) = @_;
my $pos = $hunk->{start} + $$rdelta;
foreach my $change (@{$hunk->{changes}})
{
if ($change->[0] eq '+')
{
splice(@$ary, $pos, 0, $change->[1]);
lib/Algorithm/Diff/Apply.pm view on Meta::CPAN
sub __hunks_identical
{
my ($h1, $h2) = @_;
$h1->{start} == $h2->{start} or return 0;
$#{$h1->{changes}} == $#{$h2->{changes}} or return 0;
foreach my $i (0 .. $#{$h1->{changes}})
{
my ($op1, $data1, $hash1) = @{ $h1->{changes}->[$i] };
my ($op2, $data2, $hash2) = @{ $h2->{changes}->[$i] };
lib/Algorithm/Diff/Apply.pm view on Meta::CPAN
{
print STDERR "-- begin seq tag=\"$tag\" --\n";
my @diff = @{$dset{$tag}};
for my $diff (@diff)
{
print STDERR "\n\@".$diff->{start}."\n";
for my $e (@{$diff->{changes}})
{
my ($op, $data) = @$e;
$data = quotemeta($data);
$data =~ s{^(.{0,75})(.*)}{
view all matches for this distribution
view release on metacpan or search on metacpan
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Diff/HTMLTable.pm view on Meta::CPAN
croak $files{$name} . " is not a file" if !-f $files{$name};
croak $files{$name} . " is not a readable file" if !-r $files{$name};
}
my $html = $self->_start_table( %files );
$html .= $self->_build_table( %files );
$html .= $self->_end_table( %files );
return $html;
}
sub _start_table {
my $self = shift;
my %files = @_;
my $old = $self->_file_info( $files{a}, 'old' );
my $new = $self->_file_info( $files{b}, 'new' );
view all matches for this distribution
view release on metacpan or search on metacpan
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
view all matches for this distribution
view release on metacpan or search on metacpan
}
if (ctx->thresh.max >= 0) {
struct LK *lk;
if (GIMME_V == G_ARRAY) {
SV **start, **end;
XSprePUSH;
start = SP+1;
for (lk = ctx->links.arr[ctx->thresh.max]; lk; lk = lk->link) {
AV *arr;
/* only count transitions */
if (lk->link && lk->link->i == lk->i)
continue;
av_push(arr, newSViv(lk->j));
XPUSHs(sv_2mortal(newRV_noinc((SV *)arr)));
}
/* reverse the stack */
end = SP;
while (start < end) {
SV *tmp = *start;
*start++ = *end;
*end-- = tmp;
}
}
else {
j = 0;
view all matches for this distribution
view release on metacpan or search on metacpan
#
# This subroutine changes $File_Length_Difference
#
# Fields in a Hunk:
# blocks - a list of Block objects
# start - index in file 1 where first block of the hunk starts
# end - index in file 1 where last block of the hunk ends
#
# Variables:
# before_diff - how much longer file 2 is than file 1 due to all hunks
# until but NOT including this one
my $before_diff = $File_Length_Difference; # BEFORE this hunk
my $after_diff = $before_diff + $block->{"length_diff"};
$File_Length_Difference += $block->{"length_diff"};
# @remove_array and @insert_array hold the items to insert and remove
# Save the start & beginning of each array. If the array doesn't exist
# though (e.g., we're only adding items in this block), then figure
# out the line number based on the line number of the other file and
# the current difference in file lengths
my @remove_array = $block->remove;
my @insert_array = $block->insert;
my ($a1, $a2, $b1, $b2, $start1, $start2, $end1, $end2);
$a1 = @remove_array ? $remove_array[0 ]->{"item_no"} : -1;
$a2 = @remove_array ? $remove_array[-1]->{"item_no"} : -1;
$b1 = @insert_array ? $insert_array[0 ]->{"item_no"} : -1;
$b2 = @insert_array ? $insert_array[-1]->{"item_no"} : -1;
$start1 = $a1 == -1 ? $b1 - $before_diff : $a1;
$end1 = $a2 == -1 ? $b2 - $after_diff : $a2;
$start2 = $b1 == -1 ? $a1 + $before_diff : $b1;
$end2 = $b2 == -1 ? $a2 + $after_diff : $b2;
# At first, a hunk will have just one Block in it
my $hunk = {
"start1" => $start1,
"start2" => $start2,
"end1" => $end1,
"end2" => $end2,
"blocks" => [$block],
};
bless $hunk, $class;
$hunk->flag_context($context_items);
return $hunk;
}
# Change the "start" and "end" fields to note that context should be added
# to this hunk
sub flag_context {
my ($hunk, $context_items) = @_;
return unless $context_items; # no context
# add context before
my $start1 = $hunk->{"start1"};
my $num_added = $context_items > $start1 ? $start1 : $context_items;
$hunk->{"start1"} -= $num_added;
$hunk->{"start2"} -= $num_added;
# context after
my $end1 = $hunk->{"end1"};
$num_added = ($end1+$context_items > $#f1) ?
$#f1 - $end1 :
sub does_overlap {
my ($hunk, $oldhunk) = @_;
return "" unless $oldhunk; # first time through, $oldhunk is empty
# Do I actually need to test both?
return ($hunk->{"start1"} - $oldhunk->{"end1"} <= 1 ||
$hunk->{"start2"} - $oldhunk->{"end2"} <= 1);
}
# Prepend hunk arg1 to hunk arg0
# Note that arg1 isn't updated! Only arg0 is.
sub prepend_hunk {
my ($hunk, $oldhunk) = @_;
$hunk->{"start1"} = $oldhunk->{"start1"};
$hunk->{"start2"} = $oldhunk->{"start2"};
unshift (@{$hunk->{"blocks"}}, @{$oldhunk->{"blocks"}});
}
# Calculate item number range.
my $range1 = $hunk->unified_range(1);
my $range2 = $hunk->unified_range(2);
print "@@ -$range1 +$range2 @@\n";
# Outlist starts containing the hunk of file 1.
# Removing an item just means putting a '-' in front of it.
# Inserting an item requires getting it from file2 and splicing it in.
# We splice in $num_added items. Remove blocks use $num_added because
# splicing changed the length of outlist.
# We remove $num_removed items. Insert blocks use $num_removed because
# their item numbers---corresponding to positions in file *2*--- don't take
# removed items into account.
my $low = $hunk->{"start1"};
my $hi = $hunk->{"end1"};
my ($num_added, $num_removed) = (0,0);
my @outlist = @$fileref1[$low..$hi];
map {s/^/ /} @outlist; # assume it's just context
$num_removed++;
}
foreach my $item ($block->insert) {
my $op = $item->{"sign"}; # +
my $i = $item->{"item_no"};
my $offset = $i - $hunk->{"start2"} + $num_removed;
splice(@outlist,$offset,0,"$op$$fileref2[$i]");
$num_added++;
}
}
my $range2 = $hunk->context_range(2);
# Print out file 1 part for each block in context diff format if there are
# any blocks that remove items
print "*** $range1 ****\n";
my $low = $hunk->{"start1"};
my $hi = $hunk->{"end1"};
if (@blocklist = grep {$_->remove} @{$hunk->{"blocks"}}) {
my @outlist = @$fileref1[$low..$hi];
map {s/^/ /} @outlist; # assume it's just context
foreach my $block (@blocklist) {
map {s/$/\n/} @outlist; # add \n's
print @outlist;
}
print "--- $range2 ----\n";
$low = $hunk->{"start2"};
$hi = $hunk->{"end2"};
if (@blocklist = grep {$_->insert} @{$hunk->{"blocks"}}) {
my @outlist = @$fileref2[$low..$hi];
map {s/^/ /} @outlist; # assume it's just context
foreach my $block (@blocklist) {
}
}
sub context_range {
# Generate a range of item numbers to print. Only print 1 number if the range
# has only one item in it. Otherwise, it's 'start,end'
my ($hunk, $flag) = @_;
my ($start, $end) = ($hunk->{"start$flag"},$hunk->{"end$flag"});
$start++; $end++; # index from 1, not zero
my $range = ($start < $end) ? "$start,$end" : $end;
return $range;
}
sub unified_range {
# Generate a range of item numbers to print for unified diff
# Print number where block starts, followed by number of lines in the block
# (don't print number of lines if it's 1)
my ($hunk, $flag) = @_;
my ($start, $end) = ($hunk->{"start$flag"},$hunk->{"end$flag"});
$start++; $end++; # index from 1, not zero
my $length = $end - $start + 1;
my $first = $length < 2 ? $end : $start; # strange, but correct...
my $range = $length== 1 ? $first : "$first,$length";
return $range;
}
} # end Package Hunk
view all matches for this distribution