summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp36
-rw-r--r--lldb/source/Commands/CommandObjectSettings.h10
-rw-r--r--lldb/source/Interpreter/Args.cpp15
3 files changed, 34 insertions, 27 deletions
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index 63f5048b875..1a2ce9d835f 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -108,13 +108,24 @@ CommandObjectSettingsSet::~CommandObjectSettingsSet()
}
+#include "llvm/ADT/StringRef.h"
+static inline void StripLeadingSpaces(llvm::StringRef &Str)
+{
+ while (!Str.empty() && isspace(Str[0]))
+ Str = Str.substr(1);
+}
bool
-CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result)
+CommandObjectSettingsSet::ExecuteRawCommandString (const char *raw_command, CommandReturnObject &result)
{
UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
- const int argc = command.GetArgumentCount ();
+ Args cmd_args(raw_command);
+
+ // Process possible options.
+ if (!ParseOptions (cmd_args, result))
+ return false;
+ const int argc = cmd_args.GetArgumentCount ();
if ((argc < 2) && (!m_options.m_reset))
{
result.AppendError ("'settings set' takes more arguments");
@@ -122,8 +133,7 @@ CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result)
return false;
}
- const char *var_name = command.GetArgumentAtIndex (0);
- std::string var_name_string;
+ const char *var_name = cmd_args.GetArgumentAtIndex (0);
if ((var_name == NULL) || (var_name[0] == '\0'))
{
result.AppendError ("'settings set' command requires a valid variable name; No value supplied");
@@ -131,17 +141,15 @@ CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result)
return false;
}
- var_name_string = var_name;
- command.Shift();
-
- const char *var_value;
- std::string value_string;
-
- command.GetQuotedCommandString (value_string);
- var_value = value_string.c_str();
+ // Split the raw command into var_name and value pair.
+ std::string var_name_string = var_name;
+ llvm::StringRef raw_str(raw_command);
+ llvm::StringRef value_str = raw_str.split(var_name_string).second;
+ StripLeadingSpaces(value_str);
+ std::string value_string = value_str.str();
if (!m_options.m_reset
- && var_value == NULL)
+ && value_string.empty())
{
result.AppendError ("'settings set' command requires a valid variable value unless using '--reset' option;"
" No value supplied");
@@ -150,7 +158,7 @@ CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result)
else
{
Error err = usc_sp->SetVariable (var_name_string.c_str(),
- var_value,
+ value_string.c_str(),
eVarSetOperationAssign,
m_options.m_override,
m_interpreter.GetDebugger().GetInstanceName().AsCString());
diff --git a/lldb/source/Commands/CommandObjectSettings.h b/lldb/source/Commands/CommandObjectSettings.h
index 13f781f4d07..e446da7edee 100644
--- a/lldb/source/Commands/CommandObjectSettings.h
+++ b/lldb/source/Commands/CommandObjectSettings.h
@@ -50,7 +50,15 @@ public:
virtual bool
Execute (Args& command,
- CommandReturnObject &result);
+ CommandReturnObject &result)
+ { return false; }
+
+ virtual bool
+ WantsRawCommandString() { return true; }
+
+ virtual bool
+ ExecuteRawCommandString (const char *raw_command,
+ CommandReturnObject &result);
virtual Options *
GetOptions ();
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index f32b25c9127..dfd01ee1565 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -168,7 +168,7 @@ Args::SetCommandString (const char *command)
if (command && command[0])
{
static const char *k_space_separators = " \t";
- static const char *k_space_separators_with_slash_and_quotes = " \t \\'\"`";
+ static const char *k_space_separators_with_slash_and_quotes = " \t \\'\"";
const char *arg_end = NULL;
const char *arg_pos;
for (arg_pos = command;
@@ -280,10 +280,7 @@ Args::SetCommandString (const char *command)
first_quote_char = quote_char;
arg_pos = arg_end;
-
- if (quote_char != '`')
- ++arg_pos; // Skip the quote character if it is not a backtick
-
+ ++arg_pos; // Skip the quote character
arg_piece_start = arg_pos; // Note we are starting from later in the string
// Skip till the next quote character
@@ -298,13 +295,7 @@ Args::SetCommandString (const char *command)
if (end_quote)
{
if (end_quote > arg_piece_start)
- {
- // Keep the backtick quote on commands
- if (quote_char == '`')
- arg.append (arg_piece_start, end_quote + 1 - arg_piece_start);
- else
- arg.append (arg_piece_start, end_quote - arg_piece_start);
- }
+ arg.append (arg_piece_start, end_quote - arg_piece_start);
// If the next character is a space or the end of
// string, this argument is complete...
OpenPOWER on IntegriCloud