简体   繁体   English

uncrustify:如何将 arguments 的多行 C function 调用组合到单行?

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

I am using uncrustify 0.69.0 (I can't get 0.71.0 to compile yet).我正在使用 uncrustify 0.69.0(我还无法编译 0.71.0)。 I have the following:我有以下内容:

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

And I want uncrustify to combine them to a single line:我希望 unrustify 将它们组合成一行:

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

This old 2012 question is similar but existed during a much older version of uncrustify and did not have a solution: Uncrustify Collapse Multiline Function Call Is there a solution today?这个 2012 年的老问题很相似,但存在于更旧版本的 uncrustify 中并且没有解决方案: Uncrustify Collapse Multiline Function Call今天有解决方案吗?

2020-07-27- I tried to make a comment but it limited me to mostly nothing of value. 2020-07-27- 我试图发表评论,但它限制了我几乎没有任何价值。 So I'm updating my original question.... strange- nl_func_call_args is not found in my config files.... but this is:所以我正在更新我原来的问题......奇怪 - 在我的配置文件中找不到 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

Notice that the options dont allow to "delete".请注意,选项不允许“删除”。 Doing a search in all the config files I have back to.67 does not find nl_func_call_args.在我返回的所有配置文件中进行搜索。67 没有找到 nl_func_call_args。 if one removes any.uncrustify.cfg and runs uncrustify --update-config one will NOT find nl_func_call_args.如果删除 any.uncrustify.cfg 并运行 uncrustify --update-config 将找不到 nl_func_call_args。 When I get a new version of uncrustify I ALWAYS run a default and analyze what changed.当我获得新版本的 uncrustify 时,我总是运行默认设置并分析发生了什么变化。 This is the only way I can trust the configs.这是我可以信任配置的唯一方法。 My original question still stands.我原来的问题仍然存在。 This is about creating a standard for C code.这是关于为 C 代码创建标准。 I see a LOT of crazy function call formatting, especially in recent years.我看到很多疯狂的 function 调用格式,尤其是近年来。 The only way to get it into shape is to FIRST remove all the multiline crap.使其成形的唯一方法是首先删除所有多行废话。 Then I can edit if needed to a better format.然后我可以根据需要编辑为更好的格式。 Otherwise I'm editing EVERY STINKING line.否则,我正在编辑每一行。 For the record I have been writing C since 1981 and almost 100% adhere to K&R.作为记录,我自 1981 年以来一直在写 C,几乎 100% 坚持 K&R。 I have a handful of deviations.我有一些偏差。 I also use VI so ALL of the format features that were in the original VI I still want code to adhere to so this editor will work properly.我也使用 VI,所以我仍然希望代码遵守原始 VI 中的所有格式功能,这样这个编辑器才能正常工作。 regards oldunixguy关于oldunixguy

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

That option was introduced on 2016-06-27 (796b5ba5)该选项于 2016-06-27 (796b5ba5) 引入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM