When using indent(1) to indent source code, unrecognized tokens such as "0b00101010" are split (e.g. "0b 00101010"). Such constructs are however valid using avr-gcc from the ports, and upcoming releases of gcc will support this binary notation [1]. References: 1. As noticed by Frank Behrens: http://lists.freebsd.org/pipermail/freebsd-hackers/2008-April/024343.html Fix: The following patch attempt to detect numbers in different bases, assert it is valid, but avoid splitting tokens on unrecognized data: How-To-Repeat: % echo "int x = 0b00101010 ;" > foo.c % avr-gcc -c foo.c % indent foo.c % avr-gcc -c foo.c foo.c:1: error: expected ',' or ';' before 'b00101010' % cat foo.c int x = 0 b00101010;
FWIW, Our base GCC 4.2 brought support for binary constants in r255107. Such constructs are used in Mesa. With the patch as-is, indent would be able to break valid code as pointed out by Peter Jeremy in: https://lists.freebsd.org/pipermail/freebsd-hackers/2008-April/024336.html The fix doesn't look trivial.
A commit references this bug: Author: pstef Date: Thu May 18 17:15:59 UTC 2017 New revision: 318471 URL: https://svnweb.freebsd.org/changeset/base/318471 Log: indent(1): Support binary integer literals. This was done by Romain Tarti?re for PR123553. I initially thought that it would break code like this: #define b00101010 -1 if (0 b00101010) ... by joining 0 and b00101010 together. However, the real problem with that patch was that once it saw a 0, it assumed that the number was base r2, 8 or 16, ignoring base r10 floating point numbers. I fixed that. I didn't copy the diagnostic part of the original patch as it seems out of scope of implementing binary integer literals formatting. PR: 123553 Submitted by: romain (original version) Approved by: pfg (mentor) Changes: head/usr.bin/indent/lexi.c head/usr.bin/indent/tests/Makefile head/usr.bin/indent/tests/binary.0 head/usr.bin/indent/tests/binary.0.stdout
Committed as r318471.