[Po4a-devel]Two small issues with Po.pm
Nicolas François
nicolas.francois@centraliens.net
Thu, 25 Nov 2004 00:27:46 +0100
--n8g4imXOkfNTN/H1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello,
There is a first issue which causes a bad formatting of the po4a.7 and
Locale::Po4a::TransTractor manpages:
Here is an example:
http://po4a.alioth.debian.org/es/Locale/Po4a/TransTractor.html#DESCRIPCION
(at the end of this section, the "bone" is broken)
This is caused by a line ending by a \ in a no-wrap paragraph.
The Po unescape function replace ([^\\])\\n by $1\n
I think it should instead replace "even number of \ followed by \n"
thus s/([^\\](\\\\)*)\\n/$1\n/g;
(I'm joining Po.pm.escape.patch)
If you think it is the right way to fix this issue, then I will also
change other similar regular expressions in this module (there are many
others).
The second issue is one of the problems detected by the WDIFF category of
the testsuite (some text is present in the original, but not in the
translation, or the contrary).
If a man page contains something like that (in a wrapped paragraph):
\fP
foo
then the font stack may "delay" the font modifier, and po4a generates the
following paragraph: "\nfoo". The result of gettext with this msgid is
always a null string.
I will fix the Man module so that the empty line will be pushed without
translation, but the Po module may need the second patch.
(I'm joining Po.pm.defined_empty.patch and foo.1, which trigger this
issue)
Both patches work, but I'm not sure of my perl and I would prefer you have
a look at them.
Regards,
--
Nekral
--n8g4imXOkfNTN/H1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Po.pm.escape.patch"
Index: lib/Locale/Po4a/Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.29
diff -a -u -r1.29 Po.pm
--- lib/Locale/Po4a/Po.pm 5 Nov 2004 20:33:51 -0000 1.29
+++ lib/Locale/Po4a/Po.pm 24 Nov 2004 21:20:31 -0000
@@ -972,7 +972,7 @@
print STDERR "\nunescape [$text]====" if $debug{'escape'};
$text = join("",split(/\n/,$text));
$text =~ s/\\"/"/g;
- $text =~ s/([^\\])\\n/$1\n/g;
+ $text =~ s/([^\\](\\\\)*)\\n/$1\n/g;
$text =~ s/^\\n/\n/mg;
$text =~ s/([^\\])\\t/$1\t/g;
$text =~ s/\\\\/\\/g;
--n8g4imXOkfNTN/H1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Po.pm.defined_empty.patch"
Index: lib/Locale/Po4a/Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.29
diff -a -u -r1.29 Po.pm
--- lib/Locale/Po4a/Po.pm 5 Nov 2004 20:33:51 -0000 1.29
+++ lib/Locale/Po4a/Po.pm 24 Nov 2004 22:30:19 -0000
@@ -1057,7 +1057,7 @@
my @lines=split(/\n/,"$text");
my $res="";
my $first=1;
- while (my $line=shift @lines) {
+ while (defined(my $line=shift @lines)) {
if ($first && length($line) > $col - 10) {
unshift @lines,$line;
$first=0;
--n8g4imXOkfNTN/H1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="foo.1"
.TH foo 1
.SH NAME
\fB
.nf
foo
.fi
\fP
foo
--n8g4imXOkfNTN/H1--