X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=i18n-diff-auditor;h=e2c010142d334bc42b439bf8b9c590e7a9c95802;hb=1b5fa179018c14bb6bc8cd9149dee0a4ea7085bc;hp=116b0f82fd314fe005ef3de278ba39bbeae922c5;hpb=1c9a99297143d028936205973ebbeba47f5e8213;p=dgit.git diff --git a/i18n-diff-auditor b/i18n-diff-auditor index 116b0f82..e2c01014 100755 --- a/i18n-diff-auditor +++ b/i18n-diff-auditor @@ -122,6 +122,7 @@ sub qp ($) { sub semiparse ($) { ($_) = @_; my @o; + #my $in = $_; # entries contain # T type # E exact input text (does not contain here doc contents) @@ -137,12 +138,18 @@ sub semiparse ($) { $q ||= '"'; push @o, { T => 'heredoc', Q => $q, Delim => $d, E => $&, P => "<<$q$d$q" }; - s{^ - ( .* \n ) - ( (?: (?! $d \n ) .* \n )*? ) - $d \n - }{ $1 }xe or die "missing end of here doc $d\n"; - $o[$#o]{V} = $2; + if (s{^ + ( .* \n ) + ( (?: (?! $d \n ) .* \n )*? ) + $d \n + }{ $1 }xe) { + $o[$#o]{V} = $2; + } else { + m{^.*\n} or confess; + $_ = $&; + $o[$#o]{V} = $'; + $o[$#o]{Invented} = 1; + } } elsif (s{^ (["'])( (?: [^\\'"] | \\ [^"'] | (?! \1 ) [^"] @@ -176,6 +183,7 @@ sub semiparse ($) { next if grep { !is_string($_) } @inputs; my $q = $inputs[0]{Q}; next if grep { $_->{Q} ne $q } @inputs; + next if grep { $_->{Invented} } @inputs; my $new = { T => 'joinedstrings', E => (join '.', map { $_->{E} } @inputs), P => (join '.', map { $_->{P} } @inputs), @@ -222,6 +230,7 @@ sub analyse_chunk_core () { next if $x->{E} eq $y->{E}; next if $x->{E} eq 'sprintf' and $y->{E} eq 'f_'; next if $x->{E} eq 'die' and $y->{E} eq 'confess'; + next if $x->{E} eq 'die' and $y->{E} eq 'fail'; if ($y->{E} eq '+' and @ys >= 3 and $ys[0]{E} eq '(' @@ -282,6 +291,7 @@ sub analyse_chunk_core () { $xs = substr($xs, length($lit)); }; for (;;) { + #print STDERR Dumper($fmt, $xs, \@xs, @ys); if ($fmt !~ m{\%[^\%]}) { $exactly->($fmt, '(tail)'); $fmt = ''; @@ -355,6 +365,8 @@ sub analyse_chunk () { return unless length $@; if ($@ =~ m{^missing end of here doc (\S+)\n}) { # fudge this + # (this never happens now, but in the future we might + # want this code again eg to try adding to the chunk) $before .= "\n$1\n"; $after .= "\n$1\n"; next;