Author: jtn
Date: Mon May 19 22:23:20 2014
New Revision: 24899

URL: http://svn.gna.org/viewcvs/freeciv?rev=24899&view=rev
Log:
Some updates to CodingStyle from http://www.freeciv.org/wiki/Coding_Style
and other cleanups.

See gna patch #4689.

Modified:
    branches/S2_5/doc/CodingStyle

Modified: branches/S2_5/doc/CodingStyle
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/doc/CodingStyle?rev=24899&r1=24898&r2=24899&view=diff
==============================================================================
--- branches/S2_5/doc/CodingStyle       (original)
+++ branches/S2_5/doc/CodingStyle       Mon May 19 22:23:20 2014
@@ -254,6 +254,25 @@
       int build = pcity->shield_stock;
     }
 
+- When declaring a pointer, there should be a space before '*' and no space
+  after, except if it is a second '*'.
+
+    struct unit *find_random_unit(struct unit **array, size_t num)
+    {
+      struct unit *const *prand = array + fc_rand(num);
+
+      return *prand;
+    }
+
+  instead of
+
+    struct unit* find_random_unit(struct unit* *array, size_t num)
+    {
+      struct unit * const* prand = array + fc_rand(num);
+
+      return *prand;
+    }
+
 
 ============================================================================
   Bracing
@@ -261,14 +280,14 @@
 
 - Function braces begin and end in the first column:
 
-    int foo()
+    int foo(void)
     {
       return 0;
     }
 
   instead of
 
-    int foo() {
+    int foo(void) {
       return 0;
     }
 
@@ -315,7 +334,7 @@
 - Avoid storing magic values in external processes. For example, savegames
   shouldn't contain any enumerators as magic numbers. They should be saved
   as strings, to keep compatibility when their definition is changed. For
-  doing this, there are some tools in utility/specenum_gen.h; have a look on
+  doing this, there are some tools in utility/specenum_gen.h; have a look at
   it.
 
 - Avoid the usage of the default case in switch statements, if possible. The
@@ -367,7 +386,7 @@
     #include "myfileheader.h"
 
 - For headers within a subdirectory path, the common rule is to set them
-  in a additional group, after the same group (don't forget the location
+  in an additional group, after the same group (don't forget the location
   comment).
 
     /* common */
@@ -377,7 +396,7 @@
     #include "pf_tools.h"
 
   However, there is an exception to this. The last group is always the one
-  we are working on it. So, if we are working on the common part, the order
+  we are working on. So, if we are working on the common part, the order
   should be:
 
     /* common/aicore */
@@ -474,8 +493,8 @@
   Miscellaneous
 ============================================================================
 
-- If an empty block is needed you should put an explanatory comment in an
-  empty block (i.e. {}):
+- If an empty statement is needed, you should put an explanatory comment
+  in an empty block (i.e. {}):
 
     while (*i++) {
       /* Do nothing. */
@@ -496,11 +515,11 @@
 
 - Try to use static inline functions and const data instead of macros.
 
-- If helper functions internal to freeciv are added use the prefix 'fc_'.
-  Do not use 'my_' because it is also used by MYSQL and could be included
-  in some libs.
-
-- Do not use assert(), neither die() but the macros defined within
+- If helper functions internal to freeciv are added, prefix their names
+  with 'fc_'. Do not use 'my_' because it is also used by MySQL and could
+  be included in some libs.
+
+- Do not use assert() or die(); instead use the macros defined within
   utility/log.h:
 
     fc_assert(condition)
@@ -517,6 +536,8 @@
 
   This way error conditions can be handled gracefully while still enforcing
   invariants you expect not to be violated in the code.
+  (By default execution will continue with a warning, but it can be made
+  to halt by specifying the '-F' option to the client or server.)
 
     int foo_get_id(const struct foo *pfoo)
     {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to