Describe the issue
The parser fails and stops parsing if a comment is at the end of a line defining an element with a variable number of possible elements following the token. For example, when defining a line like l 1 3 # First line, it's unknown how many vertex indices follow after the l. The while loop condition only looks for new line characters. Subsequently, the parser fails when it encounters the # character.
To Reproduce
Steps to reproduce the behaviour:
- Compile TinyObjLoader
- Load the .obj-file in the attached .zip-archive via ParseFromFile: linien.zip
- See error: Failed to parse `l' line (e.g. a zero value for vertex index. Line 43).
For convenience, try this example project:
tiny_obj_loader_parser_bug.zip
Remarks
This bug only applies to tokens that have a variable number of elements:
- vw (skin weight)
- l (line)
- p (points)
- f (face)
- g (group)
Expected behaviour
The parser should stop parsing a line once it reaches the comment character #.
Environment
- TinyObjLoader version: The latest version of tiny_obj_loader.h (commit 5cd3842)
- OS: Windows 10 x64
- Compiler: MSVC 17.10.9 with C++20 support enabled
- Other environment: N/A