summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2008-08-03 11:17:05 +0200
committerJonas Smedegaard <dr@jones.dk>2013-10-13 00:47:50 +0200
commita3c58e4bbd0b8d0f5632f38287cdb1b1db114bcb (patch)
treebc4d0fe9c50ea1ed19dd253cf1734d8eab0345c6
parent6efb13d8a0a075b4a78ae4bbe6c59a2e4a565266 (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).
-rw-r--r--Locale/Po4a/Text.pm15
1 files changed, 11 insertions, 4 deletions
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;