From bdd90adfa25f3a3777690c124f9be16eaa7bfaef Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 17 May 2021 23:50:34 +0200 Subject: [PATCH] - astyle: align options; add projects script --- support/scripts/astyle-project.sh | 29 +++++++++++++++++++++++++++++ support/scripts/astyle.sh | 7 ++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 support/scripts/astyle-project.sh diff --git a/support/scripts/astyle-project.sh b/support/scripts/astyle-project.sh new file mode 100755 index 00000000..22feaa42 --- /dev/null +++ b/support/scripts/astyle-project.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# +# astyle-project.sh - Formatting source code using astyle +# +# Copyright (C) 2021 Sven Hoefer +# License: WTFPLv2 +# + +usage() { + echo "Usage: astyle-project.sh " +} + +test "$1" == "--help" && { usage; exit 0; } +test -z "$1" && { usage; exit 1; } + +type astyle.sh >/dev/null 2>&1 || { echo >&2 "astyle.sh required. Aborting."; exit 1; } + +PROJECT=$1 + +files=$(find ${PROJECT}/ -type f -name '*.c' -or -name '*.cpp' -or -name '*.h') + +if [ -z "$files" ]; then + exit 0 +fi + +for file in $files; do + astyle.sh $file + dos2unix -k $file +done diff --git a/support/scripts/astyle.sh b/support/scripts/astyle.sh index f5ddf519..34bcd352 100755 --- a/support/scripts/astyle.sh +++ b/support/scripts/astyle.sh @@ -21,17 +21,22 @@ for file in $@; do --style=allman \ --formatted -v \ \ - --indent=force-tab=8 \ + --convert-tabs \ + --indent=tab \ --indent-classes \ --indent-preproc-define \ --indent-switches \ + --indent-after-parens \ --max-instatement-indent=80 \ --lineend=linux \ \ --unpad-paren \ \ --pad-oper \ + --pad-comma \ --pad-header \ + --pad-param-type \ + --attach-return-type-decl \ \ --align-pointer=name \ \