[Lldb-commits] [lldb] r237741 - Remove trailing slash from dumping directory FileSpec.

Chaoren Lin chaorenl at google.com
Tue May 19 16:11:58 PDT 2015


Author: chaoren
Date: Tue May 19 18:11:58 2015
New Revision: 237741

URL: http://llvm.org/viewvc/llvm-project?rev=237741&view=rev
Log:
Remove trailing slash from dumping directory FileSpec.

Reviewers: domipheus, ovyalov

Reviewed By: ovyalov

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D9862

Modified:
    lldb/trunk/include/lldb/Host/FileSpec.h
    lldb/trunk/source/Host/common/FileSpec.cpp

Modified: lldb/trunk/include/lldb/Host/FileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=237741&r1=237740&r2=237741&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Host/FileSpec.h Tue May 19 18:11:58 2015
@@ -259,9 +259,13 @@ public:
     ///
     /// @param[in] s
     ///     The stream to which to dump the object description.
+    ///
+    /// @param[in] trailing_slash
+    ///     If true and the file is a non root directory, then a trailing slash
+    ///     will be added.
     //------------------------------------------------------------------
     void
-    Dump (Stream *s) const;
+    Dump(Stream *s, bool trailing_slash = true) const;
 
     //------------------------------------------------------------------
     /// Existence test.

Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=237741&r1=237740&r2=237741&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Tue May 19 18:11:58 2015
@@ -609,12 +609,13 @@ FileSpec::RemoveBackupDots (const ConstS
 // directory delimiter, and the filename.
 //------------------------------------------------------------------
 void
-FileSpec::Dump(Stream *s) const
+FileSpec::Dump(Stream *s, bool trailing_slash) const
 {
     if (s)
     {
         m_directory.Dump(s);
-        if (m_directory && m_directory.GetStringRef().back() != '/')
+        if ((m_filename || trailing_slash) && m_directory &&
+                !m_directory.GetStringRef().endswith("/"))
             s->PutChar('/');
         m_filename.Dump(s);
     }
@@ -816,7 +817,7 @@ void
 FileSpec::GetPath(llvm::SmallVectorImpl<char> &path, bool denormalize) const
 {
     StreamString stream;
-    Dump(&stream);
+    Dump(&stream, false);
     path.append(stream.GetString().begin(), stream.GetString().end());
     Normalize(path, m_syntax);
     if (denormalize && !path.empty())





More information about the lldb-commits mailing list