Improved white space trimming

This commit is contained in:
Robert Osfield
2014-02-05 11:06:39 +00:00
parent d91c8b81cd
commit cdf9886a9e

View File

@@ -49,10 +49,12 @@ std::string osgDB::trimEnclosingSpaces(const std::string& str)
{
if (str.empty()) return str;
std::string::size_type start = str.find_first_not_of(' ');
const std::string whitespaces(" \t\f\v\n\r");
std::string::size_type start = str.find_first_not_of(whitespaces);
if (start==std::string::npos) return std::string();
std::string::size_type end = str.find_last_not_of(' ');
std::string::size_type end = str.find_last_not_of(whitespaces);
if (end==std::string::npos) return std::string();
return std::string(str, start, (end-start)+1);