diff options
author | Jonas Smedegaard <dr@jones.dk> | 2008-08-03 11:17:05 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2008-08-03 11:33:42 +0200 |
commit | b7cdbb930e3c984fba06e86030e37189e2fe214a (patch) | |
tree | 149326ffc65153e06b0fc9a5d0a924d035bdd52d /perl/Locale/Po4a | |
parent | d0c0798f1ef43680ccc322caa84a5bb8d0890d6b (diff) |
Fix not stripping final newline of some files
Text parser is broken: It assumes it is parsing only a single file.
po4a 0.34 partly fixed this by checking at beginning of each iteration
of the loop if filename changed - but only then - not at the several
places do_paragraph() is done multiple times in same iteration.
This patch makes does the opposite: it ensures that all files contain a
final newline.
This breaks files that has no final newline (but those shouold be rare).
Diffstat (limited to 'perl/Locale/Po4a')
-rw-r--r-- | perl/Locale/Po4a/Text.pm | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/perl/Locale/Po4a/Text.pm b/perl/Locale/Po4a/Text.pm index 093b572..fad995a 100644 --- a/perl/Locale/Po4a/Text.pm +++ b/perl/Locale/Po4a/Text.pm @@ -140,6 +140,7 @@ sub parse { $paragraph=""; } + # TODO: preserve original line ends throughout the code instead chomp($line); $self->{ref}="$ref"; if ($debianchangelog and @@ -162,6 +163,8 @@ sub parse { $line =~ m/^%%?\s*$/) { # Found end of fortune do_paragraph($self,$paragraph,$wrapped_mode); + # FIXME: test if this is still needed when always adding + # newline in do_paragraph() $self->pushline("\n") unless ( $wrapped_mode == 0 or $paragraph eq ""); $paragraph=""; @@ -170,8 +173,6 @@ sub parse { } elsif ($line =~ /^\s*$/) { # Break paragraphs on lines containing only spaces do_paragraph($self,$paragraph,$wrapped_mode); - $self->pushline("\n") unless ( $wrapped_mode == 0 - or $paragraph eq ""); $paragraph=""; $wrapped_mode = 1; $self->pushline($line."\n"); @@ -277,10 +278,16 @@ TEST_BULLET: } # TODO: detect indented paragraphs - $self->pushline( $self->translate($paragraph, + my $transfinal = $self->translate($paragraph, $self->{ref}, "Plain text", - "wrap" => $wrap) ); + "wrap" => $wrap); + + # TODO: preserve original line ends throughout the code instead + chomp $transfinal; + $transfinal .= "\n"; + + $self->pushline( $transfinal ); } 1; |