uncrustify / uncrustify

Code beautifier
http://uncrustify.sourceforge.net/
GNU General Public License v2.0
2.87k stars 566 forks source link

C++/other langs: wrong spacing with nl_brace_else = remove #3634

Closed dbartolini closed 2 years ago

dbartolini commented 2 years ago

With Uncrustify_d-0.74.0-338-50025791 the spacing between else if and { is wrong.

Command (debug.txt):

./build/uncrustify -p debug.txt -c elseif.cfg -f elseif.cpp

Input:

if (false)
{
}
else if (false)
{
}

Output:

if (false) {
} else if (false)   {
}

Expected output:

if (false) {
} else if (false) {
}

If you remove nl_brace_else = remove from config uncrustify produces expected output. If you disable this code block uncrustify produces expected output.

I didn't investigate further.

guy-maurel commented 2 years ago

you need to use the option

# Add or remove space between ')' and '{' of control statements.
sp_sparen_brace                 = force
dbartolini commented 2 years ago

It does the trick. Thanks.