Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding braces for If-else using Uncrustify

I was wondering if there is any way to add braces in nested If-else using Uncrustify. For example:

if( stat_error == -1 ){
   if ( debug > 0 )
      printf( "...ERROR ); //I would like to add braces around here.
   exit( -1 );
} else {

I have seen this:

# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'.
mod_full_brace_if                        = add   # ignore/add/remove/force

But it doesn't seem to work for nested conditionals.

Is there any way to do it?

like image 741
Cod1ngFree Avatar asked Dec 02 '13 16:12

Cod1ngFree


1 Answers

My experience with Uncrustify in your example :

Add or remove braces on single - line if statement. Will not remove the braces if they contain an else.

mod_full_brace_if = add

Make all if / elseif / else statements in a chain be braced or not. Overrides mod_full_brace_if.

If any must be braced, they are all braced. If all can be unbraced, then the braces are removed.

mod_full_brace_if_chain = false

And it worked for me.

like image 153
mtb Avatar answered Oct 10 '22 08:10

mtb