texinfo-commits
[Top][All Lists]
Advanced

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

[7582] Plaintext.pm _convert don't use method call syntax


From: gavinsmith0123
Subject: [7582] Plaintext.pm _convert don't use method call syntax
Date: Mon, 26 Dec 2016 17:48:06 +0000 (UTC)

Revision: 7582
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7582
Author:   gavin
Date:     2016-12-26 17:48:06 +0000 (Mon, 26 Dec 2016)
Log Message:
-----------
Plaintext.pm _convert don't use method call syntax

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Makefile.am
    trunk/tp/Texinfo/Convert/Plaintext.pm
    trunk/tp/t/test_utils.pl

Removed Paths:
-------------
    trunk/tp/DebugTexinfo/DebugCount.pm
    trunk/tp/t/results/test_count/
    trunk/tp/t/test_count.t

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2016-12-26 16:45:31 UTC (rev 7581)
+++ trunk/ChangeLog     2016-12-26 17:48:06 UTC (rev 7582)
@@ -1,5 +1,17 @@
 2016-12-26  Gavin Smith  <address@hidden>
 
+       * tp/Texinfo/Convert/Plaintext.pm (_convert): Don't use method 
+       call syntax for recursive calls.
+       * tp/DebugTexinfo/DebugCount.pm: Remove, as it isn't used much.
+       * doc/texinfo.texi (Customization Variables and Options) 
+       <TEXINFO_OUTPUT_FORMAT>: Remove mention of
+       'debugcount'.
+       * tp/t/test_count.t: Delete test.
+       * tp/t/test_utils.pl: Don't use "DebugTexinfo::DebugCount" 
+       module.
+
+2016-12-26  Gavin Smith  <address@hidden>
+
        * tp/Texinfo/Parser.pm (whole file): Use assignment from @_
        for subroutine arguments instead of "shift".  This shortens the
        code and may be slightly more efficient.

Deleted: trunk/tp/DebugTexinfo/DebugCount.pm
===================================================================
--- trunk/tp/DebugTexinfo/DebugCount.pm 2016-12-26 16:45:31 UTC (rev 7581)
+++ trunk/tp/DebugTexinfo/DebugCount.pm 2016-12-26 17:48:06 UTC (rev 7582)
@@ -1,108 +0,0 @@
-# DebugTexinfo::DebugCount.pm: gather information on bytes and lines
-# count for debugging purposes.
-#
-# Copyright 2011, 2012 Free Software Foundation, Inc.
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License,
-# or (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-# 
-# Original author: Patrice Dumas <address@hidden>
-# ./texi2any.pl --set TEXINFO_OUTPUT_FORMAT=debugcount file.texi
-
-use strict;
-
-use Texinfo::Convert::Info;
-
-package DebugTexinfo::DebugCount;
-use vars qw(@ISA);
address@hidden = qw(Texinfo::Convert::Info);
-
-sub _convert($$)
-{
-  my $self = shift;
-  my $root = shift;
-  
-  $self->{'level'}++;
-  $self->{'command_type_nr'}++;
-  $self->_update_count_context();
-  my $bytes_before = $self->{'count_context'}->[-1]->{'bytes'};
-  my $number_before = 
"($self->{'count_context'}->[-1]->{'bytes'},$self->{'count_context'}->[-1]->{'lines'})";
-  my $command_nr = '['.$self->{'command_type_nr'}.']';
-  my $command_type = '';
-  $command_type .= '@'.$root->{'cmdname'} if ($root->{'cmdname'});
-  $command_type .= ":$root->{'type'}" if ($root->{'type'});
-  if (defined($root->{'text'})) {
-    $command_type .= ":text";
-    my $text = $root->{'text'};
-    $text =~ s/\n/\\n/g;
-    $text =~ s/\f/\\f/g;
-    $command_type .= "|$text|";
-  }
-  my $string_before = ' ' x $self->{'level'}. "$command_nr $number_before 
$command_type\n";
-  push @{$self->{'debug_count_strings'}}, $string_before;
-  
-  my $text =
-    Texinfo::Convert::Plaintext::_convert($self, $root);
-  my $all_locations_string = '';
-  if ($self->{'count_context'}->[-1]->{'locations'}) {
-    foreach my $location (@{$self->{'count_context'}->[-1]->{'locations'}}) {
-      my $location_nr;
-      if (defined($self->{'debug_location_counts'})
-           and defined ($self->{'debug_location_counts'}->{$location})) {
-        $location_nr = $self->{'debug_location_counts'}->{$location};
-      } else {
-        $self->{'debug_location_counter'}++;
-        $location_nr = $self->{'debug_location_counter'};
-        $self->{'debug_location_counts'}->{$location} = $location_nr;
-      }
-      my $location_string = '';
-      if (defined($location->{'lines'})) {
-        $location_string .= " l $location->{'lines'}";
-      }
-      if (defined($location->{'bytes'})) {
-        $location_string .= " b $location->{'bytes'}";
-      }
-      if (defined($self->{'debug_locations_strings'}->{$location})) {
-        if ($self->{'debug_locations_strings'}->{$location} eq 
$location_string) {
-          $location_string = '';
-        } else {
-          $self->{'debug_locations_strings'}->{$location} = $location_string;
-          $location_string = " ($location_nr)$location_string";
-        }
-      } else {
-        $self->{'debug_locations_strings'}->{$location} = $location_string;
-        $location_string = " ($location_nr)$location_string";
-      }
-      $all_locations_string .= $location_string if ($location_string);
-    }
-    $all_locations_string .= "\n" if ($all_locations_string);
-  }
-  #push @{$self->{'debug_count_strings'}}, ' ' x $self->{'level'}. "TEXT: 
$text|\n"
-  #  if ($self->{'count_context'}->[-1]->{'bytes'} > $bytes_before);
-  $self->_update_count_context();
-  my $number_after = 
"($self->{'count_context'}->[-1]->{'bytes'},$self->{'count_context'}->[-1]->{'lines'})";
-  my $string_after = ' ' x $self->{'level'}. "$command_nr $number_after\n";
-  $string_after .= " locations $all_locations_string"
-     if ($all_locations_string ne '');
-  push @{$self->{'debug_count_strings'}}, $string_after;
-  $self->{'level'}--;
-  if ($self->{'level'} > 0) {
-    return $text;
-  } else {
-    my $result = join('',@{$self->{'debug_count_strings'}}).$text;
-    @{$self->{'debug_count_strings'}} = ();
-    return $result;
-  }
-}
-
-1;

