More robust parsing of the PlyHeader

This commit is contained in:
Gianpaolo Palma 2017-11-27 13:30:04 +01:00
parent 91b8a61d42
commit f40db898e3
1 changed files with 4 additions and 4 deletions

View File

@ -476,7 +476,7 @@ namespace nanoply
std::getline(fileStream, line); std::getline(fileStream, line);
std::transform(line.begin(), line.end(), line.begin(), ::tolower); std::transform(line.begin(), line.end(), line.begin(), ::tolower);
last = false; last = false;
if (line == "end_header") if (line.find("end_header") != std::string::npos)
last = true; last = true;
return true; return true;
} }
@ -1139,7 +1139,7 @@ namespace nanoply
token = strtok(tempStr, " \t"); token = strtok(tempStr, " \t");
if (strstr(token, "element") == NULL) if (strstr(token, "element") == NULL)
return false; return false;
token = strtok(0, " \t\n"); token = strtok(0, " \t\r\n");
name = std::string(token); name = std::string(token);
plyElem = PlyElemEntity::NNP_UNKNOWN_ELEM; plyElem = PlyElemEntity::NNP_UNKNOWN_ELEM;
ElementMapIterator iter = mapElem.begin(); ElementMapIterator iter = mapElem.begin();
@ -1162,7 +1162,7 @@ namespace nanoply
} }
iter++; iter++;
} }
token = strtok(0, " \t\n"); token = strtok(0, " \t\r\n");
cnt = atoi(token); cnt = atoi(token);
for (size_t i = 0; i < propStr.size(); i++) for (size_t i = 0; i < propStr.size(); i++)
if (!AddProperty(propStr[i])) if (!AddProperty(propStr[i]))
@ -1512,7 +1512,7 @@ namespace nanoply
{ {
this->filename = filename; this->filename = filename;
this->errInfo = NNP_OK; this->errInfo = NNP_OK;
std::ifstream input(filename, std::ios::binary); std::ifstream input(filename);
if (!input.good()) if (!input.good())
{ {
this->errInfo = NNP_UNABLE_TO_OPEN; this->errInfo = NNP_UNABLE_TO_OPEN;