summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-06-18 00:58:06 +0000
committerEnrico Granata <egranata@apple.com>2013-06-18 00:58:06 +0000
commit9b27c6f0d4239c0bbf55894560970d3a484489d7 (patch)
tree099397f5bc2bd506c6ead843a216d6aad5cc991f /lldb/source/Interpreter/ScriptInterpreterPython.cpp
parentde5fde0b05a89e865ff0fb365f15e04b1eb52b8a (diff)
downloadbcm5719-llvm-9b27c6f0d4239c0bbf55894560970d3a484489d7.tar.gz
bcm5719-llvm-9b27c6f0d4239c0bbf55894560970d3a484489d7.zip
<rdar://problem/13926101>
Allow “command script import” to work with folder names that have a ‘ (tick) in them Kudos to StackOverflow (question 1494399) for the replace_all code! llvm-svn: 184158
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 5ad38c2fc9b..7242e182c24 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -2577,6 +2577,19 @@ ReadPythonBacktrace (PyObject* py_backtrace)
return retval;
}
+uint64_t replace_all(std::string& str, const std::string& oldStr, const std::string& newStr)
+{
+ size_t pos = 0;
+ uint64_t matches = 0;
+ while((pos = str.find(oldStr, pos)) != std::string::npos)
+ {
+ matches++;
+ str.replace(pos, oldStr.length(), newStr);
+ pos += newStr.length();
+ }
+ return matches;
+}
+
bool
ScriptInterpreterPython::LoadScriptingModule (const char* pathname,
bool can_reload,
@@ -2624,13 +2637,14 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname,
target_file.GetFileType() == FileSpec::eFileTypeRegular ||
target_file.GetFileType() == FileSpec::eFileTypeSymbolicLink)
{
- const char* directory = target_file.GetDirectory().GetCString();
+ std::string directory(target_file.GetDirectory().GetCString());
+ replace_all(directory,"'","\\'");
// now make sure that Python has "directory" in the search path
StreamString command_stream;
command_stream.Printf("if not (sys.path.__contains__('%s')):\n sys.path.insert(1,'%s');\n\n",
- directory,
- directory);
+ directory.c_str(),
+ directory.c_str());
bool syspath_retval = ExecuteMultipleLines(command_stream.GetData(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false));
if (!syspath_retval)
{
OpenPOWER on IntegriCloud