summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2016-08-23 17:13:33 +0000
committerJim Ingham <jingham@apple.com>2016-08-23 17:13:33 +0000
commit291fd3504429f2fb8ca45e7f1430d30b7da4f477 (patch)
tree0511a668f5408d106fc9281478198697242a7e89 /lldb/source
parent9ec5a61358fa7e5f4af389562a62400dd7201504 (diff)
downloadbcm5719-llvm-291fd3504429f2fb8ca45e7f1430d30b7da4f477.tar.gz
bcm5719-llvm-291fd3504429f2fb8ca45e7f1430d30b7da4f477.zip
Change the PathMappingList::FindFile to use FileSpec API's
Also, when appending path components, collapse multiple "/" into one at the join. llvm-svn: 279533
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Host/common/FileSpec.cpp3
-rw-r--r--lldb/source/Target/PathMappingList.cpp13
2 files changed, 8 insertions, 8 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp
index 53c0ab40e67..62117b78f06 100644
--- a/lldb/source/Host/common/FileSpec.cpp
+++ b/lldb/source/Host/common/FileSpec.cpp
@@ -1552,6 +1552,9 @@ FileSpec::AppendPathComponent(const char *new_path)
stream.PutChar(GetPrefferedPathSeparator(m_syntax));
}
+ while (IsPathSeparator(new_path[0], m_syntax))
+ new_path++;
+
stream.PutCString(new_path);
const bool resolve = false;
diff --git a/lldb/source/Target/PathMappingList.cpp b/lldb/source/Target/PathMappingList.cpp
index 7bb86d9d895..bc1334aca46 100644
--- a/lldb/source/Target/PathMappingList.cpp
+++ b/lldb/source/Target/PathMappingList.cpp
@@ -224,6 +224,7 @@ PathMappingList::ReverseRemapPath (const ConstString &path, ConstString &new_pat
for (const auto& it : m_pairs)
{
+ // FIXME: This should be using FileSpec API's to do the path appending.
const size_t prefixLen = it.second.GetLength();
if (::strncmp (it.second.GetCString(), path_cstr, prefixLen) == 0)
{
@@ -242,7 +243,6 @@ PathMappingList::FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const
if (!m_pairs.empty())
{
char orig_path[PATH_MAX];
- char new_path[PATH_MAX];
const size_t orig_path_len = orig_spec.GetPath (orig_path, sizeof(orig_path));
if (orig_path_len > 0)
{
@@ -255,13 +255,10 @@ PathMappingList::FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const
{
if (::strncmp (pos->first.GetCString(), orig_path, prefix_len) == 0)
{
- const size_t new_path_len = snprintf(new_path, sizeof(new_path), "%s/%s", pos->second.GetCString(), orig_path + prefix_len);
- if (new_path_len < sizeof(new_path))
- {
- new_spec.SetFile (new_path, true);
- if (new_spec.Exists())
- return true;
- }
+ new_spec.SetFile(pos->second.GetCString(), false);
+ new_spec.AppendPathComponent(orig_path+prefix_len);
+ if (new_spec.Exists())
+ return true;
}
}
}
OpenPOWER on IntegriCloud