From 07e0a4bd93f6a4c69e823ee8f23a3bc26bc08a1a Mon Sep 17 00:00:00 2001 From: Mathieu Westphal <mathieu.westphal@kitware.com> Date: Thu, 20 Feb 2025 17:43:43 +0100 Subject: [PATCH] vtkOBJImporter: Fix small parsing issues with spaces --- IO/Import/vtkOBJImporter.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/IO/Import/vtkOBJImporter.cxx b/IO/Import/vtkOBJImporter.cxx index 47564142619..71311607936 100644 --- a/IO/Import/vtkOBJImporter.cxx +++ b/IO/Import/vtkOBJImporter.cxx @@ -418,8 +418,8 @@ int vtkOBJPolyDataProcessor::RequestData(vtkInformation* vtkNotUsed(request), _extractLine(rawLine); // in the OBJ format the first characters determine how to interpret the line: - // Skip comments - if (strcmp(cmd, "#") == 0) + // Skip comments and empty lines + if (cmd[0] == '#' || cmd[0] == '\0') { continue; } @@ -430,9 +430,13 @@ int vtkOBJPolyDataProcessor::RequestData(vtkInformation* vtkNotUsed(request), { pLine++; } - // Recover the mtllib without the \n at the end + while (isspace(*(pEnd - 1)) && pLine < pEnd) + { + pEnd--; + } + // Recover the mtllib mtlname = vtksys::SystemTools::GetFilenamePath(this->FileName) + "/" + - std::string(pLine, strlen(pLine) - 1); + std::string(pLine, pEnd - pLine); mtllibDefined = true; break; } -- GitLab