User forums > General (but related to Code::Blocks)
² character bug
Jenna:
--- Quote from: Biplab on June 28, 2008, 06:43:11 pm ---I can confirm this bug. But encoding handling code is not the culprit here as the file is saved properly.
Disable Code Completion plugin. It's causing this lock-up.
--- End quote ---
I just did a complete install of C::B 8.02 with all plugins and tested it.
But filesaving works as normal, egally whether I have a "²" in file or not.
Code Completion is enabled and I also tested it with the C::B sources, because it's a quite large project, but there is no difference between filesaving with or without the "²".
I tested with "UTF-8" and "WINDOWS-1252".
Biplab:
--- Quote from: jens on June 28, 2008, 10:09:47 pm ---I just did a complete install of C::B 8.02 with all plugins and tested it.
But filesaving works as normal, egally whether I have a "²" in file or not.
Code Completion is enabled and I also tested it with the C::B sources, because it's a quite large project, but there is no difference between filesaving with or without the "²".
I tested with "UTF-8" and "WINDOWS-1252".
--- End quote ---
I tested on Windows XP and this bug can be reproduced even for latest revisions. Though on Linux this is not reproducible which makes the task of detecting the buggy code more difficult.
Jenna:
I can confirm now for Win XP.
I's funny, it does not happen on linux (at least on the versions I use) and on w2k.
If I have some time I try to debug it.
The file get's saved, but the Notebook-state does not change (the star remains there) that gives a hint where (or maybe better when it happens).
Jenna:
It happens because wxIsdigit() treats "²" and "³" as digit on XP.
This leads to an endless loop in "tokenizer.cpp" (in "DoGetToken()"), because both characters are not in the list of characters that get filtered out.
I can provide two patches:
The first one puts both characters to the list used by CharInString in "Do GetToken()", but that would make the behaviour different on different systems and I think that's not good. And in fact "²" and "³" are not really digits, and therefore should not be used in code.
The second patch filters out both characters and treats them as normal characters. That leads to the same behaviour on linux, w2k and winxp.
The characters can't be used directly in source-code, instead their ascii-code has to be used.
First patch (not really good, but works):
--- Code: ---Index: src/plugins/codecompletion/parser/tokenizer.cpp
===================================================================
--- src/plugins/codecompletion/parser/tokenizer.cpp (revision 5106)
+++ src/plugins/codecompletion/parser/tokenizer.cpp (working copy)
@@ -560,7 +560,10 @@
else if (wxIsdigit(CurrentChar()))
{
// numbers
- while (NotEOF() && CharInString(CurrentChar(), _T("0123456789.abcdefABCDEFXxLl")))
+ wxString tmp=_T("0123456789.abcdefABCDEFXxLl");
+ tmp << wxChar(178);
+ tmp << wxChar(179);
+ while (NotEOF() && CharInString(CurrentChar(), tmp))
MoveToNextChar();
if (IsEOF())
return wxEmptyString;
--- End code ---
Second patch (better):
--- Code: ---Index: src/plugins/codecompletion/parser/tokenizer.cpp
===================================================================
--- src/plugins/codecompletion/parser/tokenizer.cpp (revision 5106)
+++ src/plugins/codecompletion/parser/tokenizer.cpp (working copy)
@@ -557,6 +557,11 @@
m_Str = m_Buffer.Mid(start, m_TokenIndex - start);
m_IsOperator = m_Str.IsSameAs(TokenizerConsts::operator_str);
}
+ else if (c == 178 || c == 179)
+ {
+ m_Str = c;
+ MoveToNextChar();
+ }
else if (wxIsdigit(CurrentChar()))
{
// numbers
--- End code ---
Both patches work on linux and windows.
Biplab:
--- Quote from: jens on June 29, 2008, 11:03:40 pm ---It happens because wxIsdigit() treats "²" and "³" as digit on XP.
--- End quote ---
This seems to be a bug in MS Runtime (Most likely). I compiled the following code with GCC, Borland C++, MSVC 8, Digital Mars 8.5, OpenWatcom 1.8.
--- Code: ---#include <iostream>
#include <tchar.h>
using namespace std;
int main()
{
int i;
for (i = 128; i < 255; ++i)
{
if (iswdigit(i))
cout << i << " is a digit" << endl;
}
return 0;
}
--- End code ---
Only GCC & MSVC 8 returns the following output.
--- Quote ---178 is a digit
179 is a digit
185 is a digit
Process returned 0 (0x0) execution time : 0.125 s
Press any key to continue.
--- End quote ---
So you can see that there is another character which can cause this bug. :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version