From bd5964cbbb89a7009f9c25150fb4260298862191 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 1 Oct 2018 03:05:08 +0100 Subject: [PATCH] i18n: i18n-diff-auditor: handle invented here doc end differently Signed-off-by: Ian Jackson --- i18n-diff-auditor | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/i18n-diff-auditor b/i18n-diff-auditor index 85392c09..13454197 100755 --- a/i18n-diff-auditor +++ b/i18n-diff-auditor @@ -138,12 +138,17 @@ 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 { + s{ \n (.*) }{ \n }s; + $o[$#o]{V} = $1; + $o[$#o]{Invented} = 1; + } } elsif (s{^ (["'])( (?: [^\\'"] | \\ [^"'] | (?! \1 ) [^"] @@ -177,6 +182,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), @@ -357,6 +363,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; -- 2.30.2