Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Mar 2016 08:47:33 +0100
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        Bryan Drewery <bdrewery@FreeBSD.org>
Cc:        Pietro Cerutti <gahr@FreeBSD.org>, Matthew Seaman <matthew@freebsd.org>, freebsd-hackers@freebsd.org, owner-freebsd-hackers@freebsd.org
Subject:   Re: Code Formatter for STYLE(9)?
Message-ID:  <20160325074733.GA36953@ivaldir.etoilebsd.net>
In-Reply-To: <56F48322.9030208@FreeBSD.org>
References:  <56F3EBB1.1060603@embedded-brains.de> <56F3FFB3.6070801@FreeBSD.org> <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> <56F48322.9030208@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--GvXjxJ+pjyke8COw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Mar 24, 2016 at 05:15:30PM -0700, Bryan Drewery wrote:
> 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
>=20
> It's not quite right. It is adding {} to single-line if statements in
> some code.

Yes this is un purpose for pkg
>=20
> >  static __inline struct filemon *
> >  filemon_acquire(struct filemon *filemon)
> >  {
> > -
> > -       if (filemon !=3D NULL)
> > +       if (filemon !=3D NULL) {
> >                 refcount_acquire(&filemon->refcnt);
> > +       }
> >         return (filemon);
> >  }
>=20
> It's also not aware of our (silly?) blank line with no declarations rule:

I couldn't find how to make that
>=20
> >  static __inline void
> >  filemon_drop(struct filemon *filemon)
> >  {
> > -
> >         sx_xunlock(&filemon->lock);
> >         filemon_release(filemon);
> >  }
>=20
> And wrapping multiple conditions:
>=20
> > -       if (p->p_filemon !=3D NULL && p !=3D curproc)
> > +       if ((p->p_filemon !=3D NULL) && (p !=3D curproc)) {
> >                 return (EBUSY);
> > +       }

Same I couldn't find how to make that better
>=20
> It's also not respecting the wrap rule of tabs + 4 spaces.

same
>=20
> It's also adding random blank lines before functions and macros.

yup

The above reasons are why it has not been automatically used in pkg.
It is the closer I could get, I would be happy to get patches to improve

Best regards,
Bapt

--GvXjxJ+pjyke8COw
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJW9O0PAAoJEGOJi9zxtz5aRoEP/Rg8W8woYQ+qkchAV8QOVX3B
uSgqNqV03kmOT5ZvSGpwgKx4LWTZOnn2WglZiCGtflL+TkuYyVhw8D2hxznRgmsu
zsJakqkEGARRmW6GA/H7x3B+SEMUVGiV9IHEamGhtUEEtw2k+3Cn5jRFFny3JI3T
nGbgceEFewlhnDg1sco8VZIk9eFVE5Lbp72FPtW5AmOm2tN6XN4neUwj/SBT6QGl
Hykgrn+WYyV9k7J3OMqpX0HUQ/f+LZGl9oX7yGBKJ4R9SaImLvaSvVtIZoquRvok
ct/dFojkc5+wtb6bc48I3Kgu2EsOYg2rn91Q8t1ITvs6uCjrh5HxuWcbdoNx4wcr
BF5ewkilcGZE7yhFsfQJfoQCQ5HHoUGs+1/LVO7YCg2EGxTQJe3984hbqVacB72i
FqgIFstYh97gJWsdmPHgsLL7c+LX3oqdpC/fSOtQnZPIPcP2hnzB109mXZV7WfLz
Pfy22W1BLuxWMYZd4SD4qsmBYB1apyj9nK9dJOknsT/AJ93ALe2BXemHeFnHRNso
ezIak10QKEwDxpw02H33enwC3vH7DwQT+W+HEZjrAoUep9KuZbly5SqWwVUTleVA
OyxUPknmeyorpmj0kW3B6YriCgr16hx42RiH0AMwgkpXyXCjG9QPtTECZ1il1kDL
2Roq+EKfDD2+n5aVZpWW
=Wmj1
-----END PGP SIGNATURE-----

--GvXjxJ+pjyke8COw--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160325074733.GA36953>