Index: Texinfo/Convert/Info.pm =================================================================== --- Texinfo/Convert/Info.pm (revision 6226) +++ Texinfo/Convert/Info.pm (working copy) @@ -148,6 +148,7 @@ sub output($) } else { $result .= $node_text; } + $self->_update_count_context(); if (defined($self->get_conf('SPLIT_SIZE')) and $self->{'count_context'}->[-1]->{'bytes'} > $out_file_nr * $self->get_conf('SPLIT_SIZE') @@ -205,6 +206,7 @@ sub output($) return undef; } print $fh $complete_header; + $self->_update_count_context(); $self->{'count_context'}->[-1]->{'bytes'} += $complete_header_bytes; push @indirect_files, [$self->{'output_filename'}.'-'.$out_file_nr, $self->{'count_context'}->[-1]->{'bytes'}]; Index: Texinfo/Convert/Plaintext.pm =================================================================== --- Texinfo/Convert/Plaintext.pm (revision 6234) +++ Texinfo/Convert/Plaintext.pm (working copy) @@ -717,9 +717,10 @@ sub _add_text_count($$) { my $self = shift; my $text = shift; - $self->{'count_context'}->[-1]->{'bytes'} - += Texinfo::Common::count_bytes($self, $text, - $self->{'output_perl_encoding'}); + if (!defined $self->{'count_context'}->[-1]->{'pending_text'}) { + $self->{'count_context'}->[-1]->{'pending_text'} = ''; + } + $self->{'count_context'}->[-1]->{'pending_text'} .= $text; } sub _add_lines_count($$) @@ -729,6 +730,19 @@ sub _add_lines_count($$) $self->{'count_context'}->[-1]->{'lines'} += $lines_count; } +sub _update_count_context($) +{ + my $self = shift; + if (defined $self->{'count_context'}->[-1]->{'pending_text'}) { + $self->{'count_context'}->[-1]->{'bytes'} += + Texinfo::Common::count_bytes($self, + $self->{'count_context'}->[-1]->{'pending_text'}, + $self->{'output_perl_encoding'}); + delete $self->{'count_context'}->[-1]->{'pending_text'}; + } +} + +# Save the line and byte offset of $ROOT. sub _add_location($$) { my $self = shift; @@ -736,8 +750,8 @@ sub _add_location($$) my $location = { 'lines' => $self->{'count_context'}->[-1]->{'lines'} }; push @{$self->{'count_context'}->[-1]->{'locations'}}, $location; if (!($root->{'extra'} and $root->{'extra'}->{'index_entry'})) { - $location->{'bytes'} - = $self->{'count_context'}->[-1]->{'bytes'}; + _update_count_context($self); + $location->{'bytes'} = $self->{'count_context'}->[-1]->{'bytes'}; $location->{'root'} = $root; } else { $location->{'index_entry'} = $root; @@ -770,12 +784,16 @@ sub _count_added($$$) my $text = shift; #$self->_add_lines_count($container->end_line_count()); - $self->{'count_context'}->[-1]->{'lines'} += $container->end_line_count(); + $self->{'count_context'}->[-1]->{'lines'} += $container->{'end_line_count'}; #$self->_add_text_count($text); - $self->{'count_context'}->[-1]->{'bytes'} += - Texinfo::Common::count_bytes($self, $text, - $self->{'output_perl_encoding'}); + #$self->{'count_context'}->[-1]->{'bytes'} += + # Texinfo::Common::count_bytes($self, $text, + # $self->{'output_perl_encoding'}); + if (!defined $self->{'count_context'}->[-1]->{'pending_text'}) { + $self->{'count_context'}->[-1]->{'pending_text'} = ''; + } + $self->{'count_context'}->[-1]->{'pending_text'} .= $text; return $text; }