Closed TomTheFurry closed 1 year ago
Hi, I can't reproduce the issue. I see skipLine
correctly handling comments in \r\n
mode. Do you have an fbx file I can try to reproduce this?
I amon the phone atm so can't give a sample right now, but basically, in here:
if (cursor->current < cursor->end) ++cursor->current;
While the 'next line' token is detected correctly on the loop before the linked line, which advances the cursor til it hit the 'next line' token, the linked line then, disregard whether it is a '\n' or '\r\n', and instead just advances 1 character. This makes the 'skipLine()' to fail to skip the actual line.
what happens in case of ;comment\r\n
is:
\r
\r
because it fails on *(cursor.current + 1) != '\n'
(emphasis on !=)\n
if (cursor->current < cursor->end) ++cursor->current;
so the whole line is correctly skippedI must be misunderstanding something.
Oh. That's my mistake then. Apologies for wasting your time here. I did not notice that is a 'not equal' sign instead of a 'equal' sign.
No problem.
The
static void skipLine(Cursor* cursor)
when encountering a line terminated with\r\n
new lines style, it only advance the cursor up to the\n
, as it is hardcoded to advance 1 character once it see the new line characters sequence (checked viaisEndLine(const Cursor& cursor)
which does check both cases of new lines style properly).This issue in effect while does not cause it to stuck in the main
tokenizeText(...)
parsing loop, it does however fail to parse an element properly when there is a;Comment here
comment in a line between properties. This failure is caused byreadTextElement(...)
callingskipWhitespaces(cursor)
on many different cases, all which then callskipLine(cursor)
if it encounter a comment. This due to above bug cause the cursor to still be on a\n
character after the call toskipWhitespaces(...)
, thus failing the parsing.A simple fix is to have the
skipLine(..)
make sure to move the cursor up by 2 characters if it encounter the\r\n
style new line.Background info:
This group of issues are discovered when our team is porting OpenFBX library to run natively on C#. Our company is planning to use OpenFBX to expend model loading support for our game (and game engine), as we are currently using block bench parsing and loading only which provides limited features. While the modified C# port is currently closed source and for internal use only, it is undecided whether we will release the port in any format once it is to a stage we are happy with.