[Lldb-commits] [lldb] r244992 - Add a better fix for searching for spaces in BSD archive object names where we only trim trailing spaces.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 13 17:18:53 PDT 2015


Author: gclayton
Date: Thu Aug 13 19:18:52 2015
New Revision: 244992

URL: http://llvm.org/viewvc/llvm-project?rev=244992&view=rev
Log:
Add a better fix for searching for spaces in BSD archive object names where we only trim trailing spaces.

I made an example where I had a file named "testtesttestt .o" (16 chars) that I was able to put into a .a file and we would previously truncate the object name to "testtesttestt" since we searched for any space in the name. I believe the BSD archive docs say that filenames with spaces will use the extended format, but our current libtool doesn't so I wanted to fix it by only removing trailing spaces.


Modified:
    lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp

Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=244992&r1=244991&r2=244992&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Thu Aug 13 19:18:52 2015
@@ -103,11 +103,13 @@ ObjectContainerBSDArchive::Object::Extra
     }
     else
     {
-        // Strip off any spaces (if the object file name contains spaces it
-        // will use the extended format above).
-        const size_t space_pos = str.find(' ');
-        if (space_pos != std::string::npos)
-            str.erase (space_pos);
+        // Strip off any trailing spaces.
+        const size_t last_pos = str.find_last_not_of(' ');
+        if (last_pos != std::string::npos)
+        {
+            if (last_pos + 1 < 16)
+                str.erase (last_pos + 1);
+        }
         ar_name.SetCString(str.c_str());
     }
 




More information about the lldb-commits mailing list