Fixed crash in offreader with dos line endings. (Thanks to

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@257 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Jan Möbius
2010-01-04 12:02:09 +00:00
parent cf91d704d6
commit 9da1a2c1a7

View File

@@ -355,10 +355,10 @@ int _OFFReader_::getColorType(std::string& _line, bool _texCoordsAvailable) cons
return 0; return 0;
//first remove spaces at start/end of the line //first remove spaces at start/end of the line
while (_line[0] == ' ') while (std::isspace(_line[0]))
_line = _line.substr(1); _line = _line.substr(1);
while (_line[ _line.length()-1 ] == ' ') while (std::isspace(_line[ _line.length()-1 ]))
_line = _line.substr(0, _line.length()-2); _line = _line.substr(0, _line.length()-1);
//count the remaining items in the line //count the remaining items in the line
size_t found; size_t found;
@@ -370,7 +370,7 @@ int _OFFReader_::getColorType(std::string& _line, bool _texCoordsAvailable) cons
found=_line.find_first_of(" ",found+1); found=_line.find_first_of(" ",found+1);
} }
if (_line != "") count++; if (!_line.empty()) count++;
if (_texCoordsAvailable) count -= 2; if (_texCoordsAvailable) count -= 2;