From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4Y8f-00076B-V6 for qemu-devel@nongnu.org; Fri, 16 Sep 2011 09:07:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4Y8e-0000zJ-NN for qemu-devel@nongnu.org; Fri, 16 Sep 2011 09:07:29 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:33690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4Y8e-0000zA-Jf for qemu-devel@nongnu.org; Fri, 16 Sep 2011 09:07:28 -0400 Received: by ywm39 with SMTP id 39so3520749ywm.4 for ; Fri, 16 Sep 2011 06:07:28 -0700 (PDT) Message-ID: <4E734A0D.3010309@codemonkey.ws> Date: Fri, 16 Sep 2011 08:07:25 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1315760411-26359-1-git-send-email-weil@mail.berlios.de> In-Reply-To: <1315760411-26359-1-git-send-email-weil@mail.berlios.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Add astyle option file for code formatting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: qemu-devel@nongnu.org On 09/11/2011 12:00 PM, Stefan Weil wrote: > For new C code (and maybe also for existing code), a code formatter > like Artistic Style is helpful because it can fix tabs, indentation > and other style issues. > > This option file tries to set astyle options which match QEMU's > coding conventions. > > The quality of astyle's code formatting depends on the astyle version > (I got best results with newer versions) and on the code which is going > to be formatted. > > For some code, formatting of brackets and operators does not work well. > Fixing indentation and tabs always worked well for me. > > Signed-off-by: Stefan Weil > --- > scripts/astylerc | 16 ++++++++++++++++ > 1 files changed, 16 insertions(+), 0 deletions(-) > create mode 100644 scripts/astylerc > > diff --git a/scripts/astylerc b/scripts/astylerc > new file mode 100644 > index 0000000..dcf9e3f > --- /dev/null > +++ b/scripts/astylerc > @@ -0,0 +1,16 @@ > +# Artistic Style (astyle) options for qemu source code. > + > +# Usage: > +# astyle --options=scripts/astylerc {source files} > + > +# For best results, use latest astyle from http://astyle.sourceforge.net/. Please put a copyright in this file. FWIW, this is what I use with emacs: (c-add-style "qemu" '("stroustrup" (indent-tabs-mode . nil) (c-basic-offset . 4) (tab-width . 8) ) nil) ; t = set this style, nil = don't Regards, Anthony Liguori > + > +add-brackets > +align-pointer=name > +convert-tabs > +style=otbs > +brackets=linux > +indent=spaces=4 > +pad-oper > +pad-header > +unpad-paren