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