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   |
 |
mirek
Messages: 14255 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? 
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   |
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? 
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!
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:32:22 CEST 2025
Total time taken to generate the page: 0.00944 seconds
|