chiark / gitweb /
auditor wip before output
[dgit-junk.git] / i18n-diff-auditor
index f8528d97d1e26b430b4cb43eb382172a276ebe75..b9bd4e50e17e1643c894ad961bfbe2e7771f594a 100755 (executable)
@@ -151,26 +151,27 @@ sub semiparse ($) {
 sub analyse_chunk_core () {
     die "plain deletion\n" unless defined $after;
     die "plain insertion\n" unless defined $before;
-    my @before = semiparse $before;
-    my @after = semiparse $after;
+    my @xs = semiparse $before;
+    my @ys = semiparse $after;
     my $next_something = sub {
        my ($ary,$var,$what) = @_;
        die "ran out of $what\n" unless @$ary;
        $$var = shift @$ary;
     };
     my ($x,$y);
-    my $next_before = sub { $next_something->(\@before, \$x, 'before'); };
-    my $next_after  = sub { $next_something->(\@after , \$y, 'after' ); };
+    my $next_x = sub { $next_something->(\@xs, \$x, 'before'); };
+    my $next_y = sub { $next_something->(\@ys, \$y, 'after' ); };
     my $is_string = sub { $_[0]{T} =~ m/heredoc|string/; };
     for (;;) {
-       last unless @before or @after;
-       $next_before->();
-       $next_after->();
+       last unless @xs or @ys;
+       $next_x->();
+       $next_y->();
        next if $x->{E} eq $y->{E};
        my $string_changed;
-       if ($y->{E} eq '__' or $y->{E} eq '_f') {
-           $next_after->();
-           die "__ on non-string $y->{P}\n"     unless Sis_string->($y);
+       my $ye = $y->{E};
+       if ($ye eq '__' or $ye eq 'f_') {
+           $next_y->();
+           die "__ on non-string $y->{P}\n"     unless $is_string->($y);
            die "__ on was non-string $y->{P}\n" unless $is_string->($x);
            if ($y->{Q} ne "'") {
                die "var subst in new string\n"
@@ -182,13 +183,13 @@ sub analyse_chunk_core () {
            };
            $string_changed = $@;
        }
-       if ($y->{E} eq '__') {
+       if ($ye eq '__') {
            $_ = $y->{V};
            die "percent $& in __ ' string\n" if m{\%};
            die $string_changed if length $string_changed;
            next;
        }
-       if ($y->{E} eq 'f_') {
+       if ($ye eq 'f_') {
            my $fmt = $y->{V};
            die "no percent in _f string\n" unless $fmt =~ m{\%};
            next unless $string_changed;
@@ -210,10 +211,10 @@ sub analyse_chunk_core () {
                $fmt = $';
                if ($& eq '%%') { $exactly->('%'); next; }
                elsif ($& ne '%s') { die "unhandled %-subst $&\n"; }
-               $next_after->();
+               $next_y->();
                die "expected comma, got $y->{P}\n" unless $y->{E} eq ',';
                if ($xs =~ m{^\@}) {
-                   $next_after->();
+                   $next_y->();
                    die "\@... => not string" unless $is_string->($y);
                    die "\@... => $y->{P}" if $y->{Q} ne '"';
                    $exactly->($y->{V});
@@ -221,15 +222,15 @@ sub analyse_chunk_core () {
                }
                my $bras = 0;
                for (;;) {
-                   if (!$bras and !@after) {
+                   if (!$bras and !@ys) {
                        last;
                    }
-                   $next_after->();
+                   $next_y->();
                    if (!$bras and
                        (grep { $y->{E} eq $_ } qw( or xor and not ; : )
                         or $y->{T} eq 'ket'
                        )) {
-                       unshift @after, $y;
+                       unshift @ys, $y;
                        last;
                    }
                    $xs =~ s{^\s+}{};