[Parted-edge] [PATCH] Create the needed infra-structure to enforce the coding style
Leandro Dorileo
ldorileo at gmail.com
Wed Apr 18 03:06:01 UTC 2007
Hi Otavio
This script must be used very carefully cause it can make a lot of unneeded
changes and it may cause some confusion while looking the git repository
history being hard to track some changes. I did a test here in my local
repository and a git diff told me that it changed/reindented a lot of files.
I suggest to run it once (now for example) in the whole tree and before
commiting each patch (after have applied it) from now on. Look, I may haven`t
understood it`s purpose well.
[]`s
--
Dorileo
On Tuesday 17 April 2007 20:59, Otavio Salvador wrote:
> From: Otavio Salvador <otavio at ossystems.com.br>
>
> To enforce the coding style we'll use this infra-structure. It
> currently uses astyle for code formating and provides a 'format-code'
> Makefile target that does the indentation.
>
> This new infra-structure has:
>
> o scripts/enforce-coding-style: script that runs astyle;
> o Makefile.am: provides the 'format-code' target;
>
> Signed-off-by: Otavio Salvador <otavio at ossystems.com.br>
> ---
> Makefile.am | 3 +++
> scripts/enforce-coding-style | 37 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 0f6318c..5f7cace 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -1,3 +1,6 @@
> SUBDIRS = src test
>
> EXTRA_DIST = AUTHORS TODO README configure
> +
> +format-code:
> + scripts/enforce-coding-style
> \ No newline at end of file
> diff --git a/scripts/enforce-coding-style b/scripts/enforce-coding-style
> new file mode 100755
> index 0000000..7715cd3
> --- /dev/null
> +++ b/scripts/enforce-coding-style
> @@ -0,0 +1,37 @@
> +#!/bin/sh
> +
> +##########################################################################
>## +# Copyright (c) 2006, 2007 O.S. Systems
> +# Copyright (c) 2007 Free Software Foundation, Inc.
> +#
> +# Author: Otavio Salvador <otavio at ossystems.com.br>
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +# General Public License for more details.
> +##########################################################################
>## +
> +if [ ! -x /usr/bin/astyle ]; then
> + echo "ERROR: You need to have astyle installed."
> + exit 1
> +fi
> +
> +astyle --mode=c \
> + --indent=spaces=4 \
> + --indent-classes \
> + --indent-switches \
> + --indent-cases \
> + --indent-namespaces \
> + --brackets=linux \
> + -p \
> + --convert-tabs \
> + --break-blocks \
> + --break-blocks=all \
> + $(find . -iname '*.h' -o -iname '*.c' -o -iname '*.hpp' -o \
> + -iname '*.cpp' -o -iname '*.cc')
More information about the Parted-edge
mailing list