News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Some strange behaviors

Started by GeO, August 07, 2009, 02:18:58 PM

Previous topic - Next topic

GeO

Currently i found some strange behaviors using the new CC Branch of Code::Blocks:
1) if i enter while () and then press "." it will be autocompleted as while ().while
2) if i enter "ret" and then press "CTRL-SPACE" (for autocompletion) it shows me: return ,SHORT ,short_f.....
(see attachment)

[attachment deleted by admin]

ollydbg

#1
I can confirm the first issue.
But, if there's no space between "while" and "(", then it has no error tips.

For the second issue, in my Chinese system Windows XP, ctrl + space will do a input method switch, so, I cant reproduce it. Continuing enter "retu" will give the right tip "return".

Edit
After change the short cut to "ALT +/", I can't reproduce the second issue. It can give the correct tip list with the prefix I entered.




[attachment deleted by admin]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

blueshake

This  not only happened in the new CC Branch of Code::Blocks,but also in normal version.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

blueshake

I found all the keywords had this problem. and the keywords will show twice .for example .
when you type cla and the codecompletion tip will show two class.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

ollydbg

Quote from: blueshake on August 09, 2009, 10:37:06 AM
I found all the keywords had this problem. and the keywords will show twice .for example .
when you type cla and the codecompletion tip will show two class.
Really? But I have only one "class" in the tip list.



[attachment deleted by admin]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

blueshake

That is right.I download the svn 5716 Nightly builds.and it still exist ,it is strange .
see the attachment .

[attachment deleted by admin]
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

ollydbg

That's strange. My local copy was using "trunk + cc_branch + my own patch" , so...
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

blueshake

QuoteCurrently i found some strange behaviors using the new CC Branch of Code::Blocks:
1) if i enter
Code:

while ()

and then press "." it will be autocompleted as
Code:

while ().while
this problem can be solved by this patch.
Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 5744)
+++ nativeparser.cpp (working copy)
@@ -1214,8 +1214,8 @@
                         case '(': --nest; break;
                     }
                 }
-                if ((x > 0) && (wxIsalnum(line.GetChar(x - 1)) || line.GetChar(x - 1) == '_'))
-                    --x;
+                //if ((x > 0) && (wxIsalnum(line.GetChar(x - 1)) || line.GetChar(x - 1) == '_'))
+                //    --x;
             }
         }
     }
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

ollydbg

Can you explain a little about this modify on the function:


unsigned int NativeParser::FindCCTokenStart(const wxString& line)
{
    ......
    return x;
}


Thanks!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

The function is list below:

unsigned int NativeParser::FindCCTokenStart(const wxString& line)
{
   int x = line.Length() - 1;
   int nest = 0;

   bool repeat = true;
   while (repeat)
   {
       repeat = false;
       while ((x >= 0) && (wxIsalnum(line.GetChar(x)) || line.GetChar(x) == '_'))
           --x;

       if ( (x > 0) &&
            ( (line.GetChar(x) == '>' && line.GetChar(x - 1) == '-') ||
              (line.GetChar(x) == ':' && line.GetChar(x - 1) == ':') ) )
       {
           x -= 2;
           repeat = true;
       }
       else if ((x >= 0) && (line.GetChar(x) == '.'))
       {
           --x;
           repeat = true;
       }

       if (repeat)
       {
           // now we 're just before the "." or "->" or "::"
           // skip any whitespace
           while ((x >= 0) && (line.GetChar(x) == ' ' || line.GetChar(x) == '\t'))
               --x;

           // check for function/array/cast ()
           if ((x >= 0) && (line.GetChar(x) == ')' || line.GetChar(x) == ']'))
           {
               ++nest;
               while (--x >= 0 && nest != 0)
               {
                   #if wxCHECK_VERSION(2, 9, 0)
                   switch (line.GetChar(x).GetValue())
                   #else
                   switch (line.GetChar(x))
                   #endif
                   {
                       case ']':
                       case ')': ++nest; break;

                       case '[':
                       case '(': --nest; break;
                   }
               }
               if ((x > 0) && (wxIsalnum(line.GetChar(x - 1)) || line.GetChar(x - 1) == '_'))
                   --x;
           }
       }
   }
   ++x;

   if (x < 0)
       x = 0;

   while (line.GetChar(x) == ' ' || line.GetChar(x) == '\t')
       ++x;

   //Manager::Get()->GetLogManager()->DebugLog("Starting at %d \"%s\"", x, line.Mid(x).c_str());
   return x;
}


