changeset 25548:d6050ba12c0c

Call get_ASCII_filename for std::ifstream (bug #49118). * debug.cc, dlmread.cc, help.cc, load-save.cc, urlwrite.cc, ov-java.cc, fileinfo.cc, url-transfer.cc: Call get_ASCII_filename for filename argument of std::ifstream to circumvent the wide char WinAPI.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 03 Jul 2018 21:06:00 +0200
parents 2b9a30925a9c
children 8cc9e21b15a7
files libinterp/corefcn/debug.cc libinterp/corefcn/dlmread.cc libinterp/corefcn/help.cc libinterp/corefcn/load-save.cc libinterp/corefcn/urlwrite.cc libinterp/octave-value/ov-java.cc liboctave/util/file-info.cc liboctave/util/url-transfer.cc
diffstat 8 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/debug.cc	Tue Jul 03 08:49:28 2018 -0700
+++ b/libinterp/corefcn/debug.cc	Tue Jul 03 21:06:00 2018 +0200
@@ -45,6 +45,7 @@
 #include "input.h"
 #include "interpreter-private.h"
 #include "interpreter.h"
+#include "lo-sysdep.h"
 #include "octave-preserve-stream-state.h"
 #include "ov-usr-fcn.h"
 #include "ov.h"
@@ -593,7 +594,7 @@
     os << "dbtype: unknown function " << name << "\n";
   else
     {
-      std::ifstream fs (ff.c_str (), std::ios::in);
+      std::ifstream fs (octave::sys::get_ASCII_filename (ff).c_str (), std::ios::in);
 
       if (! fs)
         os << "dbtype: unable to open '" << ff << "' for reading!\n";
--- a/libinterp/corefcn/dlmread.cc	Tue Jul 03 08:49:28 2018 -0700
+++ b/libinterp/corefcn/dlmread.cc	Tue Jul 03 21:06:00 2018 +0200
@@ -34,6 +34,7 @@
 
 #include "file-ops.h"
 #include "lo-ieee.h"
+#include "lo-sysdep.h"
 
 #include "defun.h"
 #include "interpreter.h"
@@ -220,7 +221,7 @@
 
       tname = find_data_file_in_load_path ("dlmread", tname);
 
-      input_file.open (tname.c_str (), std::ios::in);
+      input_file.open (octave::sys::get_ASCII_filename (tname).c_str (), std::ios::in);
 
       if (! input_file)
         error ("dlmread: unable to open file '%s'", fname.c_str ());
--- a/libinterp/corefcn/help.cc	Tue Jul 03 08:49:28 2018 -0700
+++ b/libinterp/corefcn/help.cc	Tue Jul 03 21:06:00 2018 +0200
@@ -37,6 +37,7 @@
 #include "cmd-edit.h"
 #include "file-ops.h"
 #include "file-stat.h"
+#include "lo-sysdep.h"
 #include "oct-env.h"
 #include "oct-locbuf.h"
 #include "str-vec.h"
@@ -581,8 +582,9 @@
 
     if (! initialized)
       {
-        std::ifstream file (m_built_in_docstrings_file.c_str (),
-                            std::ios::in | std::ios::binary);
+        std::ifstream file (
+          octave::sys::get_ASCII_filename (m_built_in_docstrings_file).c_str (),
+          std::ios::in | std::ios::binary);
 
         if (! file)
           error ("failed to open docstrings file: %s",
@@ -664,8 +666,9 @@
         std::streampos beg = txt_limits.first;
         std::streamoff len = txt_limits.second;
 
-        std::ifstream file (m_built_in_docstrings_file.c_str (),
-                            std::ios::in | std::ios::binary);
+        std::ifstream file (
+          octave::sys::get_ASCII_filename (m_built_in_docstrings_file).c_str (),
+          std::ios::in | std::ios::binary);
 
         if (! file)
           error ("failed to open docstrings file: %s",
--- a/libinterp/corefcn/load-save.cc	Tue Jul 03 08:49:28 2018 -0700
+++ b/libinterp/corefcn/load-save.cc	Tue Jul 03 21:06:00 2018 +0200
@@ -226,7 +226,8 @@
 {
   bool retval = false;
 
-  std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary);
+  std::ifstream file (octave::sys::get_ASCII_filename (fname).c_str (),
+                      std::ios::in | std::ios::binary);
 
   unsigned char magic[2];
   if (file.read (reinterpret_cast<char *> (&magic[0]), 2)
@@ -326,7 +327,8 @@
 
   if (! use_zlib)
     {
-      std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary);
+      std::ifstream file (octave::sys::get_ASCII_filename (fname).c_str (),
+                          std::ios::in | std::ios::binary);
       if (file)
         {
           retval = get_file_format (file, orig_fname);
@@ -834,7 +836,8 @@
           else
 #endif
             {
-              std::ifstream file (fname.c_str (), mode);
+              std::ifstream file (
+                octave::sys::get_ASCII_filename (fname).c_str (), mode);
 
               if (! file)
                 error ("load: unable to open input file '%s'",
--- a/libinterp/corefcn/urlwrite.cc	Tue Jul 03 08:49:28 2018 -0700
+++ b/libinterp/corefcn/urlwrite.cc	Tue Jul 03 21:06:00 2018 +0200
@@ -35,6 +35,7 @@
 #include "dir-ops.h"
 #include "file-ops.h"
 #include "file-stat.h"
+#include "lo-sysdep.h"
 #include "oct-env.h"
 #include "oct-handle.h"
 #include "glob-match.h"
@@ -637,7 +638,8 @@
       else
         {
           // FIXME: Does ascii mode need to be flagged here?
-          std::ifstream ifile (file.c_str (), std::ios::in | std::ios::binary);
+          std::ifstream ifile (octave::sys::get_ASCII_filename (file).c_str (),
+                               std::ios::in | std::ios::binary);
 
           if (! ifile.is_open ())
             error ("__ftp_mput__: unable to open file");
--- a/libinterp/octave-value/ov-java.cc	Tue Jul 03 08:49:28 2018 -0700
+++ b/libinterp/octave-value/ov-java.cc	Tue Jul 03 21:06:00 2018 +0200
@@ -53,6 +53,7 @@
 #include "file-stat.h"
 #include "fpucw-wrappers.h"
 #include "load-path.h"
+#include "lo-sysdep.h"
 #include "oct-env.h"
 #include "oct-shlib.h"
 #include "ov-java.h"
@@ -237,7 +238,7 @@
 
     void read_java_opts (const std::string& filename)
     {
-      std::ifstream js (filename.c_str ());
+      std::ifstream js (octave::sys::get_ASCII_filename (filename).c_str ());
 
       if (! js.bad () && ! js.fail ())
         {
@@ -358,7 +359,7 @@
 {
   std::string classpath;
 
-  std::ifstream fs (filepath.c_str ());
+  std::ifstream fs (octave::sys::get_ASCII_filename (filepath).c_str ());
 
   if (! fs.bad () && ! fs.fail ())
     {
--- a/liboctave/util/file-info.cc	Tue Jul 03 08:49:28 2018 -0700
+++ b/liboctave/util/file-info.cc	Tue Jul 03 21:06:00 2018 +0200
@@ -31,6 +31,7 @@
 #include "file-info.h"
 #include "file-stat.h"
 #include "lo-error.h"
+#include "lo-sysdep.h"
 
 namespace octave
 {
@@ -80,7 +81,8 @@
 
     size_t sz = fs.size ();
 
-    std::ifstream file (fname.c_str (), std::ios::in | std::ios::binary);
+    std::ifstream file (octave::sys::get_ASCII_filename (fname).c_str (),
+                        std::ios::in | std::ios::binary);
 
     if (file)
       {
--- a/liboctave/util/url-transfer.cc	Tue Jul 03 08:49:28 2018 -0700
+++ b/liboctave/util/url-transfer.cc	Tue Jul 03 21:06:00 2018 +0200
@@ -202,8 +202,9 @@
               else
                 {
                   // FIXME: Does ascii mode need to be flagged here?
-                  std::ifstream ifile (realfile.c_str (),
-                                       std::ios::in | std::ios::binary);
+                  std::ifstream ifile (
+                    octave::sys::get_ASCII_filename (realfile).c_str (),
+                    std::ios::in | std::ios::binary);
 
                   if (! ifile.is_open ())
                     {