Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
+our @analysed_x;
+our @analysed_y;
+
sub analyse_chunk_core () {
die "plain deletion\n" unless defined $after;
die "plain insertion\n" unless defined $before;
my @xs = semiparse $before;
my @ys = semiparse $after;
sub analyse_chunk_core () {
die "plain deletion\n" unless defined $after;
die "plain insertion\n" unless defined $before;
my @xs = semiparse $before;
my @ys = semiparse $after;
+ @analysed_x = @analysed_y = ();
my $next_something = sub {
my $next_something = sub {
- my ($ary,$var,$what) = @_;
+ my ($ary,$anal,$var,$what) = @_;
die "ran out of $what\n" unless @$ary;
die "ran out of $what\n" unless @$ary;
+ my $r = shift @$ary;
+ push @$anal, $r->{P};
+ $$var = $r;
- my $next_x = sub { $next_something->(\@xs, \$x, 'before'); };
- my $next_y = sub { $next_something->(\@ys, \$y, 'after' ); };
+ my $next_x = sub { $next_something->(\@xs, \@analysed_x, \$x, 'before'); };
+ my $next_y = sub { $next_something->(\@ys, \@analysed_y, \$y, 'after' ); };
for (;;) {
last unless @xs or @ys;
$next_x->();
for (;;) {
last unless @xs or @ys;
$next_x->();
my ($lit, $what) = @_;
my $xl = substr($xs, 0, length($lit));
if ($xl ne $lit) {
my ($lit, $what) = @_;
my $xl = substr($xs, 0, length($lit));
if ($xl ne $lit) {
- debug $ichunkstart, "not exactly x: $xl";
+ debug $ichunkstart, "not exactly x: $xs";
debug $ichunkstart, "not exactly y: $lit";
my $next = @ys ? $ys[0]{P} : '(end)';
die "string contents mismatch near $what before $next\n";
debug $ichunkstart, "not exactly y: $lit";
my $next = @ys ? $ys[0]{P} : '(end)';
die "string contents mismatch near $what before $next\n";
$ichunkend = $i;
eval { analyse_chunk(); 1; };
if (length $@) {
$ichunkend = $i;
eval { analyse_chunk(); 1; };
if (length $@) {
+ debug $ichunkstart, "done x: @analysed_x";
+ debug $ichunkstart, "done y: @analysed_y";
push @report, { M => $@,
S => $ichunkstart,
E => $ichunkend };
push @report, { M => $@,
S => $ichunkstart,
E => $ichunkend };