6

我想知道是否有任何方法可以使用 Uncrustify 在嵌套的 If-else 中添加大括号。例如:

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

我见过这个:

# 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

但它似乎不适用于嵌套条件。

有什么办法吗?

4

2 回答 2

4

我在您的示例中使用 Uncrustify 的经验:

在单行if语句中添加或删除大括号。如果大括号包含else.

mod_full_brace_if = add

使链中的所有if//语句都被支撑elseif或不支撑。else覆盖mod_full_brace_if

如果有任何必须支撑,它们都被支撑。如果所有都可以解开,则移除大括号。

mod_full_brace_if_chain = false

它对我有用。

于 2015-11-17T16:01:41.460 回答
-4

你需要添加一个返回语句应该是这样的

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

Insert else statement
}
return statement here
}
于 2013-12-02T16:30:05.783 回答