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(-) 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 /c4?h=master'>c4/633ADA2D-05AF-44AD-91FD-18E4862EC3D2@gmx.de/debian
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2023-06-27 09:35:08 +0200
committerJonas Smedegaard <dr@jones.dk>2023-06-27 09:35:08 +0200
commitfd54908da2b05c526dd3bee9b6dcd093214a220d (patch)
treec69c845069c99d1d01044f6fafda7c08433329c6 /tags/fb/c4/633ADA2D-05AF-44AD-91FD-18E4862EC3D2@gmx.de/debian
parentba46132213560cf3335d53560d519c0ec0190da2 (diff)
Diffstat (limited to 'tags/fb/c4/633ADA2D-05AF-44AD-91FD-18E4862EC3D2@gmx.de/debian')
-rw-r--r--tags/fb/c4/633ADA2D-05AF-44AD-91FD-18E4862EC3D2@gmx.de/debian0
1 files changed, 0 insertions, 0 deletions