[Lldb-commits] [lldb] r176545 - 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 <property> <value>" can have a <value> that is quoted:

Greg Clayton gclayton at apple.com
Tue Mar 5 18:19:38 PST 2013


Author: gclayton
Date: Tue Mar  5 20:19:38 2013
New Revision: 176545

URL: http://llvm.org/viewvc/llvm-project?rev=176545&view=rev
Log:
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 <property> <value>" can have a <value> that is quoted:

settings set prompt "(lldb2) "


Modified:
    lldb/trunk/source/Interpreter/OptionValueString.cpp
    lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py
    lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb

Modified: lldb/trunk/source/Interpreter/OptionValueString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueString.cpp?rev=176545&r1=176544&r2=176545&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueString.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueString.cpp Tue Mar  5 20:19:38 2013
@@ -55,6 +55,28 @@ OptionValueString::SetValueFromCString (
                                         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:

Modified: lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py?rev=176545&r1=176544&r2=176545&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py (original)
+++ lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py Tue Mar  5 20:19:38 2013
@@ -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> "')
 

Modified: lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb?rev=176545&r1=176544&r2=176545&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb (original)
+++ lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb Tue Mar  5 20:19:38 2013
@@ -1,2 +1 @@
-settings set prompt [with-three-trailing-spaces]   
-
+settings set prompt "[with-three-trailing-spaces]   "
\ No newline at end of file





More information about the lldb-commits mailing list