chiark / gitweb /
auditor wip can call analyse_chunk
[dgit-junk.git] / i18n-diff-auditor
index 777bf47ededa166703f847d7290a1c839d394727..420e25dc2199205a7aba724140edd35cd52d159c 100755 (executable)
@@ -1,38 +1,69 @@
 #!/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;
 }
 
-sub l ($) { confess unless l_ok $_[0]; };
+sub l ($) {
+    my ($i) = @_;
+    confess $i unless l_ok $i;
+};
 
-our ($ifilehead, $ihunkhead, $ichunk);
+our ($ifilehead, $ihunkhead, $ichunkstart, $ichunkend);
 our ($before, $after);
 
+sub analyse_chunk () {
+    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;
-       $ichunk = $ihunkhead + 1;
-       for (;;) {
-           l_ok $ichunk or last;
-           
-       while (l_ok $ichunk and 
+       m{^\@\@} or confess "$ihunkhead $_ ?";
+       my $i = $ihunkhead + 1;
+       for (; ; $i++) {
+           if (!l_ok $i or m{^ } or m{^\@\@}) {
+               if (defined $ichunkstart) {
+                   $ichunkend = $i;
+                   analyse_chunk();
+                   $ichunkstart = $ichunkend = $before = $after = undef;
+               }
+               l_ok $i or last;
+               m{^\@\@} and last;
+           } elsif (m{^[-+]}) {
+               my $which = $& eq '-' ? \$before : \$after;
+               $ichunkstart //= $i;
+               $$which //= '';
+               $$which .= $';
+           } else {
+               confess "$i $_ ?";
+           }
+       }
+       $ichunkend = $i;
+       $ihunkhead = $i;
     }
-       
-    confess unless m{^\@\@};
-          
-
-while (<>){
-    if (m/^diff.*/) {
-       my $headline = 
 }