summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/OptionValueFormatEntity.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-06-03 02:02:48 +0000
committerGreg Clayton <gclayton@apple.com>2015-06-03 02:02:48 +0000
commitb2e0c1198283dc4cbdf3cd724a628ae2537dfc14 (patch)
tree160f3623078529c748b211a41d75a6b35266e63e /lldb/source/Interpreter/OptionValueFormatEntity.cpp
parentda86b6d409edd7af98a42dad65f33e5e49e43115 (diff)
downloadbcm5719-llvm-b2e0c1198283dc4cbdf3cd724a628ae2537dfc14.tar.gz
bcm5719-llvm-b2e0c1198283dc4cbdf3cd724a628ae2537dfc14.zip
Fixed "format-string" based settings so they can have quotes on them without leaving the quotes in the format string:
(lldb) settings set thread-format "abc" (lldb) settings set thread-format 'abc' (lldb) settings set thread-format abc We strip the quotes before processing the format string and return an "error: mismatched quotes" if mismatched quotes are given. <rdar://problem/21210789> llvm-svn: 238896
Diffstat (limited to 'lldb/source/Interpreter/OptionValueFormatEntity.cpp')
-rw-r--r--lldb/source/Interpreter/OptionValueFormatEntity.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index 27a11eedd37..66d8d8419ed 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -66,7 +66,7 @@ OptionValueFormatEntity::DumpValue (const ExecutionContext *exe_ctx, Stream &str
Error
OptionValueFormatEntity::SetValueFromString (llvm::StringRef value_str,
- VarSetOperationType op)
+ VarSetOperationType op)
{
Error error;
switch (op)
@@ -79,6 +79,25 @@ OptionValueFormatEntity::SetValueFromString (llvm::StringRef value_str,
case eVarSetOperationReplace:
case eVarSetOperationAssign:
{
+ // Check if the string starts with a quote character after removing leading and trailing spaces.
+ // If it does start with a quote character, make sure it ends with the same quote character
+ // and remove the quotes before we parse the format string. If the string doesn't start with
+ // a quote, leave the string alone and parse as is.
+ llvm::StringRef trimmed_value_str = value_str.trim();
+ if (!trimmed_value_str.empty())
+ {
+ const char first_char = trimmed_value_str[0];
+ if (first_char == '"' || first_char == '\'')
+ {
+ const size_t trimmed_len = trimmed_value_str.size();
+ if (trimmed_len == 1 || value_str[trimmed_len-1] != first_char)
+ {
+ error.SetErrorStringWithFormat("mismatched quotes");
+ return error;
+ }
+ value_str = trimmed_value_str.substr(1,trimmed_len-2);
+ }
+ }
FormatEntity::Entry entry;
error = FormatEntity::Parse(value_str, entry);
if (error.Success())
OpenPOWER on IntegriCloud