chiark / gitweb /
i18n: i18n-diff-auditor: fix striang (de)concatenation
[dgit.git] / i18n-diff-auditor
index 80840913235bfe81230a885531651f0340e0a05b..e8914c004e0d20e0de81675d913430d2ac0d924f 100755 (executable)
@@ -108,7 +108,7 @@ our ($ichunkstart, $ichunkend);
 our ($before, $after);
 
 sub is_string ($) { $_[0]{T} =~ m/heredoc|string/; }
-sub is_trans ($) { grep { $_[0]{E} eq $_ } qw(__ f_); }
+sub is_trans ($) { grep { $_[0]{E} eq $_ } qw(__ f_ i_); }
 
 sub semiparse ($) {
     ($_) = @_;
@@ -160,9 +160,10 @@ sub semiparse ($) {
            die "cannot tokenise \`$&'";
        }
     }
-    for (my $i=@o-2; $i>0; --$i) {
+    for (my $i=0; $i+2 < @o; $i++) {
        next unless $o[$i+1]{E} eq '.';
        my @inputs = @o[$i, $i+2];
+       #print STDERR Dumper(\@inputs);
        next if grep { !is_string($_) } @inputs;
        my $q = $inputs[0]{Q};
        next if grep { $_->{Q} ne $q } @inputs;
@@ -173,6 +174,7 @@ sub semiparse ($) {
                    Q => $q,
                  };
        @o = (@o[0..$i-1], $new, @o[$i+3..$#o]);
+       $i--; # counteracts $i++
     }
     debug $ichunkstart, "semiparsed: ".join ' ', map { $_->{P} } @o;
     return @o;
@@ -238,6 +240,10 @@ sub analyse_chunk_core () {
            die $string_changed if length $string_changed;
            next;
        }
+       if ($ye eq 'i_') {
+           die $string_changed if length $string_changed;
+           next;
+       }
        if ($ye eq 'f_') {
            my $fmt = $y->{V};
            die "no percent in _f string\n" unless $fmt =~ m{\%};