Changes between Version 38 and Version 39 of Hacking


Ignore:
Timestamp:
02/02/25 18:56:29 (3 weeks ago)
Author:
zaytsev
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Hacking

    v38 v39  
    1  
    21= HACKING = 
    32 
     
    109 * Follow the GNU-Style guidelines. 
    1110 
    12 To format the code, use the '''indent''' utility with following options: 
    13 {{{ 
    14 indent \ 
    15   --gnu-style \ 
    16   --format-first-column-comments \ 
    17   --indent-level4 \ 
    18   --brace-indent0 \ 
    19   --line-length100 \ 
    20   --no-tabs \ 
    21   --blank-lines-after-procedures  
    22 }}} 
    23  
    24 or in short notation: 
    25 {{{ 
    26 indent -gnu -fc1 -i4 -bli0 -nut -bap -l100 
    27 }}} 
    28  
    29 or just run 
     11To format the code, use the '''clang-format''' (version 19): 
     12 
    3013{{{ 
    3114make indent 
     
    5033(void) edit_delete (edit); 
    5134 
    52 /*  This is a one line comment. Allocate additional memory.  */ 
     35// This is a one line comment. Allocate additional memory. 
    5336mem = (char *) malloc (memneed); 
    5437 
     
    7255//This is a one line comment. 
    7356 
    74 /*This is a one line comment.*/ 
    75  
    7657/* This is a multi line comment, 
    7758   with some more words...*/ 
     
    11091=== Braces === 
    11192 
    112 Braces 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.  
     93Braces 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. 
    11394 
    11495Functions are different and the beginning left brace should be located in the first column on the next line. 
     
    11697If the beginning statement has to be broken across lines due to length, the beginning brace should be on a line of its own. 
    11798 
    118 Do not unnecessarily use braces where a single statement will do.  
     99Do not unnecessarily use braces where a single statement will do. 
    119100 
    120101'''This is right:''' 
     
    146127=== Goto === 
    147128 
    148 Use "goto" only when necessary. "goto"s are evil, but they can greatly enhance readability and reduce memory leaks when used as the single exit point from a function.  
     129Use "goto" only when necessary. "goto"s are evil, but they can greatly enhance readability and reduce memory leaks when used as the single exit point from a function. 
    149130 
    150131'''This is right:''' 
     
    318299    WPanel *panel = current_panel; 
    319300    int i; 
    320      
     301 
    321302    const ComputeDirSizeUI *ui = compute_dir_size_create_ui (); 
    322303 
     
    376357 
    377358#include "lib/global.h" 
    378 #include "lib/tty/tty.h"        /* LINES, tty_touch_screen() */ 
    379 #include "lib/tty/win.h"        /* do_enter_ca_mode() */ 
    380  
    381 #include "src/subshell.h"       /* use_subshell */ 
    382 #include "src/help.h"           /* interactive_display() */ 
     359#include "lib/tty/tty.h"        // LINES, tty_touch_screen() 
     360#include "lib/tty/win.h"        // do_enter_ca_mode() 
     361 
     362#include "src/subshell.h"       // use_subshell 
     363#include "src/help.h"           // interactive_display() 
    383364#include "src/setup.h" 
    384365}}} 
     
    393374#include <sys/stat.h> 
    394375 
    395 #include "src/subshell.h"       /* use_subshell */ 
    396 #include "src/help.h"           /* interactive_display() */ 
    397  
    398 #include "lib/tty/tty.h"        /* LINES, tty_touch_screen() */ 
    399 #include "lib/tty/win.h"        /* do_enter_ca_mode() */ 
     376#include "src/subshell.h"       // use_subshell 
     377#include "src/help.h"           // interactive_display() 
     378 
     379#include "lib/tty/tty.h"        // LINES, tty_touch_screen() 
     380#include "lib/tty/win.h"        // do_enter_ca_mode() 
    400381 
    401382#include "src/setup.h" 
     
    407388'''This is right:''' 
    408389{{{ 
    409 #include "lib/tty/tty.h"        /* LINES, tty_touch_screen() */ 
    410 #include "lib/tty/win.h"        /* do_enter_ca_mode() */ 
    411 #include "src/subshell.h"       /* use_subshell */ 
    412 #include "src/help.h"           /* interactive_display() */ 
    413 }}} 
     390#include "lib/tty/tty.h"        // LINES, tty_touch_screen() 
     391#include "lib/tty/win.h"        // do_enter_ca_mode() 
     392#include "src/subshell.h"       // use_subshell 
     393#include "src/help.h"           // interactive_display() 
     394}}}