Author Topic: BUG on Compiler "Other settings"  (Read 4191 times)

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
BUG on Compiler "Other settings"
« on: November 28, 2009, 09:44:37 am »
I had setten the "Other setting" for Global compiler settings :
"Save build log to HTML file when build is finished" and "Always output the full command line in the generated HTML file".

so, after compile process finished, I found a html file's link in the log window. BUT It didn't open the HTML file after I click the link text. why? because the HTML file is saved in "C:\Documents and Settings\...". the path inlcude some SPACE char.

It looks like:

file://C:\Documents and Settings\NANYU\My Documents\CodeBlocks Projects\Hello CodeBlocks\Hello CodeBlocks_build_log.html

BTW: the HTML file generated by c::b didn't set the encoding (UTF-8), so it can not been show rightly If it have some non-english character.

sorry for my pool  English.. (
« Last Edit: November 28, 2009, 12:46:25 pm by nanyu »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: BUG on Compiler "Other settings"
« Reply #1 on: November 28, 2009, 11:17:43 am »
Hi nanyu,

do you use a selfcompiled C::B ?

If yes, it would be nice, if you could test the attached patch.

Everybody else can/should test it also (especially if non-english chars are in path) to test whether it could break anything.
For me it works fine with spaces and german umlauts in filename and/or path.

[attachment deleted by admin]

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: BUG on Compiler "Other settings"
« Reply #2 on: November 28, 2009, 02:56:36 pm »
jens : thank you!

I have done this test.

after this patch C::B work well with the "SPACE " char in the filename or path. I click the link text,the "HTML Viewer" tool was shown by c::b. If the log's context include Chinese char, it show good well.

But if the Project file's name include Chinese char, then the "HTML Viewer" didn't shown after I click the link text,  I copy and past into the Brower(FF or IE)'s address box. Browers can't open the html_log_file also. IE will say "Windows can not found  “file://C:%5cDocuments%20and%20Settings%5cZhuangYanDell%5cMy%20Documents%5cCodeBlocks%20Projects%5c%2d%87%e5%0b%0d%57%5c%2d%87%e5%0b%0d%57_build_log.html” ...

I guess :
1, Windows XP (Chinese version) encoded Filename by GBK default.
2, So, in the C::B's memory , the FileName encoded by GBK also.
3, the function : tmpFilename.BuildURI() , convert the filename to "URL" format from GBK.
4, But, the brower expect utf_8.

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: BUG on Compiler "Other settings"
« Reply #3 on: November 28, 2009, 05:30:56 pm »
I made some changes to code.

Code: [Select]
    wxString tmpBuildLogFilename = m_BuildLogFilename;
    tmpBuildLogFilename.Replace(wxT("\\"), wxT("/"), true);
    wxString utf8BuildLogFilename = wxString::From8BitData(tmpBuildLogFilename.utf8_str().data());
    wxString uriBuildLogFilename = wxURI(utf8BuildLogFilename).BuildURI();
   
    #if wxCHECK_VERSION(2, 9, 0)
    Manager::Get()->GetLogManager()->Log(F(_T("file://%s"), uriBuildLogFilename.wx_str()), m_PageIndex, Logger::warning);
    #else
    Manager::Get()->GetLogManager()->Log(F(_T("file://%s"), uriBuildLogFilename.c_str()), m_PageIndex, Logger::warning);
    #endif

 Now copy the link text to Firefox, FF will open the html log file OK, but IE cann't yet.
 It seem that C::B's HTML viewer no support a url include Chinese even the Chinese char was converted by wxURI.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: BUG on Compiler "Other settings"
« Reply #4 on: November 28, 2009, 05:58:29 pm »
As far as I see only the spaces are a problem.

So this one might work:

Code: [Select]
    wxString tmpFilename = m_BuildLogFilename;
    tmpFilename.Replace(_T(" "), wxT("%20"), true);

    #if wxCHECK_VERSION(2, 9, 0)
    Manager::Get()->GetLogManager()->Log(F(_T("file://%s"), tmpFilename.wx_str()), m_PageIndex, Logger::warning);
    #else
    Manager::Get()->GetLogManager()->Log(F(_T("file://%s"), tmpFilename.c_str()), m_PageIndex, Logger::warning);
    #endif


Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: BUG on Compiler "Other settings"
« Reply #5 on: November 29, 2009, 03:50:42 am »
As far as I see only the spaces are a problem.

So this one might work:

Code: [Select]
    wxString tmpFilename = m_BuildLogFilename;
    tmpFilename.Replace(_T(" "), wxT("%20"), true);

    #if wxCHECK_VERSION(2, 9, 0)
    Manager::Get()->GetLogManager()->Log(F(_T("file://%s"), tmpFilename.wx_str()), m_PageIndex, Logger::warning);
    #else
    Manager::Get()->GetLogManager()->Log(F(_T("file://%s"), tmpFilename.c_str()), m_PageIndex, Logger::warning);
    #endif


Yesterday I did the same thing. It couldn't do right work. That is , if the link include some Chinese char, the underline will stop beforer the first Chinese char.  It look like:

file:://abcd/[HERE IS THE FIRST CHINESE CHAR]_log.html