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
In some cases CParser can be out of buffer [message #20512] Sat, 21 March 2009 21:38 Go to next message
gridem is currently offline  gridem
Messages: 45
Registered: August 2008
Member
The corresponding patch is attached.
  • Attachment: upp2.patch
    (Size: 1.38KB, Downloaded 236 times)
Re: In some cases CParser can be out of buffer [message #20514 is a reply to message #20512] Sun, 22 March 2009 00:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
gridem wrote on Sat, 21 March 2009 16:38

The corresponding patch is attached.


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
Re: In some cases CParser can be out of buffer [message #20523 is a reply to message #20514] Sun, 22 March 2009 09:06 Go to previous messageGo to next message
gridem is currently offline  gridem
Messages: 45
Registered: August 2008
Member
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.
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 next message
mirek is currently offline  mirek
Messages: 13975
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.
Re: In some cases CParser can be out of buffer [message #20573 is a reply to message #20525] Tue, 24 March 2009 08:32 Go to previous messageGo to next message
gridem is currently offline  gridem
Messages: 45
Registered: August 2008
Member
luzr wrote on Sun, 22 March 2009 11:27



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.



So, I used the CParser in mixed mode. And I found that in some cases CParser shows wrong line number. Applied patch will solve such kind of issue.

I used the NoSkipSpaces because I need not to skip spaces after the last bracket but inside brackets I used SkipSpaces.

I notices that CParser works very fast and it's really useful and easy to use. It's amazing!
Re: In some cases CParser can be out of buffer [message #20576 is a reply to message #20573] Tue, 24 March 2009 11:02 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Actually, from the last reply, I am not sure whether there are some remaining issues from your point of view:)

Mirek
Previous Topic: bug StaticConditionVariable::Initialize() has no implementation
Next Topic: The problem with 'Null'
Goto Forum:
  


Current Time: Mon Apr 29 15:10:21 CEST 2024

Total time taken to generate the page: 0.02879 seconds