Don't make paths with /Foo//bar, that confuses everybody down the line.

This gets the file completer for absolute paths working again.

llvm-svn: 217722
This commit is contained in:
Jim Ingham 2014-09-12 23:39:38 +00:00
parent cf3f3683f8
commit 1adba8b6e3
1 changed files with 10 additions and 1 deletions

View File

@ -946,6 +946,8 @@ FileSpec::EnumerateDirectory
lldb_utility::CleanUp <DIR *, int> dir_path_dir(opendir(dir_path), NULL, closedir);
if (dir_path_dir.is_valid())
{
char dir_path_last_char = dir_path[strlen(dir_path) - 1];
long path_max = fpathconf (dirfd (dir_path_dir.get()), _PC_NAME_MAX);
#if defined (__APPLE_) && defined (__DARWIN_MAXPATHLEN)
if (path_max < __DARWIN_MAXPATHLEN)
@ -990,7 +992,14 @@ FileSpec::EnumerateDirectory
if (call_callback)
{
char child_path[PATH_MAX];
const int child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name);
// Don't make paths with "/foo//bar", that just confuses everybody.
int child_path_len;
if (dir_path_last_char == '/')
child_path_len = ::snprintf (child_path, sizeof(child_path), "%s%s", dir_path, dp->d_name);
else
child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name);
if (child_path_len < (int)(sizeof(child_path) - 1))
{
// Don't resolve the file type or path