texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...


From: Patrice Dumas
Subject: texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...
Date: Tue, 15 Nov 2011 00:00:44 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/11/15 00:00:43

Modified files:
        tp             : texi2any.pl 
        tp/Texinfo     : Common.pm Parser.pm 
        tp/Texinfo/Convert: Converter.pm DocBook.pm HTML.pm Info.pm 
                            Text.pm XML.pm 

Log message:
        Remove files that were created if --force is not set and an error
        happen.
        
        Have the caller close files that are not closed already.
        
        Close STDOUT only on exit.
        
        Abort if a file close lead to an error.
        
        Fix out file names.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.90&r2=1.91
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.335&r2=1.336
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Converter.pm?cvsroot=texinfo&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/DocBook.pm?cvsroot=texinfo&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.209&r2=1.210
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Info.pm?cvsroot=texinfo&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.82&r2=1.83
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/XML.pm?cvsroot=texinfo&r1=1.54&r2=1.55

Patches:
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -b -r1.90 -r1.91
--- texi2any.pl 13 Nov 2011 23:55:21 -0000      1.90
+++ texi2any.pl 15 Nov 2011 00:00:42 -0000      1.91
@@ -425,9 +425,25 @@
   warn sprintf(__p("warning: warning_message", "warning: %s\n"), $text);
 }
 
-sub handle_errors($$) {
+sub _exit($$)
+{
+  my $error_count = shift;
+  my $opened_files = shift;
+
+  if ($opened_files and !get_conf('FORCE')) {
+    while (@$opened_files) {
+      my $opened_file = shift (@$opened_files);
+      unlink ($opened_file);
+    }
+  }
+  exit (1) if ($error_count and (!get_conf('FORCE')
+     or $error_count > get_conf('ERROR_LIMIT')));
+}
+
+sub handle_errors($$$) {
   my $self = shift;
   my $error_count = shift;
+  my $opened_files = shift;
   my ($errors, $new_error_count) = $self->errors();
   $error_count += $new_error_count if ($new_error_count);
   foreach my $error_message (@$errors) {
@@ -435,8 +451,7 @@
                                            or !get_conf('NO_WARN'));
   }
   
-  exit (1) if ($error_count and (!get_conf('FORCE')
-     or $error_count > get_conf('ERROR_LIMIT')));
+  _exit($error_count, $opened_files);
   return $error_count;
 }
 
@@ -735,7 +750,7 @@
        $format = 'raw_text';
      } else {
        set_from_cmdline ($var, $value);
-       # FIXME do that here or all command line options are processed?
+       # FIXME do that here or when all command line options are processed?
        if ($var eq 'L2H' and get_conf('L2H')) {
          locate_and_load_init_file($latex2html_file, 
                                [ @conf_dirs, @program_init_dirs ]);
@@ -924,6 +939,9 @@
      unless (scalar(@input_files) >= 1);
 
 my $file_number = -1;
+my @opened_files = ();
+my %unclosed_files;
+my $error_count = 0;
 # main processing
 while(@input_files)
 {
@@ -970,9 +988,8 @@
   my $parser = Texinfo::Parser::parser($parser_options);
   my $tree = $parser->parse_texi_file($input_file_name);
 
-  my $error_count = 0;
   if (!defined($tree)) {
-    handle_errors($parser, $error_count);
+    handle_errors($parser, $error_count, address@hidden);
     next;
   }
 
@@ -1000,7 +1017,7 @@
                       $macro_expand_file, $!));
         $error_macro_expand_file = 1;
       }
-      delete $parser->{'unclosed_files'}->{$macro_expand_file};
+      
$parser->Texinfo::Convert::Converter::register_close_file($macro_expand_file);
     } else {
       warn (sprintf(__("Could not open %s for writing: %s\n"), 
                     $macro_expand_file, $!));
@@ -1009,12 +1026,11 @@
 
     if ($error_macro_expand_file) {
       $error_count++;
-      exit (1) if ($error_count and (!get_conf('FORCE')
-         or $error_count > get_conf('ERROR_LIMIT')));
+      _exit($error_count, address@hidden);
     }
   }
   if (get_conf('DUMP_TEXI')) {
-    handle_errors($parser, $error_count);
+    handle_errors($parser, $error_count, address@hidden);
     next;
   }
   Texinfo::Structuring::associate_internal_references($parser);
@@ -1032,7 +1048,7 @@
   if ($formats_table{$format}->{'floats'}) {
     Texinfo::Structuring::number_floats($floats);
   }
