Mercurial > geeqie
comparison CODING @ 685:f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
author | bruclik |
---|---|
date | Mon, 19 May 2008 00:54:59 +0000 |
parents | f31ae0d9e163 |
children | 83d3abd80b64 |
comparison
equal
deleted
inserted
replaced
684:9f00d0d874fa | 685:f20e7cebcb12 |
---|---|
1 Please keep the general coding style of Geeqie: | 1 GPL header, in every file, like this: |
2 | 2 |
3 Space after if, while and for: | 3 /** @file relativ/path/with/this/file/name.c |
4 ------------------------------ | 4 * Short description of this file. |
5 * @author Author1 | |
6 * @author Author2 | |
7 * | |
8 * Optionaly detailed description of this file | |
9 * on more lines. | |
10 */ | |
11 | |
12 /* | |
13 * This file is a part of Geeqie project (http://geeqie.sourceforge.net/). | |
14 * Copyright (C) 2008 Geeqie team | |
15 * | |
16 * This program is free software; you can redistribute it and/or modify | |
17 * it under the terms of the GNU General Public License as published by | |
18 * the Free Software Foundation; either version 2 of the License, or | |
19 * (at your option) any later version. | |
20 * | |
21 * This program is distributed in the hope that it will be useful, | |
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 * GNU General Public License for more details. | |
25 */ | |
5 | 26 |
6 while (...) | 27 -------------------------------------------------------------------------------- |
7 for (...) | |
8 if (...) | |
9 | 28 |
10 Indentation of {}: | 29 svn change-log: |
11 ------------------ | |
12 | 30 |
13 while (...) | 31 Use whole sentences begins with Capital letter. For each modification use new line. |
32 Or you can write the theme, colon and then every change on new line, begin | |
33 with "- ". | |
34 | |
35 Example: | |
36 | |
37 I done some bugfixes. | |
38 Library: | |
39 - I change the interface | |
40 - added some new functions | |
41 | |
42 -------------------------------------------------------------------------------- | |
43 | |
44 sources: | |
45 | |
46 Indentation: tabs | |
47 Names of variables & functions: small_letters | |
48 of defines: CAPITAL_LETTERS | |
49 | |
50 Try to use explicit variable and function names. | |
51 | |
52 | |
53 Try not to use macros. | |
54 Use EITHER "struct foo" OR "foo"; never both | |
55 | |
56 Conditions, cycles: | |
57 | |
58 if (<cond>) | |
14 { | 59 { |
60 <command>; | |
15 ... | 61 ... |
16 } | 62 <command>; |
17 | |
18 if (...) | |
19 { | |
20 ... | |
21 } | 63 } |
22 else | 64 else |
23 { | 65 { |
66 <command>; | |
24 ... | 67 ... |
68 <command>; | |
69 } | |
70 | |
71 if (<cond_very_very_very_very_very_very_very_very_very_long> && | |
72 <cond2very_very_very_very_very_very_very_very_very_long) | |
73 <the_only_command>; | |
74 | |
75 switch (<var>) | |
76 { | |
77 case 0: | |
78 <command>; | |
79 <command>; | |
80 break; | |
81 case 1: | |
82 <command>; break; | |
25 } | 83 } |
26 | 84 |
27 Spaces around operators: | 85 for (i = 0; i <= 10; i++) |
28 ------------------------ | 86 { |
87 <command>; | |
88 ... | |
89 <command>; | |
90 } | |
91 | |
29 | 92 |
30 i = 2; | 93 Functions: |
31 x = i * (j / 2); | |
32 | 94 |
95 int bar(<var_def>, <var_def>, <var_def>) | |
96 { | |
97 <command>; | |
98 ... | |
99 <command>; | |
33 | 100 |
34 Space after comma: | 101 return 0; // i.e. SUCCESS; if error, you must return minus <err_no> |
35 ------------------ | |
36 func(a, b, c); | |
37 | |
38 Functions without any parameter should be declared using void: | |
39 -------------------------------------------------------------- | |
40 gint function(void) | |
41 { | |
42 ... | |
43 } | 102 } |
44 | 103 |
45 Use glib types: | 104 void bar2(void) |
46 --------------- | 105 { |
47 Please use glib types when possible (ie. gint and gchar instead of int and char) | 106 <command>; |
48 . | 107 ... |
108 <command>; | |
109 } | |
49 | 110 |
50 Use glib functions: | 111 Pragma: (Indentation 2 spaces) |
51 ------------------- | 112 |
113 #ifdef ENABLE_NLS | |
114 # undef _ | |
115 # define _(String) (String) | |
116 #endif /* ENABLE_NLS */ | |
117 | |
118 Headers: | |
119 | |
120 #ifndef _FILENAME_H | |
121 | |
122 -------------------------------------------------------------------------------- | |
123 | |
124 Use spaces around every operator (except ".", "->", "++" and "--"); | |
125 unary operator '*' and '&' are missing the space from right; | |
126 (and also unary '-'). | |
127 As you can see above, parentheses are closed to inside, i.e. " (blah blah) " | |
128 In "function(<var>)" there are no space before '('. | |
129 You MAY use more tabs/spaces than you OUGHT TO (according to this CodingStyle), if | |
130 it makes your code nicer in being verticaly indented. | |
131 | |
132 -------------------------------------------------------------------------------- | |
133 | |
134 Use glib types when possible (ie. gint and gchar instead of int and char). | |
52 Use glib functions when possible (ie. g_ascii_isspace() instead of isspace()). | 135 Use glib functions when possible (ie. g_ascii_isspace() instead of isspace()). |
53 Check if used functions are not deprecated. | 136 Check if used functions are not deprecated. |
54 | 137 |
55 Others: | 138 -------------------------------------------------------------------------------- |
56 ------- | |
57 Check twice the indentation and spurious whitespaces. | |
58 | 139 |
59 Try to use explicit variable and function names. | 140 Documentation: use Doxygen |