[Lldb-commits] [lldb] r288247 - Fix handling of consecutive slashes in FileSpec::GetNormalizedPath()
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 30 08:08:45 PST 2016
Author: labath
Date: Wed Nov 30 10:08:45 2016
New Revision: 288247
URL: http://llvm.org/viewvc/llvm-project?rev=288247&view=rev
Log:
Fix handling of consecutive slashes in FileSpec::GetNormalizedPath()
The core of the function was actually handling them correctly. However, the
early exit was being too optimistic and did not give the function a chance to
fire if the path did not contain dots as well.
Fix that and add a couple of unit tests.
Modified:
lldb/trunk/source/Host/common/FileSpec.cpp
lldb/trunk/unittests/Host/FileSpecTest.cpp
Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=288247&r1=288246&r2=288247&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Wed Nov 30 10:08:45 2016
@@ -544,7 +544,8 @@ bool FileSpec::Equal(const FileSpec &a,
FileSpec FileSpec::GetNormalizedPath() const {
// Fast path. Do nothing if the path is not interesting.
if (!m_directory.GetStringRef().contains(".") &&
- (m_filename.GetStringRef() != ".." && m_filename.GetStringRef() != "."))
+ !m_directory.GetStringRef().contains("//") &&
+ m_filename.GetStringRef() != ".." && m_filename.GetStringRef() != ".")
return *this;
llvm::SmallString<64> path, result;
Modified: lldb/trunk/unittests/Host/FileSpecTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/FileSpecTest.cpp?rev=288247&r1=288246&r2=288247&view=diff
==============================================================================
--- lldb/trunk/unittests/Host/FileSpecTest.cpp (original)
+++ lldb/trunk/unittests/Host/FileSpecTest.cpp Wed Nov 30 10:08:45 2016
@@ -206,6 +206,9 @@ TEST(FileSpecTest, GetNormalizedPath) {
{"/foo/./bar", "/foo/bar"},
{"/foo/..", "/"},
{"/foo/.", "/foo"},
+ {"/foo//bar", "/foo/bar"},
+ {"/foo//bar/baz", "/foo/bar/baz"},
+ {"/foo//bar/./baz", "/foo/bar/baz"},
{"/./foo", "/foo"},
{"/", "/"},
{"//", "//"},
More information about the lldb-commits
mailing list