summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp2
-rw-r--r--lldb/source/Interpreter/Args.cpp36
-rw-r--r--lldb/source/Interpreter/OptionValueArch.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueEnumeration.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueSInt64.cpp3
-rw-r--r--lldb/source/Interpreter/OptionValueString.cpp13
-rw-r--r--lldb/source/Interpreter/OptionValueUInt64.cpp3
7 files changed, 33 insertions, 30 deletions
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index ed677afabcb..b7cbb7d5ffd 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -243,7 +243,7 @@ protected:
// Split the raw command into var_name and value pair.
llvm::StringRef raw_str(command);
std::string var_value_string = raw_str.split(var_name).second.str();
- const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
+ const char *var_value_cstr = Args::StripSpaces(var_value_string, true, false, false);
Error error;
if (m_options.m_global)
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 4f0219fb858..50d3fff50a2 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -870,26 +870,24 @@ Args::StripSpaces (std::string &s, bool leading, bool trailing, bool return_null
bool
Args::StringToBoolean (const char *s, bool fail_value, bool *success_ptr)
{
- if (s && s[0])
+ llvm::StringRef ref = llvm::StringRef(s).trim();
+ if (ref.equals_lower("false") ||
+ ref.equals_lower("off") ||
+ ref.equals_lower("no") ||
+ ref.equals_lower("0"))
{
- if (::strcasecmp (s, "false") == 0 ||
- ::strcasecmp (s, "off") == 0 ||
- ::strcasecmp (s, "no") == 0 ||
- ::strcmp (s, "0") == 0)
- {
- if (success_ptr)
- *success_ptr = true;
- return false;
- }
- else
- if (::strcasecmp (s, "true") == 0 ||
- ::strcasecmp (s, "on") == 0 ||
- ::strcasecmp (s, "yes") == 0 ||
- ::strcmp (s, "1") == 0)
- {
- if (success_ptr) *success_ptr = true;
- return true;
- }
+ if (success_ptr)
+ *success_ptr = true;
+ return false;
+ }
+ else
+ if (ref.equals_lower("true") ||
+ ref.equals_lower("on") ||
+ ref.equals_lower("yes") ||
+ ref.equals_lower("1"))
+ {
+ if (success_ptr) *success_ptr = true;
+ return true;
}
if (success_ptr) *success_ptr = false;
return fail_value;
diff --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp
index 7df149234bd..eae903ce5be 100644
--- a/lldb/source/Interpreter/OptionValueArch.cpp
+++ b/lldb/source/Interpreter/OptionValueArch.cpp
@@ -55,8 +55,10 @@ OptionValueArch::SetValueFromCString (const char *value_cstr, VarSetOperationTyp
case eVarSetOperationReplace:
case eVarSetOperationAssign:
- if (value_cstr && value_cstr[0])
+ if (value_cstr)
{
+ std::string value = llvm::StringRef(value_cstr).trim().str();
+ value_cstr = value.c_str();
if (m_current_value.SetTriple (value_cstr))
{
m_value_was_set = true;
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp
index dbaeb185fa3..b5cdd81ee2e 100644
--- a/lldb/source/Interpreter/OptionValueEnumeration.cpp
+++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp
@@ -69,7 +69,7 @@ OptionValueEnumeration::SetValueFromCString (const char *value, VarSetOperationT
case eVarSetOperationAssign:
if (value && value[0])
{
- ConstString const_enumerator_name(value);
+ ConstString const_enumerator_name(llvm::StringRef(value).trim());
const EnumerationMapEntry *enumerator_entry = m_enumerations.FindFirstValueForName (const_enumerator_name.GetCString());
if (enumerator_entry)
{
diff --git a/lldb/source/Interpreter/OptionValueSInt64.cpp b/lldb/source/Interpreter/OptionValueSInt64.cpp
index c69172921a6..d62353d93d4 100644
--- a/lldb/source/Interpreter/OptionValueSInt64.cpp
+++ b/lldb/source/Interpreter/OptionValueSInt64.cpp
@@ -51,7 +51,8 @@ OptionValueSInt64::SetValueFromCString (const char *value_cstr, VarSetOperationT
case eVarSetOperationAssign:
{
bool success = false;
- int64_t value = StringConvert::ToSInt64 (value_cstr, 0, 0, &success);
+ std::string value_str = llvm::StringRef(value_cstr).trim().str();
+ int64_t value = StringConvert::ToSInt64 (value_str.c_str(), 0, 0, &success);
if (success)
{
if (value >= m_min_value && value <= m_max_value)
diff --git a/lldb/source/Interpreter/OptionValueString.cpp b/lldb/source/Interpreter/OptionValueString.cpp
index a1b80d8fc4f..9012ab178e3 100644
--- a/lldb/source/Interpreter/OptionValueString.cpp
+++ b/lldb/source/Interpreter/OptionValueString.cpp
@@ -57,24 +57,25 @@ OptionValueString::SetValueFromCString (const char *value_cstr,
Error error;
std::string value_str_no_quotes;
- if (value_cstr)
+ llvm::StringRef trimmed = value_cstr ? llvm::StringRef(value_cstr).trim() : llvm::StringRef();
+ if (trimmed.size() > 0)
{
- switch (value_cstr[0])
+ switch (trimmed.front())
{
case '"':
case '\'':
{
- size_t len = strlen(value_cstr);
- if (len <= 1 || value_cstr[len-1] != value_cstr[0])
+ if (trimmed.size() <= 1 || trimmed.back() != trimmed.front())
{
error.SetErrorString("mismatched quotes");
return error;
}
- value_str_no_quotes.assign (value_cstr + 1, len - 2);
- value_cstr = value_str_no_quotes.c_str();
+ trimmed = trimmed.drop_front().drop_back().str();
}
break;
}
+ value_str_no_quotes = trimmed.str();
+ value_cstr = value_str_no_quotes.c_str();
}
switch (op)
diff --git a/lldb/source/Interpreter/OptionValueUInt64.cpp b/lldb/source/Interpreter/OptionValueUInt64.cpp
index 48de433d36c..dc06cfe93d5 100644
--- a/lldb/source/Interpreter/OptionValueUInt64.cpp
+++ b/lldb/source/Interpreter/OptionValueUInt64.cpp
@@ -58,7 +58,8 @@ OptionValueUInt64::SetValueFromCString (const char *value_cstr, VarSetOperationT
case eVarSetOperationAssign:
{
bool success = false;
- uint64_t value = StringConvert::ToUInt64 (value_cstr, 0, 0, &success);
+ std::string value_str = llvm::StringRef(value_cstr).trim().str();
+ uint64_t value = StringConvert::ToUInt64 (value_str.c_str(), 0, 0, &success);
if (success)
{
m_value_was_set = true;
OpenPOWER on IntegriCloud