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.

llvm-svn: 244992
This commit is contained in:
Greg Clayton
2015-08-14 00:18:52 +00:00
parent 34fa813d9b
commit 5da0dde965

View File

@@ -103,11 +103,13 @@ ObjectContainerBSDArchive::Object::Extract (const DataExtractor& data, lldb::off
}
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());
}