summaryrefslogtreecommitdiff
path: root/i18n-diff-auditor
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2018-10-01 03:05:08 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-10-01 03:09:59 +0100
commitbd5964cbbb89a7009f9c25150fb4260298862191 (patch)
tree0e252f55e4333a3bdaf5f23877f7018e7633b5b4 /i18n-diff-auditor
parent48c68afc2da8437dbe274ba3013ece2d1515d9e9 (diff)
i18n: i18n-diff-auditor: handle invented here doc end differently
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'i18n-diff-auditor')
-rwxr-xr-xi18n-diff-auditor20
1 files changed, 14 insertions, 6 deletions
diff --git a/i18n-diff-auditor b/i18n-diff-auditor
index 85392c0..1345419 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;