Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on March 29, 2012, 03:51:47 am

Title: wxIsalpha issue in tokenizer
Post by: ollydbg on March 29, 2012, 03:51:47 am
Code
    wxChar a = _T('中');
    if(wxIsalpha(a))
    {
        ....
    }
The if clause will run. We have such code:
Code
wxString Tokenizer::DoGetToken()
{
    int start = m_TokenIndex;
    bool needReplace = false;

    wxString str;
    wxChar   c = CurrentChar();

    if (c == '_' || wxIsalpha(c))
    {
        // keywords, identifiers, etc.

        // operator== is cheaper than wxIsalnum, also MoveToNextChar already includes IsEOF
        while (    ( (c == '_') || (wxIsalnum(c)) )
               &&  MoveToNextChar() )
            c = CurrentChar(); // repeat

        if (IsEOF())
            return wxEmptyString;

        needReplace = true;
        str = m_Buffer.Mid(start, m_TokenIndex - start);
    }

I'm not sure the Chinese character entered in code will cause some problem.

Like: Re: ² character bug (http://forums.codeblocks.org/index.php/topic,8700.msg63405.html#msg63405)
Title: Re: wxIsalpha issue in tokenizer
Post by: MortenMacFly on March 29, 2012, 06:55:27 am
I'm not sure the Chinese character entered in code will cause some problem.
Well I believe we had that just recently - IMHO the compiler will compile code that uses non-ASCII characters for variable / function names. No the assumption is correct. Its not nice and actually ugly and evil - but its not an error.