diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
commit | 94994d372d014ce4c8758b9605d63fae651bd8aa (patch) | |
tree | 51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /source/Interpreter/OptionValueFormatEntity.cpp | |
parent | 39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff) |
Notes
Diffstat (limited to 'source/Interpreter/OptionValueFormatEntity.cpp')
-rw-r--r-- | source/Interpreter/OptionValueFormatEntity.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/source/Interpreter/OptionValueFormatEntity.cpp b/source/Interpreter/OptionValueFormatEntity.cpp index ce1a84e8dece..18783625b86f 100644 --- a/source/Interpreter/OptionValueFormatEntity.cpp +++ b/source/Interpreter/OptionValueFormatEntity.cpp @@ -9,10 +9,6 @@ #include "lldb/Interpreter/OptionValueFormatEntity.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Utility/Stream.h" @@ -41,14 +37,30 @@ bool OptionValueFormatEntity::Clear() { return true; } +static void EscapeBackticks(llvm::StringRef str, std::string &dst) { + dst.clear(); + dst.reserve(str.size()); + + for (size_t i = 0, e = str.size(); i != e; ++i) { + char c = str[i]; + if (c == '`') { + if (i == 0 || str[i - 1] != '\\') + dst += '\\'; + } + dst += c; + } +} + void OptionValueFormatEntity::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) { if (dump_mask & eDumpOptionType) strm.Printf("(%s)", GetTypeAsCString()); if (dump_mask & eDumpOptionValue) { if (dump_mask & eDumpOptionType) - strm.PutCString(" = \""); - strm << m_current_format.c_str() << '"'; + strm.PutCString(" = "); + std::string escaped; + EscapeBackticks(m_current_format, escaped); + strm << '"' << escaped << '"'; } } |