Author Topic: astyle problem?  (Read 5802 times)

Offline liuyg

  • Multiple posting newcomer
  • *
  • Posts: 12
astyle problem?
« on: September 06, 2005, 11:52:23 am »
I would like to use KR style with astyle tool, but I find this in astyle of plugin's settings of settings:
Code
namespace foospace {     
    int Foo() {
        if (isBar) {
            bar();
            return 1;
         }
         else   --------------------????? It's very stranger. It  is not KR style
            return 0;
    }
}

KR style should be :
Code
    namespace foospace {
        int Foo() {
            if (isBar) {
                bar();
                return 1;
            } else           ---- this
                return 0;
        }
    }

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: astyle problem?
« Reply #1 on: September 06, 2005, 12:16:56 pm »
These examples were copied verbatim from astyle's documentation.
Have you tried formatting with this style and behaves wrong?
In other words, is the sample wrong or the behaviour?
Be patient!
This bug will be fixed soon...

Offline liuyg

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: astyle problem?
« Reply #2 on: September 07, 2005, 11:33:25 am »
HI,

Thanks for your reply.

The astyle sample in codeblocks  is wrong. I have checked  astyle document. It should be '}else' .

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: astyle problem?
« Reply #3 on: September 07, 2005, 11:45:08 am »
Thanks, I 'll correct it :)
Be patient!
This bug will be fixed soon...

m00

  • Guest
Re: astyle problem?
« Reply #4 on: December 28, 2005, 06:56:11 pm »
Same problem as with Linux style; it's not right. In the astyle document shows:
http://cvs.sourceforge.net/viewcvs.py/*checkout*/astyle/astyle_1.x/astyle.html?rev=1.28
Code
namespace foospace
{
int Foo()
{
if (isBar) {
bar();
return 1;
} else /* difference */
return 0;
}
}

But in C::B 1.0r2 has this:
Code
namespace foospace
{
int Foo()
{
if (isBar) {
bar();
return 1;
}
else /* difference */
return 0;
}
}

K&R style problem still exist in C::B 1.0r2. I have no idea if it's arleady fixed in SVN, so just a FYI.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: astyle problem?
« Reply #5 on: December 28, 2005, 07:43:17 pm »
Hello,

I have tried with RC2 (Windows XP SP2) and Linux style issue is there. K&R seems to work quite ok. This is what I get when using K&R:

Quote
namespace foospace
{                             <-- This is false
    int Foo() {
        if (isBar) {
            bar();
            return 1;
        } else /* difference */
            return 0;
    }
}

Java style has the same problem as K&R

I will check if this problem still exists with a SVN binary snapshot.

Michael
« Last Edit: December 28, 2005, 07:56:25 pm by Michael »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: astyle problem?
« Reply #6 on: December 28, 2005, 07:55:03 pm »
I have tried now with C::B SVN rev1578 (from Therion), but it seems that there is another issue with K&R:

Quote
namespace foospace
{                           <-- This is false
    int Foo() {
        if (isBar) {
            bar();
            return 1;
        }
        else /* difference */       <-- This is false
            return 0;
    }
}

With linux style same difference between code and linux style example in plugin settings.

Java style has the same problem as described in my previous post.

Michael
« Last Edit: December 28, 2005, 07:58:38 pm by Michael »

grv575

  • Guest
Re: astyle problem?
« Reply #7 on: December 28, 2005, 10:23:12 pm »
I have tried now with C::B SVN rev1578 (from Therion), but it seems that there is another issue with K&R:

Quote
namespace foospace
{                           <-- This is false
    int Foo() {
        if (isBar) {
            bar();
            return 1;
        }
        else /* difference */       <-- This is false
            return 0;
    }
}

With linux style same difference between code and linux style example in plugin settings.

Java style has the same problem as described in my previous post.

Michael


This:

Code
namespace foospace
{
    int Foo()
    {
        if (isBar) {
            bar();
            return 1;
        } else
            return 0;
    }
}

is K&R - i.e. functions use the C bracket convention, while expressions use the java bracket convention.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: astyle problem?
« Reply #8 on: December 29, 2005, 10:09:34 pm »
This:

Code
namespace foospace
{
    int Foo()
    {
        if (isBar) {
            bar();
            return 1;
        } else
            return 0;
    }
}

is K&R - i.e. functions use the C bracket convention, while expressions use the java bracket convention.

Thank you for the explanation, but the position of else is not correct (C::B SVN rev1578) or did I miss something?

Michael