prep_perlop();
-our ($ifilehead, $ihunkhead, $ichunkstart, $ichunkend);
+our ($ifilehead, $ifirsthunkhead);
+our ($ihunkhead, $ihunkend);
+our ($ichunkstart, $ichunkend);
our ($before, $after);
sub semiparse ($) {
$$var = shift @$ary;
};
my ($x,$y);
- my $next_before = sub { $next_something->(\@xs, \$x, 'before'); };
- my $next_after = sub { $next_something->(\@ys , \$y, 'after' ); };
+ my $next_x = sub { $next_something->(\@xs, \$x, 'before'); };
+ my $next_y = sub { $next_something->(\@ys, \$y, 'after' ); };
my $is_string = sub { $_[0]{T} =~ m/heredoc|string/; };
for (;;) {
last unless @xs or @ys;
- $next_before->();
- $next_after->();
+ $next_x->();
+ $next_y->();
next if $x->{E} eq $y->{E};
my $string_changed;
- if ($y->{E} eq '__' or $y->{E} eq '_f') {
- $next_after->();
- die "__ on non-string $y->{P}\n" unless Sis_string->($y);
+ my $ye = $y->{E};
+ if ($ye eq '__' or $ye eq 'f_') {
+ $next_y->();
+ die "__ on non-string $y->{P}\n" unless $is_string->($y);
die "__ on was non-string $y->{P}\n" unless $is_string->($x);
if ($y->{Q} ne "'") {
die "var subst in new string\n"
};
$string_changed = $@;
}
- if ($y->{E} eq '__') {
+ if ($ye eq '__') {
$_ = $y->{V};
die "percent $& in __ ' string\n" if m{\%};
die $string_changed if length $string_changed;
next;
}
- if ($y->{E} eq 'f_') {
+ if ($ye eq 'f_') {
my $fmt = $y->{V};
die "no percent in _f string\n" unless $fmt =~ m{\%};
next unless $string_changed;
$fmt = $';
if ($& eq '%%') { $exactly->('%'); next; }
elsif ($& ne '%s') { die "unhandled %-subst $&\n"; }
- $next_after->();
+ $next_y->();
die "expected comma, got $y->{P}\n" unless $y->{E} eq ',';
if ($xs =~ m{^\@}) {
- $next_after->();
+ $next_y->();
die "\@... => not string" unless $is_string->($y);
die "\@... => $y->{P}" if $y->{Q} ne '"';
$exactly->($y->{V});
if (!$bras and !@ys) {
last;
}
- $next_after->();
+ $next_y->();
if (!$bras and
(grep { $y->{E} eq $_ } qw( or xor and not ; : )
or $y->{T} eq 'ket'
}
}
+our @report;
+our $last_filehead = -1;
+
+sub report_on_hunk () {
+ return unless @report;
+ if ($last_filehead != $ifilehead) {
+ foreach (my $i=$ifilehead; $i<$ifirsthunkhead; $i++) {
+ print $d[$i];
+ }
+ $last_filehead = $ifilehead;
+ }
+ my $dummy_r = { S => (scalar @d)+1, E => (scalar @d)+1 };
+ my $r;
+ for (my $i=$ihunkhead; ; $i++) {
+ for (;;) {
+ $r //= shift @report;
+ $r //= $dummy_r;
+ last if $i < $r->{E};
+ confess unless $r->{Done} == 03;
+ $r = undef;
+ }
+
+ last unless $i<$ihunkend;
+
+ if ($i == $r->{S}) {
+ print "!! $r->{M}";
+ $r->{Done} |= 01;
+ }
+ if ($i >= $r->{S}) {
+ print "!";
+ $r->{Done} |= 02;
+ } else {
+ print " ";
+ }
+ print $d[$i];
+ }
+ confess unless $r = $dummy_r;
+}
+
for ($ifilehead = 0; l_ok $ifilehead; $ifilehead++) {
m{^diff} or next;
- while (l_ok $ifilehead and m{^diff|^index|^---|^\Q+++\E}) { $ifilehead++ }
- $ihunkhead = $ifilehead;
+ $ifirsthunkhead = $ifilehead;
+ while (l_ok $ifirsthunkhead and
+ m{^diff|^index|^---|^\Q+++\E}) {
+ $ifirsthunkhead++
+ }
+ $ihunkhead = $ifirsthunkhead;
while (l_ok $ihunkhead) {
m{^\@\@} or confess "$ihunkhead $_ ?";
my $i = $ihunkhead + 1;
$ichunkend = $i;
eval { analyse_chunk(); 1; };
if (length $@) {
- print Dumper('REPORT',
- $ichunkstart, $ichunkend,
- $before, $after,
- $@);
+ push @report, { M => $@,
+ S => $ichunkstart,
+ E => $ichunkend };
}
$ichunkstart = $ichunkend = $before = $after = undef;
}
confess "$i $_ ?";
}
}
+ $ihunkend = $i;
+ report_on_hunk();
$ichunkend = $i;
$ihunkhead = $i;
}