diff options
author | Rui Ueyama <ruiu@google.com> | 2013-09-10 19:45:51 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2013-09-10 19:45:51 +0000 |
commit | f42d4247ae1138c6deed50f92dcd1a4f34e07dec (patch) | |
tree | 0e4fd79f9e891171d4b70ecfc5cc055876d91dc3 /include | |
parent | 8e12d95d15e4140311919a3b60461817baf68ca5 (diff) | |
download | external_llvm-f42d4247ae1138c6deed50f92dcd1a4f34e07dec.tar.gz external_llvm-f42d4247ae1138c6deed50f92dcd1a4f34e07dec.tar.bz2 external_llvm-f42d4247ae1138c6deed50f92dcd1a4f34e07dec.zip |
Add getenv() wrapper that works on multibyte environment variable.
On Windows, character encoding of multibyte environment variable varies
depending on settings. The only reliable way to handle it I think is to use
GetEnvironmentVariableW().
GetEnvironmentVariableW() works on wchar_t string, which is on Windows UTF16
string. That's not ideal because we use UTF-8 as the internal encoding in LLVM.
This patch defines a wrapper function which takes and returns UTF-8 string for
GetEnvironmentVariableW().
The wrapper function does not do any conversion and just forwards the argument
to getenv() on Unix.
Differential Revision: http://llvm-reviews.chandlerc.com/D1612
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/Process.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index a23c4add42..6d6add0f3e 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -25,11 +25,14 @@ #ifndef LLVM_SUPPORT_PROCESS_H #define LLVM_SUPPORT_PROCESS_H +#include "llvm/ADT/Optional.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/TimeValue.h" namespace llvm { +class StringRef; + namespace sys { class self_process; @@ -161,6 +164,10 @@ public: /// @brief Prevent core file generation. static void PreventCoreFiles(); + // This function returns the environment variable \arg name's value as a UTF-8 + // string. \arg Name is assumed to be in UTF-8 encoding too. + static Optional<std::string> GetEnv(StringRef name); + /// This function determines if the standard input is connected directly /// to a user's input (keyboard probably), rather than coming from a file /// or pipe. |