Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pp_indent_case does not work as intended. #2253

Open
Josar opened this issue Apr 9, 2019 · 1 comment
Open

pp_indent_case does not work as intended. #2253

Josar opened this issue Apr 9, 2019 · 1 comment

Comments

@Josar
Copy link

Josar commented Apr 9, 2019

Maybe similar to #489

I try to define a cfg for uncrustify. But now i have this issue.
I think there are some options that clashes.

uint16_t testing(test_t tests)
{

    uint16_t rslt = 0;

    switch (tests)
    {
        #if (TEST_1 == TEST_2)
        case test1:
        {
            rslt = 1;
            break;
        }
        #elif (TEST_1 == TEST_3)
        case test1:
        {
            rslt = 2;
            break;
        }
            #endif

    }

    return rslt;
}

The #endif is not indented correctly.
Also the indenting of the case body is not done properly.

My config

indent_columns                  = 4
indent_with_tabs                = 0

pp_indent                                 = force
  pp_indent_at_level                        = true  # Setting this to false sets all pp to column 1 and solves the problem
    pp_indent_count                           = 4
    pp_indent_if                              = 0
pp_space                                  = remove
  pp_space_count                            = 0
pp_region_indent_code                     = false
  pp_indent_region                          = 0
pp_if_indent_code                         = true
pp_define_at_level                        = false

The issue occurs when pp_indent_at_level = true .

@Josar
Copy link
Author

Josar commented Apr 22, 2019

It seems to be the #endif of surounded cases which indented one time too much.

uint8 TestSwitch(uint8 test){
    switch (test)
    {
        #if (TEST_1 == TEST_2)
        #elif (TEST_1 == TEST_3)
        #else
        #endif

        #if (TEST_1 == TEST_2)
            {}
        #elif (TEST_1 == TEST_3)
            {}
        #else
            {}
        #endif

        #if (TEST_1 == TEST_2)
        case TESTING_1:
        {

        }
        #elif (TEST_1 == TEST_3)
        case TESTING_1:
        {
        }
        #else
        case TESTING_1:
        {
        }
            #endif

            #if (TEST_1 == TEST_2)
            case TESTING_1:
            {

            }
            #elif (TEST_1 == TEST_3)
            case TESTING_1:
            {
            }
            #else
            case TESTING_1:
            {
            }
                #endif
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants