Code::Blocks Forums

User forums => Help => Topic started by: liuyg on September 08, 2005, 10:40:13 am

Title: extension problem
Post by: liuyg on September 08, 2005, 10:40:13 am
HI,

Another problem!  :D

I open MS SDK Sample file which extension is 'Cpp' with CB. But CB can't recognize it. No highlight, No source foler in project window.
All 'Cpp' file are in other folder.
Title: Re: extension problem
Post by: thomas on September 08, 2005, 11:09:22 am
Hmm... was going to say that probably the lexer files are case sensitive, but that is not the case.


The guilty code pieces are in editorcolorset.cpp, lines 508-512:

void EditorColorSet::SetFileMasks(HighlightLanguage lang, const wxString& masks, const wxString& separator)
{
    if (lang != HL_NONE)
        m_Sets[lang].m_FileMasks = GetArrayFromString(masks.Lower(), separator);
}



and lines 265-277:

HighlightLanguage EditorColorSet::GetLanguageForFilename(const wxString& filename)
{
   // first search in filemasks
   for (int i = 0; i < HL_LAST; ++i)
   {
      for (unsigned int x = 0; x < m_Sets.m_FileMasks.GetCount(); ++x)
      {
         if (filename.Matches(m_Sets.m_FileMasks.Item(x)))
                return i;
      }
   }
    return HL_NONE;
}


wxString::Matches does clobbing, but is not case sensitive and is case sensitive (which is why it does not work).


Try replacing line 272 with:

Code
if (filename.Lower().Matches(m_Sets[i].m_FileMasks.Item(x)))
and see if that works.
Then you may want to submit a bug report (or a patch) on SF so this is not forgotten ;)
Title: Re: extension problem
Post by: liuyg on September 09, 2005, 09:04:39 am
OH, As you said, I find a bug!   :)

I am only a normal user of CB and have not time to study CB source. In fact, I have not downloaded CB source.  Can you submit a bug report to development team instead of me? This will make CB more perfect.
Thanks for your detail solution.
Title: Re: extension problem
Post by: thomas on September 09, 2005, 05:07:49 pm
done
Title: Re: extension problem
Post by: rickg22 on September 09, 2005, 08:01:24 pm
the function Matches has an optional parameter to say it whether it should use case-insensitive comparisons.
Title: Re: extension problem
Post by: thomas on September 11, 2005, 12:20:30 pm
Even easier then :)
You already fixed it, I guess?
Title: Re: extension problem
Post by: mandrav on September 11, 2005, 03:29:28 pm
the function Matches has an optional parameter to say it whether it should use case-insensitive comparisons.
No, it doesnt (at least under wx2.4)

Even easier then :)
You already fixed it, I guess?
Already fixed ;)