From 022ba0f48b83f15ced508aa4545b0bff6212c6b3 Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Sun, 14 Feb 2016 13:06:11 -0600 Subject: [PATCH] Add preferred astylerc configuration Astyle is a code formatting utility that can quickly reformat a source file based on the settings of its configuration file. The added configuration file will format to a style mostly consistent with the Linux Kernel Style guide: https://www.kernel.org/doc/Documentation/CodingStyle While conformance to this document is not the goal, it supplies a reasonable set of guidelines to be used in Hamlib. --- .gitignore | 1 + README.developer | 22 +++++++++++++++++++--- scripts/astylerc | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 scripts/astylerc diff --git a/.gitignore b/.gitignore index 5af52a7b3..671f89b16 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.o *.lo *.la +*.orig *.swp Makefile Makefile.in diff --git a/README.developer b/README.developer index 3bfa5a18c..1e6deda08 100644 --- a/README.developer +++ b/README.developer @@ -542,17 +542,29 @@ readability. Align closing braces with the opening block's keyword. In function definitions put the opening brace on its own line under the definition's parameter line. -Hamlib source code is no place for an entry into the obsfucated C contest! +A configuration file for the Artistic Style (http://astyle.sourceforge.net/) +utility can be found in the scripts directory. The settings it provides should +conform reasonably close to the Linux style guide referenced above. This file +can be copied to $HOME/.astylerc where it will be used as the default +configuration. If you already have an existing .astylerc, passing + + --options=/path/to/hamlib/scripts/astylerc + +will use this file as the configuration for formatting. Consider using this +utility whenever working on a given C source file in Hamlib. + +Hamlib source code is no place for an entry into the obfuscated C contest! Many of us are hobbyists and write this for fun. Easy to read and understand logic is preferred over a clever solution. If your solution must be written in a clever fashion, please document it well in your comments. -Any header files included from the hamlib/ directory should be enclosed -in <>: +Any header files included from the hamlib/ directory should be enclosed in <>: + #include # Per GNU GCC documentation Other included header files (backend and rig specific headers) should be enclosed in "": + #include "yaesu.h" Contributed code should always keep the source base in a compilable state, @@ -581,6 +593,7 @@ Hamlib should also compile with the following common compilers: Portability issues to watch: + * C99 is probably (in 2016) a reasonable target * little vs. big endian systems (use shifts or adhoc functions) * 64 bit int: avoid them in API * printf/scanf of 64bit int: use PRIll (cast value to int64_t) and SCNll @@ -672,6 +685,9 @@ big, you can send it as a compressed attachment. 8.3.1 Changelog +A ChangeLog file is no longer manually maintained. At some point it may be +automatically generated from the Git commit log for source tarballs. + Simply summarize your changes when the files are committed to Git or, if providing patches to the mailing list, provide a summary so the uploader can include it in the commit message which will show in the commit log (Git diff --git a/scripts/astylerc b/scripts/astylerc new file mode 100644 index 000000000..b92959106 --- /dev/null +++ b/scripts/astylerc @@ -0,0 +1,32 @@ +# astylerc--custom options for astyle +# Intended to follow the Linux style guide as closely as possible: +# https://www.kernel.org/doc/Documentation/CodingStyle + +# Linux kernel style formatting/indenting. +style=linux + +# Use tabs with a width of 8 spaces. +indent=force-tab=8 + +# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...). +break-blocks + +# Remove extra space padding around parenthesis on the inside and outside. +unpad-paren + +# Insert space padding around operators. +pad-oper + +# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...). +pad-header + +# Attach a pointer operator (*) to name (name) and reference operator (&) +# to type (type). +align-pointer=name +align-reference=type + +# Don't break one-line blocks. +keep-one-line-blocks + +# Don't break complex statements and multiple statements residing on a single line. +keep-one-line-statements