summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2016-09-22 16:00:01 +0000
committerTodd Fiala <todd.fiala@gmail.com>2016-09-22 16:00:01 +0000
commit36bf6a46d8f012ed644e94fd94d7f1611e03fa0a (patch)
tree8c3c3c0eafa54d032b162ba0bbc7566c30900a3d /lldb/source/Interpreter
parentd5d57635baf6f3aa8d937e20f43dad75179f2cee (diff)
downloadbcm5719-llvm-36bf6a46d8f012ed644e94fd94d7f1611e03fa0a.tar.gz
bcm5719-llvm-36bf6a46d8f012ed644e94fd94d7f1611e03fa0a.zip
added environment variable-related Args gtests
Also fixed up a couple misbehaving functions. It is perfectly legal to have env vars with no values (i.e. the '=' and following need not be present). llvm-svn: 282171
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/Args.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 36ea78cee1d..25bcac81779 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -976,13 +976,15 @@ void Args::LongestCommonPrefix(std::string &common_prefix) {
void Args::AddOrReplaceEnvironmentVariable(llvm::StringRef env_var_name,
llvm::StringRef new_value) {
- if (env_var_name.empty() || new_value.empty())
+ if (env_var_name.empty())
return;
// Build the new entry.
std::string var_string(env_var_name);
- var_string += "=";
- var_string += new_value;
+ if (!new_value.empty()) {
+ var_string += "=";
+ var_string += new_value;
+ }
size_t index = 0;
if (ContainsEnvironmentVariable(env_var_name, &index)) {
@@ -1006,7 +1008,7 @@ bool Args::ContainsEnvironmentVariable(llvm::StringRef env_var_name,
llvm::StringRef name, value;
std::tie(name, value) = arg_value.split('=');
- if (name == env_var_name && !value.empty()) {
+ if (name == env_var_name) {
if (argument_index)
*argument_index = i;
return true;
OpenPOWER on IntegriCloud