4 In addition to this file, please read `submitting-patches` and
5 `translation-help` in the same directory for additional info on contributing.
10 1. All code should be indented with tabs. (Ignore the use of only spaces in
11 this file) By default, source files contain the following VIM modeline:
15 /* vim: set ts=2 sw=2 noet: */
18 2. When opening new blocks such as 'while', 'if', or 'for', leave the opening
19 brace on the same line as the beginning of the codeblock. The closing brace
20 gets its own line (the only exception being 'else'). Do not use extra
21 spaces around the parentheses of the block. ALWAYS use opening and closing
22 braces, even if it's just a one-line block. This reduces future error when
23 blocks are expanded beyond one line.
27 for(lp = list; lp; lp = lp->next) {
28 newlist = _alpm_list_add(newlist, strdup(lp->data));
43 3. When declaring a new function, put the opening and closing braces on their
44 own line. Also, when declaring a pointer, do not put a space between the
45 asterisk and the variable name.
49 alpm_list_t *alpm_list_add(alpm_list_t *list, void *data)
51 alpm_list_t *ptr, *lp;
61 4. Comments should be ANSI-C89 compliant. That means no `// Comment` style;
62 use only `/* Comment */` style.
64 /* This is a comment */
68 5. Return statements should be written like a function call.
74 6. The sizeof() operator should accept a type, not a value. (TODO: in certain
75 cases, it may be better- should this be a set guideline? Read "The Practice
82 7. When using strcmp() (or any function that returns 0 on success) in a
83 conditional statement, use != 0 or == 0 and not the negation (!) operator.
84 It reads much cleaner for humans (using a negative to check for success is
85 confusing) and the compiler will treat it correctly anyway.
98 Currently our #include usage is in messy shape, but this is no reason to
99 continue down this messy path. When adding an include to a file, follow this
100 general pattern, including blank lines:
106 #include <standardheader.h>
111 Follow this with some more headers, depending on whether the file is in libalpm
112 or pacman proper. For libalpm:
117 #include "yourfile.h"
118 #include "alpm_list.h"
119 #include "anythingelse.h"
127 #include <alpm_list.h>
130 #include "yourfile.h"
131 #include "anythingelse.h"
135 vim: set ts=2 sw=2 syntax=asciidoc et: