diff options
| author | Pavel Labath <labath@google.com> | 2015-02-16 13:13:39 +0000 |
|---|---|---|
| committer | Pavel Labath <labath@google.com> | 2015-02-16 13:13:39 +0000 |
| commit | df50f9440dc4a56a67d9150d24069f379dde74e5 (patch) | |
| tree | f70f62fc69bb9406d1cc2c8c124d9d4dc97fdc63 /lldb/source/Interpreter/OptionValueString.cpp | |
| parent | 0247b970c4c988219f348601ea124da498f96822 (diff) | |
| download | llvm-df50f9440dc4a56a67d9150d24069f379dde74e5.zip llvm-df50f9440dc4a56a67d9150d24069f379dde74e5.tar.gz llvm-df50f9440dc4a56a67d9150d24069f379dde74e5.tar.bz2 | |
Handle trailing spaces on "settings set" command more correctly
Summary:
Currently we have some settings which treat "\ " on settings set commands specially. E.g., it is
a valid way of specifying an argument of " " to a target. However, this fails if "\ " is the last
argument as CommandObjectSettingsSet strips trailing whitespace. This resulted in a surprising
argument of "\" to the target.
This patch disables the training whitespace removal at a global
level. Instead, for each argument type we locally determine whether whitespace stripping makes
sense. Currently, I strip whitespace for all simple object type except of regex and
format-string, with the rationale that these two object types do their own complex parsing and we
want to interfere with them as least as possible. Specifically, stripping the whitespace of a
regex "\ " will result in a (surprising?) error "trailing backslash". Furthermore, the default
value of dissasembly-format setting already contains a trailing space and there is no way for the
user to type this in manually if we strip whitespace.
Reviewers: clayborg, zturner
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D7592
llvm-svn: 229382
Diffstat (limited to 'lldb/source/Interpreter/OptionValueString.cpp')
| -rw-r--r-- | lldb/source/Interpreter/OptionValueString.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lldb/source/Interpreter/OptionValueString.cpp b/lldb/source/Interpreter/OptionValueString.cpp index a1b80d8..9012ab1 100644 --- a/lldb/source/Interpreter/OptionValueString.cpp +++ b/lldb/source/Interpreter/OptionValueString.cpp @@ -57,24 +57,25 @@ OptionValueString::SetValueFromCString (const char *value_cstr, Error error; std::string value_str_no_quotes; - if (value_cstr) + llvm::StringRef trimmed = value_cstr ? llvm::StringRef(value_cstr).trim() : llvm::StringRef(); + if (trimmed.size() > 0) { - switch (value_cstr[0]) + switch (trimmed.front()) { case '"': case '\'': { - size_t len = strlen(value_cstr); - if (len <= 1 || value_cstr[len-1] != value_cstr[0]) + if (trimmed.size() <= 1 || trimmed.back() != trimmed.front()) { error.SetErrorString("mismatched quotes"); return error; } - value_str_no_quotes.assign (value_cstr + 1, len - 2); - value_cstr = value_str_no_quotes.c_str(); + trimmed = trimmed.drop_front().drop_back().str(); } break; } + value_str_no_quotes = trimmed.str(); + value_cstr = value_str_no_quotes.c_str(); } switch (op) |
