comparison liboctave/system/lo-sysdep.cc @ 32188:85255746fc21

Add isenv function (patch #10354). * libinterp/corefcn/sysdep.cc (Fisenv): Add new function. * liboctave/system/lo-sysdep.cc, liboctave/system/lo-sysdep.h (isenv_wrapper): Add new function. * liboctave/system/oct-env.cc, liboctave/system/oct-env.h (env::isenv): Add new function. * doc/interpreter/system.txi: Add reference to isenv. * etc/NEWS.9.md: Add note about new function.
author John Donoghue <john.donoghue@ieee.org>
date Wed, 31 May 2023 16:29:09 -0400
parents 3c608abd55f5
children 3c2c585965cc
comparison
equal deleted inserted replaced
32187:829a32a4171c 32188:85255746fc21
703 #else 703 #else
704 return octave_unsetenv_wrapper (name.c_str ()); 704 return octave_unsetenv_wrapper (name.c_str ());
705 #endif 705 #endif
706 } 706 }
707 707
708 bool
709 isenv_wrapper (const std::string& name)
710 {
711 #if defined (OCTAVE_USE_WINDOWS_API)
712 std::wstring wname = u8_to_wstring (name);
713 wchar_t *env = _wgetenv (wname.c_str ());
714 #else
715 char *env = ::getenv (name.c_str ());
716 #endif
717 return env != 0;
718 }
719
708 std::wstring 720 std::wstring
709 u8_to_wstring (const std::string& utf8_string) 721 u8_to_wstring (const std::string& utf8_string)
710 { 722 {
711 // convert multibyte UTF-8 string to wide character string 723 // convert multibyte UTF-8 string to wide character string
712 static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> 724 static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>