-  $error_count = handle_errors($parser, $error_count);
+  $error_count = handle_errors($parser, $error_count, address@hidden);
   if (get_conf('SIMPLE_MENU')
       and $formats_table{$format}->{'simple_menu'}) {
     $parser->Texinfo::Structuring::set_menus_to_simple_menu();
@@ -1051,7 +1067,25 @@
   $converter_options->{'htmlxref_files'} = address@hidden;
   my $converter = 
&{$formats_table{$format}->{'converter'}}($converter_options);
   $converter->output($tree);
-  handle_errors($converter, $error_count);
+  push @opened_files, $converter->converter_opened_files();
+  handle_errors($converter, $error_count, address@hidden);
+  my $converter_unclosed_files = $converter->converter_unclosed_files();
+  if ($converter_unclosed_files) {
+    foreach my $unclosed_file (keys(%$converter_unclosed_files)) {
+      if ($unclosed_file eq '-') {
+        $unclosed_files{$unclosed_file} 
+          = $converter_unclosed_files->{$unclosed_file};
+      } else {
+        if (!close($converter_unclosed_files->{$unclosed_file})) {
+          warn (sprintf(__("Error on closing %s: %s\n"), 
+                           $unclosed_file, $!));
+          $error_count++;
+          _exit($error_count, address@hidden);
+        }
+      }
+    }
+  }
+  
   if (defined(get_conf('INTERNAL_LINKS')) and $file_number == 0
       and $formats_table{$format}->{'internal_links'}) {
     my $internal_links_text 
@@ -1070,7 +1104,7 @@
                       $internal_links_file, $!));
         $error_internal_links_file = 1;
       }
-      delete $parser->{'unclosed_files'}->{$internal_links_file};
+      $converter->register_close_file($internal_links_file);
     } else {
       warn (sprintf(__("Could not open %s for writing: %s\n"), 
                     $internal_links_file, $!));
@@ -1078,9 +1112,18 @@
     }
     if ($error_internal_links_file) {
       $error_count++;
-      exit (1) if ($error_count and (!get_conf('FORCE')
-         or $error_count > get_conf('ERROR_LIMIT')));
+      _exit($error_count, address@hidden);
+    }
     }
+}
+
+foreach my $unclosed_file (keys(%unclosed_files)) {
+  if (!close($unclosed_files{$unclosed_file})) {
+    warn (sprintf(__("Error on closing %s: %s\n"), 
+                     $unclosed_file, $!));
+    $error_count++;
+    _exit($error_count, address@hidden);
   }
 }
 
+1;

Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- Texinfo/Common.pm   13 Nov 2011 23:57:38 -0000      1.99
+++ Texinfo/Common.pm   15 Nov 2011 00:00:42 -0000      1.100
@@ -771,7 +771,6 @@
   if ($file eq '-') {
     binmode(STDOUT, ":encoding($encoding)") if ($encoding);
     if ($self) {
-      push @{$self->{'opened_files'}}, $file;
       $self->{'unclosed_files'}->{$file} = \*STDOUT;
     }
     return \*STDOUT;
@@ -791,6 +790,8 @@
   if ($self) {
     push @{$self->{'opened_files'}}, $file;
     $self->{'unclosed_files'}->{$file} = $filehandle;
+    #print STDERR "OOOOOOO $file ".join('|',@{$self->{'opened_files'}})."\n";
+    #cluck;
   }
   return $filehandle;
 }

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.335
retrieving revision 1.336
diff -u -b -r1.335 -r1.336
--- Texinfo/Parser.pm   13 Nov 2011 23:55:21 -0000      1.335
+++ Texinfo/Parser.pm   15 Nov 2011 00:00:42 -0000      1.336
@@ -3337,8 +3337,6 @@
                          'extra' => {'line' => $line }};
           $current = $current->{'contents'}->[-1];
           last;
-          # FIXME(Karl) accept also not spaces at the line beginning?
-        #} elsif ($line =~ /^(.*?)address@hidden([a-zA-Z][\w-]*)/
         } elsif ($line =~ /^(\s*?)address@hidden([a-zA-Z][\w-]*)/
                  and ($2 eq $current->{'cmdname'})) {
           my $end_command = $2;

Index: Texinfo/Convert/Converter.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Converter.pm,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- Texinfo/Convert/Converter.pm        8 Nov 2011 00:05:50 -0000       1.65
+++ Texinfo/Convert/Converter.pm        15 Nov 2011 00:00:43 -0000      1.66
@@ -26,6 +26,8 @@
 use Texinfo::Common;
 use Texinfo::Convert::Text;
 
+use Carp qw(cluck);
+
 require Exporter;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 @ISA = qw(Exporter Texinfo::Report);
@@ -152,6 +154,17 @@
   }
 }
 
