From a90695ff9e9240422b2f4ff64fad8618f2321f7e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 30 Sep 2018 12:37:35 +0100 Subject: [PATCH] auditor wip --- i18n-diff-auditor | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/i18n-diff-auditor b/i18n-diff-auditor index 777bf47..393ee59 100755 --- a/i18n-diff-auditor +++ b/i18n-diff-auditor @@ -11,28 +11,43 @@ sub l_ok ($) { 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($before, $after); +} + for ($ifilehead = 0; l_ok $ifilehead; $ifilehead++) { m{^diff} or next; while (l_ok $ifilehead and m{^index|^---|^\Q+++\E}) { } $ihunkhead = $ifilehead; while (l_ok $ihunkhead) { - m{^\@\@} or confess; - $ichunk = $ihunkhead + 1; + m{^\@\@} or confess "$_ ?"; + my $i = $ihunkhead + 1; for (;;) { - l_ok $ichunk or last; - - while (l_ok $ichunk and + 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; + } elif (m{^[-+]}) { + my $which = $& eq '-' ? \$before : \$after; + $ichunkfirst //= $i; + $$which //= ''; + $$which .= $'; + } else { + confess "$_ ?"; + } + } + $ihunkhead = $i; } - - confess unless m{^\@\@}; - - -while (<>){ - if (m/^diff.*/) { - my $headline = } -- 2.30.2