diff options
author | Brad King <brad.king@kitware.com> | 2023-11-19 16:41:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-11-19 16:41:31 (GMT) |
commit | 9812861652b7011b6cb7e93ec1256fb2a18b44e5 (patch) | |
tree | c94f92605635bdf94c77c246d10ed271c19524c2 /Source/kwsys/SystemTools.cxx | |
parent | 67be468693c19cdc5377d0d090c055d58f484ed2 (diff) | |
parent | 09b90d4377d3bf199114ae9aa65fe30161c2467d (diff) | |
download | CMake-9812861652b7011b6cb7e93ec1256fb2a18b44e5.zip CMake-9812861652b7011b6cb7e93ec1256fb2a18b44e5.tar.gz CMake-9812861652b7011b6cb7e93ec1256fb2a18b44e5.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream
* upstream-KWSys:
KWSys 2023-11-19 (8ce4c90d)
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 3bb7869..cefb922 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -412,18 +412,6 @@ inline void Realpath(const std::string& path, std::string& resolved_path, } #endif -#if !defined(_WIN32) && defined(__COMO__) -// Hack for como strict mode to avoid defining _SVID_SOURCE or _BSD_SOURCE. -extern "C" { -extern FILE* popen(__const char* __command, __const char* __modes) __THROW; -extern int pclose(FILE* __stream) __THROW; -extern char* realpath(__const char* __restrict __name, - char* __restrict __resolved) __THROW; -extern char* strdup(__const char* __s) __THROW; -extern int putenv(char* __string) __THROW; -} -#endif - namespace KWSYS_NAMESPACE { double SystemTools::GetTime() @@ -777,12 +765,16 @@ const char* SystemTools::GetEnv(const std::string& key) bool SystemTools::GetEnv(const char* key, std::string& result) { #if defined(_WIN32) - const std::wstring wkey = Encoding::ToWide(key); - const wchar_t* wv = _wgetenv(wkey.c_str()); - if (wv) { - result = Encoding::ToNarrow(wv); - return true; + auto wide_key = Encoding::ToWide(key); + auto result_size = GetEnvironmentVariableW(wide_key.data(), nullptr, 0); + if (result_size <= 0) { + return false; } + std::wstring wide_result; + wide_result.resize(result_size - 1); + GetEnvironmentVariableW(wide_key.data(), &wide_result[0], result_size); + result = Encoding::ToNarrow(wide_result); + return true; #else const char* v = getenv(key); if (v) { |