diff liboctave/system/oct-env.cc @ 29492:be4b78fb4411

Replace Unicode conversion functions from gnulib with STL functions. * liboctave/system/lo-sysdep.cc (u8_to_wstring, u8_from_wstring): Use C++11 functions to convert between UTF-8 and the Unicode encoding that is used for "wstring"s. (putenv_wrapper): Use "u8_to_wstring" instead of "u8_to_wchar". * liboctave/system/oct-env.cc (do_get_user_config_directory, do_get_user_data_directory): Use "u8_from_wstring" instead of "u8_from_wchar". * libinterp/corefcn/sysdep.cc (popen): Use "u8_to_wstring" instead of "u8_to_wchar".
author Markus Mützel <markus.muetzel@gmx.de>
date Fri, 02 Apr 2021 19:28:07 +0200
parents 7854d5752dd2
children aef11bb4e6d1
line wrap: on
line diff
--- a/liboctave/system/oct-env.cc	Mon Apr 05 09:15:48 2021 -0700
+++ b/liboctave/system/oct-env.cc	Fri Apr 02 19:28:07 2021 +0200
@@ -61,8 +61,6 @@
 #include "unistd-wrappers.h"
 
 #if defined (OCTAVE_USE_WINDOWS_API)
-#  include "uniconv-wrappers.h"
-
 #  include <windows.h>
 #  include <shlobj.h>
 #endif
@@ -254,18 +252,14 @@
       wchar_t path[MAX_PATH+1];
       if (SHGetFolderPathW (nullptr, CSIDL_APPDATA | CSIDL_FLAG_DONT_VERIFY,
                             nullptr, SHGFP_TYPE_CURRENT, path) == S_OK)
-        {
-          char *app_data = u8_from_wchar (path);
-          cfg_dir = app_data;
-          free (app_data);
-        }
+        cfg_dir = u8_from_wstring (path);
 #else
       cfg_dir = do_getenv ("XDG_CONFIG_HOME");
+#endif
 
       if (cfg_dir.empty ())
         cfg_dir = do_get_home_directory () + sys::file_ops::dir_sep_str ()
              + ".config";
-#endif
 
       return cfg_dir;
     }
@@ -279,18 +273,14 @@
       wchar_t path[MAX_PATH+1];
       if (SHGetFolderPathW (nullptr, CSIDL_APPDATA | CSIDL_FLAG_DONT_VERIFY,
                             nullptr, SHGFP_TYPE_CURRENT, path) == S_OK)
-        {
-          char *app_data = u8_from_wchar (path);
-          data_dir = app_data;
-          free (app_data);
-        }
+        data_dir = u8_from_wstring (path);
 #else
       data_dir = do_getenv ("XDG_DATA_HOME");
+#endif
 
       if (data_dir.empty ())
         data_dir = do_get_home_directory () + sys::file_ops::dir_sep_str ()
              + ".local" + sys::file_ops::dir_sep_str () + "share";
-#endif
 
       return data_dir;
   }