Mercurial > octave
changeset 28470:39c078e14824 stable
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.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 13 Jun 2020 18:27:25 +0200 |
parents | 10f4ac250b89 |
children | a6c89130cfaa |
files | liboctave/system/lo-sysdep.cc |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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; }