Changes between Version 38 and Version 39 of Hacking
- Timestamp:
- 02/02/25 18:56:29 (3 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Hacking
v38 v39 1 2 1 = HACKING = 3 2 … … 10 9 * Follow the GNU-Style guidelines. 11 10 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 11 To format the code, use the '''clang-format''' (version 19): 12 30 13 {{{ 31 14 make indent … … 50 33 (void) edit_delete (edit); 51 34 52 / * This is a one line comment. Allocate additional memory. */35 // This is a one line comment. Allocate additional memory. 53 36 mem = (char *) malloc (memneed); 54 37 … … 72 55 //This is a one line comment. 73 56 74 /*This is a one line comment.*/75 76 57 /* This is a multi line comment, 77 58 with some more words...*/ … … 110 91 === Braces === 111 92 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. 93 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. 113 94 114 95 Functions are different and the beginning left brace should be located in the first column on the next line. … … 116 97 If the beginning statement has to be broken across lines due to length, the beginning brace should be on a line of its own. 117 98 118 Do not unnecessarily use braces where a single statement will do. 99 Do not unnecessarily use braces where a single statement will do. 119 100 120 101 '''This is right:''' … … 146 127 === Goto === 147 128 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. 129 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. 149 130 150 131 '''This is right:''' … … 318 299 WPanel *panel = current_panel; 319 300 int i; 320 301 321 302 const ComputeDirSizeUI *ui = compute_dir_size_create_ui (); 322 303 … … 376 357 377 358 #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() 383 364 #include "src/setup.h" 384 365 }}} … … 393 374 #include <sys/stat.h> 394 375 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() 400 381 401 382 #include "src/setup.h" … … 407 388 '''This is right:''' 408 389 {{{ 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 }}}