Changes between Version 8 and Version 9 of Hacking


Ignore:
Timestamp:
02/15/11 21:10:43 (13 years ago)
Author:
angel_il
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Hacking

    v8 v9  
    33 
    44 * Maximum Line Width is 100 Characters.  The reason is not about people with low-res screens but rather sticking to 100 columns prevents you from easily nesting more than one level of if statements or other code blocks. 
    5  * Use 4 Space Tabs to Indent.  With whitespace fillers. 
     5 * Use 4 Space Tabs with whitespace fillers to Indent. Never use tabs. 
    66 * No Trailing Whitespace  
    77 * Follow the GNU-Style guidelines.  We won't go through all of them here. 
     
    3333'''This is right:''' 
    3434{{{ 
    35     int i; 
    36  
    3735    /* 
    3836     * This is a multi line comment, 
     
    5856     * @return              0 on success and -1 on error. 
    5957     */ 
    60     int example(int param1, int *result1); 
     58    int example (int param1, int *result1); 
     59 
    6160}}} 
    6261 
     
    6968    /* This is a multi line comment, 
    7069       with some more words...*/ 
     70 
     71}}} 
     72 
     73=== Code blocks (if, for, case...)=== 
     74 
     75Always follow an 'if' keyword with a space but don't include additional 
     76spaces following or preceding the parentheses in the conditional. 
     77 
     78This is right: 
     79{{{ 
     80    if (i == 0) 
     81}}} 
     82This is wrong: 
     83{{{ 
     84    if ( i == 0 ) 
     85    /*  
     86    if (0 == i) 
     87}}} 
     88 
     89Always insert a space between the name and left parentheses when invoking functions. 
     90 
     91This is right: 
     92{{{ 
     93    do_example (int param1, int *result1); 
     94}}} 
     95This is wrong: 
     96{{{ 
     97    do_example(int param1, int *result1); 
     98}}} 
     99 
     100 
     101 
     102Braces for code blocks used by '''for, if, switch, while, do..while''', etc. should begin on the next line after the statement keyword and end on a line of their own.  
     103 
     104Functions are different and the beginning left brace should be located in the first column on the next line. 
     105 
     106If the beginning statement has to be broken across lines due to length, the beginning brace should be on a line of its own. 
     107 
     108This is right: 
     109{{{ 
     110    if (xterm_flag && xterm_title) 
     111    { 
     112        path = strip_home_and_password (current_panel->cwd); 
     113    ... 
     114    } 
     115 
     116    for (j = 0; j < 10; j++) 
     117    { 
     118        for (i = 0; str_options[i].opt_name != NULL; i++) 
     119            g_free (*str_options[i].opt_addr); 
     120    } 
     121 
     122}}} 
     123This is wrong: 
     124{{{ 
     125    if (xterm_flag && xterm_title) { 
     126        path = strip_home_and_password (current_panel->cwd); 
     127    ... 
     128    } 
     129 
     130    if (xterm_flag && xterm_title) 
     131    { 
     132        path = strip_home_and_password (current_panel->cwd); } 
     133 
     134    for (k = 0; k < 10; k++) 
     135        for (j = 0; j < 10; j++) 
     136            for (i = 0; str_options[i].opt_name != NULL; i++) 
     137                g_free (*str_options[i].opt_addr); 
     138 
    71139}}} 
    72140