# HG changeset patch # User bruclik # Date 1211158499 0 # Node ID f20e7cebcb126581ee48903249cc1044a41df080 # Parent 9f00d0d874fa6f3c7b92e2e61d5bc9e7987a196f Updated CODING (GPL header, macros, svn change-log, ...). diff -r 9f00d0d874fa -r f20e7cebcb12 CODING --- a/CODING Sun May 18 21:14:01 2008 +0000 +++ b/CODING Mon May 19 00:54:59 2008 +0000 @@ -1,59 +1,140 @@ -Please keep the general coding style of Geeqie: +GPL header, in every file, like this: -Space after if, while and for: ------------------------------- +/** @file relativ/path/with/this/file/name.c + * Short description of this file. + * @author Author1 + * @author Author2 + * + * Optionaly detailed description of this file + * on more lines. + */ + +/* + * This file is a part of Geeqie project (http://geeqie.sourceforge.net/). + * Copyright (C) 2008 Geeqie team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ -while (...) -for (...) -if (...) +-------------------------------------------------------------------------------- + +svn change-log: -Indentation of {}: ------------------- +Use whole sentences begins with Capital letter. For each modification use new line. +Or you can write the theme, colon and then every change on new line, begin +with "- ". + +Example: + +I done some bugfixes. +Library: +- I change the interface +- added some new functions + +-------------------------------------------------------------------------------- + +sources: -while (...) +Indentation: tabs +Names of variables & functions: small_letters + of defines: CAPITAL_LETTERS + +Try to use explicit variable and function names. + + +Try not to use macros. +Use EITHER "struct foo" OR "foo"; never both + +Conditions, cycles: + +if () { + ; ... - } - -if (...) - { - ... + ; } else { + ; ... + ; + } + +if ( && + ; + +switch () + { + case 0: + ; + ; + break; + case 1: + ; break; } -Spaces around operators: ------------------------- - -i = 2; -x = i * (j / 2); - +for (i = 0; i <= 10; i++) + { + ; + ... + ; + } + -Space after comma: ------------------- -func(a, b, c); +Functions: -Functions without any parameter should be declared using void: --------------------------------------------------------------- -gint function(void) +int bar(, , ) { -... + ; + ... + ; + + return 0; // i.e. SUCCESS; if error, you must return minus } -Use glib types: ---------------- -Please use glib types when possible (ie. gint and gchar instead of int and char) -. +void bar2(void) +{ + ; + ... + ; +} + +Pragma: (Indentation 2 spaces) + +#ifdef ENABLE_NLS +# undef _ +# define _(String) (String) +#endif /* ENABLE_NLS */ + +Headers: -Use glib functions: -------------------- +#ifndef _FILENAME_H + +-------------------------------------------------------------------------------- + +Use spaces around every operator (except ".", "->", "++" and "--"); + unary operator '*' and '&' are missing the space from right; + (and also unary '-'). +As you can see above, parentheses are closed to inside, i.e. " (blah blah) " + In "function()" there are no space before '('. +You MAY use more tabs/spaces than you OUGHT TO (according to this CodingStyle), if + it makes your code nicer in being verticaly indented. + +-------------------------------------------------------------------------------- + +Use glib types when possible (ie. gint and gchar instead of int and char). Use glib functions when possible (ie. g_ascii_isspace() instead of isspace()). Check if used functions are not deprecated. -Others: -------- -Check twice the indentation and spurious whitespaces. +-------------------------------------------------------------------------------- -Try to use explicit variable and function names. +Documentation: use Doxygen