From 21c895e3d50399c696867f904915accc38bbecce Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 6 Mar 2013 02:19:38 +0000 Subject: [PATCH] Now that "settings set" will strip leading and trailing spaces, we need a way to be able to specify string values that contain spaces. So now settings setting " can have a that is quoted: settings set prompt "(lldb2) " llvm-svn: 176545 --- lldb/source/Interpreter/OptionValueString.cpp | 22 ++++++++++++++++++++++ .../abbreviation/TestAbbreviations.py | 2 +- .../abbreviation/change_prompt.lldb | 3 +-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lldb/source/Interpreter/OptionValueString.cpp b/lldb/source/Interpreter/OptionValueString.cpp index 91a9803..df047bd 100644 --- a/lldb/source/Interpreter/OptionValueString.cpp +++ b/lldb/source/Interpreter/OptionValueString.cpp @@ -55,6 +55,28 @@ OptionValueString::SetValueFromCString (const char *value_cstr, VarSetOperationType op) { Error error; + + std::string value_str_no_quotes; + if (value_cstr) + { + switch (value_cstr[0]) + { + case '"': + case '\'': + { + size_t len = strlen(value_cstr); + if (len <= 1 || value_cstr[len-1] != value_cstr[0]) + { + error.SetErrorString("mismatched quotes"); + return error; + } + value_str_no_quotes.assign (value_cstr + 1, len - 2); + value_cstr = value_str_no_quotes.c_str(); + } + break; + } + } + switch (op) { case eVarSetOperationInvalid: diff --git a/lldb/test/functionalities/abbreviation/TestAbbreviations.py b/lldb/test/functionalities/abbreviation/TestAbbreviations.py index e621738..e9247cc 100644 --- a/lldb/test/functionalities/abbreviation/TestAbbreviations.py +++ b/lldb/test/functionalities/abbreviation/TestAbbreviations.py @@ -62,7 +62,7 @@ class AbbreviationsTestCase(TestBase): self.expect("lo li", startstr = "Logging categories for ") - self.runCmd("se se prompt Sycamore> ") + self.runCmd("se se prompt 'Sycamore> '") self.expect("se sh prompt", startstr = 'prompt (string) = "Sycamore> "') diff --git a/lldb/test/functionalities/abbreviation/change_prompt.lldb b/lldb/test/functionalities/abbreviation/change_prompt.lldb index 13e47ae..116db1d 100644 --- a/lldb/test/functionalities/abbreviation/change_prompt.lldb +++ b/lldb/test/functionalities/abbreviation/change_prompt.lldb @@ -1,2 +1 @@ -settings set prompt [with-three-trailing-spaces] - +settings set prompt "[with-three-trailing-spaces] " \ No newline at end of file -- 2.7.4