Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
wxsmith code generate tab or spaces issue
(1/1)
ollydbg:
Firstly, I do not familiar with wxsmith's source code, but I do see an issue:
--- Code: ---wxString wxsCoder::RebuildCode(wxString& BaseIndentation,const wxChar* Code,int CodeLen,wxString& EOL)
{
wxString Tab;
bool UseTab = Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/use_tab"), false);
int TabSize = Manager::Get()->GetConfigManager(_T("editor"))->ReadInt(_T("/tab_size"), 4);
if ( !UseTab )
{
Tab.Append(_T(' '),TabSize);
}
if ( EOL.IsEmpty() )
{
int EolMode = Manager::Get()->GetConfigManager(_T("editor"))->ReadInt(_T("/eol/eolmode"), 0);
switch ( EolMode )
{
case 1: EOL = _T("\r"); break;
case 2: EOL = _T("\n"); break;
default: EOL = _T("\r\n");
}
}
BaseIndentation.Prepend(EOL);
wxString Result;
Result.reserve(CodeLen+10);
while ( *Code )
{
switch ( *Code )
{
case _T('\n'):
{
while (Result.Last() == _T(' ') || Result.Last() == _T('\t'))
Result.RemoveLast();
Result << BaseIndentation;
break;
}
case _T('\t'): if ( UseTab ) { Result << Tab; break; }
default: Result << *Code;
}
Code++;
}
return Result;
}
--- End code ---
The Value "Tab" is either "empty string" or "four spaces".
There is something wrong with the line:
--- Code: ---case _T('\t'): if ( UseTab ) { Result << Tab; break; }
--- End code ---
I think it should be:
--- Code: ---case _T('\t'): if ( !UseTab ) { Result << Tab; break; }
--- End code ---
Otherwise, the '\t' is always added to the code, right?
oBFusCATed:
And what is the test case to reproduce the problem?
ollydbg:
--- Quote from: oBFusCATed on August 27, 2012, 09:33:35 am ---And what is the test case to reproduce the problem?
--- End quote ---
There is an option: Configure Eidtor->General setting->Use Tab chars.
Whenever you select this option or not, the generate xrc/wxs file always use "Tabs". I would like use "4 spaces" in the xrc/wxs file, but I can't find a way.
I suspect the source code above cause the problem(I'm going to debug the code myself), I think the wxsmith should follow those options, but in-fact, it was not.
EDIT:
The code snippet in my original post was related to generate the source in h/cpp files, they are not related to code generation for xrc/wxs. but what the logic seems still wrong. :)
Navigation
[0] Message Index
Go to full version