Mercurial > octave
changeset 25517:7fbc39a46be8
Add wrapper to fopen for files with non-ASCII chars in path on Windows (bug #49118).
* lo-sysdep.[cc/h]: Add new function "octave::sys::fopen".
* gl2ps-print.cc, gzip.cc (CFile), oct-parse.in.yy (parse_fcn_file): Replace
uses of "std::fopen" with "octave::sys::fopen".
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 29 Jun 2018 15:35:11 +0200 |
parents | 8945a6a6c0eb |
children | 3e2eddff9672 |
files | libinterp/corefcn/gl2ps-print.cc libinterp/dldfcn/gzip.cc libinterp/parse-tree/oct-parse.in.yy liboctave/system/lo-sysdep.cc liboctave/system/lo-sysdep.h |
diffstat | 5 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-print.cc Fri Jun 29 12:33:09 2018 +0200 +++ b/libinterp/corefcn/gl2ps-print.cc Fri Jun 29 15:35:11 2018 +0200 @@ -1116,7 +1116,7 @@ { // Write gl2ps output directly to file. - fp = std::fopen (stream.c_str (), "w"); + fp = octave::sys::fopen (stream.c_str (), "w"); if (! fp) error (R"(gl2ps_print: failed to create file "%s")", stream.c_str ());
--- a/libinterp/dldfcn/gzip.cc Fri Jun 29 12:33:09 2018 +0200 +++ b/libinterp/dldfcn/gzip.cc Fri Jun 29 15:35:11 2018 +0200 @@ -98,7 +98,7 @@ CFile (void) = delete; CFile (const std::string& path, const std::string& mode) - : m_fp (std::fopen (path.c_str (), mode.c_str ())) + : m_fp (octave::sys::fopen (path, mode)) { if (! m_fp) throw std::runtime_error ("unable to open file");
--- a/libinterp/parse-tree/oct-parse.in.yy Fri Jun 29 12:33:09 2018 +0200 +++ b/libinterp/parse-tree/oct-parse.in.yy Fri Jun 29 15:35:11 2018 +0200 @@ -64,6 +64,7 @@ #include "interpreter.h" #include "lex.h" #include "load-path.h" +#include "lo-sysdep.h" #include "oct-hist.h" #include "oct-map.h" #include "ov-classdef.h" @@ -4506,7 +4507,7 @@ FILE *ffile = nullptr; if (! full_file.empty ()) - ffile = std::fopen (full_file.c_str (), "rb"); + ffile = octave::sys::fopen (full_file, "rb"); if (ffile) {
--- a/liboctave/system/lo-sysdep.cc Fri Jun 29 12:33:09 2018 +0200 +++ b/liboctave/system/lo-sysdep.cc Fri Jun 29 15:35:11 2018 +0200 @@ -140,6 +140,17 @@ return true; } + std::FILE * + fopen (const std::string& filename, const std::string& mode) + { +#if defined (OCTAVE_USE_WINDOWS_API) + return _wfopen (u8_to_wstring (filename).c_str (), + u8_to_wstring (mode).c_str ()); +#else + return std::fopen (filename.c_str (), mode.c_str ()); +#endif + } + std::wstring u8_to_wstring (const std::string& utf8_string) { @@ -173,5 +184,6 @@ return retval; } + } }
--- a/liboctave/system/lo-sysdep.h Fri Jun 29 12:33:09 2018 +0200 +++ b/liboctave/system/lo-sysdep.h Fri Jun 29 15:35:11 2018 +0200 @@ -44,6 +44,8 @@ extern bool get_dirlist (const std::string& dirname, string_vector& dirlist, std::string& msg); + extern std::FILE * fopen (const std::string& name, const std::string& mode); + extern std::wstring u8_to_wstring (const std::string&); extern std::string u8_from_wstring (const std::wstring&);