uncrustify:如何将多行 C 函数调用的参数组合到一行上?

uncrustify: how to combine arguments of multiline C function call on to a single line?

本文关键字:组合 一行 参数 函数调用 uncrustify      更新时间:2023-10-16

我正在使用uncrustify 0.69.0(我还不能编译0.71.0(。我有以下几点:

sendto(cmd_sock, buf, strlen(buf),
0, (struct sockaddr *)&fromCmd,
sizeof(struct sockaddr_in));

我想解脱将它们合并为一行:

sendto(cmd_sock, buf, strlen(buf), 0, (struct sockaddr *)&fromCmd, sizeof(struct sockaddr_in));

这个 2012 年的旧问题类似,但在更旧版本的 uncrustify 中存在并且没有解决方案: 解脱脱壳折叠多行函数调用 今天有解决方案吗?

2020-07-27- 我试图发表评论,但它限制了我基本上没有任何价值。所以我正在更新我原来的问题.... 奇怪 - 在我的配置文件中找不到nl_func_call_args....但这是:

# Whether to add a newline after each ',' in a function call if '(' and ')'
# are in different lines.
nl_func_call_args_multi_line    = false    # true/false

请注意,这些选项不允许"删除"。 在我回到 .67 的所有配置文件中进行搜索找不到nl_func_call_args.如果删除任何 .uncrustify.cfg 并运行 uncrustify --update-config 将找不到nl_func_call_args。当我获得新版本的 uncrustify 时,我总是运行默认值并分析更改的内容。这是我信任配置的唯一方法。我最初的问题仍然存在。这是关于为 C 代码创建标准。我看到很多疯狂的函数调用格式,尤其是近年来。使其成形的唯一方法是首先删除所有多行废话。然后,如果需要,我可以编辑为更好的格式。否则,我正在编辑每条臭行。为了记录,我从1981年开始写C,几乎100%遵守K&R。我有一些偏差。我也使用 VI,所以原始 VI 中的所有格式功能我仍然希望代码遵守,以便此编辑器正常工作。 问候 奥尔杜尼克斯盖

# Add or remove newline after each ',' in a function call.
nl_func_call_args               = remove   # ignore/add/remove/force

该选项于 2016-06-27 (796b5ba5( 引入