aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/Args.cpp20
-rw-r--r--lldb/source/Interpreter/CommandReturnObject.cpp10
2 files changed, 30 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 50b43b16..f32b25c 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -864,6 +864,26 @@ Args::StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t
return 0;
}
+const char *
+Args::GetShellSafeArgument (const char *unsafe_arg, std::string &safe_arg)
+{
+ safe_arg.assign (unsafe_arg);
+ size_t prev_pos = 0;
+ while (prev_pos < safe_arg.size())
+ {
+ // Escape spaces and quotes
+ size_t pos = safe_arg.find_first_of(" '\"", prev_pos);
+ if (pos != std::string::npos)
+ {
+ safe_arg.insert (pos, 1, '\\');
+ prev_pos = pos + 2;
+ }
+ else
+ break;
+ }
+ return safe_arg.c_str();
+}
+
int32_t
Args::StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, Error &error)
diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp
index eb6fae4..51e6ee6 100644
--- a/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Core/Error.h"
#include "lldb/Core/StreamString.h"
using namespace lldb;
@@ -134,6 +135,15 @@ CommandReturnObject::AppendError (const char *in_string, int len)
GetErrorStream().Printf ("error: %*.*s\n", len, len, in_string);
}
+void
+CommandReturnObject::SetError (const Error &error, const char *fallback_error_cstr)
+{
+ const char *error_cstr = error.AsCString();
+ if (error_cstr == NULL)
+ error_cstr = fallback_error_cstr;
+ AppendError (error_cstr);
+ SetStatus (eReturnStatusFailed);
+}
// Similar to AppendError, but do not prepend 'Error: ' to message, and
// don't append "\n" to the end of it.