如何使用 Uncrustify 拆分 C 中一行上完成的多个操作?

问题描述 投票:0回答:1

在 C 中,我想将一行上完成的多个操作拆分到各自的行中。

例如

int foo;
int bar;
foo = 123; bar = 456;

应改为:

int foo;
int bar;
foo = 123;
bar = 456;

我可以使用哪些 Uncrustify 配置选项来实现此目的?

我正在使用 Uncrustify 0.72.0。

c formatting uncrustify
1个回答
0
投票

我的解决方案是将此设置设置为 true:

# Whether to add a newline after semicolons, except in 'for' statements.
nl_after_semicolon              = true    # true/false

我还必须将此设置设置为 true,否则它会弄乱单行情况:

# Whether to add a newline after a 'case' statement.
nl_after_case                   = true    # true/false

例如它会改变:

case SOME_ENUMERATION: printf("Hello World!\n"); break;

致:

case SOME_ENUMERATION: printf("Hello World!\n");
    break;

我还必须将此设置设置为 true,否则它会弄乱单行 if 语句:

# Don't split one-line if/else statements, as in 'if(...) b++;'.
nl_if_leave_one_liners          = true    # true/false

例如它会改变:

if (some_condition) { break; }

致:

if (some_condition) { break;
}
© www.soinside.com 2019 - 2024. All rights reserved.