qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] astyle: Formatting rules for QEMU


From: Blue Swirl
Subject: Re: [Qemu-devel] [PATCH] astyle: Formatting rules for QEMU
Date: Sat, 18 Feb 2012 10:10:33 +0000

On Sat, Feb 18, 2012 at 09:07, Stefan Weil <address@hidden> wrote:
> These AStyle rules try to implement the QEMU coding style.
>
> AStyle can also fix only certain aspects of the coding style,
> for example indentation.
>
> Signed-off-by: Stefan Weil <address@hidden>
> ---
>
> Hi Blue,
>
> maybe this AStyle rules work better. I tried them with target-sparc,
> and the result does look quite good.

There are still indentation problems when expressions continue to next
line, also this does not look OK:
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -36,7 +36,7 @@

 #define DYNAMIC_PC  1 /* dynamic pc value */
 #define JUMP_PC     2 /* dynamic pc value which takes only two values
-                         according to jump_pc[T2] */
+according to jump_pc[T2] */

Moving the brace to same line as switch case should not be necessary.

Overall astyle seems to be a better tool than GNU indent.

I also tried to use Emacs to perform the indenting with the attached
scripts, but the result is not that great either, especially some
macros and helper.h confuse indentation.

> Regards,
> Stefan
>
>  scripts/astylerc |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
>  create mode 100644 scripts/astylerc
>
> diff --git a/scripts/astylerc b/scripts/astylerc
> new file mode 100644
> index 0000000..dfbfd41
> --- /dev/null
> +++ b/scripts/astylerc
> @@ -0,0 +1,19 @@
> +# 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/.
> +
> +add-brackets
> +align-pointer=name
> +convert-tabs
> +max-code-length=80

This is only supported by the SVN HEAD, not even the download tarball offered.

> +style=otbs
> +brackets=linux
> +indent=spaces=4
> +max-code-length=80
> +max-instatement-indent=60
> +pad-oper
> +pad-header
> +unpad-paren
> --
> 1.7.9
>

Attachment: emacs_format_file
Description: Binary data

Attachment: emacs_format_file.el
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]