chiark / gitweb /
i18n: i18n-diff-auditor: handle invented here doc end differently
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Oct 2018 02:05:08 +0000 (03:05 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Oct 2018 02:09:59 +0000 (03:09 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
i18n-diff-auditor

index 85392c0..1345419 100755 (executable)
@@ -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;