Fixed handlinge of fgets returning a 0 length string

This commit is contained in:
Robert Osfield 2016-08-10 12:00:18 +01:00
parent f8c090ff7f
commit 26bce07f2b

View File

@ -588,9 +588,11 @@ ReaderWriterSTL::ReaderObject::ReadResult ReaderWriterSTL::AsciiReaderObject::re
while (fgets(buf, sizeof(buf), fp))
{
// strip '\n' or '\r\n' and trailing whitespace
unsigned int len = strlen(buf) - 1;
unsigned int len = strlen(buf);
if (len==0) continue;
// strip '\n' or '\r\n' and trailing whitespace
--len;
while (len && (buf[len] == '\n' || buf[len] == '\r' || isspace(buf[len])))
{
buf[len--] = '\0';