Modified: trunk/tp/Makefile.am
===================================================================
--- trunk/tp/Makefile.am        2016-12-26 16:45:31 UTC (rev 7581)
+++ trunk/tp/Makefile.am        2016-12-26 17:48:06 UTC (rev 7582)
@@ -105,7 +105,6 @@
 
 debugmodulesdir = $(pkgdatadir)/DebugTexinfo
 dist_debugmodules_DATA = \
- DebugTexinfo/DebugCount.pm \
  DebugTexinfo/DebugTree.pm
 
 initdir = $(datadir)/texinfo/init

Modified: trunk/tp/Texinfo/Convert/Plaintext.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Plaintext.pm       2016-12-26 16:45:31 UTC (rev 
7581)
+++ trunk/tp/Texinfo/Convert/Plaintext.pm       2016-12-26 17:48:06 UTC (rev 
7582)
@@ -1550,13 +1550,10 @@
 
 sub _convert($$);
 
-# Convert the Texinfo tree under $ROOT to plain text.  Note that this
-# function should be called as "$self->_convert" to allow the
-# DebugTexinfo::DebugCount::_convert method to override this one.
+# Convert the Texinfo tree under $ROOT to plain text.
 sub _convert($$)
 {
-  my $self = shift;
-  my $root = shift;
+  my ($self, $root) = @_;
 
   my $formatter = $self->{'formatters'}->[-1];
 
@@ -1642,7 +1639,7 @@
       }
     } else {
       my $tree = $self->gdt($root->{'text'});
-      my $converted = $self->_convert($tree);
+      my $converted = _convert($self, $tree);
       return $converted;
     }
   }
