mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-18 07:15:00 -05:00
081f64aea3
The HACKING file seemed to be broken : http://archlinux.org/pacman/HACKING.html And indeed, running asciidoc HACKING issued a number of warnings : WARNING: HACKING: line 27: missing [paradef-default] C-style entry type: numbered : expected 1 got 3 WARNING: HACKING: line 44: list item 3 out of sequence WARNING: HACKING: line 49: missing [paradef-default] C-style entry type: numbered : expected 2 got 4 WARNING: HACKING: line 62: list item 4 out of sequence type: numbered : expected 3 got 5 WARNING: HACKING: line 69: list item 5 out of sequence type: numbered : expected 4 got 6 WARNING: HACKING: line 75: list item 6 out of sequence type: numbered : expected 5 got 7 WARNING: HACKING: line 83: list item 7 out of sequence WARNING: HACKING: line 104: missing [paradef-default] C-style entry WARNING: HACKING: line 116: missing [paradef-default] C-style entry WARNING: HACKING: line 126: missing [paradef-default] C-style entry I just followed the syntax example there : http://www.methods.co.nz/asciidoc/userguide.html#X56 And all is fine now :) Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
139 lines
3.6 KiB
Plaintext
139 lines
3.6 KiB
Plaintext
Pacman - Contributing
|
|
=====================
|
|
|
|
This file is meant to give you a brief overview of coding style and other
|
|
concerns when hacking on pacman. If you are interested in contributing, please
|
|
read link:submitting-patches.html[submitting-patches] and
|
|
link:translation-help.html[translation-help] as well.
|
|
|
|
Coding style
|
|
------------
|
|
|
|
1. All code should be indented with tabs. (Ignore the use of only spaces in
|
|
this file) By default, source files contain the following VIM modeline:
|
|
+
|
|
[code,C]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* vim: set ts=2 sw=2 noet: */
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
2. When opening new blocks such as 'while', 'if', or 'for', leave the opening
|
|
brace on the same line as the beginning of the codeblock. The closing brace
|
|
gets its own line (the only exception being 'else'). Do not use extra
|
|
spaces around the parentheses of the block. ALWAYS use opening and closing
|
|
braces, even if it's just a one-line block. This reduces future error when
|
|
blocks are expanded beyond one line.
|
|
+
|
|
[code,C]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
for(lp = list; lp; lp = lp->next) {
|
|
newlist = _alpm_list_add(newlist, strdup(lp->data));
|
|
}
|
|
|
|
while(it) {
|
|
ptr = it->next;
|
|
if(fn) {
|
|
fn(it->data);
|
|
} else {
|
|
return(1);
|
|
}
|
|
free(it);
|
|
it = ptr;
|
|
}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
3. When declaring a new function, put the opening and closing braces on their
|
|
own line. Also, when declaring a pointer, do not put a space between the
|
|
asterisk and the variable name.
|
|
+
|
|
[code,C]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
alpm_list_t *alpm_list_add(alpm_list_t *list, void *data)
|
|
{
|
|
alpm_list_t *ptr, *lp;
|
|
|
|
ptr = list;
|
|
if(ptr == NULL) {
|
|
...
|
|
}
|
|
...
|
|
}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
4. Comments should be ANSI-C89 compliant. That means no `// Comment` style;
|
|
use only `/* Comment */` style.
|
|
|
|
/* This is a comment */
|
|
NOT
|
|
// This is a comment
|
|
|
|
5. Return statements should be written like a function call.
|
|
|
|
return(0);
|
|
NOT
|
|
return 0;
|
|
|
|
6. The sizeof() operator should accept a type, not a value. (TODO: in certain
|
|
cases, it may be better- should this be a set guideline? Read "The Practice
|
|
of Programming")
|
|
|
|
sizeof(alpm_list_t);
|
|
NOT
|
|
sizeof(*mylist);
|
|
|
|
7. When using strcmp() (or any function that returns 0 on success) in a
|
|
conditional statement, use != 0 or == 0 and not the negation (!) operator.
|
|
It reads much cleaner for humans (using a negative to check for success is
|
|
confusing) and the compiler will treat it correctly anyway.
|
|
|
|
if(strcmp(a, b) == 0)
|
|
NOT
|
|
if(!strcmp(a, b))
|
|
|
|
|
|
Other Concerns
|
|
--------------
|
|
|
|
Header Includes
|
|
~~~~~~~~~~~~~~~
|
|
|
|
Currently our #include usage is in messy shape, but this is no reason to
|
|
continue down this messy path. When adding an include to a file, follow this
|
|
general pattern, including blank lines:
|
|
|
|
[code,C]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
#include "config.h"
|
|
|
|
#include <standardheader.h>
|
|
#include <another.h>
|
|
#include <...>
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Follow this with some more headers, depending on whether the file is in libalpm
|
|
or pacman proper. For libalpm:
|
|
|
|
[code,C]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* libalpm */
|
|
#include "yourfile.h"
|
|
#include "alpm_list.h"
|
|
#include "anythingelse.h"
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
For pacman:
|
|
|
|
[code,C]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
#include <alpm.h>
|
|
#include <alpm_list.h>
|
|
|
|
/* pacman */
|
|
#include "yourfile.h"
|
|
#include "anythingelse.h"
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
/////
|
|
vim: set ts=2 sw=2 syntax=asciidoc et:
|
|
/////
|