texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp/Texinfo/Convert Line.pm Paragraph.pm...


From: Patrice Dumas
Subject: texinfo/tp/Texinfo/Convert Line.pm Paragraph.pm...
Date: Sat, 22 Jan 2011 17:12:36 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/01/22 17:12:31

Modified files:
        tp/Texinfo/Convert: Line.pm Paragraph.pm Plaintext.pm 
                            UnFilled.pm 

Log message:
        Count lines added in containers.  Use this information in the caller to
        update the lines count.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Line.pm?cvsroot=texinfo&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Paragraph.pm?cvsroot=texinfo&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/UnFilled.pm?cvsroot=texinfo&r1=1.5&r2=1.6

Patches:
Index: Line.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Line.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- Line.pm     16 Jan 2011 01:24:20 -0000      1.11
+++ Line.pm     22 Jan 2011 17:12:31 -0000      1.12
@@ -36,7 +36,7 @@
   my $conf = shift;
   my $self = {'indent_length' => 0, 'counter' => 0,
               'space' => '', 'frenchspacing' => 0, 'line_beginning' => 1,
-              'lines_counter' => 0};
+              'lines_counter' => 0, 'end_line_count' => 0};
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
       if ($key eq 'text') {
@@ -61,22 +61,41 @@
   print STDERR "line ($self->{'line_beginning'},$self->{'counter'}) word: 
$word, space `$self->{'space'}' end_sentence: $end_sentence\n"; 
 }
 
-# end a line.
 sub end_line($)
 {
   my $line = shift;
-  my $result = $line->add_pending_word();
+  return $line->_end_line();
+}
+
+# end a line.
+sub _end_line($)
+{
+  my $line = shift;
+  my $result = $line->_add_pending_word();
   $line->{'line_beginning'} = 1;
   $line->{'space'} = '';
   $line->{'lines_counter'}++;
+  $line->{'end_line_count'}++;
   print STDERR "END_LINE\n" if ($line->{'DEBUG'});
   return "$result\n";
 }
 
-# put a pending word and spaces in the result string.
+sub end_line_count($)
+{
+  my $line = shift;
+  return $line->{'end_line_count'};
+}
+
 sub add_pending_word($)
 {
   my $line = shift;
+  $line->{'end_line_count'} = 0;
+  return $line->_add_pending_word();
+}
+# put a pending word and spaces in the result string.
+sub _add_pending_word($)
+{
+  my $line = shift;
   my $result = '';
 
   if (defined($line->{'word'})) {
@@ -102,19 +121,30 @@
 sub end($)
 {
   my $line = shift;
-  my $result = $line->add_pending_word();
+  $line->{'end_line_count'} = 0;
+  my $result = $line->_add_pending_word();
   $result .= $line->{'space'};
   print STDERR "END_LINE\n" if ($line->{'DEBUG'});
   return $result;
 }
 
-# add a word and/or spaces and end of sentence.
 sub add_next($;$$$)
 {
   my $line = shift;
   my $word = shift;
   my $space = shift;
   my $end_sentence = shift;
+  $line->{'end_line_count'} = 0;
+  return $line->_add_next($word, $space, $end_sentence);
+}
+
+# add a word and/or spaces and end of sentence.
+sub _add_next($;$$$)
+{
+  my $line = shift;
+  my $word = shift;
+  my $space = shift;
+  my $end_sentence = shift;
   my $result = '';
 
   if (defined($word)) {
@@ -123,7 +153,7 @@
     print STDERR "WORD+ $word -> $line->{'word'}\n" if ($line->{'DEBUG'});
   }
   if (defined($space)) {
-    $result .= $line->add_pending_word();
+    $result .= $line->_add_pending_word();
     $line->{'space'} = $space;
   }
   if (defined($end_sentence)) {
@@ -171,6 +201,7 @@
 {
   my $line = shift;
   my $text = shift;
+  $line->{'end_line_count'} = 0;
   my $result = '';
 
   while ($text ne '') {
@@ -183,7 +214,7 @@
       my $spaces = $1;
       print STDERR "SPACES\n" if ($line->{'DEBUG'});
       my $added_word = $line->{'word'};
-      $result .= $line->add_pending_word();
+      $result .= $line->_add_pending_word();
       if ($line->{'protect_spaces'}) {
         $result .= $spaces;
         $line->{'space'} = '';
@@ -197,7 +228,7 @@
       delete $line->{'end_sentence'};
     } elsif ($text =~ s/^([^\s\p{Unicode::EastAsianWidth::InFullwidth}]+)//) {
       my $added_word = $1;
-      $result .= $line->add_next($added_word);
+      $result .= $line->_add_next($added_word);
       # now check if it is considered as an end of sentence
       if (defined($line->{'end_sentence'}) and 
         $added_word =~ /^[$after_punctuation_characters]*$/) {
@@ -207,13 +238,13 @@
         $line->{'end_sentence'} = 1;
       }
     } elsif ($text =~ s/^\n//) {
-      $result .= $line->end_line();
+      $result .= $line->_end_line();
     } elsif ($text =~ s/^(\p{Unicode::EastAsianWidth::InFullwidth})//) {
       my $added = $1;
       print STDERR "EAST_ASIAN\n" if ($line->{'DEBUG'});
       $line->{'word'} = '' if (!defined($line->{'word'}));
       $line->{'word'} .= $added;
-      $result .= $line->add_pending_word();
+      $result .= $line->_add_pending_word();
       delete $line->{'end_sentence'};
       $line->{'space'} = '';
     }

Index: Paragraph.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Paragraph.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- Paragraph.pm        16 Jan 2011 01:24:20 -0000      1.12
+++ Paragraph.pm        22 Jan 2011 17:12:31 -0000      1.13
@@ -36,7 +36,7 @@
   my $conf = shift;
   my $self = {'max' => 72, 'indent_length' => 0, 'counter' => 0, 
               'word_counter' => 0, 'space' => '', 'frenchspacing' => 0,
-              'lines_counter' => 0};
+              'lines_counter' => 0, 'end_line_count' => 0};
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
       $self->{$key} = $conf->{$key};
@@ -60,13 +60,26 @@
 {
   my $paragraph = shift;
   return '' if ($paragraph->{'ignore_columns'});
-  return $paragraph->end_line();
+  return $paragraph->_end_line();
+}
+
+sub end_line_count($)
+{
+  my $paragraph = shift;
+  return $paragraph->{'end_line_count'};
 }
 
-# end a line.
 sub end_line($)
 {
   my $paragraph = shift;
+  $paragraph->{'end_line_count'} = 0;
+  return $paragraph->_end_line();
+}
+
+# end a line.
+sub _end_line($)
+{
+  my $paragraph = shift;
   $paragraph->{'counter'} = 0;
   $paragraph->{'space'} = '';
   if (defined($paragraph->{'indent_length_next'})) {
@@ -74,14 +87,22 @@
     delete $paragraph->{'indent_length_next'};        
   }
   $paragraph->{'lines_counter'}++;
+  $paragraph->{'end_line_count'}++;
   print STDERR "END_LINE\n" if ($paragraph->{'DEBUG'});
   return "\n";
 }
 
-# put a pending word and spaces in the result string.
 sub add_pending_word($)
 {
   my $paragraph = shift;
+  $paragraph->{'end_line_count'} = 0;
+  return $paragraph->_add_pending_word();
+}
+
+# put a pending word and spaces in the result string.
+sub _add_pending_word($)
+{
+  my $paragraph = shift;
   my $result = '';
 
   if (defined($paragraph->{'word'})) {
@@ -112,22 +133,34 @@
 sub end($)
 {
   my $paragraph = shift;
+  $paragraph->{'end_line_count'} = 0;
   print STDERR "PARA END\n" if ($paragraph->{'DEBUG'});
-  my $result = $paragraph->add_pending_word();
+  my $result = $paragraph->_add_pending_word();
   if ($paragraph->{'counter'} != 0) {
     $result .= "\n"; 
     $paragraph->{'lines_counter'}++;
+    $paragraph->{'end_line_count'}++;
   }
   return $result;
 }
 
-# add a word and/or spaces and end of sentence.
 sub add_next($;$$$)
 {
   my $paragraph = shift;
   my $word = shift;
   my $space = shift;
   my $end_sentence = shift;
+  $paragraph->{'end_line_count'} = 0;
+  return $paragraph->_add_next($word, $space, $end_sentence);
+}
+
+# add a word and/or spaces and end of sentence.
+sub _add_next($;$$$)
+{
+  my $paragraph = shift;
+  my $word = shift;
+  my $space = shift;
+  my $end_sentence = shift;
   my $result = '';
 
   if (defined($word)) {
@@ -144,7 +177,7 @@
     }
   }
   if (defined($space)) {
-    $result .= $paragraph->add_pending_word();
+    $result .= $paragraph->_add_pending_word();
     $paragraph->{'space'} = $space;
     if ($paragraph->{'counter'} + length($paragraph->{'space'}) 
                     > $paragraph->{'max'}) {
@@ -196,6 +229,7 @@
 {
   my $paragraph = shift;
   my $text = shift;
+  $paragraph->{'end_line_count'} = 0;
   my $result = '';
 
   while ($text ne '') {
@@ -208,7 +242,7 @@
       my $spaces = $1;
       print STDERR "SPACES($paragraph->{'counter'})\n" if 
($paragraph->{'DEBUG'});
       my $added_word = $paragraph->{'word'};
-      $result .= $paragraph->add_pending_word();
+      $result .= $paragraph->_add_pending_word();
       if ($paragraph->{'protect_spaces'}) {
         $paragraph->{'space'} .= $spaces;
         if ($paragraph->{'space'} =~ s/\n/ /g 
@@ -234,7 +268,7 @@
         $result .= $paragraph->_cut_line();
       }
       if ($spaces =~ /\n/ and $paragraph->{'keep_end_lines'}) {
-        $result .= $paragraph->end_line();
+        $result .= $paragraph->_end_line();
       }
     } elsif ($text =~ s/^(\p{Unicode::EastAsianWidth::InFullwidth})//) {
       my $added = $1;
@@ -247,12 +281,12 @@
                                > $paragraph->{'max'}) {
         $result .= $paragraph->_cut_line();
       }
-      $result .= $paragraph->add_pending_word();
+      $result .= $paragraph->_add_pending_word();
       delete $paragraph->{'end_sentence'};
       $paragraph->{'space'} = '';
     } elsif ($text =~ s/^([^\s\p{Unicode::EastAsianWidth::InFullwidth}]+)//) {
       my $added_word = $1;
-      $result .= $paragraph->add_next($added_word);
+      $result .= $paragraph->_add_next($added_word);
       # now check if it is considered as an end of sentence
       if (defined($paragraph->{'end_sentence'})
           and $added_word =~ /^[$after_punctuation_characters]*$/) {

Index: Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- Plaintext.pm        20 Jan 2011 00:38:32 -0000      1.53
+++ Plaintext.pm        22 Jan 2011 17:12:31 -0000      1.54
@@ -568,10 +568,11 @@
   my $self = shift;
   my $converted = shift;
   my $conf = shift;
-  my $container = $self->new_formatter('line', $conf);
-  push @{$self->{'formatters'}}, $container;
+  my $formatter = $self->new_formatter('line', $conf);
+  push @{$self->{'formatters'}}, $formatter;
   my $text = $self->_convert($converted);
-  $text .= $self->_count_added_end($container->{'container'});
+  $text .= $self->_count_added($formatter->{'container'},
+                               $formatter->{'container'}->end());
   pop @{$self->{'formatters'}};
   return $text;
 }
@@ -581,11 +582,12 @@
   my $self = shift;
   my $converted = shift;
   my $conf = shift;
-  my $container = $self->new_formatter('unfilled', $conf);
-  $container->{'code'} = 1;
-  push @{$self->{'formatters'}}, $container;
+  my $formatter = $self->new_formatter('unfilled', $conf);
+  $formatter->{'code'} = 1;
+  push @{$self->{'formatters'}}, $formatter;
   my $result = $self->_convert($converted);
-  $result .= $self->_count_added_end($container->{'container'});
+  $result .= $self->_count_added($formatter->{'container'},
+                                 $formatter->{'container'}->end());
   pop @{$self->{'formatters'}};
   return $result;
 }
@@ -659,47 +661,17 @@
   return $location;
 }
 
-sub _count_added_text($$$)
+sub _count_added($$$)
 {
   my $self = shift;
   my $container = shift;
   my $text = shift;
 
-  my $line_counter_before = $container->{'lines_counter'};
-  my $result = $container->add_text($text);
-  $self->_add_lines_count($container->{'lines_counter'} - 
$line_counter_before);
-  $self->_add_text_count($result);
-  return $result;
-}
-
-sub _count_added_next($$$;$$)
-{
-  my $self = shift;
-  my $container = shift;
-  my $text = shift;
-  my $word = shift;
-  my $space = shift;
-
-  my $line_counter_before = $container->{'lines_counter'};
-  my $result = $container->add_next($text, $word, $space);
-  $self->_add_lines_count($container->{'lines_counter'} - 
$line_counter_before);
-  $self->_add_text_count($result);
-  return $result;
-}
-
-sub _count_added_end($$$)
-{
-  my $self = shift;
-  my $container = shift;
-
-  my $line_counter_before = $container->{'lines_counter'};
-  my $end = $container->end();
-  $self->_add_lines_count($container->{'lines_counter'} - 
$line_counter_before);
-  $self->_add_text_count($end);
-  return $end;
+  $self->_add_lines_count($container->end_line_count());
+  $self->_add_text_count($text);
+  return $text;
 }
 
-
 my $footnote_indent = 3;
 sub _footnotes($$)
 {
@@ -1067,8 +1039,9 @@
 
   if (defined($root->{'text'})) {
     if (!$formatter->{'_top_formatter'}) {
-      $result = $self->_count_added_text($formatter->{'container'}, 
-                  $self->_process_text($root, $formatter));
+      $result = $self->_count_added($formatter->{'container'},
+                    $formatter->{'container'}->add_text(
+                       $self->_process_text($root, $formatter)));
       return $result;
     # the following is only possible if paragraphindent is set to asis
     } elsif ($root->{'type'} and $root->{'type'} eq 
'empty_spaces_before_paragraph') {
@@ -1096,30 +1069,30 @@
         $formatter->{'container'}->inhibit_end_sentence();
         return '';
       } elsif ($command eq '*') {
-        my $line_counter_before = $formatter->{'container'}->{'lines_counter'};
-        $result = $formatter->{'container'}->add_pending_word();
-        $result .= $formatter->{'container'}->end_line();
-        $self->_add_lines_count($formatter->{'container'}->{'lines_counter'} - 
$line_counter_before);
-        $self->_add_text_count($result);
+        $result = $self->_count_added($formatter->{'container'},
+                              $formatter->{'container'}->add_pending_word());
+        $result .= $self->_count_added($formatter->{'container'},
+                              $formatter->{'container'}->end_line());
       } elsif ($command eq '.' or $command eq '?' or $command eq '!') {
-        $result .= $self->_count_added_next($formatter->{'container'}, 
-                                            $command, undef, 1);
+        $result .= $self->_count_added($formatter->{'container'},
+            $formatter->{'container'}->add_next($command, undef, 1));
       } elsif ($command eq ' ' or $command eq "\n" or $command eq "\t") {
-        $result .= $self->_count_added_next($formatter->{'container'}, 
-                                            $text_no_brace_commands{$command});
+        $result .= $self->_count_added($formatter->{'container'}, 
+            
$formatter->{'container'}->add_next($text_no_brace_commands{$command}));
       } else {
-        $result .= $self->_count_added_text($formatter->{'container'}, 
-                                            $text_no_brace_commands{$command});
+        $result .= $self->_count_added($formatter->{'container'}, 
+            
$formatter->{'container'}->add_text($text_no_brace_commands{$command}));
       }
       return $result;
     } elsif (defined($text_brace_no_arg_commands{$root->{'cmdname'}})) {
       my $text = Texinfo::Convert::Text::brace_no_arg_command($root, 
                                                     $self->{'encoding'});
       if ($command eq 'enddots') {
-        $result .= $self->_count_added_next($formatter->{'container'},
-                                             $text, undef, 1);
+        $result .= $self->_count_added($formatter->{'container'},
+                    $formatter->{'container'}->add_next($text, undef, 1));
       } else {
-        $result .= $self->_count_added_text($formatter->{'container'}, $text); 
+        $result .= $self->_count_added($formatter->{'container'}, 
+                       $formatter->{'container'}->add_text($text)); 
         if ($command eq 'dots') {
           $formatter->{'container'}->inhibit_end_sentence();
         }
@@ -1127,8 +1100,9 @@
       return $result;
     # commands with braces
     } elsif ($accent_commands{$root->{'cmdname'}}) {
-      $result .= $self->_count_added_text($formatter->{'container'},
-          Texinfo::Convert::Text::text_accents($root, $self->{'encoding'}));
+      $result .= $self->_count_added($formatter->{'container'},
+         $formatter->{'container'}->add_text(
+          Texinfo::Convert::Text::text_accents($root, $self->{'encoding'})));
       return $result;
     } elsif ($style_map{$command}) {
       if ($code_style_commands{$command}) {
@@ -1143,14 +1117,14 @@
         $formatter->{'container'}->set_space_protection(1,1)
           if ($formatter->{'w'} == 1);
       }
-      $result = $self->_count_added_text($formatter->{'container'},
-                         $style_map{$command}->[0]);
+      $result = $self->_count_added($formatter->{'container'},
+               $formatter->{'container'}->add_text($style_map{$command}->[0]));
       if ($root->{'args'}) {
         $result .= $self->_convert($root->{'args'}->[0]);
 
       }
-      $result .= $self->_count_added_text($formatter->{'container'},
-                       $style_map{$command}->[1]);
+      $result .= $self->_count_added($formatter->{'container'},
+               $formatter->{'container'}->add_text($style_map{$command}->[1]));
       if ($command eq 'w') {
         $formatter->{'w'}--;
         $formatter->{'container'}->set_space_protection(0,0)
@@ -1241,13 +1215,11 @@
       push @{$self->{'pending_footnotes'}}, {'root' => $root, 
                                              'number' => $footnote_number}
           unless ($multiple_pass);
-      return $self->_count_added_text($formatter->{'container'},
-                                            "($footnote_number)");
+      return $self->_count_added($formatter->{'container'},
+               $formatter->{'container'}->add_text("($footnote_number)"));
     } elsif ($command eq 'anchor') {
-      my $line_counter_before = $formatter->{'container'}->{'lines_counter'};
-      $result = $formatter->{'container'}->add_pending_word();
-      $self->_add_lines_count($formatter->{'container'}->{'lines_counter'} - 
$line_counter_before);
-      $self->_add_text_count($result);
+      $result = $self->_count_added($formatter->{'container'},
+                   $formatter->{'container'}->add_pending_word());
       $result .= $self->_anchor($root);
       return $result;
     } elsif ($ref_commands{$command}) {
@@ -1471,10 +1443,11 @@
                  + 
$item_indent_format_length{$root->{'parent'}->{'cmdname'}}});
       push @{$self->{'formatters'}}, $line;
       if ($root->{'parent'}->{'cmdname'} eq 'enumerate') {
-        $result = $self->_count_added_next($line->{'container'},
+        $result = $self->_count_added($line->{'container'},
+            $line->{'container'}->add_next(
           Texinfo::Convert::Text::enumerate_item_representation(
           $root->{'parent'}->{'extra'}->{'enumerate_specification'},
-          $root->{'extra'}->{'item_number'}) . '. ');
+                 $root->{'extra'}->{'item_number'}) . '. '));
       } else {
         # FIXME convert_line and no array of contents?
         $result = $self->_convert(
@@ -1483,7 +1456,8 @@
               { 'text' => ' ' }]
           });
       }
-      $result .= $self->_count_added_end($line->{'container'});
+      $result .= $self->_count_added($line->{'container'}, 
+                                     $line->{'container'}->end());
       print STDERR "  
$root->{'parent'}->{'cmdname'}($root->{'extra'}->{'item_number'}) -> 
|$result|\n" 
          if ($self->{'DEBUG'});
       pop @{$self->{'formatters'}};
@@ -1748,9 +1722,11 @@
            'indent_length_next' => 
(1+$self->{'format_context'}->[-1]->{'indent_level'})*$indent_length});
         push @{$self->{'formatters'}}, $def_paragraph;
 
-        $result .= $self->_count_added_next($def_paragraph->{'container'}, " 
-- ");
+        $result .= $self->_count_added($def_paragraph->{'container'}, 
+                        $def_paragraph->{'container'}->add_next(" -- "));
         $result .= $self->_convert({'type' => 'code', 'contents' => 
address@hidden);
-        $result .= $self->_count_added_end($def_paragraph->{'container'});
+        $result .= $self->_count_added($def_paragraph->{'container'},
+                                      $def_paragraph->{'container'}->end());
 
         pop @{$self->{'formatters'}};
         $self->{'empty_lines_count'} = 0;
@@ -1772,7 +1748,8 @@
         undef,undef,1);
     } elsif ($root->{'type'} eq 'bracketed') {
       #and $self->{'context'}->[-1] eq 'math') {
-      $result .= $self->_count_added_text($formatter->{'container'}, '{');
+      $result .= $self->_count_added($formatter->{'container'}, 
+                   $formatter->{'container'}->add_text('{'));
     }
   }
 
@@ -1804,7 +1781,8 @@
       $formatter->{'container'}->set_space_protection(undef,
         undef, undef, $frenchspacing);
     } elsif ($root->{'type'} eq 'bracketed') {
-      $result .= $self->_count_added_text($formatter->{'container'}, '}');
+      $result .= $self->_count_added($formatter->{'container'}, 
+                                     $formatter->{'container'}->add_text('}'));
     } elsif ($root->{'type'} eq 'row') {
       my @cell_beginnings;
       my @cell_lines;
@@ -1906,7 +1884,8 @@
     }
   }
   if ($paragraph) {
-    $result .= $self->_count_added_end($paragraph->{'container'});
+    $result .= $self->_count_added($paragraph->{'container'},
+                                   $paragraph->{'container'}->end());
     if ($self->{'context'}->[-1] eq 'flush' and $self->in_flushright()) {
       my $counts = pop @{$self->{'count_context'}};
       my $bytes_count;
@@ -2009,7 +1988,8 @@
     }
   }
   if ($preformatted) {
-    $result .= $self->_count_added_end($preformatted->{'container'});
+    $result .= $self->_count_added($preformatted->{'container'},
+                                   $preformatted->{'container'}->end());
     pop @{$self->{'formatters'}};
   }
 

Index: UnFilled.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/UnFilled.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- UnFilled.pm 16 Jan 2011 01:24:21 -0000      1.5
+++ UnFilled.pm 22 Jan 2011 17:12:31 -0000      1.6
@@ -33,7 +33,8 @@
   my $class = shift;
   my $conf = shift;
   my $self = {'indent_length' => 0, 'counter' => 0, 'line_beginning' => 1,
-              'leading_spaces' => '', 'only_spaces' => 1, 'lines_counter' => 
0};
+              'leading_spaces' => '', 'only_spaces' => 1, 'lines_counter' => 0,
+              'end_line_count' => 0};
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
       if ($key eq 'text') {
@@ -56,18 +57,32 @@
   print STDERR "unfilled ($self->{'line_beginning'},$self->{'only_spaces'}) 
space `$self->{'leading_spaces'}'\n"; 
 }
 
