Uncrustify Collapse Multiline Function Call

I have function calls that look like this (for no apparent reason):

func
(
    a,
    b,
    c
)

Is there a way to make uncrustify collapse the function into a single line? I have been trying for two days not on and off...

I got it to work for function declarations, but I don't get it to work for function calls.

While we are at it I also have functions that look like so:

func
(
    a, // (IN) the A
    b, // (IN) something b
    c  // (OUT) the resulting value
)

Is there a way to handle that case too, without breaking the code? Since uncrustify keeps comments, I think this is kind of impossible. With function declarations it collapses it to the first comment.

Answers

Reading the docs, I came up with this:

# Add or remove newline between a function name and the opening '('
nl_func_paren                            = remove   # ignore/add/remove/force

# Add or remove newline between a function name and the opening '(' in the definition
nl_func_def_paren                        = remove   # ignore/add/remove/force

# Add or remove newline after '(' in a function declaration
nl_func_decl_start                       = remove   # ignore/add/remove/force

# Add or remove newline after '(' in a function definition
nl_func_def_start                        = remove   # ignore/add/remove/force

# Add or remove newline after each ',' in a function declaration
nl_func_decl_args                        = remove   # ignore/add/remove/force

# Add or remove newline after each ',' in a function definition
nl_func_def_args                         = remove   # ignore/add/remove/force

# Add or remove newline before the ')' in a function declaration
nl_func_decl_end                         = remove   # ignore/add/remove/force

# Add or remove newline before the ')' in a function definition
nl_func_def_end                          = remove   # ignore/add/remove/force


As you anticipate, the comments kind-of ruin it, though. There *is* an option to change single-line comments (//) into block comments (/* ... */) though, which should make it easier for you to join lines manually (e.g. in vim v%J)

# Whether to change cpp-comments into c-comments
cmt_cpp_to_c                             = true    # false/true

I tested it with prototypes, declarations and calls:

The calls are not affected. Note also the following related option:

# Whether to fully split long function protos/calls at commas
ls_func_split_full                       = false    # false/true
Posted on by sehe

Relevant tags