#267 Breaking else and catch from closing braces in Stroustrup style

open
nobody
5
2015-01-03
2014-01-27
No

Using AStyle 2.04 on Windows, it looks like Stroustrup style does not break else and catch from closing braces.

There is the -y option, but it breaks while in do/while as well, which Stroustrup does not.

Example:

void Foo(bool isFoo)
{
    if (isFoo)
    {
        bar();
    }
    else
    {
        anotherBar();
    }

    try
    {
        thirdBar();
    }
    catch (exception &e)
    {
        panic();
    }

    do
    {
        bar();
    }
    while (isFoo);
}

Formatted with --style=stroustrup gives

void Foo(bool isFoo)
{
    if (isFoo) {
        bar();
    } else {
        anotherBar();
    }

    try {
        thirdBar();
    } catch (exception &e) {
        panic();
    }

    do {
        bar();
    } while (isFoo);
}

instead of the expected

void Foo(bool isFoo)
{
    if (isFoo) {
        bar();
    }
    else {
        anotherBar();
    }

    try {
        thirdBar();
    }
    catch (exception &e) {
        panic();
    }

    do {
        bar();
    } while (isFoo);
}

References:

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks