开发者

How to avoid misformatting of binary values with GNU indent?

开发者 https://www.devze.com 2022-12-13 00:12 出处:网络
When GNU indent (at least version 2.2.6 and 2.2.10) is used on the following code... void main () { int i = 0b01010101;

When GNU indent (at least version 2.2.6 and 2.2.10) is used on the following code...

void
main ()
{
  int i = 0b01010101;
}

it wi开发者_如何学编程ll be reformatted into this ...

void
main ()
{
  int i = 0 b01010101;
}

Is there any option in indent that avoids this behavior?


I got an answer to this question on the indent mailing list:

No intent doesn't support C derivatives: that construct isn't C.

The Binary constants using the `0b' prefix is just an extension of gcc.


#!/bin/sh

indent | sed -r 's/(0) (b[01]+)/\1\2/g'
0

精彩评论

暂无评论...
验证码 换一张
取 消