.uncrustify.cfg 6.7 KB

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