indent(1) support for gcc(1) 0b prefix
kientzle at freebsd.org
Fri May 2 04:57:49 UTC 2008
>>>But I would like to use indent(1) to reformat contributed code
>>>automatically. Unfortunately, the 0b notation is not supported by that
>>>program, and the resulting code looks like this:
>>> foo = 0 b00101010;
>>>... then compilation fails, bla bla bla...
>>I can't think of a case (outside of "0x...." context) where "...0b..."
>>would be valid C code, let alone better formated as "...0 b...".
>>Hence I see no harm in adding your patch to the base indent(1).
>>Does anyone have an example where "...0 b..." is valid C code?
> The only case I can think of is when the "b..." is an existing macro,
> i.e. something like:
> 1 #include <stdio.h>
> 3 #define b0101 + 3
In all of these cases, though, adding a space between the '0' and
the 'b' changes the meaning, so is wrong. Indent can
change/insert whitespace, but should never do so in a way that
changes the meaning of the program. In all of these cases,
having indent recognize "0b..." as a single token is the
So I don't see any point in having this recognition be
tunable. indent already has too many switches.
More information about the freebsd-hackers