Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » In some cases CParser can be out of buffer
Re: In some cases CParser can be out of buffer [message #20525 is a reply to message #20523] Sun, 22 March 2009 09:27 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14265
Registered: November 2005
Ultimate Member
gridem wrote on Sun, 22 March 2009 04:06

luzr wrote on Sun, 22 March 2009 02:07



I am perhaps missing something. Which cases? Do you have any testcase demostrating the problem?

(Note that you should not call GetChar when IsEof...)

Mirek


Yes, in case of calling GetChar twice without check on IsEof() (it can be treated as error of using CParser yet). But the function SkipTerm already has this check: two subsequent calls of SkipTerm work fine.

There is another issue: when CParser::term == '\n' and the function CParser::SkipTerm() is called than CParser::line will not be increased.


Well, one thing to understand: GetChar is "special" operation that is supposed to be used only in very special cases.

In "normal" operation, CParser::term == '\n' can never be true. If you are using GetChar to handle special cases, you must make sure that at the end, term points to non-space (simple way is to call Spaces when you are done with GetChar).

And one more thing to understand:) Some of these issues are that way are because of performance.

Especially, CParser normally never stops at "space" (e.g. term == '\n'). Look at the code, after each "term eating" operation, there is a call to DoSpaces. This is to make e.g. Char operation fast.

Of course, in "other" special cases, you might want to deal with spaces yourself, then you activate NoSkipSpaces and you have to call Spaces after each accepted term yourself.

Is there a hole in this logic? Smile

Mirek

P.S.: While a very unlikely case, I think you are right about SkipTerm and line number. I have added a fix there.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: bug StaticConditionVariable::Initialize() has no implementation
Next Topic: The problem with 'Null'
Goto Forum:
  


Current Time: Mon Jul 14 14:30:22 CEST 2025

Total time taken to generate the page: 0.04097 seconds