texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp/DebugTexinfo DebugTree.pm


From: Patrice Dumas
Subject: texinfo/tp/DebugTexinfo DebugTree.pm
Date: Sun, 15 Jan 2012 17:22:10 +0000

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

Modified files:
        tp/DebugTexinfo: DebugTree.pm 

Log message:
        Add code to the output subroutine to output to a file, while setting
        the default to stdout.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/DebugTexinfo/DebugTree.pm?cvsroot=texinfo&r1=1.6&r2=1.7

Patches:
Index: DebugTree.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/DebugTexinfo/DebugTree.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- DebugTree.pm        15 Jan 2012 16:40:52 -0000      1.6
+++ DebugTree.pm        15 Jan 2012 17:22:10 -0000      1.7
@@ -18,9 +18,11 @@
 # Original author: Patrice Dumas <address@hidden>
 
 # Example of calls
-# with creation of elements and pages:
-# ./texi2any.pl --set DEBUGTREE --set USE_NODES=0 --split section file.texi
-# no elements nor pages
+# with creation of elements corresponding to sections:
+# ./texi2any.pl --set DEBUGTREE --set USE_NODES=0 file.texi
+# with creation of elements corresponding to nodes:
+# ./texi2any.pl --set DEBUGTREE --set USE_NODES=1 file.texi
+# no elements
 # ./texi2any.pl --set DEBUGTREE file.texi
 
 use Texinfo::Convert::Converter;
@@ -31,6 +33,7 @@
 
 my %defaults = (
   'EXTENSION' => 'debugtree',
+  'OUTFILE' => '-',
 );
 
 sub converter_defaults($)
@@ -38,14 +41,26 @@
   return %defaults;
 }
 
-# FIXME this cannot be used through texi2any.pl since it should write to
-# a file (unless OUTFILE is '' which should not happen when called by 
texi2any).
 sub output($$)
 {
   my $self = shift;
   my $root = shift;
+
+
+  $self->_set_outfile();
+  return undef unless $self->_create_destination_directory();
+
+  my $fh;
+  if (! $self->{'output_file'} eq '') {
+    $fh = $self->Texinfo::Common::open_out ($self->{'output_file'});
+    if (!$fh) {
+      $self->document_error(sprintf($self->__("Could not open %s for writing: 
%s"),
+                                    $self->{'output_file'}, $!));
+      return undef;
+    }
+  }
+
   my $elements;
-  my $pages;
   if ($self) {
     if ($self->get_conf('USE_NODES')) {
       $elements = Texinfo::Structuring::split_by_node($root);
@@ -53,6 +68,7 @@
       #print STDERR "U sections\n";
       $elements = Texinfo::Structuring::split_by_section($root);
     }
+    # Currently the information added is not used further.
     if ($elements and ($self->get_conf('SPLIT') 
                        or !$self->get_conf('MONOLITHIC'))) {
       #print STDERR "S ".$self->get_conf('SPLIT')."\n";
@@ -64,7 +80,7 @@
     $root = {'type' => 'elements_root',
              'contents' => $elements };
   }
-  return _print_tree($self, $root);
+  return $self->_output_text (_print_tree($self, $root), $fh);
 }
 
 sub convert($$)



reply via email to

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