ScriptLexer is counting \r\n as 2 newlines

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
shuff
Gnoblar
Posts: 13
Joined: Sat Aug 04, 2012 11:53 pm
x 9

ScriptLexer is counting \r\n as 2 newlines

Post by shuff »

I noticed when upgrading to 1.8.0 from 1.7 that errors in my ogre.log regarding my buggy material scripts started pointing to lines beyond the end of the files. After browsing through the ScriptLexer class I'm guessing that it's related to adding support for Mac's \r newlines but the approach taken causes problems with Window's \r\n by doubling line counts and probably less significantly, doubly newline tokens. I fixed it locally and I'd be happy to submit a patch to make it work for all three cases if someone could kindly point me to the proper process for doing so.
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: ScriptLexer is counting \r\n as 2 newlines

Post by masterfalcon »

Good find. Here's the patch tracker link. But you could also submit it as a bug. http://www.ogre3d.org/developers/submit-patch
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: ScriptLexer is counting \r\n as 2 newlines

Post by madmarx »

Hi,

I made the change that count \r as a newline character.
After browsing through the ScriptLexer class I'm guessing that it's related to adding support for Mac's \r newlines but the approach taken causes problems with Window's \r\n by doubling line counts and probably less significantly, doubly newline tokens
Yes i made that :
- \r alone => new line
- \n alone => new line
This was necessary to correct some material scripts that had only \r as endofline character.
As a consequence I knew that there were doubly newline token, but i did not realise at that time that you would witness such errors.
I understand now the error you witness (and that I created). In my opinion, of we want to correct it completely, the splitting into token must be changed so that \r\n is counted as 1 new line token. Is it what you did ? If yes, thx a lot for fixing it correctly!

Best regards,
Pierre
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
shuff
Gnoblar
Posts: 13
Joined: Sat Aug 04, 2012 11:53 pm
x 9

Re: ScriptLexer is counting \r\n as 2 newlines

Post by shuff »

@masterfalcon
Thanks for humoring me and pointing out the patch/bug page that should have been obvious to me but I missed anyway. I have filed a bug report until I can get around to submitting the "release" form.

@madmarx
Thanks for the reply, in my bug report I provided a possible "least-touch" fix that was I think 2 small changes to existing lines that makes it compatible for all 3 platforms... theoretically. ;)