Code::Blocks Forums

User forums => Help => Topic started by: liuyg on September 06, 2005, 11:52:23 am

Title: astyle problem?
Post by: liuyg 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;
        }
    }
Title: Re: astyle problem?
Post by: mandrav 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?
Title: Re: astyle problem?
Post by: liuyg 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' .
Title: Re: astyle problem?
Post by: mandrav on September 07, 2005, 11:45:08 am
Thanks, I 'll correct it :)
Title: Re: astyle problem?
Post by: m00 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.
Title: Re: astyle problem?
Post by: Michael 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
Title: Re: astyle problem?
Post by: Michael 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
Title: Re: astyle problem?
Post by: grv575 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.
Title: Re: astyle problem?
Post by: Michael 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