index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Xavier Chantry <shiningxc@gmail.com> | 2008-08-21 09:09:16 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-08-23 08:38:43 -0500 |
commit | 081f64aea3aa7df13f1ccd1da601075abab6b1ba (patch) | |
tree | b3cc7c4568b4257f87ba6f86266818be1812fac6 /HACKING | |
parent | 0969c2e700c6bd7f855ddfa4e73b6ccd71911ff5 (diff) |
-rw-r--r-- | HACKING | 36 |
@@ -12,10 +12,10 @@ 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: + -[C] -code~~~~~~~~~~ +[code,C] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* vim: set ts=2 sw=2 noet: */ -code~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 @@ -24,8 +24,8 @@ code~~~~~~~~~~ braces, even if it's just a one-line block. This reduces future error when blocks are expanded beyond one line. + -[C] -code~~~~~~~~~~ +[code,C] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for(lp = list; lp; lp = lp->next) { newlist = _alpm_list_add(newlist, strdup(lp->data)); } @@ -40,14 +40,14 @@ while(it) { free(it); it = ptr; } -code~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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. + -[C] -code~~~~~~~~~~ +[code,C] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data) { alpm_list_t *ptr, *lp; @@ -58,7 +58,7 @@ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data) } ... } -code~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4. Comments should be ANSI-C89 compliant. That means no `// Comment` style; use only `/* Comment */` style. @@ -101,37 +101,37 @@ 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: -[C] -code~~~~~~~~~~ +[code,C] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include "config.h" #include <standardheader.h> #include <another.h> #include <...> -code~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Follow this with some more headers, depending on whether the file is in libalpm or pacman proper. For libalpm: -[C] -code~~~~~~~~~~ +[code,C] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* libalpm */ #include "yourfile.h" #include "alpm_list.h" #include "anythingelse.h" -code~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For pacman: -[C] -code~~~~~~~~~~ +[code,C] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include <alpm.h> #include <alpm_list.h> /* pacman */ #include "yourfile.h" #include "anythingelse.h" -code~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ///// vim: set ts=2 sw=2 syntax=asciidoc et: |