# HG changeset patch # User Markus Mützel # Date 1606656008 -3600 # Node ID f873857f5f865c5ce02b95d3f6c8cd56b21a523b # Parent c7498b5aece09e3bfb4821fe7f20c2d06dff035b system: Support executing commands with non-ASCII characters on Windows (bug #59572). * liboctave/system/lo-sysdep.h, liboctave/system/lo-sysdep.cc (octave::sys::system): Add new function. * libinterp/corefcn/toplev.cc (Fsystem), libinterp/corefcn/oct-hist.cc (history_system::do_edit_history): Use new function. * src/mkoctfile.in.cc (run_command): Add FIXME note. diff -r c7498b5aece0 -r f873857f5f86 libinterp/corefcn/oct-hist.cc --- a/libinterp/corefcn/oct-hist.cc Fri Dec 04 18:33:23 2020 +0100 +++ b/libinterp/corefcn/oct-hist.cc Sun Nov 29 14:20:08 2020 +0100 @@ -469,7 +469,7 @@ volatile interrupt_handler old_interrupt_handler = ignore_interrupts (); - int status = system (cmd.c_str ()); + int status = octave::sys::system (cmd); set_interrupt_handler (old_interrupt_handler); diff -r c7498b5aece0 -r f873857f5f86 libinterp/corefcn/toplev.cc --- a/libinterp/corefcn/toplev.cc Fri Dec 04 18:33:23 2020 +0100 +++ b/libinterp/corefcn/toplev.cc Sun Nov 29 14:20:08 2020 +0100 @@ -293,7 +293,7 @@ retval = run_command_and_return_output (cmd_str); else { - int status = system (cmd_str.c_str ()); + int status = octave::sys::system (cmd_str); // The value in status is as returned by waitpid. If // the process exited normally, extract the actual exit diff -r c7498b5aece0 -r f873857f5f86 liboctave/system/lo-sysdep.cc --- a/liboctave/system/lo-sysdep.cc Fri Dec 04 18:33:23 2020 +0100 +++ b/liboctave/system/lo-sysdep.cc Sun Nov 29 14:20:08 2020 +0100 @@ -27,6 +27,8 @@ # include "config.h" #endif +#include + #include "dir-ops.h" #include "file-ops.h" #include "lo-error.h" @@ -51,6 +53,18 @@ { namespace sys { + int + system (const std::string& cmd_str) + { +#if defined (OCTAVE_USE_WINDOWS_API) + const std::wstring wcmd_str = u8_to_wstring (cmd_str); + + return _wsystem (wcmd_str.c_str ()); +#else + return ::system (cmd_str.c_str ()); +#endif + } + std::string getcwd (void) { diff -r c7498b5aece0 -r f873857f5f86 liboctave/system/lo-sysdep.h --- a/liboctave/system/lo-sysdep.h Fri Dec 04 18:33:23 2020 +0100 +++ b/liboctave/system/lo-sysdep.h Sun Nov 29 14:20:08 2020 +0100 @@ -41,6 +41,8 @@ { namespace sys { + extern int system (const std::string& cmd_str); + extern std::string getcwd (void); extern int chdir (const std::string&); diff -r c7498b5aece0 -r f873857f5f86 src/mkoctfile.in.cc --- a/src/mkoctfile.in.cc Fri Dec 04 18:33:23 2020 +0100 +++ b/src/mkoctfile.in.cc Sun Nov 29 14:20:08 2020 +0100 @@ -589,6 +589,7 @@ if (verbose) std::cout << cmd << std::endl; + // FIXME: Call _wsystem on Windows or octave::sys::system. int result = system (cmd.c_str ()); if (octave_wifexited_wrapper (result))