diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 63f5048b8758..1a2ce9d835f3 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 13f781f4d077..e446da7edee1 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 f32b25c9127e..dfd01ee1565b 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... diff --git a/lldb/test/functionalities/abbreviation/TestAbbreviations.py b/lldb/test/functionalities/abbreviation/TestAbbreviations.py index a3dcf99b6219..d52fb1db4ea1 100644 --- a/lldb/test/functionalities/abbreviation/TestAbbreviations.py +++ b/lldb/test/functionalities/abbreviation/TestAbbreviations.py @@ -38,7 +38,7 @@ class AbbreviationsTestCase(TestBase): patterns = ["Executing commands in '.*change_prompt.lldb'"]) self.expect("settings show prompt", - startstr = 'prompt (string) = "[old-oak]"') + startstr = 'prompt (string) = "[with-three-trailing-spaces] "') self.runCmd("settings set -r prompt") @@ -51,7 +51,7 @@ class AbbreviationsTestCase(TestBase): self.runCmd("se se prompt Sycamore> ") self.expect("se sh prompt", - startstr = 'prompt (string) = "Sycamore>"') + startstr = 'prompt (string) = "Sycamore> "') self.runCmd("se se -r prompt") self.expect("set sh prompt", diff --git a/lldb/test/functionalities/abbreviation/change_prompt.lldb b/lldb/test/functionalities/abbreviation/change_prompt.lldb index 3342a2a78c77..13e47ae95a7a 100644 --- a/lldb/test/functionalities/abbreviation/change_prompt.lldb +++ b/lldb/test/functionalities/abbreviation/change_prompt.lldb @@ -1 +1,2 @@ -settings set prompt [old-oak] +settings set prompt [with-three-trailing-spaces] + diff --git a/lldb/test/settings/TestSettings.py b/lldb/test/settings/TestSettings.py index b38a255bb899..696cc943511b 100644 --- a/lldb/test/settings/TestSettings.py +++ b/lldb/test/settings/TestSettings.py @@ -58,7 +58,6 @@ class SettingsCommandTestCase(TestBase): substrs = ["term-width (int) = 70"]) #rdar://problem/10712130 - @unittest2.expectedFailure def test_set_frame_format(self): """Test that 'set frame-format' with a backtick char in the format string works as well as fullpath.""" self.buildDefault()