User forums > General (but related to Code::Blocks)
Code completion problems in 7966?
ollydbg:
--- Quote from: MortenMacFly on May 21, 2012, 06:13:37 am ---
--- Quote from: ollydbg on May 21, 2012, 05:35:01 am ---But I'm not satisfied with the logic on changing m_Str. Any ideas?
--- End quote ---
I think the issue is that the space is removed.
--- End quote ---
Yes, the m_Str is like a "stack", when you push(add) something to it, you need a trailing space.
--- Quote --- Where and why does that happen?
--- End quote ---
--- Code: ---m_Str.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_const)
--- End code ---
This code removed the trailing space, so my patch adds the space again.
MortenMacFly:
--- Quote from: ollydbg on May 21, 2012, 06:33:45 am ---Yes, the m_Str is like a "stack", when you push(add) something to it, you need a tailing space.
[...]
--- Code: ---m_Str.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_const)
--- End code ---
This code removed the tailing space, so my patch adds the space again.
--- End quote ---
So, doing something like:
--- Code: ---wxString str_stripped(m_Str); if (str_stripped.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_const)) ...
--- End code ---
...wouldn't that be better?
...or even:
--- Code: ---wxString str_stripped(m_Str); str_stripped.Trim(true).Trim(false); if (str_stripped.IsSameAs(ParserConsts::kw_const)) ...
--- End code ---
Edit: Edited the second code snippet so it is syntax-correct.
ollydbg:
Ok, I'm going to commit the patch below (in a few hours):
--- Code: ---Index: E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/parserthread.cpp (revision 7991)
+++ E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -1055,9 +1055,11 @@
}
else if (peek==ParserConsts::dcolon)
{
- if ( m_Str.IsEmpty()
- || m_Str.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_const)
- || m_Str.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_volatile) ) // what else?!
+ wxString str_stripped(m_Str);
+ str_stripped.Trim(true).Trim(false);
+ if ( str_stripped.IsEmpty()
+ || str_stripped.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_const)
+ || str_stripped.Trim(true).Trim(false).IsSameAs(ParserConsts::kw_volatile) ) // what else?!
m_EncounteredTypeNamespaces.push(token); // it's a type's namespace
else
m_EncounteredNamespaces.push(token);
--- End code ---
ollydbg:
Commited:
--- Quote ---Revision: 7992
Author: ollydbg
Date: 2012-5-21 14:14:18
Message:
* CC: Fix a bug when parsing some kind of buffer like "const ALib::CommandLine & cmd", the tailing space should be preserved in m_Str. See more details on http://forums.codeblocks.org/index.php/topic,16361.msg110868.html#msg110868
-------------------------------
M : /trunk/src/plugins/codecompletion/parser/parserthread.cpp
--- End quote ---
EDIT:
@Morten:
Thanks for the tiny fix in rev 7993.
Navigation
[0] Message Index
[*] Previous page
Go to full version