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

Apply nl_func_var_def_blk only to first block #3242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xeyownt
Copy link
Contributor

@xeyownt xeyownt commented Jul 16, 2021

Hello,

This is a small fix that addresses nl_func_var_def_blk applying to all var block in a function, not only the top one.

Consider the following example:

void foo(void)
{
    int a;
    bar();
    int b;
    baz();
}

Say you have nl_func_var_def_blk=1, this would give before this fix:

void foo(void)
{
    int a;
                 // <-- good
    bar();
    int b;
                 // <-- bad!
    baz();
}

After this fix, you get the correct:

void foo(void)
{
    int a;

    bar();
    int b;
    baz();
}

This is not the final fix though.

Ideally, if var block is preceded by any other (non-var) block,
nl_func_var_def_blk should not apply as well (because not func top).

For instance, you would still get

void foo(void)
{
    bat();
    int a;
                       // <-- space still inserted here, but a is no longer function top
    bar();
    int b;
    baz();
}

This is not the final fix though.

Ideally, if var block is preceded by any other (non-var) block,
nl_func_var_def_blk should not apply as well (because not func top).
Copy link
Collaborator

@gmaurel gmaurel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is OK, but you need to solve the problems shown at:
https://github.com/xeyownt/uncrustify/runs/3086051478?check_suite_focus=true
Add at least one test data to show how it works

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

Successfully merging this pull request may close these issues.

None yet

2 participants