texinfo-commits
[Top][All Lists]
Advanced

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

[6339] only turn CR-LF conversion off for Info output


From: Gavin D. Smith
Subject: [6339] only turn CR-LF conversion off for Info output
Date: Tue, 16 Jun 2015 23:05:45 +0000

Revision: 6339
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6339
Author:   gavin
Date:     2015-06-16 23:05:44 +0000 (Tue, 16 Jun 2015)
Log Message:
-----------
only turn CR-LF conversion off for Info output

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Common.pm
    trunk/tp/Texinfo/Convert/Info.pm

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-06-16 22:57:48 UTC (rev 6338)
+++ trunk/ChangeLog     2015-06-16 23:05:44 UTC (rev 6339)
@@ -1,3 +1,12 @@
+2015-06-17  Gavin Smith  <address@hidden>
+
+       * tp/Texinfo/Commom.pm (open_out): Add parameter which 
+       conditionalizes the calls to "binmode" on file handle.
+       * tp/Texinfo/Convert/Info.pm (_open_info_file): New function,
+       wrapping Texinfo::Common::open_out.  Call 
+       Texinfo::Common::open_out so that it calls "binmode".
+       (output): Call _open_info_file instead of open_out directly.
+
 2015-06-15  Eli Zaretskii  <address@hidden>, and
             Gavin Smith  <address@hidden>
 

Modified: trunk/tp/Texinfo/Common.pm
===================================================================
--- trunk/tp/Texinfo/Common.pm  2015-06-16 22:57:48 UTC (rev 6338)
+++ trunk/tp/Texinfo/Common.pm  2015-06-16 23:05:44 UTC (rev 6339)
@@ -1040,11 +1040,12 @@
   return $file;
 }
 
-sub open_out($$;$)
+sub open_out($$;$$)
 {
   my $self = shift;
   my $file = shift;
   my $encoding = shift;
+  my $use_binmode = shift;
 
   if (!defined($encoding) and $self 
       and defined($self->get_conf('OUTPUT_PERL_ENCODING'))) {
@@ -1052,7 +1053,7 @@
   }
 
   if ($file eq '-') {
-    binmode(STDOUT);
+    binmode(STDOUT) if $use_binmode;
     binmode(STDOUT, ":encoding($encoding)") if ($encoding);
     if ($self) {
       $self->{'unclosed_files'}->{$file} = \*STDOUT;
@@ -1064,8 +1065,9 @@
     return undef; 
   }
   # We run binmode to turn off outputting LF as CR LF under MS-Windows,
-  # so that Info tag tables will have correct offsets.
-  binmode(STDOUT);
+  # so that Info tag tables will have correct offsets.  This must be done
+  # before setting the encoding filters with binmode.
+  binmode(STDOUT) if $use_binmode;
   if ($encoding) {
     if ($encoding eq 'utf8' or $encoding eq 'utf-8-strict') {
       binmode($filehandle, ':utf8');

Modified: trunk/tp/Texinfo/Convert/Info.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Info.pm    2015-06-16 22:57:48 UTC (rev 6338)
+++ trunk/tp/Texinfo/Convert/Info.pm    2015-06-16 23:05:44 UTC (rev 6339)
@@ -94,10 +94,8 @@
     if ($self->get_conf('VERBOSE')) {
       print STDERR "Output file $self->{'output_file'}\n";
     }
-    $fh = $self->Texinfo::Common::open_out($self->{'output_file'});
+    $fh = _open_info_file($self, $self->{'output_file'});
     if (!$fh) {
-      $self->document_error(sprintf($self->__("could not open %s for writing: 
%s"),
-                                    $self->{'output_file'}, $!));
       return undef;
     }
   }
@@ -197,13 +195,9 @@
           print STDERR "New output file ".
                 $self->{'output_file'}.'-'.$out_file_nr."\n";
         }
-        $fh = $self->Texinfo::Common::open_out (
-                               $self->{'output_file'}.'-'.$out_file_nr); 
+        $fh = _open_info_file($self, $self->{'output_file'}.'-'.$out_file_nr); 
         if (!$fh) {
-           $self->document_error(sprintf(
-                  $self->__("could not open %s for writing: %s"),
-                  $self->{'output_file'}.'-'.$out_file_nr, $!));
-           return undef;
+          return undef;
         }
         print $fh $complete_header;
         $self->_update_count_context();
@@ -225,11 +219,8 @@
     if ($self->get_conf('VERBOSE')) {
       print STDERR "Outputing the split manual file $self->{'output_file'}\n";
     }
-    $fh = $self->Texinfo::Common::open_out($self->{'output_file'});
+    $fh = _open_info_file($self, $self->{'output_file'});
     if (!$fh) {
-      $self->document_error(sprintf(
-            $self->__("could not open %s for writing: %s"),
-            $self->{'output_file'}, $!));
       return undef;
     }
     $tag_text = $complete_header;
@@ -291,6 +282,23 @@
   return $result;
 }
 
+# Wrapper around Texinfo::Common::open_out.  Open the file with any CR-LF
+# conversion disabled.  We need this for tag tables to be correct under
+# MS-Windows.   Return filehandle or undef on failure.
+sub _open_info_file($$)
+{
+  my $self = shift;
+  my $filename = shift;
+  my $fh = $self->Texinfo::Common::open_out($filename, undef, 'use_binmode');
+  if (!$fh) {
+    $self->document_error(sprintf(
+        $self->__("could not open %s for writing: %s"),
+        $filename, $!));
+    return undef;
+  }
+  return $fh;
+}
+
 sub _info_header($)
 {
   my $self = shift;




reply via email to

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