# HG changeset patch # User Markus Mützel # Date 1606656008 -3600 # Sun Nov 29 14:20:08 2020 +0100 # Node ID e5b6c2f855190cef1cac5c8f5d0ce3b42b353e32 # Parent 54509b7fddd31b6b271cc9c32ffe129935f306e7 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 54509b7fddd3 -r e5b6c2f85519 libinterp/corefcn/oct-hist.cc --- a/libinterp/corefcn/oct-hist.cc Thu Nov 12 14:38:38 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 54509b7fddd3 -r e5b6c2f85519 libinterp/corefcn/toplev.cc --- a/libinterp/corefcn/toplev.cc Thu Nov 12 14:38:38 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 54509b7fddd3 -r e5b6c2f85519 liboctave/system/lo-sysdep.cc --- a/liboctave/system/lo-sysdep.cc Thu Nov 12 14:38:38 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 54509b7fddd3 -r e5b6c2f85519 liboctave/system/lo-sysdep.h --- a/liboctave/system/lo-sysdep.h Thu Nov 12 14:38:38 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 54509b7fddd3 -r e5b6c2f85519 src/mkoctfile.in.cc --- a/src/mkoctfile.in.cc Thu Nov 12 14:38:38 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))