chiark / gitweb /
auditor wip output
[dgit-junk.git] / i18n-diff-auditor
index b9bd4e50e17e1643c894ad961bfbe2e7771f594a..36f3da3005384a73e9a10de3e53da0e83ba531f0 100755 (executable)
@@ -91,7 +91,9 @@ sub prep_perlop () {
 
 prep_perlop();
 
-our ($ifilehead, $ihunkhead, $ichunkstart, $ichunkend);
+our ($ifilehead, $ifirsthunkhead);
+our ($ihunkhead, $ihunkend);
+our ($ichunkstart, $ichunkend);
 our ($before, $after);
 
 sub semiparse ($) {
@@ -264,10 +266,53 @@ sub analyse_chunk () {
     }
 }
 
+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;
@@ -277,10 +322,9 @@ for ($ifilehead = 0; l_ok $ifilehead; $ifilehead++) {
                    $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;
                }
@@ -295,6 +339,8 @@ for ($ifilehead = 0; l_ok $ifilehead; $ifilehead++) {
                confess "$i $_ ?";
            }
        }
+       $ihunkend = $i;
+       report_on_hunk();
        $ichunkend = $i;
        $ihunkhead = $i;
     }