# HG changeset patch # User Markus Mützel # Date 1592065645 -7200 # Node ID 39c078e14824fc12f0f3cdff339d08add8b45c19 # Parent 10f4ac250b89dba235478e386573b060a771d34d Use wide character API to get current directory on Windows. * liboctave/system/lo-sysdep.cc (octave::sys::getcwd): On Windows, use wide character API to get current working directory and convert to UTF-8. This partly fixes a regression that prevents executing any commands if the current working directory contains non-ASCII characters. diff -r 10f4ac250b89 -r 39c078e14824 liboctave/system/lo-sysdep.cc --- a/liboctave/system/lo-sysdep.cc Fri Jun 12 11:37:15 2020 -0400 +++ b/liboctave/system/lo-sysdep.cc Sat Jun 13 18:27:25 2020 +0200 @@ -56,6 +56,20 @@ { std::string retval; +#if defined (OCTAVE_USE_WINDOWS_API) + wchar_t *tmp = _wgetcwd (nullptr, 0); + + if (! tmp) + (*current_liboctave_error_handler) ("unable to find current directory"); + + std::wstring tmp_wstr (tmp); + free (tmp); + + std::string tmp_str = u8_from_wstring (tmp_wstr); + + retval = tmp_str; + +#else // Using octave_getcwd_wrapper ensures that we have a getcwd that // will allocate a buffer as large as necessary if buf and size are // both 0. @@ -67,6 +81,7 @@ retval = tmp; free (tmp); +#endif return retval; }