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):
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;
Second patch (better):
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
Both patches work on linux and windows.
It happens because wxIsdigit() treats "²" and "³" as digit on XP.
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.
#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;
}
Only GCC & MSVC 8 returns the following output.
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.
So you can see that there is another character which can cause this bug. :)