+sub register_close_file($$)
+{
+  my $self = shift;
+  my $filename = shift;
+  if ($self->{'unclosed_files'}->{$filename}) {
+    delete $self->{'unclosed_files'}->{$filename};
+  } else {
+    cluck "$filename not opened\n";
+  }
+}
+
 sub converter(;$)
 {
   my $class = shift;
@@ -262,6 +275,22 @@
   return $converter;
 }
 
+sub converter_unclosed_files($)
+{
+  my $self = shift;
+  return $self->{'unclosed_files'};
+}
+
+sub converter_opened_files($)
+{
+  my $self = shift;
+  if (defined($self->{'opened_files'})) {
+    return @{$self->{'opened_files'}};
+  } else {
+    return ();
+  }
+}
+
 sub _set_global_multiple_commands($;$)
 {
   my $self = shift;
@@ -412,7 +441,10 @@
       $document_name = $outfile;
     }
     if (defined($self->get_conf('SUBDIR')) and $outfile ne '') {
-      $outfile = $self->get_conf('SUBDIR')."/$outfile";
+      my $dir = $self->get_conf('SUBDIR');
+      $dir =~ s/\/*$//;
+      $dir .= '/';
+      $outfile = $dir.$outfile;
     }
     #$self->set_conf('OUTFILE', $outfile);
   } else {

Index: Texinfo/Convert/DocBook.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/DocBook.pm,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- Texinfo/Convert/DocBook.pm  13 Nov 2011 23:55:21 -0000      1.33
+++ Texinfo/Convert/DocBook.pm  15 Nov 2011 00:00:43 -0000      1.34
@@ -331,12 +331,11 @@
   $result .= $self->_output_text($header, $fh);
   $result .= $self->convert_document_sections($root, $fh);
   $result .= $self->_output_text("</book>\n", $fh);
-  if ($fh) {
-    # FIXME do not close STDOUT
-    delete $self->{'unclosed_files'}->{$self->{'output_filename'}};
+  if ($fh and $self->{'output_file'} ne '-') {
+    $self->register_close_file($self->{'output_file'});
     if (!close ($fh)) {
       $self->document_error(sprintf($self->__("Error on closing %s: %s"),
-                                    $self->{'output_filename'}, $!));
+                                    $self->{'output_file'}, $!));
     }
   }
   return $result;

Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -b -r1.209 -r1.210
--- Texinfo/Convert/HTML.pm     13 Nov 2011 23:55:22 -0000      1.209
+++ Texinfo/Convert/HTML.pm     15 Nov 2011 00:00:43 -0000      1.210
@@ -4878,7 +4878,7 @@
   if (!$self->get_conf('SPLIT')) {
     foreach my $element (@$elements) {
       if (!defined($element->{'filename'})) {
-        $element->{'filename'} = $self->{'document_name'}.$extension;
+        $element->{'filename'} = $self->{'output_filename'};
         $element->{'out_filename'} = $self->{'output_file'};
       }
     }
@@ -5098,10 +5098,10 @@
     if ($self->get_conf('SPLIT') or !$self->get_conf('MONOLITHIC')) {
       $default_filename = $self->{'document_name'}.
         $self->{'misc_pages_file_string'}->{$type};
+      $default_filename .= '.'.$extension if (defined($extension));
     } else {
-      $default_filename = $self->{'document_name'};
+      $default_filename = undef;
     }
-    $default_filename .= '.'.$extension if (defined($extension));
 
     my $filename;
     if (defined($Texinfo::Config::special_element_target_file_name)) {
@@ -5114,10 +5114,15 @@
     }
     $filename = $default_filename if (!defined($filename));
 
+    if ($self->get_conf('DEBUG')) {
+      my $fileout = $filename;
+      $fileout = 'UNDEF' if (!defined($fileout));
     print STDERR "Add special $element $type: target $target, id $id,\n".
-      "    filename $filename\n" if ($self->get_conf('DEBUG'));
+        "    filename $fileout\n" 
+    }
     if ($self->get_conf('SPLIT') or !$self->get_conf('MONOLITHIC')
-        or $filename ne $default_filename) {
+        or (defined($filename) ne defined($default_filename))
+        or (defined($filename) and $filename ne $default_filename)) {
       $self->_set_element_file($element, $filename);
       print STDERR "NEW page for $type ($filename)\n" if 
($self->get_conf('DEBUG'));
     }
@@ -6101,7 +6106,7 @@
 </html>
 EOT
 
-    delete $self->{'unclosed_files'}->{$frame_outfile};
+    $self->register_close_file($frame_outfile);
     if (!close ($frame_fh)) {
       $self->document_error(sprintf($self->__("Error on closing frame file %s: 
%s"),
                                     $frame_outfile, $!));
@@ -6125,7 +6130,7 @@
     print $toc_frame_fh $shortcontents;
     print $toc_frame_fh "</body></html>\n";
 
-    delete $self->{'unclosed_files'}->{$toc_frame_outfile};
+    $self->register_close_file($toc_frame_outfile);
     if (!close ($toc_frame_fh)) {
       $self->document_error(sprintf($self->__("Error on closing TOC frame file 
%s: %s"),
                                     $toc_frame_outfile, $!));
@@ -6515,9 +6520,9 @@
       $output .= $self->_output_text($self->_convert($root), $fh);
     }
     $output .= $self->_output_text(&{$self->{'format_end_file'}}($self), $fh);
-    # FIXME do not close STDOUT
-    if ($fh) {
-      delete $self->{'unclosed_files'}->{$outfile};
+    # NOTE do not close STDOUT now to avoid a perl warning.
+    if ($fh and $outfile ne '-') {
+      $self->register_close_file($outfile);
       if (!close($fh)) {
         $self->document_error(sprintf($self->__("Error on closing %s: %s"),
                                       $outfile, $!));
@@ -6535,7 +6540,7 @@
       my $file_fh;
       $self->{'current_filename'} = $element->{'filename'};
       $self->{'counter_in_file'}->{$element->{'filename'}}++;
-      #print STDERR "TTTTTTT($element) $element->{'filename'}: 
$self->{'file_counters'}->{$element->{'filename'}}\n";
+      #print STDERR "TTTTTTT($element) $element->{'filename'}: 
$self->{'file_counters'}->{$element->{'filename'}} (out_filename 
$element->{'out_filename'})\n";
       # First do the special pages, to avoid outputting these if they are
       # empty.
       my $special_element_content;
@@ -6553,7 +6558,6 @@
         if (!$file_fh) {
           $self->document_error(sprintf($self->__("Could not open %s for 
writing: %s"),
                                     $element->{'out_filename'}, $!));
-          # FIXME close/remove files already created
           return undef;
         }
         print $file_fh "".&{$self->{'format_begin_file'}}($self, 
@@ -6574,12 +6578,14 @@
         # end file
         print $file_fh "". &{$self->{'format_end_file'}}($self);
 
-        # FIXME do not close STDOUT
-        delete $self->{'unclosed_files'}->{$element->{'out_filename'}};
+        # NOTE do not close STDOUT here to avoid a perl warning
+        if ($element->{'out_filename'} ne '-') {
+          $self->register_close_file($element->{'out_filename'});
         if (!close($file_fh)) {
           $self->document_error(sprintf($self->__("Error on closing %s: %s"),
                                 $element->{'out_filename'}, $!));
-          # FIXME(Karl) return at that point?
+            return undef;
+          }
         }
       }
     }
@@ -6630,11 +6636,11 @@
                                     $out_filename, $!));
         } else {
           print $file_fh $redirection_page;
-          delete $self->{'unclosed_files'}->{$out_filename};
+          $self->register_close_file($out_filename);
           if (!close ($file_fh)) {
             $self->document_error(sprintf($self->__("Error on closing 
redirection node file %s: %s"),
                                     $out_filename, $!));
-            # FIXME(Karl) return at that point?
+            return undef;
           }
         }
       }
@@ -6697,11 +6703,11 @@
                                     $out_filename, $!));
         } else {
           print $file_fh $redirection_page;
-          delete $self->{'unclosed_files'}->{$out_filename};
+          $self->register_close_file($out_filename);
           if (!close ($file_fh)) {
             $self->document_error(sprintf($self->__("Error on closing renamed 
node file %s: %s"),
                                     $out_filename, $!));
-            # FIXME(Karl) return at that point?
+            return undef;
           }
         }
       }

Index: Texinfo/Convert/Info.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Info.pm,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- Texinfo/Convert/Info.pm     13 Nov 2011 23:55:22 -0000      1.77
+++ Texinfo/Convert/Info.pm     15 Nov 2011 00:00:43 -0000      1.78
@@ -77,7 +77,7 @@
 
   my $fh;
   if (! $self->{'output_file'} eq '') {
-    $fh = $self->Texinfo::Common::open_out ($self->{'output_file'});
+    $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'}, $!));
@@ -123,12 +123,12 @@
           and $self->{'count_context'}->[-1]->{'bytes'} > 
                   $out_file_nr * $self->get_conf('SPLIT_SIZE') 
           and @nodes and $fh) {
-        delete $self->{'unclosed_files'}->{$self->{'output_file'}};
         my $close_error;
         if (!close ($fh)) {
           $close_error = $!;
         }
         if ($out_file_nr == 1) {
+          $self->register_close_file($self->{'output_file'});
           if (defined($close_error)) {
             $self->document_error(sprintf($self->__("Error on closing %s: %s"),
                                   $self->{'output_file'}, $close_error));
@@ -150,12 +150,12 @@
                                  $first_node_bytes_count];
           #print STDERR join(' --> ', @{$indirect_files[-1]}) ."\n";
         } else {
+          $self->register_close_file($self->{'output_file'}.'-'.$out_file_nr);
           if (defined($close_error)) {
             $self->document_error(sprintf($self->__("Error on closing %s: %s"),
                                   $self->{'output_file'}.'-'.$out_file_nr, 
                                   $close_error));
-            # FIXME return undef, interrupting processing?
-            # return undef;
+            return undef;
           }
         }
         $out_file_nr++;
@@ -177,12 +177,11 @@
   }
   my $tag_text = '';
   if ($out_file_nr > 1) {
-    delete 
$self->{'unclosed_files'}->{$self->{'output_file'}.'-'.$out_file_nr};
+    $self->register_close_file($self->{'output_file'}.'-'.$out_file_nr);
     if (!close ($fh)) {
       $self->document_error(sprintf($self->__("Error on closing %s: %s"),
                             $self->{'output_file'}.'-'.$out_file_nr, $!));
-      # FIXME(Karl) return undef, interrupting processing?
-      # return undef;
+      return undef;
     }
     $fh = $self->Texinfo::Common::open_out($self->{'output_file'});
     if (!$fh) {
@@ -236,11 +235,12 @@
   }
   if ($fh) {
     print $fh $tag_text;
-    # FIXME it should be possible to close STDOUT.  However this leads to
+    # NOTE it should be possible to close STDOUT.  However this leads to
     # 'Filehandle STDOUT reopened as FH only for input' if there are files
-    # reopened after closing STDOUT.
+    # reopened after closing STDOUT.  So closing STDOUT is handled by the
+    # caller.
     unless ($self->{'output_file'} eq '-') {
-      delete $self->{'unclosed_files'}->{$self->{'output_file'}};
+      $self->register_close_file($self->{'output_file'});
       if (!close ($fh)) {
         $self->document_error(sprintf($self->__("Error on closing %s: %s"),
                               $self->{'output_file'}, $!));

Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- Texinfo/Convert/Text.pm     13 Nov 2011 23:04:30 -0000      1.82
+++ Texinfo/Convert/Text.pm     15 Nov 2011 00:00:43 -0000      1.83
@@ -623,7 +623,7 @@
   }
   my $fh;
   if (defined($outfile)) {
-    $fh = $self->Texinfo::Common::open_out ($outfile);
+    $fh = $self->Texinfo::Common::open_out($outfile);
     return undef if (!$fh);
   }
   my $result = _convert($tree, \%options);
@@ -648,6 +648,16 @@
   return undef;
 }
 
+sub converter_unclosed_files()
+{
+  return undef;
+}
+
+sub converter_opened_files()
+{
+  return ();
+}
+ 
 1;
 
 __END__

Index: Texinfo/Convert/XML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/XML.pm,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- Texinfo/Convert/XML.pm      13 Nov 2011 23:04:30 -0000      1.54
+++ Texinfo/Convert/XML.pm      15 Nov 2011 00:00:43 -0000      1.55
@@ -279,9 +279,12 @@
   $result .= $self->_output_text($header, $fh);
   $result .= $self->convert_document_sections($root, $fh);
   $result .= $self->_output_text("</texinfo>\n", $fh);
-  if ($fh and !close ($fh)) {
+  if ($fh and $self->{'output_file'} ne '-') {
+    $self->register_close_file($self->{'output_file'});
+    if (!close ($fh)) {
     $self->document_error(sprintf($self->__("Error on closing %s: %s"),
-                                  $self->{'output_filename'}, $!));
+                                    $self->{'output_file'}, $!));
+    }
   }
 
   return $result;



reply via email to

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