From a3c58e4bbd0b8d0f5632f38287cdb1b1db114bcb Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 3 Aug 2008 11:17:05 +0200 Subject: 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). --- Locale/Po4a/Text.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Locale') diff --git a/Locale/Po4a/Text.pm b/Locale/Po4a/Text.pm index 093b572..fad995a 100644 --- a/Locale/Po4a/Text.pm +++ b/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; -- cgit v1.2.3