From 9af2fd03c7062cc37f77667fa46866da38e38139 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 9 Nov 2011 10:25:10 +0100 Subject: [PATCH 1/1] Add a script running GNU indent with the appropriate options. The set of options was given by README.coding which is also updated. --- README.coding | 6 +++--- tools/indent | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100755 tools/indent diff --git a/README.coding b/README.coding index 2a8302a1d7..791d365839 100644 --- a/README.coding +++ b/README.coding @@ -66,9 +66,9 @@ The tree is not splited on projects, but on file finality: Most files use the Kernighan & Ritchie coding style with 2 spaces of indentation. The indent program can help you to stick to it: -indent -kr -br -brs -ce -bbo --dont-break-procedure-type --no-tabs ---cuddle-do-while --cuddle-else --indent-level2 --leave-preprocessor-space ---no-space-after-function-call-names +indent -kr -l80 -nut -i2 -lps -npcs -br -brs -ce -cdw -bbo -npsl + +The script ./tools/indent runs indent with the appropriate options. FIXME: this list of arguments is still to be discussed, maybe diff --git a/tools/indent b/tools/indent new file mode 100755 index 0000000000..8e37750474 --- /dev/null +++ b/tools/indent @@ -0,0 +1,19 @@ +#!/bin/bash + +declare -a OPTIONS +OPTIONS=( + -kr # Use Kernighan & Ritchie coding style. + -l80 # Set maximum line length for non-comment lines to 80. + -nut # Use spaces instead of tabs. + -i2 # Set indentation level to 2 spaces. + -lps # Leave space between ‘#’ and preprocessor directive. + -npcs # Do not put space after the function in function calls. + -br # Put braces on line with if, etc. + -brs # Put braces on struct declaration line. + -ce # Cuddle else and preceding ‘}’. + -cdw # Cuddle while of do {} while; and preceding ‘}’. + -bbo # Prefer to break long lines before boolean operators. + -npsl # Put the type of a procedure on the same line as its name. +) + +exec indent "${OPTIONS[@]}" "$@" -- 2.20.1