This patch adds a .clang-format file, along with instructions on how to use it.
I find the GNU coding style a little unfamiliar and easy to mess up. The clang-format tool can be used to clean up a lot of idiosyncratic things such as putting a space before the parentheses after a function call. Lex Spoon
commit 90246648487939fd72a4d07e27027ae84a222417 Author: Lex Spoon <[email protected]> Date: Tue Feb 27 16:43:15 2024 -0500 Add a .clang-format file diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..2611993f --- /dev/null +++ b/.clang-format @@ -0,0 +1,13 @@ +BasedOnStyle: GNU +IndentPPDirectives: BeforeHash +UseTab: Never +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^<config.h>' + Priority: -1 + - Regex: '"system.h"' + Priority: 1 + - Regex: '<.*>' + Priority: 2 + - Regex: '.*' + Priority: 3 diff --git a/README-hacking.md b/README-hacking.md index b5647fff..61dc454c 100644 --- a/README-hacking.md +++ b/README-hacking.md @@ -248,6 +248,24 @@ the function. In writing arithmetic comparisons, use "<" and "<=" rather than ">" and ">=" <https://public-inbox.org/git/[email protected]/>. + +You can use the `clang-format` command to reformat files +automatically. +It won't fix all style problems, but it can do things +like change tabs to spaces or insert spaces before the +parentheses in a function call. +There is a suitable `.clang-format` file in this repository, +so you can usually format an individual file as simply as +follows: + + clang-format -i YOURFILE.c + +Please do not reformat pre-existing files unless you are making +major changes to them. If you do reformat a whole existing file, +then submit the reformatting change as its own commit, so that +it is easier to separate the real changes from the formatting +changes in the Git history. + ### Bison Follow the GNU Coding Standards.