I think we need to "skip any whitespace" after we find the "[" in the following line


while     ().


That is what I think is right :D:


               while (--x >= 0 && nest != 0)
               {
                   #if wxCHECK_VERSION(2, 9, 0)
                   switch (line.GetChar(x).GetValue())
                   #else
                   switch (line.GetChar(x))
                   #endif
                   {
                       case ']':
                       case ')': ++nest; break;

                       case '[':
                       case '(': --nest; break;
                   }
               }
               //***************ADD code here:
               // skip any whitespace
               while ((x >= 0) && (line.GetChar(x) == ' ' || line.GetChar(x) == '\t'))
                    --x;
                //**************
               ......



If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

blueshake

so should we  add the codes
               while ((x >= 0) && (line.GetChar(x) == ' ' || line.GetChar(x) == '\t'))
                    --x;

to the function or others?
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

MortenMacFly

Both of you got me irritated by now... So I am simply looking forward to a new patch... ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ollydbg

Step into the CC plugin when I enter the "." after


while   ()


I find that the "BreakUpComponents" function will give the components as "while".

See the screenshot


So, the code-completion related code will firstly search the global token trees, and the Keywords list, finally, it find one match "while".

So, the wrong call tip displayed.

I think the expect result that BreakUpcomponents return should be *empty* instead of a "while".
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

blueshake

i think the problem can be solved by this patch too.
which one is better, still need to further discussed.
Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 5744)
+++ nativeparser.cpp (working copy)
@@ -1248,21 +1247,20 @@
             ++startAt;
         }
     }
-
-//    Manager::Get()->GetLogManager()->DebugLog(_T("at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str());
-    while ((startAt < line.Length()) && (wxIsalnum(line.GetChar(startAt)) || line.GetChar(startAt) == '_'))
+    //Manager::Get()->GetLogManager()->DebugLog(F(_T("at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str()));
+    while ((startAt < line.Length()) && (wxIsalnum(line.GetChar(startAt)) || line.GetChar(startAt) == '_' || line.GetChar(startAt) == ' ' || line.GetChar(startAt) == '\t'))
     {
         res << line.GetChar(startAt);
         ++startAt;
     }
-
+    res.Trim();
     while ((nest > 0) && (startAt < line.Length()))
     {
         if (line.GetChar(startAt) == ')')
             --nest;
         ++startAt;
     }
-    //Manager::Get()->GetLogManager()->DebugLog("Done nest: at %d (%c): res=%s", startAt, line.GetChar(startAt), res.c_str());
+    //Manager::Get()->GetLogManager()->DebugLog(F(_T("Done nest: at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str()));

     if ((startAt < line.Length()) && (line.GetChar(startAt) == '(' || line.GetChar(startAt) == '['))
     {
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

MortenMacFly

Quote from: blueshake on August 27, 2009, 05:44:42 AM
Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 5744)
+++ nativeparser.cpp (working copy)
@@ -1248,21 +1247,20 @@
             ++startAt;
         }
     }
-
-//    Manager::Get()->GetLogManager()->DebugLog(_T("at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str());
-    while ((startAt < line.Length()) && (wxIsalnum(line.GetChar(startAt)) || line.GetChar(startAt) == '_'))
+    //Manager::Get()->GetLogManager()->DebugLog(F(_T("at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str()));
+    while ((startAt < line.Length()) && (wxIsalnum(line.GetChar(startAt)) || line.GetChar(startAt) == '_' || line.GetChar(startAt) == ' ' || line.GetChar(startAt) == '\t'))
     {
         res << line.GetChar(startAt);
         ++startAt;
     }
-
+    res.Trim();
     while ((nest > 0) && (startAt < line.Length()))
     {
         if (line.GetChar(startAt) == ')')
             --nest;
         ++startAt;
     }
-    //Manager::Get()->GetLogManager()->DebugLog("Done nest: at %d (%c): res=%s", startAt, line.GetChar(startAt), res.c_str());
+    //Manager::Get()->GetLogManager()->DebugLog(F(_T("Done nest: at %d (%c): res=%s"), startAt, line.GetChar(startAt), res.c_str()));

     if ((startAt < line.Length()) && (line.GetChar(startAt) == '(' || line.GetChar(startAt) == '['))
     {

...so is this the only thing to apply and the other two modifications are obsolete?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]