[Lldb-commits] [lldb] r217722 - Don't make paths with /Foo//bar, that confuses everybody down the line.
Jim Ingham
jingham at apple.com
Fri Sep 12 16:39:38 PDT 2014
Author: jingham
Date: Fri Sep 12 18:39:38 2014
New Revision: 217722
URL: http://llvm.org/viewvc/llvm-project?rev=217722&view=rev
Log:
Don't make paths with /Foo//bar, that confuses everybody down the line.
This gets the file completer for absolute paths working again.
Modified:
lldb/trunk/source/Host/common/FileSpec.cpp
Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=217722&r1=217721&r2=217722&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Fri Sep 12 18:39:38 2014
@@ -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
More information about the lldb-commits
mailing list