summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/Args.cpp
diff options
context:
space:
mode:
authorTamas Berghammer <tberghammer@google.com>2015-09-02 10:35:27 +0000
committerTamas Berghammer <tberghammer@google.com>2015-09-02 10:35:27 +0000
commit89d3f090b2cb81fd26d595b2c97439466822fe17 (patch)
treec095aeac1f343ffd9f67411acd5f5bba636f2410 /lldb/source/Interpreter/Args.cpp
parente6035de11ea24b55481886880da400e9e810f599 (diff)
downloadbcm5719-llvm-89d3f090b2cb81fd26d595b2c97439466822fe17.tar.gz
bcm5719-llvm-89d3f090b2cb81fd26d595b2c97439466822fe17.zip
Fix tab completion for command arguments containing spaces
If a command argument contains a space then it have to be escaped with backslash signs so the argument parsing logic can parse it properly. This CL fixes the tab completion code for the arguments to create complitions with correctly escaped strings. Differential revision: http://reviews.llvm.org/D12531 llvm-svn: 246639
Diffstat (limited to 'lldb/source/Interpreter/Args.cpp')
-rw-r--r--lldb/source/Interpreter/Args.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 2895f0ebdea..d9371fe9fa9 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -1668,3 +1668,33 @@ Args::ExpandEscapedCharacters (const char *src, std::string &dst)
}
}
+std::string
+Args::EscapeLLDBCommandArgument (const std::string& arg, char quote_char)
+{
+ const char* chars_to_escape = nullptr;
+ switch (quote_char)
+ {
+ case '\0':
+ chars_to_escape = " \t\\'\"`";
+ break;
+ case '\'':
+ chars_to_escape = "";
+ break;
+ case '"':
+ chars_to_escape = "$\"`\\";
+ break;
+ default:
+ assert(false && "Unhandled quote character");
+ }
+
+ std::string res;
+ res.reserve(arg.size());
+ for (char c : arg)
+ {
+ if (::strchr(chars_to_escape, c))
+ res.push_back('\\');
+ res.push_back(c);
+ }
+ return res;
+}
+
OpenPOWER on IntegriCloud