Trac is being migrated to new services! Issues can be found in our new YouTrack instance and WIKI pages can be found on our website.

Changes between Version 6 and Version 7 of StyleGuide


Ignore:
Timestamp:
Feb 28, 2014, 7:19:08 AM (10 years ago)
Author:
MarkDoliner
Comment:

Small improvements

Legend:

Unmodified
Added
Removed
Modified
  • StyleGuide

    v6 v7  
    1 = Coding Standards =
     1= Code Style Guide =
    22
    3 We try to follow K&R coding style in most of our code.  Some existing code violates these standards.  If you are writing a patch against some such code, please do fix violations in that block of code – but don't reformat entire files!
     3Please follow these guidelines when writing new code in Pidgin, Finch, and libpurple. If you are writing a patch against code that violates these standards, please fix violations in that block of code – but don't reformat entire files!
    44
    5 Here are some examples to help explain the intended style:
     5In general we try to follow K&R coding style in most of our code. See below for specific examples:
     6
    67
    78== Braces ==
    8  * Braces start at the same line as the if/while/do/for block
    9  * End braces are on their own lines, indented to the starting of the
    10  block, e.g.:
     9 * Prefer braces around single line blocks. Reasons:
     10   * Reduces chances of bugs, if someone adds code at the same indentation level without realizing that there are no braces.
     11   * Smaller diffs when adding code to an existing single-line block.
     12 * For functions, structs, typedefs, etc. braces start on their own lines.
     13 * For if, while, do, for, etc. braces start on the same line.
     14 * Braces end on their own lines, indented equally as the start of the
     15 block.
     16
    1117{{{
    1218#!c
    13 for (i = 0; i < x; i++) {
    14         /* the code here, indented by a tab */
    15 }
    16 }}}
    17  * The starting braces for functions, structs etc. are on their own lines e.g.:
    18 {{{
    19 #!c
    20 struct _somestruct
     19static void
     20some_function(int x, int y)
    2121{
    22         /* stuff */
     22        if (x > y) {
     23            return;
     24        }
     25
     26        for (i = 0; i < x; i++) {
     27                /* the code here, indented by a tab */
     28        }
    2329};
    2430}}}
    2531
     32
    2633== Indentation ==
    27  * We use tab for indentation (and it's preferable that you use 8-space tabs in your editor)
     34 * We use tab for indentation (and it's preferable that you use 8-space tabs in your editor).
     35 * When wrapping long lines, tab indent to the start of the statement then add two more tabs.
    2836
    2937
     
    3846}}}
    3947 * No whitespace at the end of line
     48
    4049
    4150== Comments ==
     
    5564}}}
    5665
     66
    5767== Function Definitions ==
    58 
    5968 * There should be a newline between the return type of the function and the function's name.
    6069 * Wrap parameters sensibly, preferably around 80 characters or so.
     
    7079        /* misc, other */
    7180}
     81
     82
     83== Variable Declarations ==
     84 * Prefer declaring each variable on its own line. This makes diffs easier to read and reduces churn.
     85 * Use const for variables that don't need to change or be deallocated.
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!