aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/uncrustify.cfg78
-rwxr-xr-xcontrib/uncrustify.sh14
2 files changed, 92 insertions, 0 deletions
diff --git a/contrib/uncrustify.cfg b/contrib/uncrustify.cfg
new file mode 100644
index 00000000..6ced05d7
--- /dev/null
+++ b/contrib/uncrustify.cfg
@@ -0,0 +1,78 @@
1input_tab_size = 2
2output_tab_size = 2
3
4indent_columns = 2
5indent_with_tabs = 0
6indent_case_brace = 2
7indent_label=0
8
9code_width=80
10#cmd_width=80
11
12# Leave most comments alone for now
13cmt_indent_multi=false
14sp_cmt_cpp_start=add
15
16sp_not=add
17
18sp_func_call_user_paren_paren=remove
19sp_inside_fparen=remove
20sp_after_cast=add
21
22ls_for_split_full=true
23ls_func_split_full=true
24ls_code_width=true
25
26# Arithmetic operations in wrapped expressions should be at the start
27# of the line.
28pos_arith=lead
29
30# Fully parenthesize boolean exprs
31mod_full_paren_if_bool=true
32
33# Braces should be on their own line
34nl_fdef_brace=add
35nl_enum_brace=add
36nl_struct_brace=add
37nl_union_brace=add
38nl_if_brace=add
39nl_brace_else=add
40nl_elseif_brace=add
41nl_while_brace=add
42nl_switch_brace=add
43
44# no newline between "else" and "if"
45nl_else_if=remove
46
47nl_func_paren=remove
48nl_assign_brace=remove
49
50# No extra newlines that cause noisy diffs
51nl_start_of_file=remove
52# If there's no new line, it's not a text file!
53nl_end_of_file=add
54
55sp_inside_paren = remove
56
57sp_arith = add
58sp_arith_additive = add
59
60# We want spaces before and after "="
61sp_before_assign = add
62sp_after_assign = add
63
64# we want "char *foo;"
65sp_after_ptr_star = remove
66sp_between_ptr_star = remove
67
68# we want "if (foo) { ... }"
69sp_before_sparen = add
70
71sp_inside_fparen = remove
72
73# add space before function call and decl: "foo (x)"
74sp_func_call_paren = add
75sp_func_proto_paren = add
76sp_func_proto_paren_empty = add
77sp_func_def_paren = add
78sp_func_def_paren_empty = add
diff --git a/contrib/uncrustify.sh b/contrib/uncrustify.sh
new file mode 100755
index 00000000..e8e05d3e
--- /dev/null
+++ b/contrib/uncrustify.sh
@@ -0,0 +1,14 @@
1#!/usr/bin/env bash
2
3set -eu
4
5DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6
7if ! uncrustify --version >/dev/null; then
8 echo "you need to install uncrustify for indentation"
9 exit 1
10fi
11
12find "$DIR/../src" \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) \
13 -exec uncrustify -c "$DIR/uncrustify.cfg" --replace --no-backup {} + \
14 || true