chiark / gitweb /
auditor wip can call analyse_chunk
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 Sep 2018 11:49:29 +0000 (12:49 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 Sep 2018 11:49:29 +0000 (12:49 +0100)
i18n-diff-auditor

index 393ee59b92de5213163b576e389a95c59a69ab56..420e25dc2199205a7aba724140edd35cd52d159c 100755 (executable)
@@ -1,13 +1,27 @@
 #!/usr/bin/perl -w
 use strict;
 use Carp;
+use Data::Dumper;
 
 my @d = <>;
+unshift @d, "# dummy line to make line 1 index 1 in \@d\n";
+
+our $i_last_l_ok = -1;
+our $count_i_last_l_ok;
 
 sub l_ok ($) {
     my ($i) = @_;
+
+    if ($i == $i_last_l_ok) {
+       confess $i if $count_i_last_l_ok++ > 50;
+    } else {
+       $count_i_last_l_ok = 0;
+       $i_last_l_ok = $i;
+    }
+
     return unless $i < @d;
     $_ = $d[$i];
+    #print STDERR "L $i\n";
     1;
 }
 
@@ -20,17 +34,18 @@ our ($ifilehead, $ihunkhead, $ichunkstart, $ichunkend);
 our ($before, $after);
 
 sub analyse_chunk () {
-    print Dumper($before, $after);
+    print Dumper($ichunkstart, $ichunkend, $before, $after);
+    flush STDOUT;
 }
 
 for ($ifilehead = 0; l_ok $ifilehead; $ifilehead++) {
     m{^diff} or next;
-    while (l_ok $ifilehead and m{^index|^---|^\Q+++\E}) { }
+    while (l_ok $ifilehead and m{^diff|^index|^---|^\Q+++\E}) { $ifilehead++ }
     $ihunkhead = $ifilehead;
     while (l_ok $ihunkhead) {
-       m{^\@\@} or confess "$_ ?";
+       m{^\@\@} or confess "$ihunkhead $_ ?";
        my $i = $ihunkhead + 1;
-       for (;;) {
+       for (; ; $i++) {
            if (!l_ok $i or m{^ } or m{^\@\@}) {
                if (defined $ichunkstart) {
                    $ichunkend = $i;
@@ -39,15 +54,16 @@ for ($ifilehead = 0; l_ok $ifilehead; $ifilehead++) {
                }
                l_ok $i or last;
                m{^\@\@} and last;
-           } elif (m{^[-+]}) {
+           } elsif (m{^[-+]}) {
                my $which = $& eq '-' ? \$before : \$after;
-               $ichunkfirst //= $i;
+               $ichunkstart //= $i;
                $$which //= '';
                $$which .= $';
            } else {
-               confess "$_ ?";
+               confess "$i $_ ?";
            }
        }
+       $ichunkend = $i;
        $ihunkhead = $i;
     }
 }