“力”是什么意思在 Uncrustify 中做什么?

发布于 2024-12-24 19:23:22 字数 246 浏览 5 评论 0原文

许多选项都包含 Force 值选项:

添加或删除嵌套括号之间的空格

sp_paren_paren { 忽略添加删除强制 }

这是什么意思?它与Add有何不同?

Many of the options include the Force value option:

Add or remove space between nested parens

sp_paren_paren { Ignore, Add, Remove, Force }

What does it mean? How is it different than Add?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

作妖 2024-12-31 19:23:22

添加的意思是“如果尚不存在则添加”,这意味着如果某些内容已经存在,则保留它(以及单独的格式)。 Force 意味着如果不存在则添加,如果存在则重新格式化:

// Original
if (cond)         {
    func();
}

// Add curly braces (already present, leaves formatting alone)
if (cond)         {
    func();
}

// Force curly braces
if (cond) {
    func();
}

或者另一个示例:

// Original
if (cond)
    func();

// Add curly braces
if (cond) {
    func();
}

// Force curly braces (behaves just like add in this case)
if (cond) {
    func();
}

Add means "add if not already present", meaning that if something's already there, leave it (and the formatting alone). Force means add if not present, and reformat if it is present:

// Original
if (cond)         {
    func();
}

// Add curly braces (already present, leaves formatting alone)
if (cond)         {
    func();
}

// Force curly braces
if (cond) {
    func();
}

Or another example:

// Original
if (cond)
    func();

// Add curly braces
if (cond) {
    func();
}

// Force curly braces (behaves just like add in this case)
if (cond) {
    func();
}
小情绪 2024-12-31 19:23:22

Add 如果不存在则添加。

Remove 删除(如果存在)。

Force 执行remove,然后执行add

Add adds if it is not there.

Remove removes if it is there.

Force does a remove then an add.

疏忽 2024-12-31 19:23:22

如“在A和B之间添加或删除X”

Add:当没有X出现时,只添加a X

AB -> AXB
AXB -> AXB
AXXB -> AXXB

Remove:删除所有出现的X

AB -> AB
AXB -> AB
AXXB -> AB

强制:正如edwinc所说删除然后添加 ->首先删除所有(任何)X 并
最后添加a X

AB -> AXB
AXB -> AB -> AXB
AXXB -> AB -> AXB

但有时“添加X”可能被定义为在其他地方添加一些数字X,因此Force会像Chris所说的那样“重新格式化”。

As "Add or remove X between A and B"

Add: only adds a X when there is no X appeared

AB -> AXB
AXB -> AXB
AXXB -> AXXB

Remove: removes all appeared X

AB -> AB
AXB -> AB
AXXB -> AB

Force: as edwinc said Remove then Add -> Removes all (any) X first and
adds a X finally

AB -> AXB
AXB -> AB -> AXB
AXXB -> AB -> AXB

But sometimes 'add X' may be defined as add some number X elsewhere, so Force will like a "reformat" as Chris said.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文