From 5075494e42c137adbacfb2187c688d2b8a29c351 Mon Sep 17 00:00:00 2001 From: "Yury V. Zaytsev" Date: Sun, 18 Oct 2015 12:51:31 +0200 Subject: [PATCH] maint: import a tool to check source code indentation style Signed-off-by: Yury V. Zaytsev --- maint/utils/check-indent.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 maint/utils/check-indent.sh diff --git a/maint/utils/check-indent.sh b/maint/utils/check-indent.sh new file mode 100755 index 000000000..daa612ad3 --- /dev/null +++ b/maint/utils/check-indent.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Midnight Commander - check source code indentation +# +# Copyright (C) 2015 +# The Free Software Foundation, Inc. +# +# Written by: +# Slava Zanko , 2015 +# +# This file is part of the Midnight Commander. +# +# The Midnight Commander 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 3 of the License, +# or (at your option) any later version. +# +# The Midnight Commander 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e +set -x + +findUnindentedFiles() { + local directory=$1 + find "${directory}" -name '*.[ch]' -print0 | \ + xargs -0 indent \ + --gnu-style \ + --format-first-column-comments \ + --indent-level4 \ + --brace-indent0 \ + --line-length100 \ + --no-tabs \ + --blank-lines-after-procedures + return $(git ls-files --modified | wc -l) +} + +( findUnindentedFiles "lib" && findUnindentedFiles "src" && findUnindentedFiles "tests" ) || { + echo "Sources not indented" + git ls-files --modified + exit 1 +} -- 2.11.4.GIT