-# end a line.
 sub end_line($)
 {
   my $line = shift;
+  $line->{'end_line_count'} = 0;
+  return $line->_end_line();
+}
+
+# end a line.
+sub _end_line($)
+{
+  my $line = shift;
   $line->{'line_beginning'} = 1;
   $line->{'leading_spaces'} = '';
   $line->{'only_spaces'} = 1;
   $line->{'lines_counter'}++;
+  $line->{'end_line_count'}++;
   print STDERR "END_LINE\n" if ($line->{'DEBUG'});
   return "\n";
 }
 
+sub end_line_count($)
+{
+  my $line = shift;
+  return $line->{'end_line_count'};
+}
+
 sub _add_text($$)
 {
   my $line = shift;
@@ -88,12 +103,12 @@
     }
     if ($text =~ /\n/) {
       $text =~ s/\s*$//;
-      $text .= $line->end_line;
+      $text .= $line->_end_line;
     }
   } else {
     if ($text =~ /\n/) {
       $text =~ s/\s*$//;
-      $text .= $line->end_line;
+      $text .= $line->_end_line;
     }
   }
   return $text;
@@ -103,6 +118,7 @@
 sub add_pending_word($)
 {
   my $line = shift;
+  $line->{'end_line_count'} = 0;
   return '';
 }
 
@@ -110,9 +126,8 @@
 sub end($)
 {
   my $line = shift;
+  $line->{'end_line_count'} = 0;
   return '';
-  #return $line->{'leading_spaces'};
-  #return $line->end_line();
 }
 
 # add a word and/or spaces and end of sentence.
@@ -122,6 +137,7 @@
   my $word = shift;
   my $space = shift;
   my $end_sentence = shift;
+  $line->{'end_line_count'} = 0;
   my $result = '';
 
   if (defined($word)) {
@@ -148,6 +164,7 @@
 {
   my $line = shift;
   my $text = shift;
+  $line->{'end_line_count'} = 0;
   return $line->_add_text($text);
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]