[Po4a-commits] "po4a/lib/Locale/Po4a Sgml.pm,1.115,1.116"
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Sun Oct 22 16:49:26 UTC 2006
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv12961/lib/Locale/Po4a
Modified Files:
Sgml.pm
Log Message:
Increment the line references even when nsgmls do not indicate that the
line changed: take into accound the record ends (event with type 're').
This closes Alioth's bug #300589 (reference for composite SGML documents
not perfect). (hopefully, this will stop the spammer).
Index: Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- Sgml.pm 22 Oct 2006 16:32:53 -0000 1.115
+++ Sgml.pm 22 Oct 2006 16:49:24 -0000 1.116
@@ -856,10 +856,21 @@
my $lastchar = ''; #
my $buffer= ""; # what we will soon handle
+ # Keep a reference to the last line indicated by nsgmls
+ my $line=0;
+ # Unfortunately, nsgmls do not mention all the line changes. We have
+ # to keep track of the number of lines seen in the "record ends".
+ my $adds=0;
# run the appropriate handler for each event
EVENT: while (my $event = $parse->next_event) {
# to build po entries
- my $ref=$refs[$parse->line-1];
+ my $ref=$refs[$parse->line-1+(($adds < 0)?-$adds:0)];
+ # Reset $adds (~number of lines of the current paragraph)
+ # When $adds is negative (end of paragraph), and nsgmls starts
+ # mentioning the line change.
+ $adds = 0 if ($adds < 0 and $line != $parse->line);
+ # Keep a reference to the last line indicated by nsgmls
+ $line = $parse->line;
my $type;
if ($event->type eq 'start_element') {
@@ -950,6 +961,9 @@
$self->pushline($buffer) if $buffer;
}
$buffer="";
+ # The end of paragraph was seen. $adds must be negative,
+ # so that it can be used for computing the line reference.
+ $adds=-abs($adds);
push @open,$tag;
} elsif ($indent{$event->data->name()}) {
die wrap_ref_mod($ref, "po4a::sgml", dgettext("po4a",
@@ -1024,6 +1038,9 @@
$type = $open[$#open] . $tag;
$self->end_paragraph($buffer,$ref,$type,$verb,$indent, at open);
$buffer = "";
+ # The end of paragraph was seen. $adds must be negative,
+ # so that it can be used for computing the line reference.
+ $adds=-abs($adds);
pop @open;
if (@open > 0) {
pop @open;
@@ -1081,6 +1098,8 @@
} # end of type eq 'sdata'
elsif ($event->type eq 're') {
+ # End of record, the line reference shall be incremented.
+ $adds +=1;
if ($verb) {
# Check if this line of data appear on the same line
# than the previous tag. If not, append an end of line
More information about the Po4a-commits
mailing list