From 1adba8b6e308543ef7f45a8beb9853281f46e15d Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Fri, 12 Sep 2014 23:39:38 +0000 Subject: 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 --- lldb/source/Host/common/FileSpec.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lldb/source/Host/common/FileSpec.cpp') diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp index 19846d243ed..44364ef9712 100644 --- a/lldb/source/Host/common/FileSpec.cpp +++ b/lldb/source/Host/common/FileSpec.cpp @@ -946,6 +946,8 @@ FileSpec::EnumerateDirectory lldb_utility::CleanUp 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 -- cgit v1.2.3