@@ -1883,7 +1880,7 @@
                $formatter->{'container'}->add_next($text_before, 1))
          if ($text_before ne '');
       if ($root->{'args'}) {
-        $result .= $self->_convert($root->{'args'}->[0]);
+        $result .= _convert($self, $root->{'args'}->[0]);
         if ($command eq 'strong' 
              and scalar (@{$root->{'args'}->[0]->{'contents'}})
              and $root->{'args'}->[0]->{'contents'}->[0]->{'text'}
@@ -2022,7 +2019,7 @@
            $formatter->{'container'}->add_next
                                         ("($formatted_footnote_number)", 1));
       if ($self->get_conf('footnotestyle') eq 'separate' and $self->{'node'}) {
-        $result .= $self->_convert({'contents' => 
+        $result .= _convert($self, {'contents' => 
          [{'text' => ' ('},
           {'cmdname' => 'pxref',
            'extra' => {'brace_command_contents' => 
@@ -2090,9 +2087,9 @@
   ->set_space_protection(undef,undef,undef,undef,1); # double_width_no_break
 
         if ($command eq 'xref') {
-          $result = $self->_convert({'contents' => [{'text' => '*Note '}]});
+          $result = _convert($self, {'contents' => [{'text' => '*Note '}]});
         } else {
-          $result = $self->_convert({'contents' => [{'text' => '*note '}]});
+          $result = _convert($self, {'contents' => [{'text' => '*note '}]});
         }
         my $name;
         if (defined($args[1])) {
@@ -2113,7 +2110,7 @@
         }
          
         if ($name) {
-          my $name_text = $self->_convert({'contents' => $name});
+          my $name_text = _convert($self, {'contents' => $name});
           # needed, as last word is added only when : is added below
           my $name_text_checked = $name_text
              .$self->{'formatters'}->[-1]->{'container'}->get_pending();
@@ -2130,7 +2127,7 @@
           }
           my $pre_quote = $quoting_required ? "\x{7f}" : '';
           my $post_quote = $pre_quote;
-          $name_text .= $self->_convert({'contents' => [
+          $name_text .= _convert($self, {'contents' => [
                 {'text' => "$post_quote: "}]});
           $name_text =~ s/^(\s*)/$1$pre_quote/ if $pre_quote;
           $result .= $name_text;
@@ -2139,11 +2136,11 @@
             if $pre_quote;
 
           if ($file) {
-            $result .= $self->_convert({'contents' => $file});
+            $result .= _convert($self, {'contents' => $file});
           }
           # node name
           $self->{'formatters'}->[-1]->{'suppress_styles'} = 1;
-          my $node_text = $self->_convert({'type' => '_code',
+          my $node_text = _convert($self, {'type' => '_code',
                                            'contents' => $node_content});
           delete $self->{'formatters'}->[-1]->{'suppress_styles'};
 
@@ -2173,10 +2170,10 @@
                  if $post_quote;
         } else { # Label same as node specification
           if ($file) {
-            $result .= $self->_convert({'contents' => $file});
+            $result .= _convert($self, {'contents' => $file});
           }
           $self->{'formatters'}->[-1]->{'suppress_styles'} = 1;
-          my $node_text = $self->_convert({'type' => '_code',
+          my $node_text = _convert($self, {'type' => '_code',
                                            'contents' => $node_content});
           delete $self->{'formatters'}->[-1]->{'suppress_styles'};
 
@@ -2195,7 +2192,7 @@
           }
           my $pre_quote = $quoting_required ? "\x{7f}" : '';
           my $post_quote = $pre_quote;
-          $node_text .= $self->_convert({'contents' => [
+          $node_text .= _convert($self, {'contents' => [
                 {'text' => "${post_quote}::"}]});
           _count_added($self,$self->{'formatters'}[-1]{'container'},
                        $pre_quote)
@@ -2206,7 +2203,7 @@
             # punctuation in the word.
             my $next = $self->{'current_contents'}->[-1]->[0];
             if ($next) {
-              $node_text .= $self->_convert($next);
+              $node_text .= _convert($self, $next);
               shift @{$self->{'current_contents'}->[-1]};
             }
 
@@ -2278,7 +2275,7 @@
           unshift @{$self->{'current_contents'}->[-1]}, $prepended;
           return '';
         } else {
-          $result = $self->_convert($argument);
+          $result = _convert($self, $argument);
 
           # We want to permit an end of sentence, but not force it as @. does.
           $formatter->{'container'}->allow_end_sentence();
@@ -2307,7 +2304,7 @@
     } elsif ($command eq 'math') {
       push @{$self->{'context'}}, 'math';
       if ($root->{'args'}) {
-        $result .= $self->_convert({'type' => 'frenchspacing',
+        $result .= _convert($self, {'type' => 'frenchspacing',
              'contents' => [{'type' => '_code',
                             'contents' => [$root->{'args'}->[0]]}]});
       }
@@ -2387,7 +2384,7 @@
         $expansion = {'type' => 'paragraph',
                       'contents' => [$expansion]};
       }
-      $result .= $self->_convert($expansion);
+      $result .= _convert($self, $expansion);
       #  unshift @{$self->{'current_contents'}->[-1]}, $expansion;
       #return '';
       return $result;
@@ -2575,7 +2572,7 @@
       } elsif ($root->{'parent'}->{'extra'}->{'block_command_line_contents'}) {
         # this is the text prepended to items.
         
-        $result = $self->_convert(
+        $result = _convert($self, 
           {'contents' => 
              
address@hidden>{'parent'}->{'extra'}->{'block_command_line_contents'}->[0]},
               { 'text' => ' ' }]
@@ -2709,7 +2706,7 @@
             #if ($caption->{'cmdname'} eq 'shortcaption') {
             #  $tree->{'type'} = 'frenchspacing';
             #}
-            my $caption_text = $self->_convert($tree);
+            my $caption_text = _convert($self, $tree);
             my $old_context = pop @{$self->{'context'}};
             delete $self->{'multiple_pass'};
             die if ($old_context ne 'listoffloats');
@@ -3012,7 +3009,7 @@
            'indent_length_next' => 
(1+$self->{'format_context'}->[-1]->{'indent_level'})*$indent_length});
         push @{$self->{'formatters'}}, $def_paragraph;
 
-        $result .= $self->_convert({'type' => '_code', 'contents' => [$tree]});
+        $result .= _convert($self, {'type' => '_code', 'contents' => [$tree]});
         $result .= _count_added($self, $def_paragraph->{'container'},
                                       $def_paragraph->{'container'}->end());
 
@@ -3027,7 +3024,7 @@
         my ($pre_quote, $post_quote);
         if ($arg->{'type'} eq 'menu_entry_node') {
           $self->{'formatters'}->[-1]->{'suppress_styles'} = 1;
-          my $node_text = $self->_convert({'type' => '_code',
+          my $node_text = _convert($self, {'type' => '_code',
                                       'contents' => $arg->{'contents'}});
 
           delete $self->{'formatters'}->[-1]->{'suppress_styles'};
@@ -3057,7 +3054,7 @@
           }
           $result .= $pre_quote . $node_text . $post_quote;
         } elsif ($arg->{'type'} eq 'menu_entry_name') {
-          my $entry_name = $self->_convert($arg);
+          my $entry_name = _convert($self, $arg);
           $entry_name_seen = 1;
           $pre_quote = $post_quote = '';
           if ($entry_name =~ /:/) {
@@ -3072,7 +3069,7 @@
           }
           $result .= $pre_quote . $entry_name . $post_quote;
         } else {
-          $result .= $self->_convert($arg);
+          $result .= _convert($self, $arg);
         }
       }
       $result = $self->ensure_end_of_line($result) 
@@ -3105,7 +3102,7 @@
     push @{$self->{'current_roots'}}, $root;
     while (@contents) {
       my $content = shift @contents;
-      my $text = $self->_convert($content);
+      my $text = _convert($self, $content);
       $self->{'empty_lines_count'} = 0 
         if ($preformatted and $text =~ /\S/);
       $result .= $text;
@@ -3309,14 +3306,14 @@
         if ($caption) {
           $self->{'format_context'}->[-1]->{'paragraph_count'} = 0;
           my $tree = $caption->{'args'}->[0];
-          $result .= $self->_convert($tree);
+          $result .= _convert($self, $tree);
         }
       }
     } elsif (($command eq 'quotation' 
                or $command eq 'smallquotation')
              and $root->{'extra'} and $root->{'extra'}->{'authors'}) {
       foreach my $author (@{$root->{'extra'}->{'authors'}}) {
-        $result .= $self->_convert(
+        $result .= _convert($self, 
                  $self->gdt("address@hidden --- address@hidden",
                     {'author' => $author->{'extra'}->{'misc_content'}}));
       }

Deleted: trunk/tp/t/test_count.t
===================================================================
--- trunk/tp/t/test_count.t     2016-12-26 16:45:31 UTC (rev 7581)
+++ trunk/tp/t/test_count.t     2016-12-26 17:48:06 UTC (rev 7582)
@@ -1,112 +0,0 @@
-use strict;
-
-use File::Spec;
-BEGIN { if (defined($ENV{'top_srcdir'})) {unshift @INC, 
File::Spec->catdir($ENV{'top_srcdir'}, 'tp');} }
-
-require 't/test_utils.pl';
-
-my @test_cases = (
-['commands',
-'@TeX{}. Ab. @@. @
address@hidden, @address@hidden
-
address@hidden 2
-
address@hidden 3
-
address@hidden 
-truc
address@hidden example
-
address@hidden @samp
address@hidden vitem table
-
-text
address@hidden vtable'],
-['flushright',
-'
address@hidden
-  aaa bb @anchor{rrr} ada   
- dad  sff sd @anchor{a1} and @anchor{a2} dsdbf
-
-dqs
-sqdd
-
address@hidden
-
-new para.
-
address@hidden flushright
-'],
-['flushright_in_example',
-'
address@hidden
address@hidden
-  aaa bb @anchor{rrr} ada   
-             dad  sff sd @anchor{a1} and @anchor{a2} dsdbf
-             dad  sff sd @anchor{a3} and @anchor{a4} dsdbf
-
-dqs
-sqdd
-
address@hidden
-
-new para.
-
address@hidden flushright
address@hidden example
-'],
-['multitable',
-'
address@hidden {aaa} {bb1} {ccc}
address@hidden aaa @tab bb @anchor{anch 1}
address@hidden ccc
address@hidden @tab @anchor{anch2}
address@hidden multitable
-'],
-['printindex',
-'@node Top
-
address@hidden index entry
address@hidden index entry
address@hidden looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 
index entry
-
address@hidden cp
-
address@hidden after index
-
address@hidden cp
-
address@hidden counting anchor}
-'],
-['expanded_tex',
-'AAA
address@hidden
-TTT
-GGG
address@hidden tex
-After
-
-second
address@hidden FFF
-GGG @end tex
-After2.
-', {'expanded_formats' => ['tex']}
-],
-);
-
-my %info_tests = ('printindex' => 1);
-foreach my $test (@test_cases) {
-  $test->[2]->{'test_formats'} = ['debugcount'];
-  if ($info_tests{$test->[0]}) {
-    push @{$test->[2]->{'test_formats'}}, 'info';
-  }
-}
-
-our ($arg_test_case, $arg_generate, $arg_debug);
-
-run_all ('test_count', address@hidden, $arg_test_case,
-   $arg_generate, $arg_debug);
-
-1;
-

Modified: trunk/tp/t/test_utils.pl
===================================================================
--- trunk/tp/t/test_utils.pl    2016-12-26 16:45:31 UTC (rev 7581)
+++ trunk/tp/t/test_utils.pl    2016-12-26 17:48:06 UTC (rev 7582)
@@ -41,7 +41,6 @@
 use Texinfo::Convert::HTML;
 use Texinfo::Convert::TexinfoXML;
 use Texinfo::Convert::DocBook;
-use DebugTexinfo::DebugCount;
 use File::Basename;
 use File::Copy;
 use File::Compare; # standard since 5.004
@@ -132,12 +131,10 @@
   'file_xml' => \&convert_to_xml,
   'docbook' => \&convert_to_docbook,
   'file_docbook' => \&convert_to_docbook,
-  'debugcount' => \&debugcount,
 );
 
 our %extensions = (
   'plaintext' => 'txt',
-  'debugcount' => 'txt',
   'html_text' => 'html',
   'xml' => 'xml',
   'docbook' => 'dbk',
@@ -634,26 +631,6 @@
   return ($errors, $result);
 }
 
-sub debugcount($$$$$$;$)
-{
-  my $self = shift;
-  my $test_name = shift;
-  my $format = shift;
-  my $tree = shift;
-  my $parser = shift;
-  my $parser_options = shift;
-  my $converter_options = shift;
-  $converter_options = {} if (!defined($converter_options));
-  my $converter =
-     DebugTexinfo::DebugCount->converter({'DEBUG' => $self->{'DEBUG'},
-                                         'parser' => $parser,
-                                         'output_format' => 'info',
-                                          %$converter_options });
-  my $result = $converter->convert($tree);
-  my ($errors, $error_nrs) = $converter->errors();
-  return ($errors, $result);
-}
-
 # Run a single test case.  Each test case is an array
 # [TEST_NAME, TEST_TEXT, PARSER_OPTIONS, CONVERTER_OPTIONS]
 sub test($$) 




reply via email to

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