All of lore.kernel.org
 help / color / mirror / Atom feed
From: Don Slutz <dslutz@verizon.com>
To: "Mihai Donțu" <mdontu@bitdefender.com>, xen-devel@lists.xensource.com
Subject: Re: [PATCH 3/3] xen/tools: script for automatically adjusting the coding style to xen style
Date: Wed, 10 Sep 2014 10:21:48 -0400	[thread overview]
Message-ID: <54105E7C.1090500@terremark.com> (raw)
In-Reply-To: <1410229929-14052-1-git-send-email-mdontu@bitdefender.com>


On 09/08/14 22:32, Mihai Donțu wrote:
> This is a clang-format wrapper script that can be used to do the bulk of the
> coding style work on a foreign source file. It is not yet complete, but it's
> sufficient for 98% of the cases.
>
> Signed-off-by: Mihai Donțu <mdontu@bitdefender.com>
> ---
>   xen/tools/xen-indent | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 77 insertions(+)
>   create mode 100755 xen/tools/xen-indent
>
> diff --git a/xen/tools/xen-indent b/xen/tools/xen-indent
> new file mode 100755
> index 0000000..6be507c
> --- /dev/null
> +++ b/xen/tools/xen-indent
> @@ -0,0 +1,77 @@
> +#!/bin/sh
> +
> +CLANG_FORMAT=`which clang-format 2>/dev/null`
> +
> +if [ "x$CLANG_FORMAT" = "x" ]; then
> +	printf "Error: \`clang-format' is not installed. It is usually part of clang (3.4 and newer)\n" >&2
> +	exit 1
> +fi
> +
> +if [ "x$1" = "x" ]; then
> +	printf "Usage: $0 <file[s]>\n"
> +	exit 2
> +fi
> +
> +for i in $@; do
> +	DN=`dirname "$i"`
> +	cat >"$DN/.clang-format" <<EOF
> +---
> +AccessModifierOffset:                           -8
> +IndentWidth:                                    4
> +TabWidth:                                       4
> +ConstructorInitializerIndentWidth:              4
> +AlignEscapedNewlinesLeft:                       true
> +AlignTrailingComments:                          true
> +AllowAllParametersOfDeclarationOnNextLine:      true
> +AllowShortIfStatementsOnASingleLine:            false
> +AllowShortLoopsOnASingleLine:                   false
> +AllowShortFunctionsOnASingleLine:               false
> +AlwaysBreakTemplateDeclarations:                false
> +AlwaysBreakBeforeMultilineStrings:              false
> +BreakBeforeBinaryOperators:                     false
> +BreakBeforeTernaryOperators:                    true
> +BreakConstructorInitializersBeforeComma:        false
> +BinPackParameters:                              true
> +ColumnLimit:                                    80
> +ConstructorInitializerAllOnOneLineOrOnePerLine: false
> +DerivePointerBinding:                           false
> +ExperimentalAutoDetectBinPacking:               false
> +IndentCaseLabels:                               false
> +MaxEmptyLinesToKeep:                            1
> +NamespaceIndentation:                           All
> +ObjCSpaceBeforeProtocolList:                    true
> +PenaltyBreakBeforeFirstCallParameter:           19
> +PenaltyBreakComment:                            60
> +PenaltyBreakString:                             1000
> +PenaltyBreakFirstLessLess:                      120
> +PenaltyExcessCharacter:                         1000000
> +PenaltyReturnTypeOnItsOwnLine:                  60
> +PointerBindsToType:                             false
> +SpacesBeforeTrailingComments:                   1
> +Cpp11BracedListStyle:                           false
> +Standard:                                       Cpp11
> +UseTab:                                         Never
> +BreakBeforeBraces:                              Allman
> +IndentFunctionDeclarationAfterType:             false
> +SpaceBeforeParens:                              ControlStatements
> +SpacesInParentheses:                            false
> +SpacesInAngles:                                 false
> +SpaceInEmptyParentheses:                        false
> +SpacesInCStyleCastParentheses:                  false
> +SpaceAfterControlStatementKeyword:              true
> +SpaceBeforeAssignmentOperators:                 true
> +ContinuationIndentWidth:                        4
> +EOF
> +	ERR=0
> +	$CLANG_FORMAT "$i" >"${i}.clang-tmp" || ERR=1
> +	rm -f "$DN/.clang-format"
> +	if [ $ERR -ne 0 ]; then
> +		rm -f "${i}.clang-tmp"
> +		exit 3
> +	fi
> +	sed 's#if\s*(\(.*\))#if ( \1 )#m' "${i}.clang-tmp" >"${i}.clang-tmp.1"
> +	sed 's#switch\s*(\(.*\))#switch ( \1 )#m' "${i}.clang-tmp.1" >"${i}.clang-tmp.2"
> +	sed 's#while\s*(\(.*\))#while ( \1 )#m' "${i}.clang-tmp.2" >"${i}.clang-tmp.3"

This is missing "for".  And last I knew sed does not handle multiple lines.

And what about the "do {" exception?

     -Don Slutz

> +	mv -f "${i}.clang-tmp.3" "${i}"
> +	rm -f "${i}.clang-tmp" "${i}.clang-tmp.1" "${i}.clang-tmp.2"
> +done


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2014-09-10 14:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09  2:22 [PATCH 0/3] xen: add support for skipping the current instruction Mihai Donțu
2014-09-09  2:28 ` [PATCH 1/3] x86: add support for computing the instruction length Mihai Donțu
2014-09-09  8:47   ` Mihai Donțu
2014-09-09  9:44     ` Mihai Donțu
2014-09-09 10:13       ` Masami Hiramatsu
2014-09-09 15:46         ` Mihai Donțu
2014-09-09 16:01           ` Mihai Donțu
2014-09-09 16:25             ` Jan Beulich
2014-09-09 17:14               ` Andrew Cooper
2014-09-09 17:27               ` Mihai Donțu
2014-09-09 17:57               ` Konrad Rzeszutek Wilk
2014-09-09  2:29 ` [PATCH 2/3] x86/hvm: implement hvm_get_insn_length() Mihai Donțu
2014-09-09  2:32 ` [PATCH 3/3] xen/tools: script for automatically adjusting the coding style to xen style Mihai Donțu
2014-09-09 14:50   ` Ian Campbell
2014-09-09 15:00     ` Andrew Cooper
2014-09-09 19:52     ` Tim Deegan
2014-09-10 10:59     ` Don Slutz
2014-09-10 14:21   ` Don Slutz [this message]
2014-09-09  9:47 ` [PATCH 0/3] xen: add support for skipping the current instruction Jan Beulich
2014-09-09 17:00   ` Mihai Donțu
2014-09-09 18:58     ` Tamas K Lengyel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54105E7C.1090500@terremark.com \
    --to=dslutz@verizon.com \
    --cc=mdontu@bitdefender.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.