split_fcn_params fails to properly split function calls with very long first argument.
In the folllowing example (attached as input.c)
int main(int argc, char *argv[])
{
int a, b, c;
printf("This is a very long string that goes beyond the code_width, and it should not be split", a, b, c);
return 0;
}
with configuration (attached as test.cfg):
# True: indent continued function call parameters one indent level
# False: align parameters under the open paren
indent_func_call_param = false # false/true
# Try to limit code width to N number of columns
code_width = 80 # number
# Whether to fully split long function protos/calls at commas
ls_func_split_full = false # false/true
uncrustify produces
int main(int argc, char *argv[])
{
int a, b, c;
printf(
"This is a very long string that goes beyond the code_width, and it should not be split", a, b,
c);
return 0;
}
while it should produce
int main(int argc, char *argv[])
{
int a, b, c;
printf("This is a very long string that goes beyond the code_width, and it should not be split",
a, b, c);
return 0;
}
Note that adding a new line after the fparen open when indent_func_call_param is set to false is meaning less.
Also note that it only puts c in a new line, which is not the best we can do.
Using 0.62 (and tested with master as well)
If having a very long function name such as:
very_long_function_name_printf("This is a very long string that goes beyond the code_width, and it should not be split", a, b, c);
and set the option:
ls_func_split_full = true
you'll get what you wanted to have:
very_long_function_name_printf(
"This is a very long string that goes beyond the code_width, and it should not be split",
a,
b,
c);
But I do not want
a,b, andcto appear in different lines, since they fit in a single one.Yes, you can use the option:
ls_code_width=true
and get:
very_long_function_name_printf(
"This is a very long string that goes beyond the code_width, and it should not be split",
a, b, c);
This indeed fixes somewhat (It still does not make sence to place the string bellow the function name) the behavior for this example.
However, I do not see any groups in that example, so it should be irrelevant if I am not mistaken, which makes me skeptical.
Additionally, as a side-effect I expect this change to break the grouping in some other instances of the code.
Could you push an example for this problem?
I am attaching
input.cextended with a long conditional.break_group.cfgsetsls_code_widthtotrueand producesbreak_group.c.keep_group.cfgsetsls_code_widthtofalseand produceskeep_group.c.expected.ccontains the code formated as I would expectkeep_group.cfgto format it.We have migrated the bug to:
https://github.com/uncrustify/uncrustify/issues/684