Author Topic: Code formatter  (Read 4479 times)

Offline Icek

  • Single posting newcomer
  • *
  • Posts: 5
Code formatter
« on: May 03, 2007, 08:43:51 pm »
Hi, i use CB on linux (ubuntu 6.10 and/or 7.04), but i have problem with Astyle source formatter. After formatting my code looks like this :

Code
bool CVERTEX3F::operator==(const CVERTEX3F druhy)const
{
 if ( this->x == druhy.x  &&
         this->y == druhy.y  &&
         this->z == druhy.z  )
 return true;
 else
     return false;
     
    }
   
    bool CVERTEX3F::operator!=(const CVERTEX3F druhy)const
        {
         if ( this->x != druhy.x  ||
                 this->y != druhy.y  ||
                 this->z != druhy.z  )
         return true;
         else
             return false ;
            }
           
           
            float CVERTEX3F::GetMax()
                {
                 if (this->x > this->y)
                 {
                  if (this->x > this->z)
                      {
                       return this->x;
                      }
                      return this->z;
                     }
                     
                     if (this->y > this->z)
                         {
                          return this->y;
                         }
                         
                         return this->z;
                        }
}

when i do the same on windows, it works fine...

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Code formatter
« Reply #1 on: May 03, 2007, 09:16:04 pm »
Just took your code and processed it through Source Formatter using different styles and it produces the right output.

Code::Blocks 3887 on Gentoo.

Offline Icek

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code formatter
« Reply #2 on: May 03, 2007, 09:40:10 pm »
i have tried all of them, but no one worked right...

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Code formatter
« Reply #3 on: May 03, 2007, 09:53:41 pm »
Create a new empty file, copy the wrongly formatted text of your post and paste it in that new file, now use the Source Formatter plugin. That's what I did and it worked that way.

Maybe a problem with new lines? (Just guessing)

Offline Icek

  • Single posting newcomer
  • *
  • Posts: 5
Re: Code formatter
« Reply #4 on: May 03, 2007, 10:00:23 pm »
hm, it works... but i have this problem with all files in my project... that isnt solution... couldnt be problem in ubuntu? why it works on win and on lin didnt ? with the same code...

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Code formatter
« Reply #5 on: May 04, 2007, 02:45:43 am »
OK, it seems I found the problem: new lines.

I just took a file I created on Linux, used Source Formatter and it worked. Now I converted the file using unix2dos, opened it again, used Source Formatter and got something just like the code you pasted in your first post.

I'll try to find a way to fix that. I still need to update the plugin to a more recent version of AStyle anyway.

[edit]
OK, it's fixed now. Updated to AStyle 1.20.2 too.
[/edit]
« Last Edit: May 04, 2007, 08:53:36 pm by Ceniza »