1# Configuration options for Uncrustify specifying the Mbed TLS code style.
2#
3# Note: The code style represented by this file has not yet been introduced
4# to Mbed TLS.
5#
6# Copyright The Mbed TLS Contributors
7# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
8
9
10# Wrap lines at 100 characters
11code_width = 100
12
13# Allow splitting long for statements between the condition statements
14ls_for_split_full = true
15
16# Allow splitting function calls between arguments
17ls_func_split_full = true
18
19input_tab_size = 4
20
21# Spaces-only indentation
22indent_with_tabs = 0
23
24indent_columns = 4
25
26# Indent 'case' 1 level from 'switch'
27indent_switch_case = indent_columns
28
29# Line-up strings broken by '\'
30indent_align_string = true
31
32# Braces on the same line (Egyptian-style braces)
33nl_enum_brace = remove
34nl_union_brace = remove
35nl_struct_brace = remove
36nl_do_brace = remove
37nl_if_brace = remove
38nl_for_brace = remove
39nl_else_brace = remove
40nl_while_brace = remove
41nl_switch_brace = remove
42
43# Braces on same line as keywords that follow them - 'else' and the 'while' in 'do {} while ()';
44nl_brace_else = remove
45nl_brace_while = remove
46# Space before else on the same line
47sp_brace_else = add
48# If else is on the same line as '{', force exactly 1 space between them
49sp_else_brace = force
50
51# Functions are the exception and have braces on the next line
52nl_fcall_brace = add
53nl_fdef_brace = add
54
55# Force exactly one space between ')' and '{' in statements
56sp_sparen_brace = force
57
58# At least 1 space around assignment
59sp_assign = add
60
61# Remove spaces around the preprocessor '##' token-concatenate
62sp_pp_concat = ignore
63
64# At least 1 space around '||' and '&&'
65sp_bool = add
66
67# But no space after the '!' operator
68sp_not = remove
69
70# No space after the bitwise-not '~' operator
71sp_inv = remove
72
73# No space after the addressof '&' operator
74sp_addr = remove
75
76# No space around the member '.' and '->' operators
77sp_member = remove
78
79# No space after the dereference '*' operator
80sp_deref = remove
81
82# No space after a unary negation '-'
83sp_sign = remove
84
85# No space between the '++'/'--' operator and its operand
86sp_incdec = remove
87
88# At least 1 space around comparison operators
89sp_compare = add
90
91# Remove spaces inside all kinds of parentheses:
92
93# Remove spaces inside parentheses
94sp_inside_paren = remove
95
96# No spaces inside statement parentheses
97sp_inside_sparen = remove
98
99# No spaces inside cast parentheses '( char )x' -> '(char)x'
100sp_inside_paren_cast = remove
101
102# No spaces inside function parentheses
103sp_inside_fparen = remove
104# (The case where the function has no parameters/arguments)
105sp_inside_fparens = remove
106
107# No spaces inside the first parentheses in a function type
108sp_inside_tparen = remove
109
110# (Uncrustify >= 0.74.0) No spaces inside parens in for statements
111sp_inside_for = remove
112
113# Remove spaces between nested parentheses '( (' -> '(('
114sp_paren_paren = remove
115# (Uncrustify >= 0.74.0)
116sp_sparen_paren = remove
117
118# Remove spaces between ')' and adjacent '('
119sp_cparen_oparen = remove
120
121# (Uncrustify >= 0.73.0) space between 'do' and '{'
122sp_do_brace_open = force
123
124# (Uncrustify >= 0.73.0) space between '}' and 'while'
125sp_brace_close_while = force
126
127# At least 1 space before a '*' pointer star
128sp_before_ptr_star = add
129
130# Remove spaces between pointer stars
131sp_between_ptr_star = remove
132
133# No space after a pointer star
134sp_after_ptr_star = remove
135
136# But allow a space in the case of e.g. char * const x;
137sp_after_ptr_star_qualifier = ignore
138
139# Remove space after star in a function return type
140sp_after_ptr_star_func = remove
141
142# At least 1 space after a type in variable definition etc
143sp_after_type = add
144
145# Force exactly 1 space between a statement keyword (e.g. 'if') and an opening parenthesis
146sp_before_sparen = force
147
148# Remove a space before a ';'
149sp_before_semi = remove
150# (Uncrustify >= 0.73.0) Remove space before a semi in a non-empty for
151sp_before_semi_for = remove
152# (Uncrustify >= 0.73.0) Remove space in empty first statement of a for
153sp_before_semi_for_empty = remove
154# (Uncrustify >= 0.74.0) Remove space in empty middle statement of a for
155sp_between_semi_for_empty = remove
156
157# Add a space after a ';' (unless a comment follows)
158sp_after_semi = add
159# (Uncrustify >= 0.73.0) Add a space after a semi in non-empty for statements
160sp_after_semi_for = add
161# (Uncrustify >= 0.73.0) No space after final semi in empty for statements
162sp_after_semi_for_empty = remove
163
164# Remove spaces on the inside of square brackets '[]'
165sp_inside_square = remove
166
167# Must have at least 1 space after a comma
168sp_after_comma = add
169
170# Must not have a space before a comma
171sp_before_comma = remove
172
173# No space before the ':' in a case statement
174sp_before_case_colon = remove
175
176# Must have space after a cast - '(char)x' -> '(char) x'
177sp_after_cast = add
178
179# No space between 'sizeof' and '('
180sp_sizeof_paren = remove
181
182# At least 1 space inside '{ }'
183sp_inside_braces = add
184
185# At least 1 space inside '{ }' in an enum
186sp_inside_braces_enum = add
187
188# At least 1 space inside '{ }' in a struct
189sp_inside_braces_struct = add
190
191# At least 1 space between a function return type and the function name
192sp_type_func = add
193
194# No space between a function name and its arguments/parameters
195sp_func_proto_paren = remove
196sp_func_def_paren = remove
197sp_func_call_paren = remove
198
199# No space between '__attribute__' and '('
200sp_attribute_paren = remove
201
202# No space between 'defined' and '(' in preprocessor conditions
203sp_defined_paren = remove
204
205# At least 1 space between a macro's name and its definition
206sp_macro = add
207sp_macro_func = add
208
209# Force exactly 1 space between a '}' and the name of a typedef if on the same line
210sp_brace_typedef = force
211
212# At least 1 space before a '\' line continuation
213sp_before_nl_cont = add
214
215# At least 1 space around '?' and ':' in ternary statements
216sp_cond_colon = add
217sp_cond_question = add
218
219# Space between #else/#endif and comment afterwards
220sp_endif_cmt = add
221
222# Remove newlines at the start of a file
223nl_start_of_file = remove
224
225# At least 1 newline at the end of a file
226nl_end_of_file = add
227nl_end_of_file_min = 1
228
229# Add braces in single-line statements
230mod_full_brace_do = add
231mod_full_brace_for = add
232mod_full_brace_if = add
233mod_full_brace_while = add
234
235# Remove parentheses from return statements
236mod_paren_on_return = remove
237
238# Disable removal of leading spaces in a multi-line comment if the first and
239# last lines are the same length
240cmt_multi_check_last = false
241