diff src/file-io.cc @ 6405:b298a4c12fc3

[project @ 2007-03-14 16:51:28 by jwe]
author jwe
date Wed, 14 Mar 2007 16:51:30 +0000
parents 9e058e5fa8a7
children 7f5316cadaa2
line wrap: on
line diff
--- a/src/file-io.cc
+++ b/src/file-io.cc
@@ -415,6 +415,15 @@
 #if defined (HAVE_ZLIB)
 	  std::string tmode = mode;
 
+	  // Use binary mode if 't' is not specified, but don't add
+	  // 'b' if it is already present.
+
+	  size_t bpos = tmode.find ('b');
+	  size_t tpos = tmode.find ('t');
+
+	  if (bpos == NPOS && tpos == NPOS)
+	    tmode += 'b';
+
 	  size_t pos = tmode.find ('z');
 
 	  if (pos != NPOS)
@@ -434,7 +443,7 @@
 	  else
 #endif
 	    {
-	      FILE *fptr = ::fopen (fname.c_str (), mode.c_str ());
+	      FILE *fptr = ::fopen (fname.c_str (), tmode.c_str ());
 
 	      retval = octave_stdiostream::create (fname, fptr, md, flt_fmt);