From 5ddf87cdbf6e5516917f2dfbd1c9759aa3b4120e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 30 Sep 2018 12:49:29 +0100 Subject: [PATCH] auditor wip can call analyse_chunk --- i18n-diff-auditor | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/i18n-diff-auditor b/i18n-diff-auditor index 393ee59..420e25d 100755 --- a/i18n-diff-auditor +++ b/i18n-diff-auditor @@ -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; } } -- 2.30.2