Date: Thu, 24 Mar 2016 17:15:30 -0700 From: Bryan Drewery <bdrewery@FreeBSD.org> To: Pietro Cerutti <gahr@FreeBSD.org>, Matthew Seaman <matthew@freebsd.org> Cc: freebsd-hackers@freebsd.org, owner-freebsd-hackers@freebsd.org Subject: Re: Code Formatter for STYLE(9)? Message-ID: <56F48322.9030208@FreeBSD.org> In-Reply-To: <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> References: <56F3EBB1.1060603@embedded-brains.de> <56F3FFB3.6070801@FreeBSD.org> <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --tQwMehaBEknFFUx9HPnPrg81RIpWiGnGg Content-Type: multipart/mixed; boundary="NQG1e4DpeKdiMcLQlCH5V46sx6sKovkcl" From: Bryan Drewery <bdrewery@FreeBSD.org> To: Pietro Cerutti <gahr@FreeBSD.org>, Matthew Seaman <matthew@freebsd.org> Cc: freebsd-hackers@freebsd.org, owner-freebsd-hackers@freebsd.org Message-ID: <56F48322.9030208@FreeBSD.org> Subject: Re: Code Formatter for STYLE(9)? References: <56F3EBB1.1060603@embedded-brains.de> <56F3FFB3.6070801@FreeBSD.org> <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> In-Reply-To: <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> --NQG1e4DpeKdiMcLQlCH5V46sx6sKovkcl Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 3/24/2016 9:24 AM, Pietro Cerutti wrote: > On 2016-03-24 15:54, Matthew Seaman wrote: >> On 2016/03/24 13:29, Sebastian Huber wrote: >>> Hello, >>> >>> is there a ready to use C code formatter available that honours >>> STYLE(9)? I tried clang-format, but it knows only LLVM, Google, >>> Chromium, Mozilla by default. The GNU indent --original seems to prod= uce >>> nothing usable. Same problem with astyle --style=3Dbsd. >>> >> >> pkg uses uncrustify with this config file: >> >> https://github.com/freebsd/pkg/blob/master/freebsd.cfg >> >> It's approximately what style(9) describes but doesn't cover things li= ke >> sorting include files and I don't think it was updated in response to >> the recent change allowing { brackets } around certain single-line >> statements. >=20 > It looks like it does: https://github.com/freebsd/pkg/commit/1bc61a4 >=20 It's not quite right. It is adding {} to single-line if statements in some code. > static __inline struct filemon * > filemon_acquire(struct filemon *filemon) > { > - > - if (filemon !=3D NULL) > + if (filemon !=3D NULL) { > refcount_acquire(&filemon->refcnt); > + } > return (filemon); > } It's also not aware of our (silly?) blank line with no declarations rule:= > static __inline void > filemon_drop(struct filemon *filemon) > { > - > sx_xunlock(&filemon->lock); > filemon_release(filemon); > } And wrapping multiple conditions: > - if (p->p_filemon !=3D NULL && p !=3D curproc) > + if ((p->p_filemon !=3D NULL) && (p !=3D curproc)) { > return (EBUSY); > + } It's also not respecting the wrap rule of tabs + 4 spaces. It's also adding random blank lines before functions and macros. It found a useless 'return;' at least. --=20 Regards, Bryan Drewery --NQG1e4DpeKdiMcLQlCH5V46sx6sKovkcl-- --tQwMehaBEknFFUx9HPnPrg81RIpWiGnGg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJW9IMiAAoJEDXXcbtuRpfPU1cH/ixdr8/rNMbe1OdzqRkFbQlw jYbi/LkxEdKE34e4wSEwz4prvOYp19Tv1gFirzuPWQvIBQE0wJW9wrE9InF0t2xQ qZSunrxiTu1+YbdpuJyV59B9YN3khNkyAvEyHV3tJpFOgv1TRaslPJNt9ItozE0j 3m185vII0KUx19VwYfqniFR0iKm98bqbBau1WJ7EjLusqNgN/zz+422Qu/+Snv9T eOIWFocMjAJFqU+HQTQl59HmhtQVk7icd3oWHA6fPX7nb9SUBVhQmF+D2KkFN1Y9 pa+DAeB8njSg4ZYQlasvlnDkuKitnQw+elSatWELCU9LondZkwoF68QGgBLnqIg= =W3pr -----END PGP SIGNATURE----- --tQwMehaBEknFFUx9HPnPrg81RIpWiGnGg--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56F48322.9030208>