1) Add note on line length.
2) Add guidelines about pointer formatting.
3) Add guidelines on function declarations.
4) Note that C types must also begin with "mh_".
5) Add a section with recommended vim settings.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
doc/coding_guidelines.txt | 66 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/doc/coding_guidelines.txt b/doc/coding_guidelines.txt
index 44bec11..6c0106e 100644
--- a/doc/coding_guidelines.txt
+++ b/doc/coding_guidelines.txt
@@ -12,6 +12,7 @@
1) Introduction
2) Formatting Guidelines
3) Naming Conventions
+ 4) vim Settings
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
@@ -30,7 +31,52 @@ code that will be a part of the Matahari project.
--- 2) Formatting Guidelines
-------------------------------------------------------------------------------
-a) Indentatation is 4 spaces, no tabs.
+a) Whitespace
+
+ - Indentation must be 4 spaces, no tabs.
+
+ - Do not leave trailing whitespace.
+
+b) Line Length
+
+ - Lines should be no longer than 80 characters unless limiting line length
+ significantly impacts readability.
+
+b) Pointers
+
+ - The '*' goes by the variable name, not the type:
+
+ char *foo;
+
+ - Use a space before the '*' and after the closing parenthesis in a cast:
+
+ char *foo = (char *) bar;
+
+c) Functions
+
+ - Put the return type on its own line:
+ - Place the opening brace for a function on the next line:
+
+ static int
+ foo(void)
+ {
+
+ - For functions with enough arguments that they must break to the next
+ line, align arguments with the first argument:
+
+ static int
+ function_name(int bar, const char *a, const char *b,
+ const char *c, const char *d)
+ {
+
+ - If a function name gets really long, start the arguments on their own
+ line with 8 spaces of indentation:
+
+ static int
+ really_really_long_function_name_this_is_getting_silly_now(
+ int bar, const char *a, const char *b,
+ const char *c, const char *d)
+ {
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
@@ -39,7 +85,23 @@ a) Indentatation is 4 spaces, no tabs.
--- 3) Naming Conventions
-------------------------------------------------------------------------------
-a) Public C API calls must begin with "mh_".
+a) Public C API calls and type names must begin with "mh_".
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+-------------------------------------------------------------------------------
+--- 4) vim Settings
+-------------------------------------------------------------------------------
+
+" This section contains settings that can be placed in the vimrc file that are
+" compatible with the Matahari coding guidelines.
+
+" Whitespace
+set ts=4
+set sw=4
+set expandtab
+let c_space_error=1
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--
1.7.4.4